Search in sources :

Example 46 with ForestResponse

use of com.dtflys.forest.http.ForestResponse in project forest by dromara.

the class ErrorTest method testErrorCallback.

public void testErrorCallback() {
    configuration.setTimeout(10);
    final AtomicInteger count = new AtomicInteger(0);
    final boolean[] ts = new boolean[] { false };
    errorClient.testError(new OnError() {

        @Override
        public void onError(ForestRuntimeException ex, ForestRequest request, ForestResponse response) {
            int status = response.getStatusCode();
            count.incrementAndGet();
            assertNotNull(ex);
            assertNotNull(request);
        }
    });
    assertEquals(1, count.get());
}
Also used : ForestResponse(com.dtflys.forest.http.ForestResponse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ForestRuntimeException(com.dtflys.forest.exceptions.ForestRuntimeException) OnError(com.dtflys.forest.callback.OnError) ForestRequest(com.dtflys.forest.http.ForestRequest)

Aggregations

ForestResponse (com.dtflys.forest.http.ForestResponse)46 ForestRequest (com.dtflys.forest.http.ForestRequest)38 Test (org.junit.Test)37 MockResponse (okhttp3.mockwebserver.MockResponse)34 BaseClientTest (com.dtflys.test.http.BaseClientTest)31 HttpBackend (com.dtflys.forest.backend.HttpBackend)30 ForestConfiguration (com.dtflys.forest.config.ForestConfiguration)30 AtomicReference (java.util.concurrent.atomic.AtomicReference)30 MockWebServer (okhttp3.mockwebserver.MockWebServer)30 BeforeClass (org.junit.BeforeClass)30 Rule (org.junit.Rule)30 MockServerRequest.mockRequest (com.dtflys.forest.mock.MockServerRequest.mockRequest)29 CountDownLatch (java.util.concurrent.CountDownLatch)29 TimeUnit (java.util.concurrent.TimeUnit)29 AssertionsForClassTypes.assertThat (org.assertj.core.api.AssertionsForClassTypes.assertThat)29 ForestNetworkException (com.dtflys.forest.exceptions.ForestNetworkException)3 ForestRuntimeException (com.dtflys.forest.exceptions.ForestRuntimeException)3 HttpclientForestResponseFactory (com.dtflys.forest.backend.httpclient.response.HttpclientForestResponseFactory)2 ForestRetryException (com.dtflys.forest.exceptions.ForestRetryException)2 Date (java.util.Date)2