1 package org.xmlhammer.gui.wizard;
2
3 import junit.framework.Test;
4 import junit.framework.TestCase;
5 import junit.framework.TestSuite;
6
7 import org.xmlhammer.PreferencesHandler;
8
9 public class NewXPathWizardTest extends TestCase {
10 private static NewXPathWizard wizard = null;
11
12 protected NewXPathWizardTest(String test) {
13 super(test);
14 }
15
16 protected void setUp() throws Exception {
17 PreferencesHandler.getInstance().useDefaultPreferences();
18 }
19
20 public void openWizard() throws Exception {
21 wizard = new NewXPathWizard(null);
22
23 wizard.setModal(false);
24
25
26 assertTrue(wizard.getPage() instanceof InputTypeSelectionPage);
27 }
28
29 public void nextFilterPage() throws Exception {
30 wizard.nextPage();
31
32 assertTrue(wizard.getPage() instanceof InputFilterPage);
33 }
34
35 public void backFilterPage() throws Exception {
36 wizard.backPage();
37
38 assertTrue(wizard.getPage() instanceof InputFilterPage);
39 }
40
41 public void backInputTypePage() throws Exception {
42 wizard.backPage();
43
44 assertTrue(wizard.getPage() instanceof InputTypeSelectionPage);
45 }
46
47 public void nextURIsPage() throws Exception {
48 ((InputTypeSelectionPage)wizard.getPage()).selectInputURIs();
49
50 wizard.nextPage();
51
52 assertTrue(wizard.getPage() instanceof InputURIsPage);
53 }
54
55 public void nextParserPropertiesPage() throws Exception {
56 wizard.nextPage();
57
58 assertTrue(wizard.getPage() instanceof ParserPropertiesPage);
59 }
60
61 public void nextValidationSelectionPage() throws Exception {
62 wizard.nextPage();
63
64 assertTrue(wizard.getPage() instanceof ValidationSelectionPage);
65 }
66
67 public void testValidationSelectionPage() throws Exception {
68 ValidationSelectionPage page = (ValidationSelectionPage)wizard.getPage();
69
70 page.selectExternalSchema();
71 assertFalse(page.isValidating());
72
73
74 assertTrue(page.getNext() instanceof SchemaURIsPage);
75
76 page.selectWellformedness();
77 assertFalse(page.isValidating());
78 assertNull(page.getSchemaLanguage());
79 assertTrue(page.getURIs().size() == 0);
80 assertTrue(page.getNext() instanceof XPathPage);
81
82 page.selectInternalDTD();
83 assertTrue(page.isValidating());
84 assertNull(page.getSchemaLanguage());
85 assertTrue(page.getURIs().size() == 0);
86 assertTrue(page.getNext() instanceof XPathPage);
87
88 page.selectInternalXSD();
89 assertTrue(page.isValidating());
90 assertEquals("http://www.w3.org/2001/XMLSchema", page.getSchemaLanguage());
91 assertTrue(page.getURIs().size() == 0);
92 assertTrue(page.getNext() instanceof XPathPage);
93
94 page.selectInternalDTDExternalSchema();
95 assertTrue(page.isValidating());
96
97
98 assertTrue(page.getNext() instanceof SchemaURIsPage);
99 }
100
101 public void backValidationSelectionPage() throws Exception {
102 wizard.backPage();
103
104 assertTrue(wizard.getPage() instanceof ValidationSelectionPage);
105 }
106
107 public void nextSchemaURIsPage() throws Exception {
108 ((ValidationSelectionPage)wizard.getPage()).selectExternalSchema();
109 wizard.nextPage();
110
111 assertTrue(wizard.getPage() instanceof SchemaURIsPage);
112 }
113
114 public void backParserPropertiesPage() throws Exception {
115 wizard.backPage();
116
117 assertTrue(wizard.getPage() instanceof ParserPropertiesPage);
118 }
119
120 public void nextXPathPage() throws Exception {
121 wizard.nextPage();
122
123 assertTrue(wizard.getPage() instanceof XPathPage);
124 }
125
126 public void backSchemaURIsPage() throws Exception {
127 wizard.backPage();
128
129 assertTrue(wizard.getPage() instanceof SchemaURIsPage);
130 }
131
132 public void cancelWizard() throws Exception {
133 wizard.cancel();
134
135 assertFalse(wizard.isVisible());
136 assertTrue(wizard.isCancelled());
137 }
138
139 public static Test suite() {
140 TestSuite suite = new TestSuite("New XPath Wizard Test");
141
142 suite.addTest(new NewXPathWizardTest("openWizard"));
143 suite.addTest(new NewXPathWizardTest("nextFilterPage"));
144 suite.addTest(new NewXPathWizardTest("backInputTypePage"));
145 suite.addTest(new NewXPathWizardTest("nextURIsPage"));
146 suite.addTest(new NewXPathWizardTest("nextParserPropertiesPage"));
147 suite.addTest(new NewXPathWizardTest("nextValidationSelectionPage"));
148 suite.addTest(new NewXPathWizardTest("testValidationSelectionPage"));
149 suite.addTest(new NewXPathWizardTest("nextSchemaURIsPage"));
150 suite.addTest(new NewXPathWizardTest("nextXPathPage"));
151 suite.addTest(new NewXPathWizardTest("backSchemaURIsPage"));
152 suite.addTest(new NewXPathWizardTest("backValidationSelectionPage"));
153 suite.addTest(new NewXPathWizardTest("backParserPropertiesPage"));
154 suite.addTest(new NewXPathWizardTest("cancelWizard"));
155
156 return suite;
157 }
158 }