@Test
public void testExport()
                        throws Exception {

    String storedQueryResource = "storedQuery.xml";
    StoredQueryDefinition queryDefinition = parseStoredQueryDefinition( storedQueryResource );
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter( stream );
    StoredQueryDefinition200Encoder.export( queryDefinition, writer );
    writer.close();
    assertThat( xml( stream.toString() ),
                hasXPath( "/wfs:StoredQueryDefinition/wfs:QueryExpressionText/wfs:Query/@typeNames",
                          is( "cp:CadastralParcel" ), NS_CONTEXT ) );
    assertThat( xml( stream.toString() ),
                hasXPath( "/wfs:StoredQueryDefinition/wfs:Parameter/@name", is( "label" ), NS_CONTEXT ) );
    assertThat( xml( stream.toString() ), isSimilarTo( the( storedQueryResource ) ) );
}