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.w3c.dom.Document ; 69 70 import junit.framework.TestCase; 71 72 public class AncestorOrSelfAxisIteratorTest extends TestCase { 73 74 private Iterator iterator; 75 76 public AncestorOrSelfAxisIteratorTest(String name) { 77 super(name); 78 } 79 80 protected void setUp() throws ParserConfigurationException { 81 82 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 83 factory.setNamespaceAware(true); 84 Document doc = factory.newDocumentBuilder().newDocument(); 85 doc.appendChild(doc.createElement("root")); 86 87 iterator = new AncestorOrSelfAxisIterator(doc, new org.jaxen.dom.DocumentNavigator()); 88 89 } 90 91 92 public void testNoInfiniteLoops() { 93 94 iterator.next(); 95 try { 96 iterator.next(); 97 fail("Iterated twice"); 98 } 99 catch (NoSuchElementException ex) { 100 } 101 102 } 103 104 105 public void testRemove() { 106 107 try { 108 iterator.remove(); 109 fail("Removed from iterator"); 110 } 111 catch (UnsupportedOperationException ex) { 112 } 113 114 } 115 116 } 117 | Popular Tags |