use of org.apache.sling.distribution.DistributionRequest in project sling by apache.
the class PrivilegeDistributionRequestAuthorizationStrategyTest method testCheckPermissionWithoutSession.
@Test(expected = DistributionException.class)
public void testCheckPermissionWithoutSession() throws Exception {
String jcrPrivilege = "foo";
PrivilegeDistributionRequestAuthorizationStrategy strategy = new PrivilegeDistributionRequestAuthorizationStrategy(jcrPrivilege);
DistributionRequest distributionRequest = mock(DistributionRequest.class);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
strategy.checkPermission(resourceResolver, distributionRequest);
}
use of org.apache.sling.distribution.DistributionRequest in project sling by apache.
the class LocalDistributionPackageExporterTest method testExport.
@Test
public void testExport() throws Exception {
DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
when(packageBuilder.createPackage(any(ResourceResolver.class), any(DistributionRequest.class))).thenReturn(mock(DistributionPackage.class));
LocalDistributionPackageExporter localdistributionPackageExporter = new LocalDistributionPackageExporter(packageBuilder);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.ADD, "/");
final List<DistributionPackage> distributionPackages = new ArrayList<DistributionPackage>();
localdistributionPackageExporter.exportPackages(resourceResolver, distributionRequest, new DistributionPackageProcessor() {
@Override
public void process(DistributionPackage distributionPackage) {
distributionPackages.add(distributionPackage);
}
@Override
public List<DistributionResponse> getAllResponses() {
return null;
}
@Override
public int getPackagesCount() {
return 0;
}
@Override
public long getPackagesSize() {
return 0;
}
});
assertNotNull(distributionPackages);
assertEquals(1, distributionPackages.size());
}
Aggregations