当前位置: 首页>>代码示例>>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;未经允许,请勿转载。