Created
January 30, 2014 14:41
-
-
Save jfarcand/8709938 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test(groups = { "online", "default_provider" }) | |
public void testWssRequestProxy() throws IOException, InterruptedException, ExecutionException, TimeoutException { | |
AsyncHttpClientConfig.Builder b = new AsyncHttpClientConfig.Builder(); | |
b.setFollowRedirects(true); | |
ProxyServer ps = new ProxyServer(ProxyServer.Protocol.HTTPS, "127.0.0.1", port1); | |
AsyncHttpClientConfig config = b.build(); | |
AsyncHttpClient asyncHttpClient = getAsyncHttpClient(config); | |
try { | |
RequestBuilder rb = new RequestBuilder("GET").setProxyServer(ps).setUrl(getTargetUrl2()); | |
WebSocket websocket = asyncHttpClient.executeRequest(rb.build(), new WebSocketUpgradeHandler.Builder().addWebSocketListener(new WebSocketTextListener() { | |
@Override | |
public void onMessage(String message) { | |
System.out.println(message); | |
} | |
@Override | |
public void onFragment(String fragment, boolean last) { | |
} | |
@Override | |
public void onOpen(com.ning.http.client.websocket.WebSocket websocket) { | |
System.out.println(websocket); | |
} | |
@Override | |
public void onClose(com.ning.http.client.websocket.WebSocket websocket) { | |
System.out.println(websocket); | |
} | |
@Override | |
public void onError(Throwable t) { | |
t.printStackTrace(); | |
} | |
}).build()).get(); | |
// WebSocket websocket = c.prepareGet(getTargetUrl()).execute(new WebSocketUpgradeHandler.Builder().addWebSocketListener(new WebSocketListener() { | |
// | |
// @Override | |
// public void onOpen(com.ning.http.client.websocket.WebSocket websocket) { | |
// text.set("OnOpen"); | |
// latch.countDown(); | |
// } | |
// | |
// @Override | |
// public void onClose(com.ning.http.client.websocket.WebSocket websocket) { | |
// } | |
// | |
// @Override | |
// public void onError(Throwable t) { | |
// t.printStackTrace(); | |
// latch.countDown(); | |
// } | |
// }).build()).get(); | |
// | |
Thread.sleep(600000); | |
} finally { | |
asyncHttpClient.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment