Search in sources :

Example 6 with ResourceWrapper

use of org.apache.sling.api.resource.ResourceWrapper in project sling by apache.

the class ResourceResolverWrapperTest method testResolve2.

@SuppressWarnings("deprecation")
@Test
public void testResolve2() throws Exception {
    final HttpServletRequest request = mock(HttpServletRequest.class);
    final Resource resource = mock(Resource.class);
    when(resource.getPath()).thenReturn(PATH);
    when(wrappedResolver.resolve(request)).thenReturn(resource);
    final Resource result = underTest.resolve(request);
    assertTrue(result instanceof ResourceWrapper);
    assertEquals(underTest, result.getResourceResolver());
    assertEquals(resource.getPath(), result.getPath());
    verify(wrappedResolver).resolve(request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ResourceWrapper(org.apache.sling.api.resource.ResourceWrapper) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Example 7 with ResourceWrapper

use of org.apache.sling.api.resource.ResourceWrapper in project sling by apache.

the class ResourceResolverWrapperTest method testGetParent.

@Test
public void testGetParent() throws Exception {
    final Resource parent = mock(Resource.class);
    final Resource child = mock(Resource.class);
    when(parent.getPath()).thenReturn(PATH);
    when(wrappedResolver.getParent(child)).thenReturn(parent);
    Resource result = underTest.getParent(child);
    assertTrue(result instanceof ResourceWrapper);
    assertEquals(parent.getPath(), result.getPath());
    verify(wrappedResolver).getParent(child);
}
Also used : ResourceWrapper(org.apache.sling.api.resource.ResourceWrapper) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Example 8 with ResourceWrapper

use of org.apache.sling.api.resource.ResourceWrapper in project sling by apache.

the class ResourceResolverWrapperTest method testCopy.

@Test
public void testCopy() throws Exception {
    final String source = "source";
    final String destination = "destination";
    final Resource expected = mock(Resource.class);
    when(expected.getPath()).thenReturn(destination);
    when(wrappedResolver.copy(source, destination)).thenReturn(expected);
    final Resource result = underTest.copy(source, destination);
    assertTrue(result instanceof ResourceWrapper);
    assertEquals(underTest, result.getResourceResolver());
    assertEquals(destination, result.getPath());
    verify(wrappedResolver).copy(source, destination);
}
Also used : ResourceWrapper(org.apache.sling.api.resource.ResourceWrapper) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Example 9 with ResourceWrapper

use of org.apache.sling.api.resource.ResourceWrapper in project sling by apache.

the class ResourceResolverWrapperTest method testResolve.

@Test
public void testResolve() throws Exception {
    final HttpServletRequest request = mock(HttpServletRequest.class);
    final Resource resource = mock(Resource.class);
    when(resource.getPath()).thenReturn(PATH);
    when(wrappedResolver.resolve(request, PATH)).thenReturn(resource);
    final Resource result = underTest.resolve(request, PATH);
    assertTrue(result instanceof ResourceWrapper);
    assertEquals(underTest, result.getResourceResolver());
    assertEquals(resource.getPath(), result.getPath());
    verify(wrappedResolver).resolve(request, PATH);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ResourceWrapper(org.apache.sling.api.resource.ResourceWrapper) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Example 10 with ResourceWrapper

use of org.apache.sling.api.resource.ResourceWrapper in project sling by apache.

the class ResourceResolverWrapperTest method testGetResource.

@Test
public void testGetResource() throws Exception {
    final Resource resource = mock(Resource.class);
    when(resource.getPath()).thenReturn(PATH);
    when(wrappedResolver.getResource(PATH)).thenReturn(resource);
    final Resource result = underTest.getResource(PATH);
    assertTrue(result instanceof ResourceWrapper);
    assertEquals(underTest, result.getResourceResolver());
    assertEquals(resource.getPath(), result.getPath());
    verify(wrappedResolver).getResource(PATH);
}
Also used : ResourceWrapper(org.apache.sling.api.resource.ResourceWrapper) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Aggregations

ResourceWrapper (org.apache.sling.api.resource.ResourceWrapper)19 Resource (org.apache.sling.api.resource.Resource)18 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1 ResourceMetadata (org.apache.sling.api.resource.ResourceMetadata)1