Search in sources :

Example 1 with DistributionQueueProcessor

use of org.apache.sling.distribution.queue.DistributionQueueProcessor in project sling by apache.

the class SimpleDistributionQueueProviderTest method testEnableQueueProcessing.

@Test
public void testEnableQueueProcessing() throws Exception {
    Scheduler scheduler = mock(Scheduler.class);
    ScheduleOptions options = mock(ScheduleOptions.class);
    when(scheduler.NOW(-1, 1)).thenReturn(options);
    when(options.canRunConcurrently(false)).thenReturn(options);
    when(options.name(any(String.class))).thenReturn(options);
    String name = "dummy-agent";
    SimpleDistributionQueueProvider simpledistributionQueueProvider = new SimpleDistributionQueueProvider(scheduler, name, false);
    DistributionQueueProcessor processor = mock(DistributionQueueProcessor.class);
    simpledistributionQueueProvider.enableQueueProcessing(processor);
}
Also used : DistributionQueueProcessor(org.apache.sling.distribution.queue.DistributionQueueProcessor) ScheduleOptions(org.apache.sling.commons.scheduler.ScheduleOptions) Scheduler(org.apache.sling.commons.scheduler.Scheduler) Test(org.junit.Test)

Example 2 with DistributionQueueProcessor

use of org.apache.sling.distribution.queue.DistributionQueueProcessor in project sling by apache.

the class SimpleDistributionQueueProcessorTest method testRunWithNoQueue.

@Test
public void testRunWithNoQueue() throws Exception {
    DistributionQueue queue = mock(DistributionQueue.class);
    DistributionQueueProcessor queueProcessor = mock(DistributionQueueProcessor.class);
    SimpleDistributionQueueProcessor simpleDistributionQueueProcessor = new SimpleDistributionQueueProcessor(queue, queueProcessor);
    simpleDistributionQueueProcessor.run();
}
Also used : DistributionQueueProcessor(org.apache.sling.distribution.queue.DistributionQueueProcessor) DistributionQueue(org.apache.sling.distribution.queue.DistributionQueue) Test(org.junit.Test)

Example 3 with DistributionQueueProcessor

use of org.apache.sling.distribution.queue.DistributionQueueProcessor in project sling by apache.

the class SimpleDistributionQueueProcessorTest method testRunWithOneNonEmptyQueue.

@Test
public void testRunWithOneNonEmptyQueue() throws Exception {
    SimpleDistributionQueueProvider queueProvider = mock(SimpleDistributionQueueProvider.class);
    Collection<SimpleDistributionQueue> queues = new LinkedList<SimpleDistributionQueue>();
    SimpleDistributionQueue queue = mock(SimpleDistributionQueue.class);
    DistributionQueueItem item = mock(DistributionQueueItem.class);
    when(queue.getHead()).thenReturn(new DistributionQueueEntry(null, item, null)).thenReturn(null);
    queues.add(queue);
    when(queueProvider.getQueues()).thenReturn(queues);
    DistributionQueueProcessor queueProcessor = mock(DistributionQueueProcessor.class);
    SimpleDistributionQueueProcessor simpleDistributionQueueProcessor = new SimpleDistributionQueueProcessor(queue, queueProcessor);
    simpleDistributionQueueProcessor.run();
}
Also used : DistributionQueueProcessor(org.apache.sling.distribution.queue.DistributionQueueProcessor) DistributionQueueEntry(org.apache.sling.distribution.queue.DistributionQueueEntry) LinkedList(java.util.LinkedList) DistributionQueueItem(org.apache.sling.distribution.queue.DistributionQueueItem) Test(org.junit.Test)

Example 4 with DistributionQueueProcessor

use of org.apache.sling.distribution.queue.DistributionQueueProcessor in project sling by apache.

the class SimpleDistributionQueueProcessorTest method testRunWithOneEmptyQueue.

@Test
public void testRunWithOneEmptyQueue() throws Exception {
    SimpleDistributionQueueProvider queueProvider = mock(SimpleDistributionQueueProvider.class);
    Collection<SimpleDistributionQueue> queues = new LinkedList<SimpleDistributionQueue>();
    SimpleDistributionQueue queue = mock(SimpleDistributionQueue.class);
    when(queue.getHead()).thenReturn(null);
    queues.add(queue);
    when(queueProvider.getQueues()).thenReturn(queues);
    DistributionQueueProcessor queueProcessor = mock(DistributionQueueProcessor.class);
    SimpleDistributionQueueProcessor simpleDistributionQueueProcessor = new SimpleDistributionQueueProcessor(queue, queueProcessor);
    simpleDistributionQueueProcessor.run();
}
Also used : DistributionQueueProcessor(org.apache.sling.distribution.queue.DistributionQueueProcessor) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 5 with DistributionQueueProcessor

use of org.apache.sling.distribution.queue.DistributionQueueProcessor in project sling by apache.

the class SimpleDistributionQueueProviderTest method testEnableQueueProcessingWithCheckpointing.

@Test
public void testEnableQueueProcessingWithCheckpointing() throws Exception {
    String name = "dummy-agent";
    try {
        Scheduler scheduler = mock(Scheduler.class);
        ScheduleOptions options = mock(ScheduleOptions.class);
        when(scheduler.NOW(-1, 1)).thenReturn(options);
        when(options.canRunConcurrently(false)).thenReturn(options);
        when(options.name(any(String.class))).thenReturn(options);
        SimpleDistributionQueueProvider simpledistributionQueueProvider = new SimpleDistributionQueueProvider(scheduler, name, true);
        DistributionQueueProcessor processor = mock(DistributionQueueProcessor.class);
        simpledistributionQueueProvider.enableQueueProcessing(processor);
    } finally {
        new File(name + "-simple-queues-checkpoints").deleteOnExit();
    }
}
Also used : DistributionQueueProcessor(org.apache.sling.distribution.queue.DistributionQueueProcessor) ScheduleOptions(org.apache.sling.commons.scheduler.ScheduleOptions) Scheduler(org.apache.sling.commons.scheduler.Scheduler) File(java.io.File) Test(org.junit.Test)

Aggregations

DistributionQueueProcessor (org.apache.sling.distribution.queue.DistributionQueueProcessor)9 Test (org.junit.Test)9 DistributionQueueEntry (org.apache.sling.distribution.queue.DistributionQueueEntry)4 ScheduleOptions (org.apache.sling.commons.scheduler.ScheduleOptions)3 Scheduler (org.apache.sling.commons.scheduler.Scheduler)3 File (java.io.File)2 LinkedList (java.util.LinkedList)2 DistributionQueue (org.apache.sling.distribution.queue.DistributionQueue)2 DistributionQueueItem (org.apache.sling.distribution.queue.DistributionQueueItem)2 Job (org.apache.sling.event.jobs.Job)2 JobConsumer (org.apache.sling.event.jobs.consumer.JobConsumer)2 JobManager (org.apache.sling.event.jobs.JobManager)1 QueueConfiguration (org.apache.sling.event.jobs.QueueConfiguration)1 BundleContext (org.osgi.framework.BundleContext)1 Configuration (org.osgi.service.cm.Configuration)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1