use of org.asynchttpclient.ws.WebSocketListener in project camel by apache.
the class WebsocketConsumerRouteTest method testWSBytesHttpCall.
@Test
public void testWSBytesHttpCall() throws Exception {
AsyncHttpClient c = new DefaultAsyncHttpClient();
WebSocket websocket = c.prepareGet("ws://127.0.0.1:" + port + "/echo").execute(new WebSocketUpgradeHandler.Builder().addWebSocketListener(new WebSocketListener() {
@Override
public void onOpen(WebSocket websocket) {
}
@Override
public void onClose(WebSocket websocket) {
}
@Override
public void onError(Throwable t) {
t.printStackTrace();
}
}).build()).get();
MockEndpoint result = getMockEndpoint("mock:result");
final byte[] testmessage = "Test".getBytes("utf-8");
result.expectedBodiesReceived(testmessage);
websocket.sendMessage(testmessage);
result.assertIsSatisfied();
websocket.close();
c.close();
}
use of org.asynchttpclient.ws.WebSocketListener in project camel by apache.
the class WebsocketConsumerRouteTest method testWSHttpCall.
@Test
public void testWSHttpCall() throws Exception {
AsyncHttpClient c = new DefaultAsyncHttpClient();
WebSocket websocket = c.prepareGet("ws://127.0.0.1:" + port + "/echo").execute(new WebSocketUpgradeHandler.Builder().addWebSocketListener(new WebSocketListener() {
@Override
public void onOpen(WebSocket websocket) {
}
@Override
public void onClose(WebSocket websocket) {
}
@Override
public void onError(Throwable t) {
t.printStackTrace();
}
}).build()).get();
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedBodiesReceived("Test");
websocket.sendMessage("Test");
result.assertIsSatisfied();
websocket.close();
c.close();
}
Aggregations