Search in sources :

Example 11 with DataLayerException

use of org.forgerock.openam.sm.datalayer.api.DataLayerException 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)11 Token (org.forgerock.openam.cts.api.tokens.Token)4 Test (org.testng.annotations.Test)3 Task (org.forgerock.openam.sm.datalayer.api.Task)2 Collection (java.util.Collection)1 LdapInitializationFailedException (org.forgerock.openam.cts.exceptions.LdapInitializationFailedException)1 CreateTask (org.forgerock.openam.sm.datalayer.impl.tasks.CreateTask)1 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)1 Connection (org.forgerock.opendj.ldap.Connection)1 DN (org.forgerock.opendj.ldap.DN)1 LdapException (org.forgerock.opendj.ldap.LdapException)1 DeleteRequest (org.forgerock.opendj.ldap.requests.DeleteRequest)1