use of org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker in project sling by apache.
the class FactoryPreconditionsTest method testNames.
@Test
public void testNames() {
final ResourceProviderTracker tracker = Mockito.mock(ResourceProviderTracker.class);
final ResourceProviderStorage storage = Mockito.mock(ResourceProviderStorage.class);
Mockito.when(tracker.getResourceProviderStorage()).thenReturn(storage);
FactoryPreconditions conditions = new FactoryPreconditions();
conditions.activate(null, null, new HashSet<>(Arrays.asList("n1", "n2")), tracker);
final List<ResourceProviderHandler> handlers1 = getResourceProviderHandlersWithNames(new String[] { "n2" });
Mockito.when(storage.getAllHandlers()).thenReturn(handlers1);
assertFalse(conditions.checkPreconditions(null, null));
final List<ResourceProviderHandler> handlers2 = getResourceProviderHandlersWithNames(new String[] { "n1", "n2", "n3" });
Mockito.when(storage.getAllHandlers()).thenReturn(handlers2);
assertTrue(conditions.checkPreconditions(null, null));
final List<ResourceProviderHandler> handlers3 = getResourceProviderHandlersWithNames(new String[] { "n1" });
Mockito.when(storage.getAllHandlers()).thenReturn(handlers3);
assertFalse(conditions.checkPreconditions(null, null));
}
use of org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker in project sling by apache.
the class FactoryPreconditionsTest method testDeactivated.
@Test
public void testDeactivated() {
final ResourceProviderTracker tracker = Mockito.mock(ResourceProviderTracker.class);
final ResourceProviderStorage storage = Mockito.mock(ResourceProviderStorage.class);
Mockito.when(tracker.getResourceProviderStorage()).thenReturn(storage);
FactoryPreconditions conditions = new FactoryPreconditions();
conditions.activate(null, null, null, tracker);
assertTrue(conditions.checkPreconditions(null, null));
conditions.deactivate();
assertFalse(conditions.checkPreconditions(null, null));
}
use of org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker in project sling by apache.
the class ResourceResolverImplTest method setup.
@Before
public void setup() throws LoginException {
ResourceProvider<?> rp = new ResourceProvider<Object>() {
@Override
public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext rCtx, Resource parent) {
return null;
}
@Override
public Iterator<Resource> listChildren(ResolveContext<Object> ctx, Resource parent) {
return null;
}
};
List<ResourceProviderHandler> handlers = asList(createRPHandler(rp, "rp1", 0, "/"));
resourceProviderTracker = mock(ResourceProviderTracker.class);
ResourceProviderStorage storage = new ResourceProviderStorage(handlers);
when(resourceProviderTracker.getResourceProviderStorage()).thenReturn(storage);
ResourceResolverFactoryActivator activator = new ResourceResolverFactoryActivator();
activator.resourceProviderTracker = resourceProviderTracker;
activator.resourceAccessSecurityTracker = new ResourceAccessSecurityTracker();
commonFactory = new CommonResourceResolverFactoryImpl(activator);
final Bundle usingBundle = mock(Bundle.class);
resFac = new ResourceResolverFactoryImpl(commonFactory, usingBundle, null);
resResolver = resFac.getAdministrativeResourceResolver(null);
}
use of org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker in project sling by apache.
the class ResourceResolverFactoryTest method setup.
@Before
public void setup() {
ResourceResolverFactoryActivator activator = new ResourceResolverFactoryActivator();
activator.resourceProviderTracker = new ResourceProviderTracker();
commonFactory = new CommonResourceResolverFactoryImpl(activator);
}
Aggregations