Author: bdelacretaz
Date: Tue Dec 10 10:49:44 2013
New Revision: 1549806

URL: http://svn.apache.org/r1549806
Log:
SLING-3269 - the code was right but the tests wrong :-(

Modified:
    
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java
    
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorTestBase.java

Modified: 
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java?rev=1549806&r1=1549805&r2=1549806&view=diff
==============================================================================
--- 
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java
 (original)
+++ 
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorReturnsNullTest.java
 Tue Dec 10 10:49:44 2013
@@ -18,10 +18,9 @@
  */
 package org.apache.sling.resourceresolver.impl;
 
-import static org.junit.Assert.fail;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -53,17 +52,8 @@ public class ResourceDecoratorReturnsNul
     private void assertResources(Iterator<Resource> it, String ...paths) {
         assertNotNull("Expecting non-null Iterator", it);
         final List<String> actual = new ArrayList<String>();
-        int nullCounter = 1;
         while(it.hasNext()) {
             final Resource r = it.next();
-            
-            // TODO should not get any null Resources here
-            // remove this once SLING-3269 is fixed
-            if(r == null) {
-                actual.add("NULL_" + nullCounter++);
-                continue;
-            }
-            
             assertNotNull("Expecting no null Resources in iterator", r);
             actual.add(r.getPath());
         }
@@ -93,15 +83,12 @@ public class ResourceDecoratorReturnsNul
     
     @Test
     public void testGetNull() {
-        assertNull(resolver.getResource("/tmp/D"));
+        assertExistent(resolver.getResource("/tmp/D"), true);
     }
     
     @Test
     public void testResolveNull() {
-        // TODO this should return a non-existent resource instead of null
-        // use this once SLING-3269 is fixed
-        // assertExistent(resolver.resolve("/tmp/D"), false);
-        assertNull(resolver.resolve("/tmp/D"));
+        assertExistent(resolver.resolve("/tmp/D"), true);
     }
     
     @Test
@@ -115,13 +102,11 @@ public class ResourceDecoratorReturnsNul
     public void testVarChildren() {
         final Resource var = resolver.resolve("/var");
         assertNotNull(var);
-        // TODO remove the NULL once SLING-3269 is fixed
-        assertResources(resolver.listChildren(var), "/var/one", "/var/three", 
"NULL_1");
+        assertResources(resolver.listChildren(var), "/var/one", "/var/two", 
"/var/three");
     }
     
     @Test
     public void testFind() {
-        // TODO remove the NULL once SLING-3269 is fixed
-        assertResources(resolver.findResources("foo", QUERY_LANGUAGE), 
"/tmp/C", "/var/one", "NULL_1", "NULL_2");
+        assertResources(resolver.findResources("foo", QUERY_LANGUAGE), 
"/tmp/C", "/tmp/D", "/var/one", "/var/two");
     }
 }
\ No newline at end of file

Modified: 
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorTestBase.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorTestBase.java?rev=1549806&r1=1549805&r2=1549806&view=diff
==============================================================================
--- 
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorTestBase.java
 (original)
+++ 
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceDecoratorTestBase.java
 Tue Dec 10 10:49:44 2013
@@ -18,8 +18,8 @@
  */
 package org.apache.sling.resourceresolver.impl;
 
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletReq
 import org.apache.sling.api.resource.NonExistingResource;
 import org.apache.sling.api.resource.QueriableResourceProvider;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceDecorator;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
@@ -53,14 +54,20 @@ public abstract class ResourceDecoratorT
     
     @Before 
     public void setup() {
-        final ResourceDecoratorTracker t = new ResourceDecoratorTracker() {
-            @Override
+        final ResourceDecorator d = new ResourceDecorator() {
             public Resource decorate(Resource resource) {
-                return wrapResourceForTest(resource);
+                return 
ResourceDecoratorTestBase.this.wrapResourceForTest(resource);
+            }
+
+            public Resource decorate(Resource resource, HttpServletRequest 
request) {
+                throw new UnsupportedOperationException("Not supposed to be 
used in these tests");
             }
             
         };
         
+        final ResourceDecoratorTracker t = new ResourceDecoratorTracker();
+        t.bindResourceDecorator(d, null);
+        
         final ResourceProvider provider = new QueriableResourceProvider() {
             
             public Resource getResource(ResourceResolver resourceResolver, 
HttpServletRequest request, String path) {


Reply via email to