TomcatXmppWebSocket extends MessageInbound implements Outbound { public void write(String xml) throws IOException { LOG.info("> " + xml); CharBuffer buffer = CharBuffer.wrap(xml); outbound.writeTextMessage(buffer); } TomcatXmppWebSocket(ServerRuntimeContext serverRuntimeContext, StanzaProcessor stanzaProcessor); void onOpen(WsOutbound outbound); void onClose(int closeCode, String message); void write(String xml);  }
@Test public void write() throws IOException { TomcatXmppWebSocket context = new TomcatXmppWebSocket(serverRuntimeContext, stanzaProcessor); context.onOpen(outbound); context.write("<test></test>"); Mockito.verify(outbound).writeTextMessage(CharBuffer.wrap("<test></test>")); }