use of com.couchbase.client.dcp.state.SessionState in project components by Talend.
the class CouchbaseStreamingConnectionTest method testStartStreaming.
@Test
public void testStartStreaming() throws InterruptedException {
Mockito.when(client.initializeState(StreamFrom.BEGINNING, StreamTo.NOW)).thenReturn(Completable.complete());
Mockito.when(client.startStreaming(Mockito.<Short[]>anyVararg())).thenReturn(Completable.complete());
SessionState sessionState = Mockito.mock(SessionState.class);
Mockito.when(sessionState.isAtEnd()).thenReturn(false, false, true);
Mockito.when(client.sessionState()).thenReturn(sessionState);
BlockingQueue<ByteBuf> resultsQueue = new ArrayBlockingQueue<>(3);
streamingConnection.startStreaming(resultsQueue);
Assert.assertTrue(streamingConnection.isStreaming());
Thread.sleep(2000);
Mockito.verify(client, Mockito.times(3)).sessionState();
}
use of com.couchbase.client.dcp.state.SessionState in project components by Talend.
the class CouchbaseStreamingConnectionTest method testStartStopStreaming.
@Test
public void testStartStopStreaming() throws InterruptedException {
Mockito.when(client.initializeState(StreamFrom.BEGINNING, StreamTo.NOW)).thenReturn(Completable.complete());
Mockito.when(client.startStreaming(Mockito.<Short[]>anyVararg())).thenReturn(Completable.complete());
Mockito.when(client.stopStreaming(Mockito.<Short[]>anyVararg())).thenReturn(Completable.complete());
SessionState sessionState = Mockito.mock(SessionState.class);
Mockito.when(sessionState.isAtEnd()).thenReturn(false, true);
Mockito.when(client.sessionState()).thenReturn(sessionState);
BlockingQueue<ByteBuf> resultsQueue = new ArrayBlockingQueue<>(4);
resultsQueue.put(Mockito.mock(ByteBuf.class));
resultsQueue.put(Mockito.mock(ByteBuf.class));
resultsQueue.put(Mockito.mock(ByteBuf.class));
resultsQueue.put(Mockito.mock(ByteBuf.class));
Mockito.when(client.disconnect()).thenReturn(Completable.complete());
streamingConnection.startStreaming(resultsQueue);
streamingConnection.stopStreaming();
Thread.sleep(1500);
Mockito.verify(client, Mockito.times(2)).sessionState();
Mockito.verify(client, Mockito.times(1)).disconnect();
}
Aggregations