Search in sources :

Example 31 with CoreTokenException

use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.

the class CoreTokenAdapterTest method shouldUseTaskQueueForQuery.

@Test
public void shouldUseTaskQueueForQuery() throws CoreTokenException {
    // Given
    Collection<Token> tokens = new ArrayList<Token>();
    ResultHandler<Collection<Token>, CoreTokenException> mockResultHandler = mock(ResultHandler.class);
    given(mockResultHandler.getResults()).willReturn(tokens);
    given(mockResultHandlerFactory.getQueryHandler()).willReturn(mockResultHandler);
    TokenFilter filter = new TokenFilterBuilder().and().build();
    // When
    adapter.query(filter);
    // Then
    verify(mockTaskDispatcher).query(eq(filter), eq(mockResultHandler));
}
Also used : ArrayList(java.util.ArrayList) Collection(java.util.Collection) CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) Token(org.forgerock.openam.cts.api.tokens.Token) PartialToken(org.forgerock.openam.sm.datalayer.api.query.PartialToken) TokenFilterBuilder(org.forgerock.openam.cts.api.filter.TokenFilterBuilder) TokenFilter(org.forgerock.openam.cts.api.filter.TokenFilter) Test(org.testng.annotations.Test)

Example 32 with CoreTokenException

use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.

the class CoreTokenAdapterTest method shouldUseTaskQueueForAttributeQuery.

@Test
public void shouldUseTaskQueueForAttributeQuery() throws CoreTokenException {
    // Given
    Collection<PartialToken> partialTokens = new ArrayList<PartialToken>();
    ResultHandler<Collection<PartialToken>, CoreTokenException> mockResultHandler = mock(ResultHandler.class);
    given(mockResultHandler.getResults()).willReturn(partialTokens);
    given(mockResultHandlerFactory.getPartialQueryHandler()).willReturn(mockResultHandler);
    TokenFilter filter = new TokenFilterBuilder().returnAttribute(CoreTokenField.BLOB).build();
    // When
    adapter.attributeQuery(filter);
    // Then
    verify(mockTaskDispatcher).partialQuery(eq(filter), eq(mockResultHandler));
}
Also used : PartialToken(org.forgerock.openam.sm.datalayer.api.query.PartialToken) ArrayList(java.util.ArrayList) Collection(java.util.Collection) CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) TokenFilterBuilder(org.forgerock.openam.cts.api.filter.TokenFilterBuilder) TokenFilter(org.forgerock.openam.cts.api.filter.TokenFilter) Test(org.testng.annotations.Test)

Example 33 with CoreTokenException

use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.

the class ReaperConnectionTest method shouldNotReturnFurtherPagesOnceFailed.

@Test(expectedExceptions = IllegalStateException.class)
public void shouldNotReturnFurtherPagesOnceFailed() throws Exception {
    given(mockFactory.create()).willReturn(mockConnection);
    given(mockImpl.nextPage()).willThrow(new CoreTokenException(""));
    try {
        connection.nextPage();
    } catch (CoreTokenException e) {
    }
    connection.nextPage();
}
Also used : CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) Test(org.testng.annotations.Test)

Example 34 with CoreTokenException

use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.

the class ReaperConnectionTest method shouldCloseConnectionOnException.

@Test
public void shouldCloseConnectionOnException() throws Exception {
    given(mockFactory.create()).willReturn(mockConnection);
    given(mockImpl.nextPage()).willThrow(new CoreTokenException(""));
    try {
        connection.nextPage();
        fail();
    } catch (CoreTokenException e) {
        verify(mockConnection).close();
    }
}
Also used : CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) Test(org.testng.annotations.Test)

Example 35 with CoreTokenException

use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.

the class AsyncResultHandlerTest method shouldTimeoutIfNoResultsPublished.

@Test(timeOut = 1000)
public void shouldTimeoutIfNoResultsPublished() {
    // Given
    given(mockConfig.getQueueTimeout()).willReturn(0);
    // When
    CoreTokenException error = null;
    try {
        handler.getResults();
    } catch (CoreTokenException e) {
        error = e;
    }
    // Then
    assertThat(error).isNotNull();
}
Also used : CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) Test(org.testng.annotations.Test)

Aggregations

CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)59 JsonValue (org.forgerock.json.JsonValue)21 ServerException (org.forgerock.oauth2.core.exceptions.ServerException)19 Token (org.forgerock.openam.cts.api.tokens.Token)14 Test (org.testng.annotations.Test)11 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)10 ResourceException (org.forgerock.json.resource.ResourceException)9 PartialToken (org.forgerock.openam.sm.datalayer.api.query.PartialToken)9 BadRequestException (org.forgerock.json.resource.BadRequestException)8 ArrayList (java.util.ArrayList)7 ResourceResponse (org.forgerock.json.resource.ResourceResponse)7 SSOException (com.iplanet.sso.SSOException)6 SSOToken (com.iplanet.sso.SSOToken)6 IdRepoException (com.sun.identity.idm.IdRepoException)6 HashMap (java.util.HashMap)5 Responses.newResourceResponse (org.forgerock.json.resource.Responses.newResourceResponse)5 OAuth2ProviderSettings (org.forgerock.oauth2.core.OAuth2ProviderSettings)5 TokenFilter (org.forgerock.openam.cts.api.filter.TokenFilter)5 TokenFilterBuilder (org.forgerock.openam.cts.api.filter.TokenFilterBuilder)5 DeleteFailedException (org.forgerock.openam.cts.exceptions.DeleteFailedException)5