Search in sources :

Example 1 with CreateTask

use of org.forgerock.openam.sm.datalayer.impl.tasks.CreateTask in project OpenAM by OpenRock.

the class SeriesTaskExecutorTest method shouldCatchTimeoutWhenOfferingTaskToQueue.

@Test
public void shouldCatchTimeoutWhenOfferingTaskToQueue() throws Exception {
    // Given
    given(configuration.getQueueTimeout()).willReturn(0);
    given(configuration.getQueueSize()).willReturn(1);
    given(configuration.getProcessors()).willReturn(2);
    CreateTask task = mock(CreateTask.class);
    executor.start();
    // First create fills the queue
    executor.execute("123", task);
    // When
    DataLayerException result = null;
    try {
        // Second create causes timeout.
        executor.execute("123", task);
        fail("Expected exception");
    } catch (DataLayerException e) {
        result = e;
    }
    // Then
    assertThat(result).isNotNull();
}
Also used : DataLayerException(org.forgerock.openam.sm.datalayer.api.DataLayerException) CreateTask(org.forgerock.openam.sm.datalayer.impl.tasks.CreateTask) Test(org.testng.annotations.Test)

Aggregations

DataLayerException (org.forgerock.openam.sm.datalayer.api.DataLayerException)1 CreateTask (org.forgerock.openam.sm.datalayer.impl.tasks.CreateTask)1 Test (org.testng.annotations.Test)1