Search in sources :

Example 1 with NoneLifeCycleHandler

use of com.dtflys.forest.reflection.NoneLifeCycleHandler in project forest by dromara.

the class TestResponseFactory method testHttpclientForestResponseFactory.

@Test
public void testHttpclientForestResponseFactory() {
    ForestRequest request = new ForestRequest(ForestConfiguration.configuration());
    Date requestTime = new Date();
    HttpclientForestResponseFactory responseFactory = new HttpclientForestResponseFactory();
    HttpResponse httpResponse = mock(HttpResponse.class);
    StatusLine statusLine = mock(StatusLine.class);
    when(statusLine.getStatusCode()).thenReturn(200);
    when(httpResponse.getStatusLine()).thenReturn(statusLine);
    LifeCycleHandler lifeCycleHandler = new NoneLifeCycleHandler();
    ForestResponse response = responseFactory.createResponse(request, httpResponse, lifeCycleHandler, null, requestTime);
    assertThat(response).isNotNull().extracting(ForestResponse::getStatusCode, ForestResponse::getContent, ForestResponse::getResult).contains(200, "", null);
}
Also used : StatusLine(org.apache.http.StatusLine) ForestResponse(com.dtflys.forest.http.ForestResponse) NoneLifeCycleHandler(com.dtflys.forest.reflection.NoneLifeCycleHandler) LifeCycleHandler(com.dtflys.forest.handler.LifeCycleHandler) HttpclientForestResponseFactory(com.dtflys.forest.backend.httpclient.response.HttpclientForestResponseFactory) HttpResponse(org.apache.http.HttpResponse) ForestRequest(com.dtflys.forest.http.ForestRequest) Date(java.util.Date) NoneLifeCycleHandler(com.dtflys.forest.reflection.NoneLifeCycleHandler) Test(org.junit.Test)

Aggregations

HttpclientForestResponseFactory (com.dtflys.forest.backend.httpclient.response.HttpclientForestResponseFactory)1 LifeCycleHandler (com.dtflys.forest.handler.LifeCycleHandler)1 ForestRequest (com.dtflys.forest.http.ForestRequest)1 ForestResponse (com.dtflys.forest.http.ForestResponse)1 NoneLifeCycleHandler (com.dtflys.forest.reflection.NoneLifeCycleHandler)1 Date (java.util.Date)1 HttpResponse (org.apache.http.HttpResponse)1 StatusLine (org.apache.http.StatusLine)1 Test (org.junit.Test)1