use of javax.websocket.Session in project javaee7-samples by javaee-samples.
the class MyEndpointTest method testEndpointByteBuffer.
@Test
public void testEndpointByteBuffer() throws URISyntaxException, DeploymentException, IOException, InterruptedException {
MyEndpointByteBufferClient.latch = new CountDownLatch(1);
Session session = connectToServer(MyEndpointByteBufferClient.class, "bytebuffer");
assertNotNull(session);
assertTrue(MyEndpointByteBufferClient.latch.await(2, TimeUnit.SECONDS));
assertArrayEquals(TEXT.getBytes(), MyEndpointByteBufferClient.response);
}
use of javax.websocket.Session in project javaee7-samples by javaee-samples.
the class MyEndpointTest method testTextEndpoint.
@Test
public void testTextEndpoint() throws URISyntaxException, DeploymentException, IOException, InterruptedException {
MyEndpointTextClient.latch = new CountDownLatch(1);
Session session = connectToServer(MyEndpointTextClient.class, "text");
assertNotNull(session);
assertTrue(MyEndpointTextClient.latch.await(2, TimeUnit.SECONDS));
assertEquals(TEXT, MyEndpointTextClient.response);
}
use of javax.websocket.Session in project javaee7-samples by javaee-samples.
the class MyEndpointTest method testEndpointByteArray.
@Test
public void testEndpointByteArray() throws DeploymentException, IOException, URISyntaxException, InterruptedException {
MyEndpointByteArrayClient.latch = new CountDownLatch(1);
Session session = connectToServer(MyEndpointByteArrayClient.class, "bytearray");
assertNotNull(session);
assertTrue(MyEndpointByteArrayClient.latch.await(2, TimeUnit.SECONDS));
assertNotNull(MyEndpointByteArrayClient.response);
assertArrayEquals(TEXT.getBytes(), MyEndpointByteArrayClient.response);
}
use of javax.websocket.Session in project spring-framework by spring-projects.
the class StandardWebSocketSessionTests method getPrincipalNone.
@Test
@SuppressWarnings("resource")
public void getPrincipalNone() {
Session nativeSession = Mockito.mock(Session.class);
given(nativeSession.getUserPrincipal()).willReturn(null);
StandardWebSocketSession session = new StandardWebSocketSession(this.headers, this.attributes, null, null);
session.initializeNativeSession(nativeSession);
reset(nativeSession);
assertNull(session.getPrincipal());
verifyNoMoreInteractions(nativeSession);
}
use of javax.websocket.Session in project spring-framework by spring-projects.
the class StandardWebSocketSessionTests method getPrincipalWithNativeSession.
@Test
@SuppressWarnings("resource")
public void getPrincipalWithNativeSession() {
TestPrincipal user = new TestPrincipal("joe");
Session nativeSession = Mockito.mock(Session.class);
given(nativeSession.getUserPrincipal()).willReturn(user);
StandardWebSocketSession session = new StandardWebSocketSession(this.headers, this.attributes, null, null);
session.initializeNativeSession(nativeSession);
assertSame(user, session.getPrincipal());
}
Aggregations