@Test
public void testWriteThemeMultipleMetadataUrls()
                        throws Exception {

    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    final XMLStreamWriter writer = newInstance().createXMLStreamWriter( bos );
    writer.writeStartElement( "Layer" );
    XMLAdapter.writeElement( writer, "Title", "Container" );
    final LayerMetadata layerMetadata = createLayerMetadata();
    String mdurlTemplate = "http://md.url.org/template";
    OWSMetadataProvider provider = Mockito.mock( OWSMetadataProvider.class );
    List<DatasetMetadata> mds = new ArrayList<DatasetMetadata>();
    mds.add( createDatasetMetadata( "http://url1", "http://url2" ) );
    mds.add( createDatasetMetadata( "http://url3" ) );
    when( provider.getAllDatasetMetadata( Mockito.any( QName.class ) ) ).thenReturn( mds );
    WmsCapabilities111ThemeWriter themeWriter = new WmsCapabilities111ThemeWriter( provider, null, mdurlTemplate );
    Theme theme = new StandardTheme( layerMetadata, Collections.<Theme> emptyList(),
                                     Collections.<Layer> emptyList(), null );
    themeWriter.writeTheme( writer, theme );
    writer.writeEndElement();
    writer.flush();
    bos.close();
    final InputStream is = WmsCapabilities130ThemeWriterTest.class.getResourceAsStream( "wms111_layer_multipleMetadataUrls.xml" );
    final byte[] expected = IOUtils.readBytesAndClose( is, -1 );
    assertArrayEquals( expected, bos.toByteArray() );
}