schema.setNamespace("http://namespace.com");
schemas.add(schema);
DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
OutputStreamWriter writer = null;
CircleStreamBuffer csb = new CircleStreamBuffer();
writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
Map<String, String> prefixMap = new HashMap<String, String>();
prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
prefixMap.put("b", "namespace1");
prefixMap.put("prefix", "namespace2");
prefixMap.put("pre", "namespaceForAnno");
NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
XMLUnit.setXpathNamespaceContext(ctx);
String metadata = StringHelper.inputStreamToString(csb.getInputStream());
assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:test", metadata);
assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1", metadata);
assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/b:schemaElementTest2", metadata);
assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/prefix:schemaElementTest3", metadata);
assertXpathExists(