### Question:
JsonXMLStreamWriter extends AbstractXMLStreamWriter<JsonXMLStreamWriter.ScopeInfo> { @Override public void writeStartDocument(String encoding, String version) throws XMLStreamException { super.writeStartDocument(encoding, version); try { target.startObject(); } catch (IOException e) { throw new XMLStreamException("Cannot start document", e); } getScope().getInfo().startObjectWritten = true; } JsonXMLStreamWriter(JsonStreamTarget target, boolean repairNamespaces, boolean multiplePI, char namespaceSeparator, boolean namespaceDeclarations);  JsonXMLStreamWriter(JsonStreamTarget target, boolean repairNamespaces, boolean multiplePI, char namespaceSeparator, boolean namespaceDeclarations,
                               boolean xmlNilReadWriteEnabled, boolean xmlWriteNullForEmptyElement); void writeAttribute(String prefix, String namespaceURI, String localName, String value); void writeNamespace(String prefix, String namespaceURI); @Override void writeStartDocument(String encoding, String version); @Override void writeEndDocument(); void writeStartArray(String fieldName); void writeEndArray(); @Override void close(); @Override void flush(); void writeNumber(Number value); void writeBoolean(Boolean value);  }### Answer:
@Test(expected = XMLStreamException.class) public void testElementMultipleRoots() throws XMLStreamException { XMLStreamWriter writer = new JsonXMLOutputFactory().createXMLStreamWriter(new StringWriter()); writer.writeStartDocument(); writer.writeStartElement("foo"); writer.writeEndElement(); writer.writeStartElement("bar"); }