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

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

Introduction

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

Prototype

void setStatusCode(int i) throws IllegalStateException;

Source Link

Usage

From source file:bit.changepurse.wdk.http.TestHTTPResponse.java

private void testGetBody(HttpEntity entity) throws UnsupportedEncodingException {
    CloseableHttpResponse rawResponse = new MockedApacheResponse();
    rawResponse.setStatusCode(HTTPStatusCode.SUCCESS.toInt());
    rawResponse.setEntity(entity);// w  ww. j a  v a  2  s  .co m
    HTTPResponse response = new HTTPResponse(rawResponse);
    assertThat(response.getBody(), equalTo(CheckedExceptionMethods.toString(entity)));
    assertThat(response.toString(), notNullValue());
}

From source file:bit.changepurse.wdk.http.TestHTTPResponse.java

@Test
public void testGetLocation() {
    CloseableHttpResponse rawResponse = new MockedApacheResponse();
    rawResponse.setStatusCode(HTTPStatusCode.SUCCESS.toInt());
    String location = "http://www.google.com";
    rawResponse.addHeader("Location", location);
    HTTPResponse response = new HTTPResponse(rawResponse);
    assertThat(response.getLocationFromHeaders(), equalTo(location));
    assertThat(response.toString(), notNullValue());
}

From source file:bit.changepurse.wdk.http.TestHTTPResponse.java

@Test
public void testStatusCode() {
    CloseableHttpResponse rawResponse = new MockedApacheResponse();
    for (HTTPStatusCode statusCode : HTTPStatusCode.values()) {
        rawResponse.setStatusCode(statusCode.toInt());
        HTTPResponse response = new HTTPResponse(rawResponse);
        assertThat(response.getStatusCode(), equalTo(statusCode));
        assertThat(response.toString(), notNullValue());
    }// w  ww.j a  v a2  s  .co  m
}