当前位置: 首页>>代码示例>>Java>>正文


Java AsyncServer.stop方法代码示例

本文整理汇总了Java中com.koushikdutta.async.AsyncServer.stop方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncServer.stop方法的具体用法?Java AsyncServer.stop怎么用?Java AsyncServer.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.koushikdutta.async.AsyncServer的用法示例。


在下文中一共展示了AsyncServer.stop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNoDomain

import com.koushikdutta.async.AsyncServer; //导入方法依赖的package包/类
public void testNoDomain() throws Exception {
    AsyncServer server = new AsyncServer();

    try {
        final Semaphore semaphore = new Semaphore(0);
        server.connectSocket("www.clockworkmod-notfound.com", 8080, new ConnectCallback() {
            @Override
            public void onConnectCompleted(Exception ex, AsyncSocket socket) {
                assertTrue(ex instanceof UnknownHostException);
                semaphore.release();
            }
        });
        assertTrue(semaphore.tryAcquire(5000, TimeUnit.MILLISECONDS));
    }
    finally {
        server.stop();
    }
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:19,代码来源:DnsTests.java

示例2: testProxy

import com.koushikdutta.async.AsyncServer; //导入方法依赖的package包/类
public void testProxy() throws Exception {
        wasProxied = false;
        final AsyncServer proxyServer = new AsyncServer();
        try {
            AsyncProxyServer httpServer = new AsyncProxyServer(proxyServer) {
                @Override
                protected boolean onRequest(AsyncHttpServerRequest request, AsyncHttpServerResponse response) {
                    wasProxied = true;
                    return super.onRequest(request, response);
                }
            };

            AsyncServerSocket socket = httpServer.listen(proxyServer, 0);

//            client.getSocketMiddleware().enableProxy("localhost", 5555);

            AsyncHttpGet get = new AsyncHttpGet("http://www.clockworkmod.com");
            get.enableProxy("localhost", socket.getLocalPort());

            Future<String> ret = client.executeString(get, null);
            String data;
            assertNotNull(data = ret.get(TIMEOUT, TimeUnit.MILLISECONDS));
            assertTrue(data.contains("ClockworkMod"));
            assertTrue(wasProxied);
        }
        finally {
            proxyServer.stop();
        }
    }
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:30,代码来源:HttpClientTests.java

示例3: disabled__testClientCertificateIssue163

import com.koushikdutta.async.AsyncServer; //导入方法依赖的package包/类
public void disabled__testClientCertificateIssue163() throws Exception {
    // https://security.springthroughtest.com/hello.json

    AsyncServer server = new AsyncServer();
    try {
        AsyncHttpClient client = new AsyncHttpClient(server);
        JSONObject json = client.executeJSONObject(new AsyncHttpGet("https://security.springthroughtest.com/hello.json"), null).get();

    }
    finally {
        server.stop();
    }
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:14,代码来源:SSLTests.java


注:本文中的com.koushikdutta.async.AsyncServer.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。