use of org.apache.sling.event.jobs.JobManager in project sling by apache.
the class JobHandlingDistributionQueueTest method testPackageAddition.
@SuppressWarnings("unchecked")
@Test
public void testPackageAddition() throws Exception {
JobManager jobManager = mock(JobManager.class);
JobBuilder builder = mock(JobBuilder.class);
when(builder.properties(any(Map.class))).thenReturn(builder);
Job job = mock(Job.class);
when(job.getId()).thenReturn("id-123");
when(builder.add()).thenReturn(job);
String topic = JobHandlingDistributionQueue.DISTRIBUTION_QUEUE_TOPIC + "/aname";
when(jobManager.createJob(topic)).thenReturn(builder);
when(jobManager.findJobs(JobManager.QueryType.ALL, topic, -1)).thenReturn(Collections.<Job>emptySet());
when(builder.properties(any(Map.class))).thenReturn(builder);
DistributionQueue queue = new JobHandlingDistributionQueue("aname", topic, jobManager, true, DistributionQueueType.ORDERED);
DistributionPackageInfo packageInfo = new DistributionPackageInfo("type");
packageInfo.put(DistributionPackageInfo.PROPERTY_REQUEST_PATHS, new String[] { "/foo" });
packageInfo.put(DistributionPackageInfo.PROPERTY_REQUEST_TYPE, DistributionRequestType.ADD);
DistributionQueueItem distributionQueueItem = new DistributionQueueItem("an-id", packageInfo);
assertNotNull(queue.add(distributionQueueItem));
}
use of org.apache.sling.event.jobs.JobManager in project sling by apache.
the class JobHandlingDistributionQueueProviderTest method testEnableQueueProcessing.
@Test
public void testEnableQueueProcessing() throws Exception {
JobManager jobManager = mock(JobManager.class);
ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
Configuration config = mock(Configuration.class);
when(configAdmin.createFactoryConfiguration(QueueConfiguration.class.getName(), null)).thenReturn(config);
BundleContext context = mock(BundleContext.class);
JobHandlingDistributionQueueProvider jobHandlingdistributionQueueProvider = new JobHandlingDistributionQueueProvider("dummy-agent", jobManager, context);
DistributionQueueProcessor queueProcessor = mock(DistributionQueueProcessor.class);
jobHandlingdistributionQueueProvider.enableQueueProcessing(queueProcessor);
}
Aggregations