use of org.apache.sling.api.resource.ResourceResolverFactory in project sling by apache.
the class SlingRequestStatusHealthCheckTest method setup.
@Before
public void setup() throws Exception {
hc = new SlingRequestStatusHealthCheck();
final ResourceResolverFactory rrf = Mockito.mock(ResourceResolverFactory.class);
SetField.set(hc, "resolverFactory", rrf);
final Answer<Void> a = new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
final HttpServletRequest request = (HttpServletRequest) invocation.getArguments()[0];
final HttpServletResponse response = (HttpServletResponse) invocation.getArguments()[1];
final String path = request.getPathInfo();
if (path.length() > 0) {
final String status = path.substring(0, path.indexOf('.'));
response.setStatus(Integer.valueOf(status));
}
return null;
}
};
final SlingRequestProcessor srp = Mockito.mock(SlingRequestProcessor.class);
SetField.set(hc, "requestProcessor", srp);
Mockito.doAnswer(a).when(srp).processRequest(Matchers.any(HttpServletRequest.class), Matchers.any(HttpServletResponse.class), Matchers.any(ResourceResolver.class));
final Map<String, Object> properties = new HashMap<String, Object>();
properties.put("path", paths);
hc.activate(properties);
}
use of org.apache.sling.api.resource.ResourceResolverFactory in project sling by apache.
the class TenantProviderImplTest method testListTenantsWithoutTenantRoot.
@Test
public void testListTenantsWithoutTenantRoot() throws Exception {
TenantProviderImpl provider = new TenantProviderImpl();
final ResourceResolverFactory rrf = Mockito.mock(ResourceResolverFactory.class);
final BundleContext context = Mockito.mock(BundleContext.class);
final ResourceResolver rr = Mockito.mock(ResourceResolver.class);
Mockito.when(rrf.getServiceResourceResolver(Mockito.anyMapOf(String.class, Object.class))).thenReturn(rr);
set(provider, "factory", rrf);
provider.activate(context, new HashMap<String, Object>());
Iterator<Tenant> tenants = provider.getTenants();
TestCase.assertNotNull(tenants);
TestCase.assertFalse(tenants.hasNext());
}
use of org.apache.sling.api.resource.ResourceResolverFactory in project sling by apache.
the class ImportingDistributionPackageProcessorTest method testGetAllResponses.
@Test
public void testGetAllResponses() throws Exception {
DistributionPackageImporter importer = mock(DistributionPackageImporter.class);
SlingRepository repository = mock(SlingRepository.class);
String agentService = "agentService";
ResourceResolverFactory resourceResolverFactory = mock(ResourceResolverFactory.class);
String subServiceName = "ssn";
SimpleDistributionAgentAuthenticationInfo authInfo = new SimpleDistributionAgentAuthenticationInfo(repository, agentService, resourceResolverFactory, subServiceName);
String callingUser = "foo";
String requestId = "123";
DefaultDistributionLog log = mock(DefaultDistributionLog.class);
ImportingDistributionPackageProcessor processor = new ImportingDistributionPackageProcessor(importer, authInfo, callingUser, requestId, log);
assertNotNull(processor.getAllResponses());
assertTrue(processor.getAllResponses().isEmpty());
}
use of org.apache.sling.api.resource.ResourceResolverFactory in project sling by apache.
the class ImportingDistributionPackageProcessorTest method testGetPackagesCount.
@Test
public void testGetPackagesCount() throws Exception {
DistributionPackageImporter importer = mock(DistributionPackageImporter.class);
SlingRepository repository = mock(SlingRepository.class);
String agentService = "agentService";
ResourceResolverFactory resourceResolverFactory = mock(ResourceResolverFactory.class);
String subServiceName = "ssn";
SimpleDistributionAgentAuthenticationInfo authInfo = new SimpleDistributionAgentAuthenticationInfo(repository, agentService, resourceResolverFactory, subServiceName);
String callingUser = "foo";
String requestId = "123";
DefaultDistributionLog log = mock(DefaultDistributionLog.class);
ImportingDistributionPackageProcessor processor = new ImportingDistributionPackageProcessor(importer, authInfo, callingUser, requestId, log);
assertEquals(0, processor.getPackagesCount());
}
use of org.apache.sling.api.resource.ResourceResolverFactory in project sling by apache.
the class ImportingDistributionPackageProcessorTest method testGetPackagesSize.
@Test
public void testGetPackagesSize() throws Exception {
DistributionPackageImporter importer = mock(DistributionPackageImporter.class);
SlingRepository repository = mock(SlingRepository.class);
String agentService = "agentService";
ResourceResolverFactory resourceResolverFactory = mock(ResourceResolverFactory.class);
String subServiceName = "ssn";
SimpleDistributionAgentAuthenticationInfo authInfo = new SimpleDistributionAgentAuthenticationInfo(repository, agentService, resourceResolverFactory, subServiceName);
String callingUser = "foo";
String requestId = "123";
DefaultDistributionLog log = mock(DefaultDistributionLog.class);
ImportingDistributionPackageProcessor processor = new ImportingDistributionPackageProcessor(importer, authInfo, callingUser, requestId, log);
assertEquals(0, processor.getPackagesSize());
}
Aggregations