HmlWriter { public static void write(final Hml data, final Writer writer) throws IOException { checkNotNull(data); checkNotNull(writer); try { JAXBContext context = JAXBContext.newInstance(Hml.class); Marshaller marshaller = context.createMarshaller(); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); URL schemaURL = HmlReader.class.getResource("/org/nmdp/ngs/hml/xsd/hml-1.0.1.xsd"); Schema schema = schemaFactory.newSchema(schemaURL); marshaller.setSchema(schema); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(data, writer); } catch (JAXBException | SAXException e) { e.printStackTrace(); throw new IOException("could not marshal HML", e); } } private  HmlWriter(); static void write(final Hml data, final Writer writer); static void write(final Hml data, final File file); static void write(final Hml data, final OutputStream outputStream);  }
@Test(expected=NullPointerException.class) public void testWriteNullWriter() throws Exception { write(data, (Writer) null); }
@Test(expected=NullPointerException.class) public void testWriteNullFile() throws Exception { write(data, (File) null); }
@Test(expected=NullPointerException.class) public void testWriteNullOutputStream() throws Exception { write(data, (OutputStream) null); }
@Test public void testWriteWriter() throws Exception { try (BufferedWriter writer = new BufferedWriter(new FileWriter(createFile()))) { write(data, writer); } }
@Test public void testWriteFile() throws Exception { write(data, createFile()); }
@Test public void testWriteOutputStream() throws Exception { try (OutputStream outputStream = createOutputStream()) { write(data, outputStream); } }