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));
}
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));
}
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();
}
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();
}
}
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();
}
Aggregations