Search in sources :

Example 16 with Response

use of com.ning.http.client.Response in project killbill by killbill.

the class TestPlugin method testPassRequestsToKnownPluginButWrongPath.

@Test(groups = "slow")
public void testPassRequestsToKnownPluginButWrongPath() throws Exception {
    final String uri = TEST_PLUGIN_NAME + "/somethingSomething";
    Response response;
    response = killBillClient.pluginGET(uri);
    testAndResetAllMarkers(response, 200, new byte[] {}, false, false, false, false, false, false);
    response = killBillClient.pluginHEAD(uri);
    testAndResetAllMarkers(response, 204, new byte[] {}, false, false, false, false, false, false);
    response = killBillClient.pluginPOST(uri, null);
    testAndResetAllMarkers(response, 200, new byte[] {}, false, false, false, false, false, false);
    response = killBillClient.pluginPUT(uri, null);
    testAndResetAllMarkers(response, 200, new byte[] {}, false, false, false, false, false, false);
    response = killBillClient.pluginDELETE(uri);
    testAndResetAllMarkers(response, 200, new byte[] {}, false, false, false, false, false, false);
    response = killBillClient.pluginOPTIONS(uri);
    testAndResetAllMarkers(response, 200, new byte[] {}, false, false, false, false, false, false);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(com.ning.http.client.Response) Test(org.testng.annotations.Test)

Example 17 with Response

use of com.ning.http.client.Response in project killbill by killbill.

the class TestPlugin method testPassRequestsToUnknownPlugin.

@Test(groups = "slow")
public void testPassRequestsToUnknownPlugin() throws Exception {
    final String uri = "pluginDoesNotExist/something";
    Response response;
    // We don't test the output here as it is some Jetty specific HTML blurb
    response = killBillClient.pluginGET(uri);
    testAndResetAllMarkers(response, 404, null, false, false, false, false, false, false);
    response = killBillClient.pluginHEAD(uri);
    testAndResetAllMarkers(response, 404, null, false, false, false, false, false, false);
    response = killBillClient.pluginPOST(uri, null);
    testAndResetAllMarkers(response, 404, null, false, false, false, false, false, false);
    response = killBillClient.pluginPUT(uri, null);
    testAndResetAllMarkers(response, 404, null, false, false, false, false, false, false);
    response = killBillClient.pluginDELETE(uri);
    testAndResetAllMarkers(response, 404, null, false, false, false, false, false, false);
    response = killBillClient.pluginOPTIONS(uri);
    testAndResetAllMarkers(response, 404, null, false, false, false, false, false, false);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(com.ning.http.client.Response) Test(org.testng.annotations.Test)

Example 18 with Response

use of com.ning.http.client.Response in project pinot by linkedin.

the class JsonAsyncHttpPinotClientTransport method executeQueryAsync.

@Override
public Future<BrokerResponse> executeQueryAsync(String brokerAddress, final String query) {
    try {
        final JSONObject json = new JSONObject();
        json.put("pql", query);
        final String url = "http://" + brokerAddress + "/query";
        final Future<Response> response = _httpClient.preparePost(url).setBody(json.toString()).execute();
        return new BrokerResponseFuture(response, query, url);
    } catch (Exception e) {
        throw new PinotClientException(e);
    }
}
Also used : Response(com.ning.http.client.Response) JSONObject(org.json.JSONObject) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 19 with Response

use of com.ning.http.client.Response in project openhab1-addons by openhab.

the class PlexConnector method internalSendCommand.

private void internalSendCommand(String machineIdentifier, String url) throws IOException {
    logger.debug("Calling url {}", url);
    BoundRequestBuilder builder = client.prepareGet(url).setHeaders(getDefaultHeaders()).setHeader("X-Plex-Target-Client-Identifier", machineIdentifier);
    builder.execute(new AsyncCompletionHandler<Response>() {

        @Override
        public Response onCompleted(Response response) throws Exception {
            if (response.getStatusCode() != 200) {
                logger.error("Error while sending command to Plex: {}\r\n{}", response.getStatusText(), response.getResponseBody());
            }
            return response;
        }

        @Override
        public void onThrowable(Throwable t) {
            logger.error("Error sending command to Plex", t);
        }
    });
}
Also used : Response(com.ning.http.client.Response) BoundRequestBuilder(com.ning.http.client.AsyncHttpClient.BoundRequestBuilder) TimeoutException(org.jboss.netty.handler.timeout.TimeoutException) JAXBException(javax.xml.bind.JAXBException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) ConnectException(java.net.ConnectException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 20 with Response

use of com.ning.http.client.Response in project pinpoint by naver.

the class NingAsyncHttpClientIT method test.

@Test
public void test() throws Exception {
    AsyncHttpClient client = new AsyncHttpClient();
    try {
        Future<Response> f = client.preparePost("http://www.naver.com/").addParameter("param1", "value1").execute();
        Response response = f.get();
    } finally {
        client.close();
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event("ASYNC_HTTP_CLIENT", AsyncHttpClient.class.getMethod("executeRequest", Request.class, AsyncHandler.class), null, null, "www.naver.com", annotation("http.url", "http://www.naver.com"), annotation("http.param", "param1=value1")));
    verifier.verifyTraceCount(0);
}
Also used : Response(com.ning.http.client.Response) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) Test(org.junit.Test)

Aggregations

Response (com.ning.http.client.Response)30 Test (org.junit.Test)10 IOException (java.io.IOException)9 AsyncHttpClient (com.ning.http.client.AsyncHttpClient)7 Test (org.testng.annotations.Test)7 AsyncHttpClientConfig (com.ning.http.client.AsyncHttpClientConfig)4 Request (com.ning.http.client.Request)4 RequestBuilder (com.ning.http.client.RequestBuilder)4 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)4 HttpMethod (io.netty.handler.codec.http.HttpMethod)4 Map (java.util.Map)4 NodesInfoResponse (org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse)4 CircuitBreaker (com.nike.fastbreak.CircuitBreaker)3 Span (com.nike.wingtips.Span)3 NettyAsyncHttpProvider (com.ning.http.client.providers.netty.NettyAsyncHttpProvider)3 UnknownHostException (java.net.UnknownHostException)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 KillBillClientException (org.killbill.billing.client.KillBillClientException)3 RoleDefinition (org.killbill.billing.client.model.RoleDefinition)3 UserRoles (org.killbill.billing.client.model.UserRoles)3