### Question:
CleanXMLStreamWriter implements XMLStreamWriter { public void close() throws XMLStreamException { writer.close(); } CleanXMLStreamWriter(XMLStreamWriter writer); void writeStartElement(String s); void writeStartElement(String s, String s1); void writeStartElement(String s, String s1, String s2); void writeEmptyElement(String s, String s1); void writeEmptyElement(String s, String s1, String s2); void writeEmptyElement(String s); void writeEndElement(); void writeEndDocument(); void close(); void flush(); void writeAttribute(String localName, String value); void writeAttribute(String prefix, String namespaceUri, String localName, String value); void writeAttribute(String namespaceUri, String localName, String value); void writeNamespace(String s, String s1); void writeDefaultNamespace(String s); void writeComment(String s); void writeProcessingInstruction(String s); void writeProcessingInstruction(String s, String s1); void writeCData(String s); void writeDTD(String s); void writeEntityRef(String s); void writeStartDocument(); void writeStartDocument(String s); void writeStartDocument(String s, String s1); void writeCharacters(String s); void writeCharacters(char[] chars, int start, int len); String getPrefix(String s); void setPrefix(String s, String s1); void setDefaultNamespace(String s); void setNamespaceContext(NamespaceContext namespaceContext); NamespaceContext getNamespaceContext(); Object getProperty(String s); static final char REPLACEMENT_CHARACTER; }### Answer:
@Test public void testSurrogateAttributes() throws Exception { String surname = "\uD850\uDDAC"; String given = "\uD842\uDFB7"; String full = surname + given; Gedcomx doc = new Gedcomx(); Name name = new Name(full, new NamePart(NamePartType.Surname, surname), new NamePart(NamePartType.Given, given)); doc.addPerson(new Person().id("p." + full).name(name)); ByteArrayOutputStream bos = new ByteArrayOutputStream(); RecordSetWriter cleanWriter = new RecordSetWriter(bos, false, Gedcomx.class, RecordSet.class); cleanWriter.writeRecord(doc); cleanWriter.close(); RecordSetIterator recordSetIterator = new XmlRecordSetIterator(new ByteArrayInputStream(bos.toByteArray()), false); Gedcomx doc1 = recordSetIterator.next(); NameForm nameForm = doc1.getPerson().getName().getNameForm(); assertEquals(full, nameForm.getFullText()); assertEquals(surname, nameForm.getParts().get(0).getValue()); assertEquals(given, nameForm.getParts().get(1).getValue()); }