public void testEncode() throws Exception
{
TextLineEncoder encoder = new TextLineEncoder(
Charset.forName( "UTF-8" ), LineDelimiter.WINDOWS );
IoSession session = new DummySession();
SimpleProtocolEncoderOutput out =
new SimpleProtocolEncoderOutput()
{
protected WriteFuture doFlush( ByteBuffer buf )
{
return null;
}
};
encoder.encode( session, "ABC", out );
Assert.assertEquals( 1, out.getBufferQueue().size() );
ByteBuffer buf = ( ByteBuffer ) out.getBufferQueue().pop();
Assert.assertEquals( 5, buf.remaining() );
Assert.assertEquals( 'A', buf.get() );
Assert.assertEquals( 'B', buf.get() );
Assert.assertEquals( 'C', buf.get() );
Assert.assertEquals( '\r', buf.get() );