Search in sources :

Example 6 with QueueStore

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));
}
Also used : QueueStore(org.mule.runtime.core.internal.util.queue.QueueStore) Test(org.junit.Test)

Example 7 with QueueStore

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));
}
Also used : Serializable(java.io.Serializable) QueueStore(org.mule.runtime.core.internal.util.queue.QueueStore) Test(org.junit.Test)

Example 8 with QueueStore

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));
}
Also used : QueueStore(org.mule.runtime.core.internal.util.queue.QueueStore) Test(org.junit.Test)

Example 9 with QueueStore

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());
}
Also used : QueueStore(org.mule.runtime.core.internal.util.queue.QueueStore) Test(org.junit.Test)

Example 10 with QueueStore

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));
    }
}
Also used : QueueStore(org.mule.runtime.core.internal.util.queue.QueueStore) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

QueueStore (org.mule.runtime.core.internal.util.queue.QueueStore)10 Test (org.junit.Test)9 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)1 MuleContext (org.mule.runtime.core.api.MuleContext)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1