1 60 package org.jaxen.util; 61 62 import java.util.Iterator ; 63 import java.util.NoSuchElementException ; 64 65 import javax.xml.parsers.DocumentBuilderFactory ; 66 import javax.xml.parsers.ParserConfigurationException ; 67 68 import org.jaxen.UnsupportedAxisException; 69 import org.w3c.dom.Document ; 70 71 import junit.framework.TestCase; 72 73 public class DescendantAxisIteratorTest extends TestCase { 74 75 private Iterator iterator; 76 77 public DescendantAxisIteratorTest(String name) { 78 super(name); 79 } 80 81 protected void setUp() throws ParserConfigurationException , UnsupportedAxisException { 82 83 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 84 factory.setNamespaceAware(true); 85 Document doc = factory.newDocumentBuilder().newDocument(); 86 doc.appendChild(doc.createElement("root")); 87 88 iterator = new DescendantAxisIterator(doc, new org.jaxen.dom.DocumentNavigator()); 89 90 } 91 92 93 public void testNoInfiniteLoops() { 94 95 iterator.next(); 96 try { 97 iterator.next(); 98 fail("Iterated too far"); 99 } 100 catch (NoSuchElementException ex) { 101 } 102 103 } 104 105 106 public void testRemove() { 107 108 try { 109 iterator.remove(); 110 fail("Removed from descendant axis iterator"); 111 } 112 catch (UnsupportedOperationException ex) { 113 } 114 115 } 116 117 } 118 | Popular Tags |