use of org.apache.sling.jobs.impl.storage.InMemoryJobStorage in project sling by apache.
the class ManagerSubscriberTest method setUp.
@Before
public void setUp() throws Exception {
topicQueues = new HashMap<org.apache.sling.mom.Types.TopicName, Queue<QueueEntry>>();
messageQueues = new HashMap<org.apache.sling.mom.Types.QueueName, Queue<QueueEntry>>();
//noinspection unchecked
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
org.apache.sling.mom.Types.TopicName topic = (org.apache.sling.mom.Types.TopicName) invocationOnMock.getArguments()[0];
org.apache.sling.mom.Types.CommandName command = (org.apache.sling.mom.Types.CommandName) invocationOnMock.getArguments()[1];
@SuppressWarnings("unchecked") Map<String, Object> properties = (Map<String, Object>) invocationOnMock.getArguments()[2];
Queue<QueueEntry> queue = topicQueues.get(topic);
if (queue == null) {
queue = new ArrayBlockingQueue<QueueEntry>(100);
topicQueues.put(topic, queue);
}
queue.add(new QueueEntry(command, properties));
return null;
}
}).when(topicManager).publish(Mockito.any(org.apache.sling.mom.Types.TopicName.class), Mockito.any(org.apache.sling.mom.Types.CommandName.class), Mockito.any(Map.class));
//noinspection unchecked
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
org.apache.sling.mom.Types.QueueName topic = (org.apache.sling.mom.Types.QueueName) invocationOnMock.getArguments()[0];
@SuppressWarnings("unchecked") Map<String, Object> properties = (Map<String, Object>) invocationOnMock.getArguments()[1];
Queue<QueueEntry> queue = messageQueues.get(topic);
if (queue == null) {
queue = new ArrayBlockingQueue<QueueEntry>(100);
messageQueues.put(topic, queue);
}
queue.add(new QueueEntry(properties));
return null;
}
}).when(queueManager).add(Mockito.any(org.apache.sling.mom.Types.QueueName.class), Mockito.any(Map.class));
messageSender = new OutboundJobUpdateListener(topicManager, queueManager);
jobStorage = new InMemoryJobStorage();
jobManager = new JobManagerImpl(jobStorage, messageSender);
managerSubscriber = new ManagerSubscriber();
Field f = managerSubscriber.getClass().getDeclaredField("jobManager");
f.setAccessible(true);
f.set(managerSubscriber, jobManager);
}
use of org.apache.sling.jobs.impl.storage.InMemoryJobStorage in project sling by apache.
the class JobSubsystem method activate.
@Activate
public synchronized void activate() {
jobStorage = new InMemoryJobStorage();
messageSender = new OutboundJobUpdateListener(topicManager, queueManager);
manager = new JobManagerImpl(jobStorage, messageSender);
}
use of org.apache.sling.jobs.impl.storage.InMemoryJobStorage in project sling by apache.
the class JobManagerImplTest method setUp.
@Before
public void setUp() throws Exception {
topicQueues = new HashMap<org.apache.sling.mom.Types.TopicName, Queue<QueueEntry>>();
messageQueues = new HashMap<org.apache.sling.mom.Types.QueueName, Queue<QueueEntry>>();
//noinspection unchecked
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
org.apache.sling.mom.Types.TopicName topic = (org.apache.sling.mom.Types.TopicName) invocationOnMock.getArguments()[0];
org.apache.sling.mom.Types.CommandName command = (org.apache.sling.mom.Types.CommandName) invocationOnMock.getArguments()[1];
@SuppressWarnings("unchecked") Map<String, Object> properties = (Map<String, Object>) invocationOnMock.getArguments()[2];
LOGGER.info("Topic Manager publish {} {} {} ", new Object[] { topic, command, properties });
Queue<QueueEntry> queue = topicQueues.get(topic);
if (queue == null) {
queue = new ArrayBlockingQueue<QueueEntry>(100);
topicQueues.put(topic, queue);
}
queue.add(new QueueEntry(command, properties));
return null;
}
}).when(topicManager).publish(Mockito.any(org.apache.sling.mom.Types.TopicName.class), Mockito.any(org.apache.sling.mom.Types.CommandName.class), Mockito.any(Map.class));
//noinspection unchecked
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
org.apache.sling.mom.Types.QueueName topic = (org.apache.sling.mom.Types.QueueName) invocationOnMock.getArguments()[0];
@SuppressWarnings("unchecked") Map<String, Object> properties = (Map<String, Object>) invocationOnMock.getArguments()[1];
LOGGER.info("Queue Manager add {} {} {} ", new Object[] { topic, properties });
Queue<QueueEntry> queue = messageQueues.get(topic);
if (queue == null) {
queue = new ArrayBlockingQueue<QueueEntry>(100);
messageQueues.put(topic, queue);
}
queue.add(new QueueEntry(properties));
return null;
}
}).when(queueManager).add(Mockito.any(org.apache.sling.mom.Types.QueueName.class), Mockito.any(Map.class));
messageSender = new OutboundJobUpdateListener(topicManager, queueManager);
jobStorage = new InMemoryJobStorage();
jobManager = new JobManagerImpl(jobStorage, messageSender);
}
Aggregations