class JWSHttpServletRequestWrapper extends SecurityContextHolderAwareRequestWrapper {

	@Override
	public ServletInputStream getInputStream() throws IOException {
		final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());

		ServletInputStream inputStream = new ServletInputStream() {
			@Override
			public int read() throws IOException {
				return byteArrayInputStream.read();
			}
		};

		return inputStream;
	}

}

class JWSHttpServletRequestWrapperTest {

    private static final String TEST_CONTENT;
    @Mock
    private HttpServletRequest request;

    @Test
    public void testWrapperObtainContent() throws Exception{


        //environment
        ServletInputStream sis = new DelegatingServletInputStream(new ByteArrayInputStream( TEST_CONTENT.getBytes()));
        when(request.getInputStream()).thenReturn(sis);

        //test
        JWSHttpServletRequestWrapper jwsHttpServletRequestWrapper = new JWSHttpServletRequestWrapper(request, null);
        InputStream is = jwsHttpServletRequestWrapper.getInputStream();

        //validation
        String obtainedContent = obtainContent(is);
        Assert.assertNotNull("content should be not be null",obtainedContent);
        Assert.assertEquals("content should be the same",TEST_CONTENT,obtainedContent);


    }

}