Search in sources :

Example 1 with QueueStore

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

Example 2 with QueueStore

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

Example 3 with QueueStore

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

Example 4 with QueueStore

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

Example 5 with QueueStore

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