當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncHttpClient.close方法代碼示例

本文整理匯總了Java中com.ning.http.client.AsyncHttpClient.close方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncHttpClient.close方法的具體用法?Java AsyncHttpClient.close怎麽用?Java AsyncHttpClient.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.ning.http.client.AsyncHttpClient的用法示例。


在下文中一共展示了AsyncHttpClient.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Test
 public void test() throws Exception {
     AsyncHttpClient client = new AsyncHttpClient();
     
     try {
         Future<Response> f = client.preparePost(webServer.getCallHttpUrl()).addParameter("param1", "value1").execute();
         Response response = f.get();
     } finally {
         client.close();
     }
     
     PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
     verifier.printCache();

     String destinationId = webServer.getHostAndPort();
     String httpUrl = webServer.getCallHttpUrl();
     verifier.verifyTrace(event("ASYNC_HTTP_CLIENT", AsyncHttpClient.class.getMethod("executeRequest", Request.class, AsyncHandler.class), null, null, destinationId,
             annotation("http.url", httpUrl)));
     verifier.verifyTraceCount(0);
}
 
開發者ID:naver,項目名稱:pinpoint,代碼行數:21,代碼來源:NingAsyncHttpClientIT.java

示例2: shouldGetBadRequest

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Test
public void shouldGetBadRequest() throws Exception {
		
 final CountDownLatch latch = new CountDownLatch(1);
 
    final AsyncHttpClient c = new AsyncHttpClient();
    
    template.sendBody(RouteManager.SEDA_INPUT,jsonDiff);
    latch.await(2,TimeUnit.SECONDS);
    //get a sessionid
    Response r1 = c.prepareGet("http://localhost:"+restPort+SIGNALK_AUTH+"/demo/pass").execute().get();
    //latch2.await(3, TimeUnit.SECONDS);
    assertEquals(200, r1.getStatusCode());
    Response reponse = c.prepareGet("http://localhost:"+restPort+SIGNALK_API+"/vessels/*/navigation").setCookies(r1.getCookies()).execute().get();
    //latch.await(3, TimeUnit.SECONDS);
    logger.debug(reponse.getResponseBody());
    assertEquals(400, reponse.getStatusCode());
    
    assertEquals("Bad Request" , reponse.getResponseBody());
 
    c.close();
}
 
開發者ID:SignalK,項目名稱:signalk-server-java,代碼行數:23,代碼來源:RestApiTest.java

示例3: shouldGetEmptyResponse

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Test
public void shouldGetEmptyResponse() throws Exception {
		
 final CountDownLatch latch = new CountDownLatch(1);
 
    final AsyncHttpClient c = new AsyncHttpClient();
    
    template.sendBody(RouteManager.SEDA_INPUT,jsonDiff);
    latch.await(2,TimeUnit.SECONDS);
    //get a sessionid
    Response r1 = c.prepareGet("http://localhost:"+restPort+SIGNALK_AUTH+"/demo/pass").execute().get();
    //latch2.await(3, TimeUnit.SECONDS);
    assertEquals(200, r1.getStatusCode());
    Response reponse = c.prepareGet("http://localhost:"+restPort+SIGNALK_API+"/vessels/self/navigation/nothing").setCookies(r1.getCookies()).execute().get();
    //latch.await(3, TimeUnit.SECONDS);
    logger.debug(reponse.getResponseBody());
    assertEquals(200, reponse.getStatusCode());
    
    assertEquals("{}" , reponse.getResponseBody());
 
    c.close();
}
 
開發者ID:SignalK,項目名稱:signalk-server-java,代碼行數:23,代碼來源:RestApiTest.java

示例4: shutdown

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
/**
 * Shutdown each AHC client in the map.
 */
public void shutdown() {

    for (Entry<HttpClientType, AsyncHttpClient> entry : map.entrySet()) {
        AsyncHttpClient client = entry.getValue();
        if (client != null)
            client.close();
    }

}
 
開發者ID:eBay,項目名稱:parallec,代碼行數:13,代碼來源:HttpClientStore.java

示例5: shouldGetWsUrl

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Test
   public void shouldGetWsUrl() throws Exception {
	
       final AsyncHttpClient c = new AsyncHttpClient();
       
       //get a sessionid
       Response r1 = c.prepareGet("http://localhost:"+restPort+SIGNALK_AUTH+"/demo/pass").execute().get();
       assertEquals(200, r1.getStatusCode());
       Response r2 = c.prepareGet("http://localhost:"+restPort+SIGNALK_DISCOVERY).setCookies(r1.getCookies()).execute().get();
       Json json = Json.read(r2.getResponseBody());
       assertEquals("ws://localhost:"+wsPort+SIGNALK_WS, json.at("endpoints").at("v1").at(websocketUrl).asString());
       c.close();
}
 
開發者ID:SignalK,項目名稱:signalk-server-java,代碼行數:14,代碼來源:SubcribeWsTest.java

示例6: doTest

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
protected void doTest(int port) throws Exception {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient
            .prepareGet("http://localhost:" + port + contextPath + "/first-include")
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:12,代碼來源:ServletDispatcherIT.java

示例7: shouldGetListResponse

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Test
public void shouldGetListResponse() throws Exception {
		
 final CountDownLatch latch = new CountDownLatch(1);
 
    final AsyncHttpClient c = new AsyncHttpClient();
    
    template.sendBody(RouteManager.SEDA_INPUT,jsonDiff);
    latch.await(2,TimeUnit.SECONDS);
    //get a sessionid
    Response r1 = c.prepareGet("http://localhost:"+restPort+SIGNALK_AUTH+"/demo/pass").execute().get();
    //latch2.await(3, TimeUnit.SECONDS);
    assertEquals(200, r1.getStatusCode());
    Response reponse = c.prepareGet("http://localhost:"+restPort+SIGNALK_API+"/list/vessels/"+SignalKConstants.self+"/*").setCookies(r1.getCookies()).execute().get();
    //latch.await(3, TimeUnit.SECONDS);
    logger.debug(reponse.getResponseBody());
    assertEquals(200, reponse.getStatusCode());
    
    Json resp = Json.read(reponse.getResponseBody());
    Json list = resp.at(SignalKConstants.PATHLIST);
    assertTrue(list.isArray());
    assertTrue(list.asJsonList().get(0).asString().startsWith("vessels."+SignalKConstants.self));
 
    reponse = c.prepareGet("http://localhost:"+restPort+SIGNALK_API+"/list/vessels/*/navigation/*").setCookies(r1.getCookies()).execute().get();
    //latch.await(3, TimeUnit.SECONDS);
    logger.debug(reponse.getResponseBody());
    assertEquals(200, reponse.getStatusCode());
    			//{\"updates\":[{\"values\":[{\"value\":3.0176,\"path\":\"navigation.courseOverGroundTrue\"}],\"source\":{\"timestamp\":\"2014-08-15T16:00:00.081Z\",\"source\":\"/dev/actisense-N2K-115-128267\"}}],\"context\":\"vessels.self\"}
    
    resp = Json.read(reponse.getResponseBody());
    list = resp.at(SignalKConstants.PATHLIST);
    assertTrue(list.isArray());
    assertTrue(list.asJsonList().get(0).asString().startsWith("vessels.*.navigation"));
    c.close();
}
 
開發者ID:SignalK,項目名稱:signalk-server-java,代碼行數:36,代碼來源:RestApiTest.java

示例8: run

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
public void run() {
    AsyncHttpClient httpClient = createHttpClient();
    try {
        replayLog(httpClient);
    } catch (Exception e) {
        LOG.error(String.format("log replayer failed: %s", e.getMessage()), e);
    } finally {
        httpClient.close();
    }
}
 
開發者ID:elastisys,項目名稱:scale.commons,代碼行數:12,代碼來源:BurstingApacheLogReplayer.java

示例9: run

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
public void run() {
    AsyncHttpClient httpClient = createHttpClient();
    try {
        applyBurst(httpClient, this.requestRate, this.duration.orElse(Integer.MAX_VALUE));
    } catch (Exception e) {
        LOG.error(String.format("log replayer failed: %s", e.getMessage()), e);
    } finally {
        httpClient.close();
    }
}
 
開發者ID:elastisys,項目名稱:scale.commons,代碼行數:12,代碼來源:SteadyLoadReplayer.java

示例10: doTest

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
protected void doTest(int port) throws Exception {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + "/hello.xhtml")
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:11,代碼來源:JsfRenderIT.java

示例11: doTest

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
protected void doTest(int port) throws Exception {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode =
            asyncHttpClient.prepareGet("http://localhost:" + port + contextPath + "/async3")
                    .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:12,代碼來源:AsyncServletIT.java

示例12: transactionMarker

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
public void transactionMarker() throws Exception {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode =
            asyncHttpClient.prepareGet("http://localhost:" + getPort() + "/hello1/")
                    .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:12,代碼來源:AsyncHttpClientPluginIT.java

示例13: doTest

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
protected void doTest(int port) throws Exception {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode =
            asyncHttpClient.prepareGet("http://localhost:" + port + "/hello/abc/xyz")
                    .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:12,代碼來源:GrailsIT.java

示例14: executeApp

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addContext("", new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader = new WebappLoader(RenderJspInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    Tomcat.addServlet(context, "hello", new ForwardingServlet());
    context.addServletMapping("/hello", "hello");
    Tomcat.addServlet(context, "jsp", new JspServlet());
    context.addServletMapping("*.jsp", "jsp");

    tomcat.start();
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + "/hello")
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
    tomcat.stop();
    tomcat.destroy();
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:29,代碼來源:JspRenderIT.java

示例15: doTest

import com.ning.http.client.AsyncHttpClient; //導入方法依賴的package包/類
@Override
protected void doTest(int port) throws Exception {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + "/hello/5")
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:11,代碼來源:AnnotatedServletIT.java


注:本文中的com.ning.http.client.AsyncHttpClient.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。