use of org.apache.sling.distribution.event.impl.DistributionEventFactory in project sling by apache.
the class QueueingDistributionPackageProcessorTest method testGetPackagesCount.
@Test
public void testGetPackagesCount() throws Exception {
String callingUser = "mr-who-cares";
String requestId = "id231";
long startTime = System.currentTimeMillis();
DistributionEventFactory eventFactory = mock(DistributionEventFactory.class);
DistributionQueueDispatchingStrategy scheduleQueueStrategy = mock(DistributionQueueDispatchingStrategy.class);
DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
DefaultDistributionLog log = mock(DefaultDistributionLog.class);
String agentName = "dummy";
QueueingDistributionPackageProcessor exporterProcessor = new QueueingDistributionPackageProcessor(callingUser, requestId, startTime, eventFactory, scheduleQueueStrategy, queueProvider, log, agentName);
int packagesCount = exporterProcessor.getPackagesCount();
assertEquals(0, packagesCount);
}
use of org.apache.sling.distribution.event.impl.DistributionEventFactory in project sling by apache.
the class QueueingDistributionPackageProcessorTest method testGetPackagesSize.
@Test
public void testGetPackagesSize() throws Exception {
String callingUser = "mr-who-cares";
String requestId = "id231";
long startTime = System.currentTimeMillis();
DistributionEventFactory eventFactory = mock(DistributionEventFactory.class);
DistributionQueueDispatchingStrategy scheduleQueueStrategy = mock(DistributionQueueDispatchingStrategy.class);
DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
DefaultDistributionLog log = mock(DefaultDistributionLog.class);
String agentName = "dummy";
QueueingDistributionPackageProcessor exporterProcessor = new QueueingDistributionPackageProcessor(callingUser, requestId, startTime, eventFactory, scheduleQueueStrategy, queueProvider, log, agentName);
long packagesSize = exporterProcessor.getPackagesSize();
assertEquals(0L, packagesSize);
}
use of org.apache.sling.distribution.event.impl.DistributionEventFactory in project sling by apache.
the class QueueingDistributionPackageProcessorTest method testProcess.
@Test
public void testProcess() throws Exception {
String callingUser = "mr-who-cares";
String requestId = "id231";
long startTime = System.currentTimeMillis();
DistributionEventFactory eventFactory = mock(DistributionEventFactory.class);
DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
DistributionPackage distributionPackage = mock(DistributionPackage.class);
DistributionQueueDispatchingStrategy scheduleQueueStrategy = mock(DistributionQueueDispatchingStrategy.class);
// assume scheduling works
List<DistributionQueueItemStatus> statuses = new LinkedList<DistributionQueueItemStatus>();
DistributionQueueItemStatus qis = new DistributionQueueItemStatus(DistributionQueueItemState.QUEUED, "queue-1");
statuses.add(qis);
when(scheduleQueueStrategy.add(distributionPackage, queueProvider)).thenReturn(statuses);
DefaultDistributionLog log = mock(DefaultDistributionLog.class);
String agentName = "dummy";
QueueingDistributionPackageProcessor exporterProcessor = new QueueingDistributionPackageProcessor(callingUser, requestId, startTime, eventFactory, scheduleQueueStrategy, queueProvider, log, agentName);
DistributionPackageInfo info = new DistributionPackageInfo("type-a", new HashMap<String, Object>());
when(distributionPackage.getInfo()).thenReturn(info);
exporterProcessor.process(distributionPackage);
}
use of org.apache.sling.distribution.event.impl.DistributionEventFactory in project sling by apache.
the class SimpleDistributionAgentQueueProcessorTest method testProcess.
@Test
public void testProcess() throws Exception {
DistributionPackageExporter packageExporter = mock(DistributionPackageExporter.class);
DistributionPackageImporter packageImporter = mock(DistributionPackageImporter.class);
int retryAttempts = 3;
DefaultDistributionLog log = mock(DefaultDistributionLog.class);
DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
DistributionEventFactory eventFactory = mock(DistributionEventFactory.class);
SimpleDistributionAgentAuthenticationInfo authenticationInfo = mock(SimpleDistributionAgentAuthenticationInfo.class);
String agentName = "dummy-a";
SimpleDistributionAgentQueueProcessor queueProcessor = new SimpleDistributionAgentQueueProcessor(packageExporter, packageImporter, retryAttempts, null, log, queueProvider, eventFactory, authenticationInfo, agentName);
String id = "123-456";
DistributionQueueItem item = new DistributionQueueItem("pckg-123", new HashMap<String, Object>());
String queueName = "queue-1";
DistributionQueueItemStatus status = new DistributionQueueItemStatus(DistributionQueueItemState.QUEUED, queueName);
DistributionQueueEntry entry = new DistributionQueueEntry(id, item, status);
queueProcessor.process(queueName, entry);
}
use of org.apache.sling.distribution.event.impl.DistributionEventFactory in project sling by apache.
the class SimpleDistributionAgentTest method testGetNonExistingNamedQueue.
@Test
public void testGetNonExistingNamedQueue() throws Exception {
String name = "sample-agent";
DistributionPackageImporter packageImporter = mock(DistributionPackageImporter.class);
DistributionPackageExporter packageExporter = mock(DistributionPackageExporter.class);
DistributionRequestAuthorizationStrategy packageExporterStrategy = mock(DistributionRequestAuthorizationStrategy.class);
DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
DistributionQueueDispatchingStrategy distributionHandler = mock(DistributionQueueDispatchingStrategy.class);
DistributionEventFactory distributionEventFactory = mock(DistributionEventFactory.class);
ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
SimpleDistributionAgent agent = new SimpleDistributionAgent(name, false, null, "serviceName", packageImporter, packageExporter, packageExporterStrategy, queueProvider, distributionHandler, null, distributionEventFactory, resolverFactory, mock(SlingRepository.class), mock(DefaultDistributionLog.class), null, null, 0);
DistributionQueue queue = mock(DistributionQueue.class);
when(queueProvider.getQueue("priority")).thenReturn(queue);
assertNull(agent.getQueue("weird"));
}
Aggregations