### Question:
XMLWriter extends org.dom4j.io.XMLWriter { @Override public void writeClose(final Element element) throws IOException { while (!this.parent.peek().getQualifiedName().equals(element.getQualifiedName())) { this.writeClose(this.parent.peek()); } super.setIndentLevel(this.parent.size() - 1); if (this.lcWriter.getLastChar() == CLOSE_ANGLE_BRACKET) { super.writePrintln(); super.indent(); } super.writeClose(this.parent.pop()); } protected  XMLWriter();  XMLWriter(final OutputStream out, final OutputFormat format); void writeDocumentStart(final Document doc); void writeDocumentEnd(final Document doc); void write(final Element element, final Reader rd); void write(final Element element, final InputStream is); void writeBase64(final Element element, final InputStream is); @Override void writeOpen(final Element element); @Override void writeClose(final Element element);  }### Answer:
@Test public void testWriteClose() throws Exception { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final OutputFormat of = new OutputFormat(" ", true, "UTF-8"); this.writer = new XMLWriter(baos, of); this.writer.startDocument(); this.writer.writeOpen(new DOMElement("root")); this.writer.writeOpen(new DOMElement("doc")); this.writer.writeOpen(new DOMElement("obj")); this.writer.writeOpen(new DOMElement("prop")); this.writer.writeClose(new DOMElement("root")); this.writer.endDocument(); Assert.assertEquals("WriteClose didn't write the correct response.", TEST_CONTENT, new String(baos.toByteArray(), "UTF-8")); }