Skip to content

Commit

Permalink
Fix uts
Browse files Browse the repository at this point in the history
  • Loading branch information
mafei6827 committed Apr 15, 2024
1 parent 7fd75e3 commit 9214c2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -51,10 +52,11 @@ public void initChannel() {
serverInitializer.initChannel(mockChannel);

ArgumentCaptor<ChannelHandler> handlersCaptor = ArgumentCaptor.forClass(ChannelHandler.class);
verify(mockPipeline, times(3)).addLast(handlersCaptor.capture());
verify(mockPipeline, times(4)).addLast(handlersCaptor.capture());
List<ChannelHandler> handlers = handlersCaptor.getAllValues();
assertTrue(handlers.get(0) instanceof HttpServerCodec);
assertTrue(handlers.get(1) instanceof HTTPRequestRouter);
assertSame(handlers.get(2), ExceptionHandler.INSTANCE);
assertTrue(handlers.get(1) instanceof HttpObjectAggregator);
assertTrue(handlers.get(2) instanceof HTTPRequestRouter);
assertSame(handlers.get(3), ExceptionHandler.INSTANCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.ssl.SslContext;
import java.util.List;
Expand Down Expand Up @@ -58,11 +59,12 @@ public void initChannel() {
serverInitializer.initChannel(mockChannel);

ArgumentCaptor<ChannelHandler> handlersCaptor = ArgumentCaptor.forClass(ChannelHandler.class);
verify(mockPipeline, times(4)).addLast(handlersCaptor.capture());
verify(mockPipeline, times(5)).addLast(handlersCaptor.capture());
verify(sslContext).newHandler(byteBufAllocator);
List<ChannelHandler> handlers = handlersCaptor.getAllValues();
assertTrue(handlers.get(1) instanceof HttpServerCodec);
assertTrue(handlers.get(2) instanceof HTTPRequestRouter);
assertSame(handlers.get(3), ExceptionHandler.INSTANCE);
assertTrue(handlers.get(2) instanceof HttpObjectAggregator);
assertTrue(handlers.get(3) instanceof HTTPRequestRouter);
assertSame(handlers.get(4), ExceptionHandler.INSTANCE);
}
}

0 comments on commit 9214c2c

Please sign in to comment.