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 FollowingSiblingAxisIteratorTest extends TestCase { 74 75 private Iterator iterator; 76 77 public FollowingSiblingAxisIteratorTest(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 FollowingSiblingAxisIterator(doc, new org.jaxen.dom.DocumentNavigator()); 89 90 } 91 92 93 public void testNoInfiniteLoops() { 94 95 try { 96 iterator.next(); 97 fail("Iterated too far"); 98 } 99 catch (NoSuchElementException ex) { 100 pass(); 101 } 102 103 } 104 105 106 private void pass() { 107 } 109 110 public void testRemove() { 111 112 try { 113 iterator.remove(); 114 fail("Removed from descendant axis iterator"); 115 } 116 catch (UnsupportedOperationException ex) { 117 pass(); 118 } 119 120 } 121 122 } 123 | Popular Tags |