Search in sources :

Example 6 with ResponseSource

use of com.spotify.apollo.test.response.ResponseSource in project apollo by spotify.

the class StubClientTest method shouldReturnIterativeReplies.

@Test
public void shouldReturnIterativeReplies() throws Exception {
    ResponseWithDelay response1 = ResponseWithDelay.forResponse(Response.forPayload(encodeUtf8("first response")));
    ResponseWithDelay response2 = ResponseWithDelay.forResponse(Response.forPayload(encodeUtf8("second response")));
    List<ResponseWithDelay> responses = Arrays.asList(response1, response2);
    ResponseSource responseSequence = Responses.sequence(responses);
    stubClient.respond(responseSequence).to("http://ping");
    assertThat(getStringFromPing().toCompletableFuture().get(), is("first response"));
    assertThat(getStringFromPing().toCompletableFuture().get(), is("second response"));
}
Also used : ResponseWithDelay(com.spotify.apollo.test.response.ResponseWithDelay) ResponseSource(com.spotify.apollo.test.response.ResponseSource) Test(org.junit.Test)

Aggregations

ResponseSource (com.spotify.apollo.test.response.ResponseSource)6 ResponseWithDelay (com.spotify.apollo.test.response.ResponseWithDelay)6 Test (org.junit.Test)5 Response (com.spotify.apollo.Response)2 ByteString (okio.ByteString)2 CompletableFuture (java.util.concurrent.CompletableFuture)1