Code example for StringWriter

Methods: toString

0
  public void testNoEntity() 
  { 
    final String TEST_STRING = "Entity body should not be contained in RestException.toString()";
    RestResponse response = new RestResponseBuilder().setEntity(ByteString.copyString(TEST_STRING, "UTF-8")).build();
    RestException e = new RestException(response);
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    pw.close();
    Assert.assertEquals(sw.toString().indexOf(TEST_STRING), -1, TEST_STRING);
  } 
}