HttpWebService extends ServletBase { public String getPayloadAsString( final HttpServletRequest request ) throws IOException { BufferedReader reader = request.getReader(); if ( reader != null ) { return IOUtils.toString( reader ); } else { return null; } } HttpWebService(); @Override Log getLogger(); String getPayloadAsString( final HttpServletRequest request ); void doGetFixMe( final HttpServletRequest request, final HttpServletResponse response ); @Override void doGet( final HttpServletRequest request, final HttpServletResponse response );  }
@Test public void testGetPayloadAsString() throws Exception { when( request.getReader() ).thenReturn( reader ); assertEquals( payload, httpWebService.getPayloadAsString( request ) ); }
@Test public void testGetPayloadAsString_nullReader() throws Exception { when( request.getReader() ).thenReturn( null ); assertNull( httpWebService.getPayloadAsString( request ) ); }