View Javadoc

1   package org.xmlhammer.gui.acceptance;
2   
3   import java.io.File;
4   
5   import javax.swing.tree.MutableTreeNode;
6   
7   import junit.framework.Test;
8   import junit.framework.TestSuite;
9   
10  import org.xmlhammer.gui.output.ResultTreeModel;
11  import org.xmlhammer.gui.output.ValueNode;
12  
13  public class XPathTest extends ProjectTestCase {
14      private XPathTest(String test) {
15          super(test);
16      }
17  
18      public void openProject() throws Exception {
19          openProject(new File("src/test/resources/projects/xpath/xpath.xhp"));
20      }
21      
22      public void openNamespacesProject() throws Exception {
23          openProject(new File("src/test/resources/projects/xpath/xpath-namespaces.xhp"));
24      }
25  
26      public void openNumberProject() throws Exception {
27          openProject(new File("src/test/resources/projects/xpath/xpath-number.xhp"));
28      }
29  
30      public void openBooleanProject() throws Exception {
31          openProject(new File("src/test/resources/projects/xpath/xpath-boolean.xhp"));
32      }
33  
34      public void execute() {
35          super.execute();
36  
37          ResultTreeModel model = getApplication().getProjectsView().getSelectedView().getResultPanel().getModel();
38          assertEquals(8, ((MutableTreeNode)model.getRoot()).getChildAt(0).getChildCount());
39      }
40  
41      public void executeNumber() {
42          super.execute();
43  
44          ResultTreeModel model = getApplication().getProjectsView().getSelectedView().getResultPanel().getModel();
45          assertTrue(((MutableTreeNode)model.getRoot()).getChildAt(0).getChildAt(0) instanceof ValueNode);
46          assertEquals("2.0", ((ValueNode)((MutableTreeNode)model.getRoot()).getChildAt(0).getChildAt(0)).getValue());
47      }
48  
49      public void executeBoolean() {
50          super.execute();
51  
52          ResultTreeModel model = getApplication().getProjectsView().getSelectedView().getResultPanel().getModel();
53          assertTrue(((MutableTreeNode)model.getRoot()).getChildAt(0).getChildAt(0) instanceof ValueNode);
54          assertEquals("true", ((ValueNode)((MutableTreeNode)model.getRoot()).getChildAt(0).getChildAt(0)).getValue());
55      }
56  
57      public static Test suite() {
58          TestSuite suite = new TestSuite("XPath Projects");
59          
60          suite.addTest(new XPathTest("openProject"));
61          suite.addTest(new XPathTest("initialPage"));
62          suite.addTest(new XPathTest("hasChanged"));
63          suite.addTest(new XPathTest("execute"));
64          suite.addTest(new XPathTest("closeProject"));
65          suite.addTest(new XPathTest("openNamespacesProject"));
66          suite.addTest(new XPathTest("initialPage"));
67          suite.addTest(new XPathTest("hasChanged"));
68          suite.addTest(new XPathTest("execute"));
69          suite.addTest(new XPathTest("closeProject"));
70          suite.addTest(new XPathTest("openNumberProject"));
71          suite.addTest(new XPathTest("initialPage"));
72          suite.addTest(new XPathTest("hasChanged"));
73          suite.addTest(new XPathTest("executeNumber"));
74          suite.addTest(new XPathTest("closeProject"));
75          suite.addTest(new XPathTest("openBooleanProject"));
76          suite.addTest(new XPathTest("initialPage"));
77          suite.addTest(new XPathTest("hasChanged"));
78          suite.addTest(new XPathTest("executeBoolean"));
79          suite.addTest(new XPathTest("closeProject"));
80          suite.addTest(new XPathTest("closeApplication"));
81  
82          return suite;
83      }
84  }