XPathParser { public XPathParser() { setNamespaceContext(new DefaultNamespaceContext()); setDefaultPrefix(ArtificerConstants.SRAMP_PREFIX); } XPathParser(); NamespaceContext getNamespaceContext(); void setNamespaceContext(NamespaceContext namespaceContext); String getDefaultPrefix(); void setDefaultPrefix(String defaultPrefix); Query parseXPath(String xpath);  }
@Test public void testXPathParser() throws Exception { Collection<Properties> testCases = getTestCases(); XPathParser parser = new XPathParser(); XPathSerializationVisitor visitor = new XPathSerializationVisitor(); for (Properties properties : testCases) { String testCaseName = properties.getProperty("testcase.name"); String xpath = properties.getProperty("xpath"); String expectedXpath = properties.getProperty("expected.xpath"); String expectedErrorMessage = properties.getProperty("expected.errorMessage"); try { Query query = parser.parseXPath(xpath); visitor.reset(); query.accept(visitor); String actualXpath = visitor.getXPath(); Assert.assertNotNull("Case [" + testCaseName + "]", query); Assert.assertEquals("Case [" + testCaseName + "]", expectedXpath, actualXpath); } catch (XPathParserException e) { Assert.assertNotNull("Case [" + testCaseName + "] Got unexpected parse error: " + e.getMessage(), expectedErrorMessage); Assert.assertEquals("Case [" + testCaseName + "]", expectedErrorMessage, e.getMessage()); } catch (AssertionError e) { throw e; } catch (Throwable t) { Assert.fail("Case [" + testCaseName + "] Got unexpected error: " + t.getMessage()); } } }