Add a failing test that will pass once #1306 is fixed

This commit is contained in:
Trustin Lee 2013-04-24 18:47:36 +09:00
parent c72b5341a3
commit 5dd35448a2

View File

@ -20,7 +20,9 @@ import io.netty.buffer.ByteBufIndexFinder;
import io.netty.buffer.MessageBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.embedded.EmbeddedByteChannel;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
@ -44,7 +46,8 @@ public class ReplayingDecoderTest {
// Truncated input
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 'A' }));
assertNull(ch.readInbound());
ch.close();
ch.finish();
assertNull(ch.readInbound());
}
@ -60,4 +63,28 @@ public class ReplayingDecoderTest {
out.add(msg);
}
}
@Test
@Ignore("needs a fix")
public void testReplacement() throws Exception {
EmbeddedByteChannel ch = new EmbeddedByteChannel(new BloatedLineDecoder());
// "AB" should be forwarded to LineDecoder by BloatedLineDecoder.
ch.writeInbound(Unpooled.wrappedBuffer(new byte[]{'A', 'B'}));
assertNull(ch.readInbound());
// "C\n" should be appended to "AB" so that LineDecoder decodes it correctly.
ch.writeInbound(Unpooled.wrappedBuffer(new byte[]{'C', '\n'}));
assertEquals(Unpooled.wrappedBuffer(new byte[] { 'A', 'B', 'C' }), ch.readInbound());
ch.finish();
assertNull(ch.readInbound());
}
private static final class BloatedLineDecoder extends ChannelInboundByteHandlerAdapter {
@Override
protected void inboundBufferUpdated(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
ctx.pipeline().replace(this, "less-bloated", new LineDecoder());
}
}
}