Search in sources :

Example 41 with BasicStatusLine

use of org.apache.http.message.BasicStatusLine in project cdap-ingest by caskdata.

the class RestClientTest method testConflictResponseCodeAnalysis.

@Test
public void testConflictResponseCodeAnalysis() {
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_CONFLICT, "Conflict");
    when(response.getStatusLine()).thenReturn(statusLine);
    TestUtils.verifyResponse(HttpStatus.SC_CONFLICT, response);
    verify(response).getStatusLine();
}
Also used : BasicStatusLine(org.apache.http.message.BasicStatusLine) StatusLine(org.apache.http.StatusLine) ProtocolVersion(org.apache.http.ProtocolVersion) BasicStatusLine(org.apache.http.message.BasicStatusLine) Test(org.junit.Test)

Example 42 with BasicStatusLine

use of org.apache.http.message.BasicStatusLine in project cdap-ingest by caskdata.

the class RestClientTest method testInternalServerErrorResponseCodeAnalysis.

@Test
public void testInternalServerErrorResponseCodeAnalysis() {
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_INTERNAL_SERVER_ERROR, "Internal Server Error");
    when(response.getStatusLine()).thenReturn(statusLine);
    TestUtils.verifyResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, response);
    verify(response).getStatusLine();
}
Also used : BasicStatusLine(org.apache.http.message.BasicStatusLine) StatusLine(org.apache.http.StatusLine) ProtocolVersion(org.apache.http.ProtocolVersion) BasicStatusLine(org.apache.http.message.BasicStatusLine) Test(org.junit.Test)

Example 43 with BasicStatusLine

use of org.apache.http.message.BasicStatusLine in project cdap-ingest by caskdata.

the class RestClientTest method testBadRequestResponseCodeAnalysis.

@Test
public void testBadRequestResponseCodeAnalysis() {
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_BAD_REQUEST, "Bad Request");
    when(response.getStatusLine()).thenReturn(statusLine);
    TestUtils.verifyResponse(HttpStatus.SC_BAD_REQUEST, response);
    verify(response).getStatusLine();
}
Also used : BasicStatusLine(org.apache.http.message.BasicStatusLine) StatusLine(org.apache.http.StatusLine) ProtocolVersion(org.apache.http.ProtocolVersion) BasicStatusLine(org.apache.http.message.BasicStatusLine) Test(org.junit.Test)

Example 44 with BasicStatusLine

use of org.apache.http.message.BasicStatusLine in project FastDev4Android by jiangqqlmj.

the class MockHttpClient method execute.

// This is the only one we actually use.
@Override
public HttpResponse execute(HttpUriRequest request, HttpContext context) {
    requestExecuted = request;
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), mStatusCode, "");
    HttpResponse response = new BasicHttpResponse(statusLine);
    response.setEntity(mResponseEntity);
    return response;
}
Also used : BasicStatusLine(org.apache.http.message.BasicStatusLine) StatusLine(org.apache.http.StatusLine) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) HttpResponse(org.apache.http.HttpResponse) ProtocolVersion(org.apache.http.ProtocolVersion) BasicStatusLine(org.apache.http.message.BasicStatusLine)

Example 45 with BasicStatusLine

use of org.apache.http.message.BasicStatusLine in project elasticsearch by elastic.

the class FailureTrackingResponseListenerTests method mockResponse.

private static Response mockResponse() {
    ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
    RequestLine requestLine = new BasicRequestLine("GET", "/", protocolVersion);
    StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
    HttpResponse httpResponse = new BasicHttpResponse(statusLine);
    return new Response(requestLine, new HttpHost("localhost", 9200), httpResponse);
}
Also used : BasicStatusLine(org.apache.http.message.BasicStatusLine) StatusLine(org.apache.http.StatusLine) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) HttpResponse(org.apache.http.HttpResponse) BasicRequestLine(org.apache.http.message.BasicRequestLine) RequestLine(org.apache.http.RequestLine) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) BasicRequestLine(org.apache.http.message.BasicRequestLine) HttpHost(org.apache.http.HttpHost) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) HttpResponse(org.apache.http.HttpResponse) ProtocolVersion(org.apache.http.ProtocolVersion) BasicStatusLine(org.apache.http.message.BasicStatusLine)

Aggregations

BasicStatusLine (org.apache.http.message.BasicStatusLine)70 ProtocolVersion (org.apache.http.ProtocolVersion)54 StatusLine (org.apache.http.StatusLine)44 BasicHttpResponse (org.apache.http.message.BasicHttpResponse)37 Test (org.junit.Test)27 Header (org.apache.http.Header)17 StringEntity (org.apache.http.entity.StringEntity)17 BasicHeader (org.apache.http.message.BasicHeader)17 URL (java.net.URL)16 HttpResponse (org.apache.http.HttpResponse)16 HttpURLConnection (java.net.HttpURLConnection)15 List (java.util.List)15 HashMap (java.util.HashMap)12 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)12 ByteArrayInputStream (java.io.ByteArrayInputStream)10 IOException (java.io.IOException)9 HttpEntity (org.apache.http.HttpEntity)9 HttpHost (org.apache.http.HttpHost)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 AgentAutoRegistrationPropertiesImpl (com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl)5