- Element services = (Element) servicesList.item(0);
- String trimmedServices = XmlUtil.toString(services).replaceAll("\\s", "");
+ @Override
+ public void noMoreNodes(NodeTest forTest) throws NodeTestException {
+ assertEquals(0, defaultRefNameCount);
+ assertEquals(2, userRefNameCount);
+ }
+ };
+ nt.performTest(tester, Node.TEXT_NODE);
+ }
+
+ private void assertCorrectServiceNames(Document configCandidate, Set<String> refNames) throws NodeTestException {
+ final Set<String> refNames2 = new HashSet<>(refNames);
+ NodeList servicesNodes = configCandidate.getElementsByTagName("services");
+ assertEquals(1, servicesNodes.getLength());
+
+ NodeTest nt = new NodeTest((DocumentTraversal) configCandidate, servicesNodes.item(0));
+ NodeTester tester = new AbstractNodeTester() {
+
+ @Override
+ public void testElement(Element element) throws NodeTestException {
+ if(element.getNodeName() != null) {
+ if(element.getNodeName().equals("name")) {
+ String elmText = element.getTextContent();
+ if(refNames2.contains(elmText)) {
+ refNames2.remove(elmText);
+ } else {
+ throw new NodeTestException("Unexpected services defined: " + elmText);
+ }
+ }
+ }
+ }