本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}