use of org.eclipse.jetty.cdi.websocket.CheckSocket in project jetty.project by eclipse.
the class CdiAppTest method testWebSocket_Info_DataFromCdi.
@Test
public void testWebSocket_Info_DataFromCdi() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
client.start();
CheckSocket socket = new CheckSocket();
client.connect(socket, serverWebsocketURI.resolve("/cdi-info"));
socket.awaitOpen(2, TimeUnit.SECONDS);
socket.sendText("data|stuff");
socket.close(StatusCode.NORMAL, "Test complete");
socket.awaitClose(2, TimeUnit.SECONDS);
assertThat("Messages received", socket.getTextMessages().size(), is(2));
String response = socket.getTextMessages().poll();
System.out.println("[0]" + response);
assertThat("Message[0]", response, containsString("Hello there stuff"));
System.out.println("[1]" + socket.getTextMessages().poll());
} finally {
client.stop();
}
}
use of org.eclipse.jetty.cdi.websocket.CheckSocket in project jetty.project by eclipse.
the class CdiAppTest method testWebSocketActivated.
@Test
public void testWebSocketActivated() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
client.start();
CheckSocket socket = new CheckSocket();
client.connect(socket, serverWebsocketURI.resolve("/echo"));
socket.awaitOpen(2, TimeUnit.SECONDS);
socket.sendText("Hello");
socket.close(StatusCode.NORMAL, "Test complete");
socket.awaitClose(2, TimeUnit.SECONDS);
assertThat("Messages received", socket.getTextMessages().size(), is(1));
assertThat("Message[0]", socket.getTextMessages().poll(), is("Hello"));
} finally {
client.stop();
}
}
use of org.eclipse.jetty.cdi.websocket.CheckSocket in project jetty.project by eclipse.
the class BasicAppTest method testWebSocketEcho.
@Test
public void testWebSocketEcho() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
client.start();
CheckSocket socket = new CheckSocket();
client.connect(socket, serverWebsocketURI.resolve("/echo"));
socket.awaitOpen(2, TimeUnit.SECONDS);
socket.sendText("Hello World");
socket.close(StatusCode.NORMAL, "Test complete");
socket.awaitClose(2, TimeUnit.SECONDS);
assertThat("Messages received", socket.getTextMessages().size(), is(1));
String response = socket.getTextMessages().poll();
System.err.println(response);
assertThat("Message[0]", response, is("Hello World"));
} finally {
client.stop();
}
}
use of org.eclipse.jetty.cdi.websocket.CheckSocket in project jetty.project by eclipse.
the class CdiAppTest method testWebSocket_Info_FieldPresence.
@Test
public void testWebSocket_Info_FieldPresence() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
client.start();
CheckSocket socket = new CheckSocket();
client.connect(socket, serverWebsocketURI.resolve("/cdi-info"));
socket.awaitOpen(2, TimeUnit.SECONDS);
socket.sendText("info");
socket.close(StatusCode.NORMAL, "Test complete");
socket.awaitClose(2, TimeUnit.SECONDS);
assertThat("Messages received", socket.getTextMessages().size(), is(1));
String response = socket.getTextMessages().poll();
System.err.println(response);
assertThat("Message[0]", response, allOf(containsString("websocketSession is PRESENT"), containsString("httpSession is PRESENT"), containsString("servletContext is PRESENT")));
} finally {
client.stop();
}
}
Aggregations