Search in sources :

Example 46 with BasicStatusLine

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

the class RestClientTest method testForbiddenResponseCodeAnalysis.

@Test
public void testForbiddenResponseCodeAnalysis() {
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_FORBIDDEN, "Forbidden");
    when(response.getStatusLine()).thenReturn(statusLine);
    TestUtils.verifyResponse(HttpStatus.SC_FORBIDDEN, 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 47 with BasicStatusLine

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

the class RestClientTest method testUnauthorizedResponseCodeAnalysis.

@Test
public void testUnauthorizedResponseCodeAnalysis() {
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_UNAUTHORIZED, "Unauthorized");
    when(response.getStatusLine()).thenReturn(statusLine);
    TestUtils.verifyResponse(HttpStatus.SC_UNAUTHORIZED, 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 48 with BasicStatusLine

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

the class RestClientTest method testNotAllowedResponseCodeAnalysis.

@Test
public void testNotAllowedResponseCodeAnalysis() {
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_METHOD_NOT_ALLOWED, "Method Not Allowed");
    when(response.getStatusLine()).thenReturn(statusLine);
    TestUtils.verifyResponse(HttpStatus.SC_METHOD_NOT_ALLOWED, response);
    verify(response, new VerificationMode() {

        @Override
        public void verify(VerificationData verificationData) {
            Assert.assertEquals(2, verificationData.getAllInvocations().size());
        }
    }).getStatusLine();
}
Also used : BasicStatusLine(org.apache.http.message.BasicStatusLine) StatusLine(org.apache.http.StatusLine) ProtocolVersion(org.apache.http.ProtocolVersion) VerificationMode(org.mockito.verification.VerificationMode) VerificationData(org.mockito.internal.verification.api.VerificationData) BasicStatusLine(org.apache.http.message.BasicStatusLine) Test(org.junit.Test)

Example 49 with BasicStatusLine

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

the class RestClientTest method testNotImplementedResponseCodeAnalysis.

@Test
public void testNotImplementedResponseCodeAnalysis() {
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_NOT_IMPLEMENTED, "Not Implemented");
    when(response.getStatusLine()).thenReturn(statusLine);
    try {
        RestClient.responseCodeAnalysis(response);
        Assert.fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
    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 50 with BasicStatusLine

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

the class RestClientTest method testOkResponseCodeAnalysis.

@Test
public void testOkResponseCodeAnalysis() {
    StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_OK, "OK");
    when(response.getStatusLine()).thenReturn(statusLine);
    RestClient.responseCodeAnalysis(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)

Aggregations

BasicStatusLine (org.apache.http.message.BasicStatusLine)118 ProtocolVersion (org.apache.http.ProtocolVersion)67 Test (org.junit.Test)56 BasicHttpResponse (org.apache.http.message.BasicHttpResponse)54 StatusLine (org.apache.http.StatusLine)45 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)33 StringEntity (org.apache.http.entity.StringEntity)32 ByteArrayInputStream (java.io.ByteArrayInputStream)29 HttpResponse (org.apache.http.HttpResponse)27 IOException (java.io.IOException)19 HttpEntity (org.apache.http.HttpEntity)19 BasicHeader (org.apache.http.message.BasicHeader)19 URL (java.net.URL)17 HttpURLConnection (java.net.HttpURLConnection)16 List (java.util.List)16 Header (org.apache.http.Header)16 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)16 HashMap (java.util.HashMap)14 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)13 BasicHttpEntity (org.apache.http.entity.BasicHttpEntity)12