use of org.apache.sling.api.resource.Resource in project sling by apache.
the class ResourceDecorationTest method getRootIsDecorated.
@Test
public void getRootIsDecorated() {
final Resource r = resolver.getResource("/");
assertDecorated(r);
assertExistent(r, true);
}
use of org.apache.sling.api.resource.Resource in project sling by apache.
the class ResourceDecoratorReturnsNullTest method testVarChildren.
@Test
public void testVarChildren() {
final Resource var = resolver.resolve("/var");
assertNotNull(var);
assertResources(resolver.listChildren(var), "/var/one", "/var/two", "/var/three");
}
use of org.apache.sling.api.resource.Resource in project sling by apache.
the class ResourceDecoratorReturnsNullTest method testRootChildren.
@Test
public void testRootChildren() {
final Resource root = resolver.resolve("/");
assertNotNull(root);
assertResources(resolver.listChildren(root), "/tmp", "/var");
}
use of org.apache.sling.api.resource.Resource in project sling by apache.
the class ResourceDecoratorTestBase method mockResource.
protected Resource mockResource(String path) {
final Resource result = Mockito.mock(Resource.class);
Mockito.when(result.getPath()).thenReturn(path);
Mockito.when(result.getName()).thenReturn(ResourceUtil.getName(path));
final ResourceMetadata m = new ResourceMetadata();
Mockito.when(result.getResourceMetadata()).thenReturn(m);
return result;
}
use of org.apache.sling.api.resource.Resource in project sling by apache.
the class ResourceProviderEntryTest method testRemoveTheOnlyProvider.
@Test
public void testRemoveTheOnlyProvider() throws LoginException {
long counter = 1;
providers.clear();
for (String path : new String[] { "/foo", "/", "/foo/bar" }) {
final ResourceResolver resolver = Mockito.mock(ResourceResolver.class);
final ResourceProvider<?> p = Mockito.mock(ResourceProvider.class);
Mockito.when(p.getResource(Mockito.any(ResolveContext.class), Mockito.startsWith(path), Mockito.any(ResourceContext.class), Mockito.any(Resource.class))).thenReturn(new TestResource(resolver));
++counter;
ResourceProviderHandler h = createRPHandler(p, "rp" + counter, counter, path);
providers.add(h);
this.providersBasedResolver = null;
{
final Resource r = getResource(path);
assertEqualsResolver(resolver, r);
assertFalse(r instanceof SyntheticResource);
}
providers.remove(h);
this.providersBasedResolver = null;
{
final Resource r = getResource(path);
// If our provider is indeed gone, we should get one of the following conditions
if (r == null) {
//fine
} else if (!p.equals(r.getResourceResolver())) {
//fine
} else {
fail("Expecting inactive provider after removing it for " + path);
}
}
}
}
Aggregations