FilteringXMLStreamWriter implements XMLStreamWriter { @Override public void close() throws XMLStreamException { writer.close(); } FilteringXMLStreamWriter( XMLStreamWriter writer, List<XPath> xpaths ); @Override void writeStartElement( String localName ); @Override void writeStartElement( String namespaceURI, String localName ); @Override void writeStartElement( String prefix, String localName, String namespaceURI ); @Override void writeEmptyElement( String namespaceURI, String localName ); @Override void writeEmptyElement( String prefix, String localName, String namespaceURI ); @Override void writeEmptyElement( String localName ); @Override void writeEndElement(); @Override void writeEndDocument(); @Override void close(); @Override void flush(); @Override void writeAttribute( String localName, String value ); @Override void writeAttribute( String prefix, String namespaceURI, String localName, String value ); @Override void writeAttribute( String namespaceURI, String localName, String value ); @Override void writeNamespace( String prefix, String namespaceURI ); @Override void writeDefaultNamespace( String namespaceURI ); @Override void writeComment( String data ); @Override void writeProcessingInstruction( String target ); @Override void writeProcessingInstruction( String target, String data ); @Override void writeCData( String data ); @Override void writeDTD( String dtd ); @Override void writeEntityRef( String name ); @Override void writeStartDocument(); @Override void writeStartDocument( String version ); @Override void writeStartDocument( String encoding, String version ); @Override void writeCharacters( String text ); @Override void writeCharacters( char[] text, int start, int len ); @Override String getPrefix( String uri ); @Override void setPrefix( String prefix, String uri ); @Override void setDefaultNamespace( String uri ); @Override void setNamespaceContext( NamespaceContext context ); @Override NamespaceContext getNamespaceContext(); @Override Object getProperty( String name );  }
@Test public void testFilteringXPathSetPrefixBug() throws Exception { final XMLAdapter input = new XMLAdapter( FilteringXMLStreamWriterTest.class.getResourceAsStream( "filtering_xpath_set_prefix.xml" ) ); final List<String> list = new ArrayList<String>(); list.add( "/app:a/nix:d" ); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final XMLStreamWriter writer = getWriter( list, bos ); input.getRootElement().serialize( writer ); writer.close(); byte[] actual = bos.toByteArray(); byte[] expected = IOUtils.toByteArray( FilteringXMLStreamWriterTest.class.getResourceAsStream( "filtering_xpath_set_prefix_expected.xml" ) ); Assert.assertArrayEquals( expected, actual ); }