Search in sources :

Example 1 with AsyncCompletionHandlerBase

use of org.asynchttpclient.AsyncCompletionHandlerBase in project async-http-client by AsyncHttpClient.

the class AsyncHttpSingleTest method testAbort.

@Test(groups = "standalone")
public void testAbort() throws Exception {
    final TestSubscriber<Response> subscriber = new TestSubscriber<>();
    try (AsyncHttpClient client = asyncHttpClient()) {
        final Single<Response> underTest = AsyncHttpSingle.create(client.prepareGet("http://gatling.io"), () -> new AsyncCompletionHandlerBase() {

            @Override
            public State onStatusReceived(HttpResponseStatus status) {
                return State.ABORT;
            }
        });
        underTest.subscribe(subscriber);
        subscriber.awaitTerminalEvent();
    }
    subscriber.assertTerminalEvent();
    subscriber.assertNoErrors();
    subscriber.assertCompleted();
    subscriber.assertValue(null);
}
Also used : Response(org.asynchttpclient.Response) HttpResponseStatus(org.asynchttpclient.HttpResponseStatus) TestSubscriber(rx.observers.TestSubscriber) AsyncCompletionHandlerBase(org.asynchttpclient.AsyncCompletionHandlerBase) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test)

Aggregations

AsyncCompletionHandlerBase (org.asynchttpclient.AsyncCompletionHandlerBase)1 AsyncHttpClient (org.asynchttpclient.AsyncHttpClient)1 HttpResponseStatus (org.asynchttpclient.HttpResponseStatus)1 Response (org.asynchttpclient.Response)1 Test (org.testng.annotations.Test)1 TestSubscriber (rx.observers.TestSubscriber)1