### Question:
Xml extends XmlReader { public void save(Media media) { Check.notNull(media); try (OutputStream output = media.getOutputStream()) { final Transformer transformer = DocumentFactory.createTransformer(); normalize(NORMALIZE); writeString(Constant.XML_HEADER, Constant.ENGINE_WEBSITE); final DOMSource source = new DOMSource(root); final StreamResult result = new StreamResult(output); final String yes = "yes"; transformer.setOutputProperty(OutputKeys.INDENT, yes); transformer.setOutputProperty(OutputKeys.STANDALONE, yes); transformer.setOutputProperty(PROPERTY_INDENT, "4"); transformer.transform(source, result); } catch (final TransformerException | IOException exception) { throw new LionEngineException(exception, media, ERROR_WRITING); } } Xml(Media media);  Xml(String name);   Xml(Document document, Element root); void save(Media media); Xml createChild(String child); void add(XmlReader node); void setText(String text); void writeBoolean(String attribute, boolean content); void writeByte(String attribute, byte content); void writeShort(String attribute, short content); void writeInteger(String attribute, int content); void writeLong(String attribute, long content); void writeFloat(String attribute, float content); void writeDouble(String attribute, double content); void writeString(String attribute, String content); void removeAttribute(String attribute); void removeChild(String child); void removeChild(Xml child); void removeChildren(String children); Xml getChild(String name); Collection<Xml> getChildren(String name); Collection<Xml> getChildren();  }### Answer:
@Test void testSaveNormalized() throws IOException { final Media output = Medias.create("out.xml"); new Xml(Medias.create("normalize.xml")).save(output); assertTrue(output.getFile().delete()); }
@Test void testTransformerError() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException { final Field field = DocumentFactory.class.getDeclaredField("transformerFactory"); UtilReflection.setAccessible(field, true); final javax.xml.transform.TransformerFactory old = (TransformerFactory) field.get(DocumentFactory.class); try { field.set(DocumentFactory.class, new javax.xml.transform.TransformerFactory() { @Override public Transformer newTransformer() throws TransformerConfigurationException { throw new TransformerConfigurationException(); } @Override public Transformer newTransformer(Source source) throws TransformerConfigurationException { return null; } @Override public Templates newTemplates(Source source) throws TransformerConfigurationException { return null; } @Override public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { return null; } @Override public void setURIResolver(URIResolver resolver) { } @Override public URIResolver getURIResolver() { return null; } @Override public void setFeature(String name, boolean value) throws TransformerConfigurationException { } @Override public boolean getFeature(String name) { return false; } @Override public void setAttribute(String name, Object value) { } @Override public Object getAttribute(String name) { return null; } @Override public void setErrorListener(ErrorListener listener) { } @Override public ErrorListener getErrorListener() { return null; } }); final Media output = Medias.create("out.xml"); assertThrows(() -> new Xml(Medias.create("normalize.xml")).save(output), "[out.xml] " + Xml.ERROR_WRITING); } finally { field.set(DocumentFactory.class, old); } }