@Test public void messageReceivedShouldReceiveIfCloseNotReceived() throws Exception { Mockery context = new Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; context.setThreadingPolicy(new Synchroniser()); final NextFilter nextFilter = context.mock(NextFilter.class); final IoSession session = context.mock(IoSession.class); final Logger logger = context.mock(Logger.class); final ScheduledExecutorService scheduler = context.mock(ScheduledExecutorService.class); final WsMessage message = new WsBinaryMessage(BUFFER_ALLOCATOR.wrap(ByteBuffer.wrap(new byte[]{0x41}))); context.checking(new Expectations() { { oneOf(logger).isTraceEnabled(); will(returnValue(false)); oneOf(nextFilter).messageReceived(session, message); } }); Properties configuration = new Properties(); WsCloseFilter filter = new WsCloseFilter(WebSocketWireProtocol.RFC_6455, configuration, logger, scheduler); filter.messageReceived(nextFilter, session, message); context.assertIsSatisfied(); }
@Override public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception { if (receivedCloseFrame.get()) { return; } if (!(message instanceof WsMessage)) { nextFilter.messageReceived(session, message); } else { super.messageReceived(nextFilter, session, message); } }
WsCloseFilter extends WsFilterAdapter implements Runnable { @Override public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception { if (receivedCloseFrame.get()) { return; } if (!(message instanceof WsMessage)) { nextFilter.messageReceived(session, message); } else { super.messageReceived(nextFilter, session, message); } } }
WsCloseFilter extends WsFilterAdapter implements Runnable { @Override public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception { if (receivedCloseFrame.get()) { return; } if (!(message instanceof WsMessage)) { nextFilter.messageReceived(session, message); } else { super.messageReceived(nextFilter, session, message); } } WsCloseFilter(WebSocketWireProtocol wsVersion,
                         Properties configuration,
                         Logger logger,
                         ScheduledExecutorService scheduler); }
WsCloseFilter extends WsFilterAdapter implements Runnable { @Override public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception { if (receivedCloseFrame.get()) { return; } if (!(message instanceof WsMessage)) { nextFilter.messageReceived(session, message); } else { super.messageReceived(nextFilter, session, message); } } WsCloseFilter(WebSocketWireProtocol wsVersion,
                         Properties configuration,
                         Logger logger,
                         ScheduledExecutorService scheduler); @Override void filterWrite(NextFilter nextFilter, IoSession session,
            WriteRequest writeRequest); @Override void messageReceived(NextFilter nextFilter,
                                IoSession session,
                                Object message); @Override void filterClose(final NextFilter nextFilter,
                            final IoSession session); @Override void onPreRemove(IoFilterChain filterChain,
                            String name,
                            NextFilter nextFilter); @Override void run(); static boolean neededForProtocolVersion(WebSocketWireProtocol wsVersion); }
WsCloseFilter extends WsFilterAdapter implements Runnable { @Override public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception { if (receivedCloseFrame.get()) { return; } if (!(message instanceof WsMessage)) { nextFilter.messageReceived(session, message); } else { super.messageReceived(nextFilter, session, message); } } WsCloseFilter(WebSocketWireProtocol wsVersion,
                         Properties configuration,
                         Logger logger,
                         ScheduledExecutorService scheduler); @Override void filterWrite(NextFilter nextFilter, IoSession session,
            WriteRequest writeRequest); @Override void messageReceived(NextFilter nextFilter,
                                IoSession session,
                                Object message); @Override void filterClose(final NextFilter nextFilter,
                            final IoSession session); @Override void onPreRemove(IoFilterChain filterChain,
                            String name,
                            NextFilter nextFilter); @Override void run(); static boolean neededForProtocolVersion(WebSocketWireProtocol wsVersion);  }