use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class LocalDistributionPackageImporterTest method importPackageWithLargeHeader.
@Test
public void importPackageWithLargeHeader() throws Exception {
DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
DistributionEventFactory distributionEventFactory = mock(DistributionEventFactory.class);
LocalDistributionPackageImporter localdistributionPackageImporter = new LocalDistributionPackageImporter("mockImporter", distributionEventFactory, packageBuilder);
FileVaultContentSerializer vaultSerializer = new FileVaultContentSerializer("importPackageWithLargeHeader", new PackagingImpl(), ImportMode.UPDATE, AccessControlHandling.IGNORE, new String[0], new String[0], new String[0], false, -1);
DistributionPackageBuilder builder = new FileDistributionPackageBuilder(DistributionRequestType.ADD.name(), vaultSerializer, null, null, null, null);
ResourceResolver resourceResolver = slingContext.resourceResolver();
String[] paths = createPaths(resourceResolver, 1000, "/content/company/de/press-releases/2016/11/04/message");
DistributionPackage pkg = builder.createPackage(resourceResolver, new SimpleDistributionRequest(DistributionRequestType.ADD, paths));
InputStream streamWithHeader = DistributionPackageUtils.createStreamWithHeader(pkg);
localdistributionPackageImporter.importStream(resourceResolver, streamWithHeader);
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class LocalDistributionPackageImporterTest method testDummyImport.
@Test
public void testDummyImport() throws Exception {
DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
DistributionEventFactory distributionEventFactory = mock(DistributionEventFactory.class);
LocalDistributionPackageImporter localdistributionPackageImporter = new LocalDistributionPackageImporter("mockImporter", distributionEventFactory, packageBuilder);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionPackage distributionPackage = mock(DistributionPackage.class);
localdistributionPackageImporter.importPackage(resourceResolver, distributionPackage);
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class RemoteDistributionPackageExporterTest method testFailedPackageRetrieval.
@Test
public void testFailedPackageRetrieval() throws Exception {
DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
String[] endpoints = new String[0];
RemoteDistributionPackageExporter remotedistributionPackageExporter = new RemoteDistributionPackageExporter(mock(DefaultDistributionLog.class), packageBuilder, distributionTransportSecretProvider, endpoints, 1, new HttpConfiguration(10000));
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionPackage distributionPackage = remotedistributionPackageExporter.getPackage(resourceResolver, "123");
assertNull(distributionPackage);
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class RemoteDistributionPackageImporterTest method testDummyImport.
@Test
public void testDummyImport() throws Exception {
DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
Map<String, String> endpoints = new HashMap<String, String>();
RemoteDistributionPackageImporter remotedistributionPackageImporter = new RemoteDistributionPackageImporter(mock(DefaultDistributionLog.class), distributionTransportSecretProvider, endpoints, new HttpConfiguration(10000));
endpoints.put("default", "http://endpoint");
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionPackage distributionPackage = mock(DistributionPackage.class);
DistributionPackageInfo info = new DistributionPackageInfo("/foo");
when(distributionPackage.getInfo()).thenReturn(info);
remotedistributionPackageImporter.importPackage(resourceResolver, distributionPackage);
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class RepositoryDistributionPackageImporterTest method testImportPackageWithoutRequiredPrivileges.
@Test(expected = DistributionException.class)
public void testImportPackageWithoutRequiredPrivileges() throws Exception {
SlingRepository repository = mock(SlingRepository.class);
String serviceName = "admin";
Session session = mock(Session.class);
AccessControlManager acm = mock(AccessControlManager.class);
String privilegeName = "jcr:read";
Privilege privilege = mock(Privilege.class);
when(acm.privilegeFromName(privilegeName)).thenReturn(privilege);
when(session.getAccessControlManager()).thenReturn(acm);
when(repository.loginService(serviceName, null)).thenReturn(session);
String path = "/var/something";
RepositoryDistributionPackageImporter repositoryDistributionPackageImporter = new RepositoryDistributionPackageImporter(repository, serviceName, path, privilegeName);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionPackage distributionPackage = mock(DistributionPackage.class);
when(distributionPackage.getId()).thenReturn("someid");
repositoryDistributionPackageImporter.importPackage(resourceResolver, distributionPackage);
}
Aggregations