use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method peekDoesNotRemoveElement.
@Test
public void peekDoesNotRemoveElement() throws Exception {
QueueStore queue = createQueue();
queue.putNow(VALUE);
assertThat((String) queue.peek(), Is.is(VALUE));
assertThat((String) queue.poll(SHORT_POLL_TIMEOUT), Is.is(VALUE));
}
use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method createQueueWithCapacity.
protected QueueStore createQueueWithCapacity(int capacity) {
MuleContext mockMuleContext = mock(MuleContext.class, Answers.RETURNS_DEEP_STUBS.get());
when(mockMuleContext.getConfiguration().getWorkingDirectory()).thenReturn(temporaryFolder.getRoot().getAbsolutePath());
when(mockMuleContext.getExecutionClassLoader()).thenReturn(muleContext.getExecutionClassLoader());
when(mockMuleContext.getObjectSerializer()).thenReturn(muleContext.getObjectSerializer());
QueueStore queue = createQueueInfoDelegate(capacity, mockMuleContext);
return queue;
}
use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method offerAndPollTwice.
@Test
public void offerAndPollTwice() throws Exception {
QueueStore queue = createQueue();
queue.putNow(VALUE);
Serializable value = queue.poll(SHORT_POLL_TIMEOUT);
assertThat((String) value, is(VALUE));
assertThat(queue.poll(SHORT_POLL_TIMEOUT), nullValue());
}
use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method pollDoesNotReturnsUntilPollTimeout.
@Test
public void pollDoesNotReturnsUntilPollTimeout() throws Exception {
QueueStore queue = createQueue();
long initialTime = System.currentTimeMillis();
queue.poll(LONG_POLL_TIMEOUT);
assertThat(System.currentTimeMillis() - initialTime >= LONG_POLL_TIMEOUT, is(true));
}
use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method failIfThereIsNoCapacity.
@Test
public void failIfThereIsNoCapacity() throws Exception {
QueueStore queue = createQueueWithCapacity(1);
assertThat(queue.offer(VALUE, 0, 10), is(true));
assertThat(queue.offer(VALUE, 0, 10), is(false));
}
Aggregations