Author: bdelacretaz
Date: Mon Dec 9 13:19:11 2013
New Revision: 1549566
URL: http://svn.apache.org/r1549566
Log:
SLING-3269 - expose cases where ResourceDecorator returning null is not handled
as specified
Added:
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java
- copied, changed from r1549565,
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/IgnoredResourcesTest.java
Removed:
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/IgnoredResourcesTest.java
Modified:
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecorationTest.java
Modified:
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecorationTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecorationTest.java?rev=1549566&r1=1549565&r2=1549566&view=diff
==============================================================================
---
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecorationTest.java
(original)
+++
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecorationTest.java
Mon Dec 9 13:19:11 2013
@@ -18,6 +18,7 @@
*/
package org.apache.sling.resourceresolver.impl;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -59,13 +60,25 @@ public class ResourceDecorationTest exte
}
@Test
- public void rootIsDecorated() {
+ public void resolveRootIsDecorated() {
final Resource r = resolver.resolve((String)null);
assertDecorated(r);
assertExistent(r, true);
}
@Test
+ public void getRootIsDecorated() {
+ final Resource r = resolver.getResource("/");
+ assertDecorated(r);
+ assertExistent(r, true);
+ }
+
+ @Test
+ public void getNonExistingIsNull() {
+ assertNull(resolver.getResource("/non-existing/something"));
+ }
+
+ @Test
public void existentIsDecorated() {
final Resource r = resolver.resolve("/tmp/C");
assertDecorated(r);
Copied:
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java
(from r1549565,
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/IgnoredResourcesTest.java)
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java?p2=sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java&p1=sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/IgnoredResourcesTest.java&r1=1549565&r2=1549566&rev=1549566&view=diff
==============================================================================
---
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/IgnoredResourcesTest.java
(original)
+++
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java
Mon Dec 9 13:19:11 2013
@@ -34,19 +34,20 @@ import org.apache.sling.api.resource.Res
import org.junit.Before;
import org.junit.Test;
-/** Verify that resources are ignored when ResourceDecorator returns null */
-public class IgnoredResourcesTest extends ResourceDecoratorTestBase {
+/** Verify what happens when ResourceDecorator returns null */
+public class ResourceDecoratorReturnsNullTest extends
ResourceDecoratorTestBase {
- private Set<String> pathsToIgnore = new HashSet<String>();
+ private Set<String> pathsThatReturnNull = new HashSet<String>();
- /** Return null for ignored resources, will cause our
- * test ResourceDecorator to return null */
+ /** Return null for resources that have a path in pathsThatReturnNull.
+ * Will cause our test ResourceDecorator to return null for these
resources
+ */
protected Resource wrapResourceForTest(Resource r) {
- return isIgnored(r) ? null : r;
+ return isReturnNull(r) ? null : r;
}
- private boolean isIgnored(Resource r) {
- return pathsToIgnore.contains(r.getPath());
+ private boolean isReturnNull(Resource r) {
+ return pathsThatReturnNull.contains(r.getPath());
}
private void assertResources(Iterator<Resource> it, String ...paths) {
@@ -57,7 +58,7 @@ public class IgnoredResourcesTest extend
final Resource r = it.next();
// TODO should not get any null Resources here
- // remove this once SLING-3267 is fixed
+ // remove this once SLING-3269 is fixed
if(r == null) {
actual.add("NULL_" + nullCounter++);
continue;
@@ -77,19 +78,28 @@ public class IgnoredResourcesTest extend
@Before
public void setup() {
super.setup();
- pathsToIgnore.add("/tmp/D");
- pathsToIgnore.add("/var/two");
+ pathsThatReturnNull.add("/tmp/D");
+ pathsThatReturnNull.add("/var/two");
}
@Test
- public void testNotIgnored() {
+ public void testResolveNotNull() {
assertExistent(resolver.resolve("/tmp/A"), true);
}
+ public void testGetNotNull() {
+ assertExistent(resolver.getResource("/tmp/A"), true);
+ }
+
+ @Test
+ public void testGetNull() {
+ assertNull(resolver.getResource("/tmp/D"));
+ }
+
@Test
- public void testIgnored() {
+ public void testResolveNull() {
// TODO this should return a non-existent resource instead of null
- // use this once SLING-3267 is fixed
+ // use this once SLING-3269 is fixed
// assertExistent(resolver.resolve("/tmp/D"), false);
assertNull(resolver.resolve("/tmp/D"));
}
@@ -105,13 +115,13 @@ public class IgnoredResourcesTest extend
public void testVarChildren() {
final Resource var = resolver.resolve("/var");
assertNotNull(var);
- // TODO remove the NULL once SLING-3267 is fixed
+ // TODO remove the NULL once SLING-3269 is fixed
assertResources(resolver.listChildren(var), "/var/one", "/var/three",
"NULL_1");
}
@Test
public void testFind() {
- // TODO remove the NULL once SLING-3267 is fixed
+ // TODO remove the NULL once SLING-3269 is fixed
assertResources(resolver.findResources("foo", QUERY_LANGUAGE),
"/tmp/C", "/var/one", "NULL_1", "NULL_2");
}
}
\ No newline at end of file