You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2016/02/06 14:17:29 UTC
svn commit: r1728837 -
/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverControlTest.java
Author: cziegeler
Date: Sat Feb 6 13:17:29 2016
New Revision: 1728837
URL: http://svn.apache.org/viewvc?rev=1728837&view=rev
Log:
SLING-5492 : ResourceResolver#getParent might ask wrong resource provider
Modified:
sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverControlTest.java
Modified: sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverControlTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverControlTest.java?rev=1728837&r1=1728836&r2=1728837&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverControlTest.java (original)
+++ sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverControlTest.java Sat Feb 6 13:17:29 2016
@@ -24,6 +24,7 @@ import static org.hamcrest.Matchers.hasE
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -241,6 +242,28 @@ public class ResourceResolverControlTest
}
/**
+ * Test parent from a different provider
+ */
+ @Test
+ public void getParent_differentProviders() {
+ final Resource childResource = mock(Resource.class);
+ when(childResource.getPath()).thenReturn("/some/path");
+ when(subProvider.getResource((ResolveContext<Object>) Mockito.anyObject(), Mockito.eq("/some/path"), (ResourceContext) Mockito.anyObject(), (Resource)Mockito.eq(null))).thenReturn(childResource);
+
+ final Resource parentResource = mock(Resource.class);
+ when(parentResource.getPath()).thenReturn("/some");
+ when(rootProvider.getResource((ResolveContext<Object>) Mockito.anyObject(), Mockito.eq("/some"), (ResourceContext) Mockito.anyObject(), (Resource)Mockito.eq(null))).thenReturn(parentResource);
+
+ Resource child = crp.getResource(context, "/some/path", null, null, false);
+ assertNotNull(child);
+ assertTrue(childResource == child);
+
+ Resource parent = crp.getParent(context, child);
+ assertNotNull(parent);
+ assertTrue(parentResource == parent);
+ }
+
+ /**
* Verifies that listing the children at root lists both the synthetic and the 'real' children
*/
@Test