use of org.eclipse.jetty.websocket.jsr356.handlers.LongMessageHandler in project jetty.project by eclipse.
the class JsrSessionTest method testMessageHandlerReplaceTextHandler.
@Test
public void testMessageHandlerReplaceTextHandler() throws DeploymentException {
MessageHandler oldText = new StringWholeHandler();
// add a TEXT handler
session.addMessageHandler(oldText);
// add BINARY handler
session.addMessageHandler(new ByteArrayWholeHandler());
// remove original TEXT handler
session.removeMessageHandler(oldText);
// add new TEXT handler
session.addMessageHandler(new LongMessageHandler());
MessageHandlerWrapper wrapper = session.getMessageHandlerWrapper(MessageType.BINARY);
Assert.assertThat("Binary Handler", wrapper.getHandler(), instanceOf(ByteArrayWholeHandler.class));
Assert.assertEquals("Message Class", wrapper.getMetadata().getMessageClass(), byte[].class);
wrapper = session.getMessageHandlerWrapper(MessageType.TEXT);
Assert.assertThat("Text Handler", wrapper.getHandler(), instanceOf(LongMessageHandler.class));
Assert.assertEquals("Message Class", wrapper.getMetadata().getMessageClass(), Long.class);
}
Aggregations