Package io.airlift.http.client.StringResponseHandler

Examples of io.airlift.http.client.StringResponseHandler.StringResponse


    {
        createServer(new ErrorServlet());
        server.start();

        try (HttpClient client = new JettyHttpClient()) {
            StringResponse response = client.execute(prepareGet().setUri(httpServerInfo.getHttpUri()).build(), createStringResponseHandler());
            assertEquals(response.getStatusCode(), 500);
            assertContains(response.getBody(), "ErrorServlet.java");
        }
    }
View Full Code Here


        config.setShowStackTrace(false);
        createServer(new ErrorServlet());
        server.start();

        try (HttpClient client = new JettyHttpClient()) {
            StringResponse response = client.execute(prepareGet().setUri(httpServerInfo.getHttpUri()).build(), createStringResponseHandler());
            assertEquals(response.getStatusCode(), 500);
            assertTrue(!response.getBody().contains("ErrorServlet.java"));
        }
    }
View Full Code Here

        try {
            String contentType = response.getHeader(HttpHeaders.CONTENT_TYPE);

            if (contentType != null) {
                MediaType mediaType = MediaType.parse(contentType);
                return new StringResponse(
                        response.getStatusCode(),
                        response.getStatusMessage(),
                        response.getHeaders(),
                        new String(ByteStreams.toByteArray(response.getInputStream()), mediaType.charset().or(Charsets.UTF_8)));
            }

            return new StringResponse(
                    response.getStatusCode(),
                    response.getStatusMessage(),
                    response.getHeaders(),
                    new String(ByteStreams.toByteArray(response.getInputStream()), Charsets.UTF_8));
        }
View Full Code Here

        String expected = "{\"columns\":[" +
                "{\"name\":\"foo\",\"type\":\"bigint\"}," +
                "{\"name\":\"bar\",\"type\":\"varchar\"}]," +
                "\"data\":[[123,\"abc\"]]}\n";

        StringResponse response = executeQuery("SELECT 123 foo, 'abc' bar FROM dual");
        assertEquals(response.getStatusCode(), HttpStatus.OK.code());
        assertEquals(response.getHeader(HttpHeaders.CONTENT_TYPE), "application/json");
        assertEquals(response.getBody(), expected);
    }
View Full Code Here

        String expected = "{\"columns\":[" +
                "{\"name\":\"foo\",\"type\":\"bigint\"}," +
                "{\"name\":\"bar\",\"type\":\"varchar\"}]," +
                "\"data\":[[123,\"abc\"]]}\n";

        StringResponse response = executeQuery("SELECT 123 foo, 'abc' bar FROM dual");
        assertEquals(response.getStatusCode(), HttpStatus.OK.code());
        assertEquals(response.getHeader(HttpHeaders.CONTENT_TYPE), "application/json");
        assertEquals(response.getBody(), expected);
    }
View Full Code Here

TOP

Related Classes of io.airlift.http.client.StringResponseHandler.StringResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.