KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xdm > visitor > FindNamespaceVisitorTest


1 /*
2  * FindNamespaceVisitorTest.java
3  * JUnit based test
4  *
5  * Created on November 18, 2005, 10:34 AM
6  */

7
8 package org.netbeans.modules.xml.xdm.visitor;
9
10 import junit.framework.*;
11 import java.util.ArrayList JavaDoc;
12 import java.util.HashMap JavaDoc;
13 import java.util.List JavaDoc;
14 import java.util.Map JavaDoc;
15 import org.netbeans.modules.xml.xdm.nodes.Attribute;
16 import org.netbeans.modules.xml.xdm.nodes.Node;
17 import org.netbeans.modules.xml.xdm.nodes.Document;
18 import org.w3c.dom.NamedNodeMap JavaDoc;
19 import org.netbeans.modules.xml.xdm.XDMModel;
20 import org.netbeans.modules.xml.xdm.Util;
21
22 /**
23  *
24  * @author ajit
25  */

26 public class FindNamespaceVisitorTest extends TestCase {
27     
28     public FindNamespaceVisitorTest(String JavaDoc testName) {
29         super(testName);
30     }
31
32     protected void setUp() throws Exception JavaDoc {
33     }
34
35     public static Test suite() {
36         TestSuite suite = new TestSuite(FindNamespaceVisitorTest.class);
37         
38         return suite;
39     }
40
41     /**
42      * Test of findNamespace method, of class org.netbeans.modules.xml.xdm.visitor.FindNamespaceVisitor.
43      */

44     public void testFindNamespace() throws Exception JavaDoc {
45         
46         XDMModel xdmModel = Util.loadXDMModel("diff/TravelItinerary1.xsd");
47         Document root = xdmModel.getDocument();
48         FindNamespaceVisitor instance = new FindNamespaceVisitor(root);
49         
50         Node target = (Node)root.getDocumentElement().getChildNodes().item(19).
51                 getChildNodes().item(3).getChildNodes().item(3);
52         String JavaDoc expResult = "http://www.w3.org/2001/XMLSchema";
53         String JavaDoc result = instance.findNamespace(target);
54         assertEquals(expResult, result);
55
56         target = (Node)root.getDocumentElement().getChildNodes().item(19).
57                 getChildNodes().item(3).getChildNodes().item(3).getAttributes().item(0);
58         expResult = null;
59         result = instance.findNamespace(target);
60         assertEquals(expResult, result);
61     }
62     
63 }
64
Popular Tags