@Before
public void setUp() throws Exception {
upstreamMock = Mockito.mock(SimpleChannelUpstreamHandler.class, Answers.CALLS_REAL_METHODS.get());
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("open-channels", queryChannelsRegistry);
pipeline.addLast("delimiter", new DelimiterBasedFrameDecoder(1024, true, ChannelBuffers.wrappedBuffer(new byte[]{'\n'})));
pipeline.addLast("string-decoder", new StringDecoder(Charsets.UTF_8));
pipeline.addLast("whois-encoder", applicationContext.getBean(WhoisEncoder.class));
pipeline.addLast("exception", new ExceptionHandler());
pipeline.addLast("query-decoder", applicationContext.getBean(QueryDecoder.class));
pipeline.addLast("connection-state", new ConnectionStateHandler());
pipeline.addLast("upstreamMock", upstreamMock);
when(whoisServerPipelineFactory.getPipeline()).thenReturn(pipeline);
doAnswer(new Answer() {
@Override
public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
ResponseHandler responseHandler = (ResponseHandler) invocationOnMock.getArguments()[3];
responseHandler.handle(RpslObject.parse(queryResult));
return null;
}
}).when(queryHandler).streamResults(any(Query.class), any(InetAddress.class), anyInt(), any(ResponseHandler.class));
queryServer.start();
}
WhoisConnectionTestIntegration.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:whois
作者:
评论列表
文章目录