WebActionBase64WriteInterceptorTest.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:jrestless 作者:
public void testWrapsInputStream(String contentType) throws WebApplicationException, IOException {
    WriterInterceptorContext context = mockContext(contentType);
    OutputStream os = mock(OutputStream.class);
    when(context.getOutputStream()).thenReturn(os);

    writeInterceptor.aroundWriteTo(context);

    verifyZeroInteractions(os);

    ArgumentCaptor<OutputStream> updatedOsCapture = ArgumentCaptor.forClass(OutputStream.class);
    verify(context).setOutputStream(updatedOsCapture.capture());
    verify(context).getMediaType();
    verify(context).getOutputStream();
    verify(context).proceed();
    verifyNoMoreInteractions(context);

    OutputStream updatedOs = updatedOsCapture.getValue();

    // just make sure we have some wrapper
    assertNotSame(os, updatedOs);
    updatedOs.close();
    verify(os).close();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号