Search in sources :

Example 46 with ProtocolVersion

use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project moco by dreamhead.

the class MocoTest method should_return_same_http_version_without_specified_version_for_error_response.

@Test
public void should_return_same_http_version_without_specified_version_for_error_response() throws Exception {
    running(server, () -> {
        ProtocolVersion version10 = helper.execute(Request.Get(root()).version(HttpVersion.HTTP_1_0)).getProtocolVersion();
        assertThat(version10.getMajor(), is(1));
        assertThat(version10.getMinor(), is(0));
        ProtocolVersion version11 = helper.execute(Request.Get(root()).version(HttpVersion.HTTP_1_1)).getProtocolVersion();
        assertThat(version11.getMajor(), is(1));
        assertThat(version11.getMinor(), is(1));
    });
}
Also used : ProtocolVersion(org.apache.http.ProtocolVersion) Test(org.junit.Test)

Example 47 with ProtocolVersion

use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project moco by dreamhead.

the class MocoTest method should_return_expected_version.

@Test
public void should_return_expected_version() throws Exception {
    server.response(version(VERSION_1_0));
    running(server, () -> {
        ProtocolVersion version = helper.getResponse(root()).getProtocolVersion();
        assertThat(version.getMajor(), is(1));
        assertThat(version.getMinor(), is(0));
    });
}
Also used : ProtocolVersion(org.apache.http.ProtocolVersion) Test(org.junit.Test)

Example 48 with ProtocolVersion

use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project moco by dreamhead.

the class MocoTest method should_return_excepted_version_with_version_api.

@Test
public void should_return_excepted_version_with_version_api() throws Exception {
    server.response(version(VERSION_1_0));
    running(server, () -> {
        ProtocolVersion version = helper.getResponse(root()).getProtocolVersion();
        assertThat(version.getMajor(), is(1));
        assertThat(version.getMinor(), is(0));
    });
}
Also used : ProtocolVersion(org.apache.http.ProtocolVersion) Test(org.junit.Test)

Example 49 with ProtocolVersion

use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project moco by dreamhead.

the class MocoTemplateStandaloneTest method should_return_version_from_template.

@Test
public void should_return_version_from_template() throws IOException {
    runWithConfiguration("template.json");
    ProtocolVersion version = helper.execute(Request.Get(remoteUrl("/version_template")).version(HttpVersion.HTTP_1_0)).getProtocolVersion();
    assertThat(version.toString(), is("HTTP/1.0"));
}
Also used : ProtocolVersion(org.apache.http.ProtocolVersion) Test(org.junit.Test)

Example 50 with ProtocolVersion

use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project moco by dreamhead.

the class MocoStandaloneTest method should_return_specified_version_for_request.

@Test
public void should_return_specified_version_for_request() throws IOException {
    runWithConfiguration("foo.json");
    ProtocolVersion version = helper.execute(Request.Get(remoteUrl("/version10"))).getProtocolVersion();
    assertThat(version.getProtocol(), is("HTTP"));
    assertThat(version.getMajor(), is(1));
    assertThat(version.getMinor(), is(0));
}
Also used : ProtocolVersion(org.apache.http.ProtocolVersion) Test(org.junit.Test)

Aggregations

ProtocolVersion (org.apache.http.ProtocolVersion)143 BasicStatusLine (org.apache.http.message.BasicStatusLine)67 Test (org.junit.Test)53 BasicHttpResponse (org.apache.http.message.BasicHttpResponse)50 StatusLine (org.apache.http.StatusLine)44 HttpResponse (org.apache.http.HttpResponse)32 HttpEntity (org.apache.http.HttpEntity)31 Header (org.apache.http.Header)25 StringEntity (org.apache.http.entity.StringEntity)25 IOException (java.io.IOException)18 BasicHeader (org.apache.http.message.BasicHeader)15 URL (java.net.URL)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 HttpURLConnection (java.net.HttpURLConnection)13 HashMap (java.util.HashMap)13 List (java.util.List)13 ParseException (org.apache.http.ParseException)13 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)13 HttpHost (org.apache.http.HttpHost)12 HttpEntityEnclosingRequest (org.apache.http.HttpEntityEnclosingRequest)11