Search in sources :

Example 16 with SimpleDistributionRequest

use of org.apache.sling.distribution.SimpleDistributionRequest in project sling by apache.

the class RemoteDistributionPackageExporterTest method testNothingExported.

@Test
public void testNothingExported() 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);
    DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.ADD, "/");
    final List<DistributionPackage> distributionPackages = new ArrayList<DistributionPackage>();
    remotedistributionPackageExporter.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);
    assertTrue(distributionPackages.isEmpty());
}
Also used : ArrayList(java.util.ArrayList) DistributionTransportSecretProvider(org.apache.sling.distribution.transport.DistributionTransportSecretProvider) DefaultDistributionLog(org.apache.sling.distribution.log.impl.DefaultDistributionLog) HttpConfiguration(org.apache.sling.distribution.transport.impl.HttpConfiguration) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionPackageProcessor(org.apache.sling.distribution.packaging.DistributionPackageProcessor) DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 17 with SimpleDistributionRequest

use of org.apache.sling.distribution.SimpleDistributionRequest in project sling by apache.

the class AvroContentSerializerTest method testExtractDeep.

@Test
public void testExtractDeep() throws Exception {
    AvroContentSerializer avroContentSerializer = new AvroContentSerializer("avro");
    DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, true, "/libs");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    NavigableMap<String, List<String>> nodeFilters = new TreeMap<String, List<String>>();
    NavigableMap<String, List<String>> propertyFilters = new TreeMap<String, List<String>>();
    try {
        DistributionExportFilter filter = DistributionExportFilter.createFilter(request, nodeFilters, propertyFilters);
        avroContentSerializer.exportToStream(resourceResolver, new DistributionExportOptions(request, filter), outputStream);
        byte[] bytes = outputStream.toByteArray();
        assertNotNull(bytes);
        assertTrue(bytes.length > 0);
    } finally {
        outputStream.close();
    }
}
Also used : DistributionExportOptions(org.apache.sling.distribution.serialization.DistributionExportOptions) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) List(java.util.List) DistributionExportFilter(org.apache.sling.distribution.serialization.DistributionExportFilter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 18 with SimpleDistributionRequest

use of org.apache.sling.distribution.SimpleDistributionRequest in project sling by apache.

the class AvroContentSerializerTest method testBuildAndInstallOnSingleShallowPath.

@Test
public void testBuildAndInstallOnSingleShallowPath() throws Exception {
    String type = "avro";
    DistributionContentSerializer contentSerializer = new AvroContentSerializer(type);
    String tempFilesFolder = "target";
    String[] nodeFilters = new String[0];
    String[] propertyFilters = new String[0];
    DistributionPackageBuilder packageBuilder = new FileDistributionPackageBuilder(type, contentSerializer, tempFilesFolder, null, nodeFilters, propertyFilters);
    DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/libs/sub");
    DistributionPackage distributionPackage = packageBuilder.createPackage(resourceResolver, request);
    Resource resource = resourceResolver.getResource("/libs/sub");
    resourceResolver.delete(resource);
    resourceResolver.commit();
    assertTrue(packageBuilder.installPackage(resourceResolver, distributionPackage));
    assertNotNull(resourceResolver.getResource("/libs"));
    assertNotNull(resourceResolver.getResource("/libs/sub"));
    assertNotNull(resourceResolver.getResource("/libs/sameLevel"));
}
Also used : FileDistributionPackageBuilder(org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) FileDistributionPackageBuilder(org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) Resource(org.apache.sling.api.resource.Resource) DistributionContentSerializer(org.apache.sling.distribution.serialization.DistributionContentSerializer) Test(org.junit.Test)

Example 19 with SimpleDistributionRequest

use of org.apache.sling.distribution.SimpleDistributionRequest 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);
}
Also used : FileDistributionPackageBuilder(org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) InputStream(java.io.InputStream) FileDistributionPackageBuilder(org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) DistributionEventFactory(org.apache.sling.distribution.event.impl.DistributionEventFactory) PackagingImpl(org.apache.jackrabbit.vault.packaging.impl.PackagingImpl) FileVaultContentSerializer(org.apache.sling.distribution.serialization.impl.vlt.FileVaultContentSerializer) Test(org.junit.Test)

Example 20 with SimpleDistributionRequest

use of org.apache.sling.distribution.SimpleDistributionRequest 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());
}
Also used : SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionPackageProcessor(org.apache.sling.distribution.packaging.DistributionPackageProcessor) DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

SimpleDistributionRequest (org.apache.sling.distribution.SimpleDistributionRequest)33 DistributionRequest (org.apache.sling.distribution.DistributionRequest)31 Test (org.junit.Test)26 DistributionPackage (org.apache.sling.distribution.packaging.DistributionPackage)16 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)11 DistributionPackageBuilder (org.apache.sling.distribution.packaging.DistributionPackageBuilder)11 List (java.util.List)9 DefaultDistributionLog (org.apache.sling.distribution.log.impl.DefaultDistributionLog)8 DistributionPackageProcessor (org.apache.sling.distribution.packaging.DistributionPackageProcessor)8 FileDistributionPackageBuilder (org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder)7 TreeMap (java.util.TreeMap)6 Resource (org.apache.sling.api.resource.Resource)6 DistributionResponse (org.apache.sling.distribution.DistributionResponse)6 DistributionEventFactory (org.apache.sling.distribution.event.impl.DistributionEventFactory)6 DistributionPackageInfo (org.apache.sling.distribution.packaging.DistributionPackageInfo)6 DistributionContentSerializer (org.apache.sling.distribution.serialization.DistributionContentSerializer)6 SlingRepository (org.apache.sling.jcr.api.SlingRepository)6 ArrayList (java.util.ArrayList)5 ResourceResolverFactory (org.apache.sling.api.resource.ResourceResolverFactory)5 DistributionPackageExporter (org.apache.sling.distribution.packaging.DistributionPackageExporter)5