@Test public void encode() { IoSession session = mock(IoSession.class); ByteBuffer buff = ByteBuffer.wrap("test".getBytes()); Object encodingState = new Object(); when(session.getAttribute(new AttributeKey<Object>(Object.class, "internal_encoder"))) .thenReturn(encodingState); Object toEncode = new Object(); WriteRequest wrq = mock(WriteRequest.class); when(wrq.getMessage()).thenReturn(toEncode); when(encoder.encode(toEncode, encodingState)).thenReturn(buff); WriteFilterChainController ctrl = mock(WriteFilterChainController.class); filter.messageWriting(session, wrq, ctrl); verify(encoder).encode(toEncode, encodingState); verify(wrq).getMessage(); verify(wrq).setMessage(buff); verify(ctrl).callWriteNextFilter(wrq); verify(session).getAttribute(new AttributeKey<Object>(Object.class, "internal_encoder")); verifyNoMoreInteractions(encoder, decoder, session, ctrl, wrq); }
@SuppressWarnings("unchecked") @Override public void messageWriting(IoSession session, WriteRequest message, WriteFilterChainController controller) { LOGGER.debug("Processing a MESSAGE_WRITTING for session {}", session); ENCODED encoded = encoder.encode((MESSAGE) message.getMessage(), getEncodingState(session)); message.setMessage(encoded); super.messageWriting(session, message, controller); }
ProtocolCodecFilter extends AbstractIoFilter { @SuppressWarnings("unchecked") @Override public void messageWriting(IoSession session, WriteRequest message, WriteFilterChainController controller) { LOGGER.debug("Processing a MESSAGE_WRITTING for session {}", session); ENCODED encoded = encoder.encode((MESSAGE) message.getMessage(), getEncodingState(session)); message.setMessage(encoded); super.messageWriting(session, message, controller); } }
ProtocolCodecFilter extends AbstractIoFilter { @SuppressWarnings("unchecked") @Override public void messageWriting(IoSession session, WriteRequest message, WriteFilterChainController controller) { LOGGER.debug("Processing a MESSAGE_WRITTING for session {}", session); ENCODED encoded = encoder.encode((MESSAGE) message.getMessage(), getEncodingState(session)); message.setMessage(encoded); super.messageWriting(session, message, controller); } ProtocolCodecFilter(ProtocolEncoder<MESSAGE, ENCODED, ENCODING_STATE> encoder,
            ProtocolDecoder<ENCODED, MESSAGE, DECODING_STATE> decoder); }
ProtocolCodecFilter extends AbstractIoFilter { @SuppressWarnings("unchecked") @Override public void messageWriting(IoSession session, WriteRequest message, WriteFilterChainController controller) { LOGGER.debug("Processing a MESSAGE_WRITTING for session {}", session); ENCODED encoded = encoder.encode((MESSAGE) message.getMessage(), getEncodingState(session)); message.setMessage(encoded); super.messageWriting(session, message, controller); } ProtocolCodecFilter(ProtocolEncoder<MESSAGE, ENCODED, ENCODING_STATE> encoder,
            ProtocolDecoder<ENCODED, MESSAGE, DECODING_STATE> decoder); @SuppressWarnings("unchecked") @Override void messageReceived(IoSession session, Object in, ReadFilterChainController controller); @SuppressWarnings("unchecked") @Override void messageWriting(IoSession session, WriteRequest message, WriteFilterChainController controller); @Override void sessionOpened(IoSession session); @Override void sessionClosed(IoSession session); }
ProtocolCodecFilter extends AbstractIoFilter { @SuppressWarnings("unchecked") @Override public void messageWriting(IoSession session, WriteRequest message, WriteFilterChainController controller) { LOGGER.debug("Processing a MESSAGE_WRITTING for session {}", session); ENCODED encoded = encoder.encode((MESSAGE) message.getMessage(), getEncodingState(session)); message.setMessage(encoded); super.messageWriting(session, message, controller); } ProtocolCodecFilter(ProtocolEncoder<MESSAGE, ENCODED, ENCODING_STATE> encoder,
            ProtocolDecoder<ENCODED, MESSAGE, DECODING_STATE> decoder); @SuppressWarnings("unchecked") @Override void messageReceived(IoSession session, Object in, ReadFilterChainController controller); @SuppressWarnings("unchecked") @Override void messageWriting(IoSession session, WriteRequest message, WriteFilterChainController controller); @Override void sessionOpened(IoSession session); @Override void sessionClosed(IoSession session);  }