use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method untakeAddsElementFirst.
@Test
public void untakeAddsElementFirst() throws Exception {
QueueStore queue = createQueue();
queue.offer(VALUE, 0, 10);
queue.untake(ANOTHER_VALUE);
assertThat((String) queue.poll(10), is(ANOTHER_VALUE));
}
use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method offerAndPollSingleValue.
@Test
public void offerAndPollSingleValue() throws InterruptedException, ObjectStoreException {
QueueStore queue = createQueue();
queue.offer(VALUE, 0, OFFER_TIMEOUT);
Serializable result = queue.poll(OFFER_TIMEOUT);
assertThat((String) result, is(VALUE));
}
use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method allowOfferWhenThereIsCapacity.
@Test
public void allowOfferWhenThereIsCapacity() throws Exception {
QueueStore queue = createQueueWithCapacity(1);
assertThat(queue.offer(VALUE, 0, 10), is(true));
queue.poll(10);
assertThat(queue.offer(VALUE, 0, 10), is(true));
}
use of org.mule.runtime.core.internal.util.queue.QueueStore in project mule by mulesoft.
the class QueueStoreTestCase method clearEmptiesTheQueue.
@Test
public void clearEmptiesTheQueue() throws Exception {
QueueStore queue = createQueue();
queue.putNow(VALUE);
queue.putNow(ANOTHER_VALUE);
queue.clear();
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 offerSeveralRetrieveAllMuleEvents.
@Test
public void offerSeveralRetrieveAllMuleEvents() throws Exception {
QueueStore queue = createQueue();
ArrayList<CoreEvent> events = new ArrayList<>(NUMBER_OF_ITEMS);
for (int i = 0; i < NUMBER_OF_ITEMS; i++) {
CoreEvent testEvent = eventBuilder(muleContext).message(of("some data")).build();
events.add(testEvent);
queue.offer(testEvent, 0, NUMBER_OF_ITEMS);
}
for (int i = 0; i < NUMBER_OF_ITEMS; i++) {
assertThat(((CoreEvent) queue.poll(NUMBER_OF_ITEMS)).getContext().getId().equals(events.get(i).getContext().getId()), is(true));
}
}
Aggregations