@Test
public void testSnappyReaderInterceptor() throws IOException {
SnappyReaderInterceptor readerInterceptor = new SnappyReaderInterceptor();
MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
headers.put(SnappyReaderInterceptor.CONTENT_ENCODING, Arrays.asList(SnappyReaderInterceptor.SNAPPY));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
SnappyFramedOutputStream snappyFramedOutputStream = new SnappyFramedOutputStream(byteArrayOutputStream);
snappyFramedOutputStream.write("Hello".getBytes());
ByteArrayInputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ReaderInterceptorContext mockInterceptorContext = Mockito.mock(ReaderInterceptorContext.class);
Mockito.when(mockInterceptorContext.getHeaders()).thenReturn(headers);
Mockito.when(mockInterceptorContext.getInputStream()).thenReturn(inputStream);
Mockito.doNothing().when(mockInterceptorContext).setInputStream(Mockito.any(InputStream.class));
// call aroundReadFrom on mock
readerInterceptor.aroundReadFrom(mockInterceptorContext);
// verify that setInputStream method was called once with argument which is an instance of SnappyFramedInputStream
Mockito.verify(mockInterceptorContext, Mockito.times(1))
.setInputStream(Mockito.any(SnappyFramedInputStream.class));
}
TestSnappyReaderInterceptor.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:datacollector
作者:
评论列表
文章目录