Adding pipeline rename handler tests (#10028)

Motivation:

Current pipeline handler replace tests are replacing handler with same name.
we need test that test handler can renamed, old handlers are removed from pipeline.

Modification:

There is coverage missing related to renaming of handlers

Result:

Adds missing tests

Co-authored-by: phani254 <phani254@yahoo.com>
This commit is contained in:
Subba Rao Pasupuleti 2020-02-14 10:53:09 -05:00 committed by GitHub
parent e648aa259d
commit 0e2e17f9a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,6 +264,61 @@ public class DefaultChannelPipelineTest {
assertSame(pipeline.get("handler2"), newHandler2);
}
@Test(expected = IllegalArgumentException.class)
public void testReplaceHandlerChecksDuplicateNames() {
ChannelPipeline pipeline = new LocalChannel().pipeline();
ChannelHandler handler1 = newHandler();
ChannelHandler handler2 = newHandler();
pipeline.addLast("handler1", handler1);
pipeline.addLast("handler2", handler2);
ChannelHandler newHandler1 = newHandler();
pipeline.replace("handler1", "handler2", newHandler1);
}
@Test
public void testReplaceNameWithGenerated() {
ChannelPipeline pipeline = new LocalChannel().pipeline();
ChannelHandler handler1 = newHandler();
pipeline.addLast("handler1", handler1);
assertSame(pipeline.get("handler1"), handler1);
ChannelHandler newHandler1 = newHandler();
pipeline.replace("handler1", null, newHandler1);
assertSame(pipeline.get("DefaultChannelPipelineTest$TestHandler#0"), newHandler1);
assertNull(pipeline.get("handler1"));
}
@Test
public void testRenameChannelHandler() {
ChannelPipeline pipeline = new LocalChannel().pipeline();
ChannelHandler handler1 = newHandler();
pipeline.addLast("handler1", handler1);
pipeline.addLast("handler2", handler1);
pipeline.addLast("handler3", handler1);
assertSame(pipeline.get("handler1"), handler1);
assertSame(pipeline.get("handler2"), handler1);
assertSame(pipeline.get("handler3"), handler1);
ChannelHandler newHandler1 = newHandler();
pipeline.replace("handler1", "newHandler1", newHandler1);
assertSame(pipeline.get("newHandler1"), newHandler1);
assertNull(pipeline.get("handler1"));
ChannelHandler newHandler3 = newHandler();
pipeline.replace("handler3", "newHandler3", newHandler3);
assertSame(pipeline.get("newHandler3"), newHandler3);
assertNull(pipeline.get("handler3"));
ChannelHandler newHandler2 = newHandler();
pipeline.replace("handler2", "newHandler2", newHandler2);
assertSame(pipeline.get("newHandler2"), newHandler2);
assertNull(pipeline.get("handler2"));
}
@Test
public void testChannelHandlerContextNavigation() {
ChannelPipeline pipeline = new LocalChannel().pipeline();