@Test public void testSingle() throws Exception { NamespaceSupport ctx = parser.parse("xmlns(foo=http://bar)"); assertEquals("http://bar", ctx.getURI("foo")); }
@Test public void testEmpty() throws Exception { NamespaceSupport ctx = parser.parse(""); assertNotNull(ctx); List<String> prefixes = getPrefixes(ctx); assertTrue(prefixes.contains("xml")); // this one is always present assertEquals(1, prefixes.size()); }
@Test public void testDefaultNamespace() throws Exception { NamespaceSupport ctx = parser.parse("xmlns(http://default.namespace.com)"); assertEquals("http://default.namespace.com", ctx.getURI(XMLConstants.DEFAULT_NS_PREFIX)); }
@Test public void testFormatError() throws Exception { try { parser.parse("xmlns[bad=format]"); fail("Expected IAE"); } catch (ServiceException e) { assertProperServiceException(e); } try { parser.parse("xmlns(bad=http://format]"); fail("Expected IAE"); } catch (ServiceException e) { assertProperServiceException(e); } try { parser.parse("bad=http://format"); fail("Expected IAE"); } catch (ServiceException e) { assertProperServiceException(e); } }
@Test public void testMultiple() throws Exception { NamespaceSupport ctx = parser.parse( "xmlns(foo=http://bar), xmlns(ex=http://example.com),xmlns(gs=http://geoserver.org)"); assertEquals("http://bar", ctx.getURI("foo")); assertEquals("http://example.com", ctx.getURI("ex")); assertEquals("http://geoserver.org", ctx.getURI("gs")); }
@Test public void testWfs20Syntax() throws Exception { NamespaceKvpParser parser = new NamespaceKvpParser("namespaces", true); NamespaceSupport ctx = parser.parse( "xmlns(http://bar), xmlns(ex,http://example.com),xmlns(gs,http://geoserver.org)"); assertEquals("http://bar", ctx.getURI("")); assertEquals("http://example.com", ctx.getURI("ex")); assertEquals("http://geoserver.org", ctx.getURI("gs")); } }