rdfFragment.append(" </rdf:Description>\n");
rdfFragment.append("</rdf:RDF>");
testCon.add(new StringReader(rdfFragment.toString()), "", RDFFormat.RDFXML);
NamespaceResult nsIter = testCon.getNamespaces();
try {
Map<String, String> map = new HashMap<String, String>();
int nsCount = 0;
while (nsIter.hasNext()) {
nsCount++;
Namespace ns = nsIter.next();
map.put(ns.getPrefix(), ns.getName());
}
assertEquals("There should be exactly three namespaces", 3, nsCount);
assertTrue("namespace for prefix 'example' should exist", map.containsKey("example"));
assertTrue("namespace for prefix 'rdfs' should exist", map.containsKey("rdfs"));
assertTrue("namespace for prefix 'rdf' should exist", map.containsKey("rdf"));
assertEquals("namespace name for 'example' not well-defined", "http://example.org/",
map.get("example"));
assertEquals("namespace name for 'rdfs' not well-defined", "http://www.w3.org/2000/01/rdf-schema#",
map.get("rdfs"));
assertEquals("namespace name for 'rdf' not well-defined",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#", map.get("rdf"));
}
finally {
nsIter.close();
}
}