XsdNamespaceContext implements NamespaceContext { @Override public String getNamespaceURI(String prefix) { if (NS_PREFIX_XSD.equals(prefix)) { return NS_URI_XSD; } throw new UnsupportedOperationException("Unknown prefix \"" + prefix + "\""); }  @Override String getNamespaceURI(String prefix); @Override String getPrefix(String namespaceURI); @Override Iterator<?> getPrefixes(String namespaceURI); static final String NS_PREFIX_XSD; static final String NS_URI_XSD; }
@Test public void test_1() { XsdNamespaceContext xsdNamespaceContext = new XsdNamespaceContext(); String namespaceURI = xsdNamespaceContext.getNamespaceURI("xs"); assertEquals(XsdNamespaceContext.NS_URI_XSD, namespaceURI); }
@Test public void test_2() { XsdNamespaceContext xsdNamespaceContext = new XsdNamespaceContext(); try { xsdNamespaceContext.getNamespaceURI("foo"); fail(); } catch (Exception e) { assertEquals(UnsupportedOperationException.class, e.getClass()); assertEquals("Unknown prefix \"foo\"", e.getMessage()); } }