1 37 package net.sourceforge.cruisecontrol; 38 39 import java.io.IOException ; 40 41 import javax.management.AttributeNotFoundException ; 42 import javax.management.InstanceNotFoundException ; 43 import javax.management.MBeanException ; 44 import javax.management.ReflectionException ; 45 46 import org.jdom.Document; 47 import org.jdom.Element; 48 import org.jdom.JDOMException; 49 50 import junit.framework.TestCase; 51 52 public class JDOMSearcherTest extends TestCase { 53 private Document doc; 54 private Element root = new Element("root"); 55 private Element firstChild = new Element("first-child"); 56 private Element subChild = new Element("sub-child"); 57 58 protected void setUp() throws Exception { 59 super.setUp(); 60 61 root.addContent(firstChild); 62 firstChild.addContent(subChild); 63 doc = new Document(root); 64 } 65 66 public void testFindElement() throws Exception { 67 assertEquals(firstChild, JDOMSearcher.findElement(root, "first-child")); 68 assertEquals(subChild, JDOMSearcher.findElement(firstChild, "sub-child")); 69 assertEquals(subChild, JDOMSearcher.findElement(root, "sub-child")); 70 } 71 72 public void testGetElement() throws AttributeNotFoundException , 73 InstanceNotFoundException , MBeanException , ReflectionException , 74 IOException , JDOMException { 75 assertEquals(root, JDOMSearcher.getElement(doc, "root")); 76 assertEquals(firstChild, JDOMSearcher.getElement(doc, "first-child")); 77 assertEquals(subChild, JDOMSearcher.getElement(doc, "sub-child")); 78 } 79 } 80 | Popular Tags |