Example usage for org.apache.http.client.methods CloseableHttpResponse setStatusLine

List of usage examples for org.apache.http.client.methods CloseableHttpResponse setStatusLine

Introduction

In this page you can find the example usage for org.apache.http.client.methods CloseableHttpResponse setStatusLine.

Prototype

void setStatusLine(StatusLine statusLine);

Source Link

Usage

From source file:org.wso2.carbon.apimgt.handlers.AuthenticationHandlerTest.java

private CloseableHttpResponse getValidationResponse() throws UnsupportedEncodingException {
    ValidationResponce response = new ValidationResponce();
    response.setDeviceId("1234");
    response.setDeviceType("testdevice");
    response.setJWTToken("1234567788888888");
    response.setTenantId(-1234);//from   ww  w .  ja va  2  s  .com
    Gson gson = new Gson();
    String jsonReponse = gson.toJson(response);
    CloseableHttpResponse mockDCRResponse = new MockHttpResponse();
    BasicHttpEntity responseEntity = new BasicHttpEntity();
    responseEntity.setContent(new ByteArrayInputStream(jsonReponse.getBytes(StandardCharsets.UTF_8.name())));
    responseEntity.setContentType(TestUtils.CONTENT_TYPE);
    mockDCRResponse.setEntity(responseEntity);
    mockDCRResponse.setStatusLine(new BasicStatusLine(new ProtocolVersion("http", 1, 0), 200, "OK"));
    return mockDCRResponse;
}

From source file:org.wso2.carbon.apimgt.handlers.AuthenticationHandlerTest.java

private CloseableHttpResponse getInvalidResponse() throws UnsupportedEncodingException {
    CloseableHttpResponse mockDCRResponse = new MockHttpResponse();
    BasicHttpEntity responseEntity = new BasicHttpEntity();
    responseEntity//from  w  w w  .j ava2  s.c om
            .setContent(new ByteArrayInputStream("invalid response".getBytes(StandardCharsets.UTF_8.name())));
    responseEntity.setContentType(TestUtils.CONTENT_TYPE);
    mockDCRResponse.setEntity(responseEntity);
    mockDCRResponse.setStatusLine(new BasicStatusLine(new ProtocolVersion("http", 1, 0), 400, "Bad Request"));
    return mockDCRResponse;
}

From source file:org.wso2.carbon.apimgt.handlers.AuthenticationHandlerTest.java

private CloseableHttpResponse getDCRResponse() throws IOException {
    CloseableHttpResponse mockDCRResponse = new MockHttpResponse();
    String dcrResponseFile = TestUtils.getAbsolutePathOfConfig("dcr-response.json");
    BasicHttpEntity responseEntity = new BasicHttpEntity();
    responseEntity.setContent(//from  www .ja  v  a  2 s  .c  om
            new ByteArrayInputStream(getContent(dcrResponseFile).getBytes(StandardCharsets.UTF_8.name())));
    responseEntity.setContentType(TestUtils.CONTENT_TYPE);
    mockDCRResponse.setEntity(responseEntity);
    mockDCRResponse.setStatusLine(new BasicStatusLine(new ProtocolVersion("http", 1, 0), 200, "OK"));
    return mockDCRResponse;
}

From source file:org.wso2.carbon.apimgt.handlers.AuthenticationHandlerTest.java

private CloseableHttpResponse getAccessTokenReponse() throws IOException {
    CloseableHttpResponse mockDCRResponse = new MockHttpResponse();
    String dcrResponseFile = TestUtils.getAbsolutePathOfConfig("accesstoken-response.json");
    BasicHttpEntity responseEntity = new BasicHttpEntity();
    responseEntity.setContent(//from  www .  j a  v  a 2s .c o m
            new ByteArrayInputStream(getContent(dcrResponseFile).getBytes(StandardCharsets.UTF_8.name())));
    responseEntity.setContentType(TestUtils.CONTENT_TYPE);
    mockDCRResponse.setEntity(responseEntity);
    mockDCRResponse.setStatusLine(new BasicStatusLine(new ProtocolVersion("http", 1, 0), 200, "OK"));
    return mockDCRResponse;
}