mappings.put("test2","http://www.example.org/test#");
//add some invalid mappings
mappings.put("test:3","http://www.example.org/test#");
mappings.put("test3","http://www.example.org/test");
NamespacePrefixProvider provider = new NamespacePrefixProviderImpl(mappings);
//this tests the namespaces defined in namespaceprefix.mappings file
Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test"));
Assert.assertEquals("http://www.example.org/test-1/",provider.getNamespace("test-1"));
Assert.assertEquals("urn:example.text:",provider.getNamespace("urn_test"));
List<String> prefixes = provider.getPrefixes("http://www.example.org/test#");
Assert.assertEquals(2, prefixes.size());
Assert.assertEquals("test",prefixes.get(0));
Assert.assertEquals("test2",prefixes.get(1));
Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test"));
Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test2"));
//test that illegal mappings are not imported
Assert.assertNull(provider.getNamespace("test:3"));
Assert.assertNull(provider.getNamespace("test3"));
}