Search in sources :

Example 56 with DistributionPackage

use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.

the class ReferencePackageTest method testGetType.

@Test
public void testGetType() throws Exception {
    DistributionPackage distributionPackage = mock(DistributionPackage.class);
    String type = "dummy";
    when(distributionPackage.getType()).thenReturn(type);
    DistributionPackageInfo info = new DistributionPackageInfo(type, new HashMap<String, Object>());
    when(distributionPackage.getInfo()).thenReturn(info);
    ReferencePackage referencePackage = new ReferencePackage(distributionPackage);
    assertNotNull(referencePackage);
    assertEquals(type, referencePackage.getType());
}
Also used : DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) Test(org.junit.Test)

Example 57 with DistributionPackage

use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.

the class ReferencePackageTest method testGetSize.

@Test
public void testGetSize() throws Exception {
    DistributionPackage distributionPackage = mock(DistributionPackage.class);
    String type = "dummy";
    when(distributionPackage.getType()).thenReturn(type);
    DistributionPackageInfo info = new DistributionPackageInfo(type, new HashMap<String, Object>());
    when(distributionPackage.getInfo()).thenReturn(info);
    when(distributionPackage.getSize()).thenReturn(10L);
    ReferencePackage referencePackage = new ReferencePackage(distributionPackage);
    assertNotNull(referencePackage);
    long size = referencePackage.getSize();
    // failing assertion with assertEquals shows more details in the message
    // TODO don't we already know the expetced size? this assertion is not accurate...
    assertEquals(size, referencePackage.getSize());
}
Also used : DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) Test(org.junit.Test)

Example 58 with DistributionPackage

use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.

the class ReferencePackageTest method testRelease.

@Test
public void testRelease() throws Exception {
    DistributionPackage distributionPackage = mock(DistributionPackage.class);
    String type = "dummy";
    when(distributionPackage.getType()).thenReturn(type);
    DistributionPackageInfo info = new DistributionPackageInfo(type, new HashMap<String, Object>());
    when(distributionPackage.getInfo()).thenReturn(info);
    ReferencePackage referencePackage = new ReferencePackage(distributionPackage);
    assertNotNull(referencePackage);
    referencePackage.release("queue1", "queue2");
}
Also used : DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) Test(org.junit.Test)

Example 59 with DistributionPackage

use of org.apache.sling.distribution.packaging.DistributionPackage 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

DistributionPackage (org.apache.sling.distribution.packaging.DistributionPackage)59 Test (org.junit.Test)41 DistributionPackageInfo (org.apache.sling.distribution.packaging.DistributionPackageInfo)25 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)21 DistributionRequest (org.apache.sling.distribution.DistributionRequest)17 SimpleDistributionRequest (org.apache.sling.distribution.SimpleDistributionRequest)17 DistributionPackageBuilder (org.apache.sling.distribution.packaging.DistributionPackageBuilder)16 DefaultDistributionLog (org.apache.sling.distribution.log.impl.DefaultDistributionLog)12 DistributionQueueProvider (org.apache.sling.distribution.queue.DistributionQueueProvider)12 HashMap (java.util.HashMap)11 DistributionQueueItemStatus (org.apache.sling.distribution.queue.DistributionQueueItemStatus)10 DistributionException (org.apache.sling.distribution.common.DistributionException)9 DistributionPackageProcessor (org.apache.sling.distribution.packaging.DistributionPackageProcessor)9 SlingRepository (org.apache.sling.jcr.api.SlingRepository)9 InputStream (java.io.InputStream)8 DistributionEventFactory (org.apache.sling.distribution.event.impl.DistributionEventFactory)8 FileDistributionPackageBuilder (org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder)8 Resource (org.apache.sling.api.resource.Resource)7 DistributionPackageExporter (org.apache.sling.distribution.packaging.DistributionPackageExporter)7 DistributionQueue (org.apache.sling.distribution.queue.DistributionQueue)7