ErrorReportAccess { public static String serialize(ErrorReport newRules) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Persisting ErrorReport in a XML..."); String ret = null; try { StringWriter sw = new StringWriter(); JAXBContext context = JAXBContext.newInstance(ErrorReport.class); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_ENCODING, ENCODING); marshaller.marshal(newRules, sw); sw.close(); ret = sw.toString(); } catch (PropertyException e) { throw new RulesException("Failed to save the ErrorReport"); } catch (IOException e) { throw new RulesException("Failed to save the ErrorReport"); } catch (JAXBException e) { throw new RulesException("Failed to save the ErrorReport: " + e.getMessage()); } return ret; }  ErrorReport getErrorReport(Reader xml); static String serialize(ErrorReport newRules);  }
@Test public void testSerialize() throws IOException { ErrorReport er = new ErrorReport(); er.setText("A text"); er.setVersion("1.0.0"); String output = errorReportAccess.serialize(er); assertNotNull(output); assertTrue(output.contains(">A text<")); }