Search in sources :

Example 41 with DistributionPackage

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

the class PriorityQueueDispatchingStrategyTest method testMatchingDispatching.

@Test
public void testMatchingDispatching() throws Exception {
    PriorityQueueDispatchingStrategy dispatchingStrategy = new PriorityQueueDispatchingStrategy(selectors, queueNames);
    DistributionPackage distributionPackage = mock(SharedDistributionPackage.class);
    DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(DistributionPackageInfo.PROPERTY_REQUEST_PATHS, new String[] { "/content/news/a" });
    when(distributionPackage.getInfo()).thenReturn(new DistributionPackageInfo("vlt", properties));
    DistributionQueue news1 = mock(DistributionQueue.class);
    when(news1.getName()).thenReturn("news-publish1");
    when(queueProvider.getQueue("news-publish1")).thenReturn(news1);
    DistributionQueue news2 = mock(DistributionQueue.class);
    when(news2.getName()).thenReturn("news-publish2");
    when(queueProvider.getQueue("news-publish2")).thenReturn(news2);
    dispatchingStrategy.add(distributionPackage, queueProvider);
    verify(queueProvider).getQueue("news-publish1");
    verify(queueProvider).getQueue("news-publish2");
    verifyNoMoreInteractions(queueProvider);
}
Also used : DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) SharedDistributionPackage(org.apache.sling.distribution.packaging.impl.SharedDistributionPackage) DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) HashMap(java.util.HashMap) DistributionQueue(org.apache.sling.distribution.queue.DistributionQueue) DistributionQueueProvider(org.apache.sling.distribution.queue.DistributionQueueProvider) Test(org.junit.Test)

Example 42 with DistributionPackage

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

the class ReferencePackageTest method testDelete.

@Test
public void testDelete() 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.delete();
}
Also used : DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) Test(org.junit.Test)

Example 43 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 44 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 45 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)

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