NodeIterator { public Element getNonXliffElement() throws ConstraintViolationException { if (next == null) { String msg = "Expected non-XLIFF element, but found no further element"; throw new ConstraintViolationException(msg); } if (!(next instanceof Element)) { String msg = MessageFormat.format( "Expected non-XLIFF element, but found a node of type ''{0}''", next.getClass().getName()); throw new ConstraintViolationException(msg); } if (Schemas.XLIFF_12_NAMESPACE.equals(next.getNamespaceURI())) { String msg = MessageFormat .format( "Expected non-XLIFF element, but found XLIFF element <{1}>", next.getLocalName()); throw new ConstraintViolationException(msg); } Element ret = (Element) next; advance(); return ret; } NodeIterator(List<? extends Node> nodes, boolean ignoreWhitespaceText); boolean hasNext(); boolean nextIsText(); boolean nextIsElement(); boolean nextIsXliffElement(); boolean nextIsXliffElement(String localName); boolean nextIsNonXliffElement(); String getText(); Element getElement(); Element getXliffElement(); Element getNonXliffElement(); Element getXliffElement(String localName); void assertNoMoreNodes(); Element getXliffElement(String... localNames);  }
@Test public void testGetNonXliffElement() { ArrayList<Node> nodes = new ArrayList<Node>(); Document doc = Utils.createDocument(); nodes.add(doc.createElementNS(XLIFF_12_NAMESPACE, "abc")); nodes.add(doc.createElementNS("ns", "abc")); nodes.add(doc.createTextNode("abc")); NodeIterator ni = new NodeIterator(nodes, false); try { ni.getNonXliffElement(); fail("Expected ConstraintViolationException"); } catch (ConstraintViolationException e) { } try { ni.getElement(); } catch (ConstraintViolationException e) { fail("Did not expect ConstraintViolationException"); } try { ni.getNonXliffElement(); } catch (ConstraintViolationException e) { fail("Did not expect ConstraintViolationException"); } try { ni.getNonXliffElement(); fail("Expected ConstraintViolationException"); } catch (ConstraintViolationException e) { } try { ni.getText(); } catch (ConstraintViolationException e) { fail("Did not expect ConstraintViolationException"); } try { ni.getNonXliffElement(); fail("Expected ConstraintViolationException"); } catch (ConstraintViolationException e) { } }