View Javadoc

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 NewXSLTransformationWizardTest extends TestCase {
10      private static NewXSLTransformationWizard wizard = null;
11      
12      protected NewXSLTransformationWizardTest(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 NewXSLTransformationWizard(null);
22  
23          wizard.setModal(false);
24  //        wizard.setVisible(true);
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 nextParserSelectionPage() throws Exception {
36          wizard.nextPage();
37          
38          assertTrue(wizard.getPage() instanceof ParserSelectionPage);
39      }
40  
41      public void backFilterPage() throws Exception {
42          wizard.backPage();
43          
44          assertTrue(wizard.getPage() instanceof InputFilterPage);
45      }
46  
47      public void backInputTypePage() throws Exception {
48          wizard.backPage();
49          
50          assertTrue(wizard.getPage() instanceof InputTypeSelectionPage);
51      }
52  
53      public void nextURIsPage() throws Exception {
54          ((InputTypeSelectionPage)wizard.getPage()).selectInputURIs();
55          
56          wizard.nextPage();
57          
58          assertTrue(wizard.getPage() instanceof InputURIsPage);
59      }
60  
61      public void nextSAXParserPage() throws Exception {
62          ((ParserSelectionPage)wizard.getPage()).selectSAX();
63          wizard.nextPage();
64          
65          assertTrue(wizard.getPage() instanceof ParserPropertiesPage);
66      }
67  
68      public void nextValidationSelectionPage() throws Exception {
69          wizard.nextPage();
70          
71          assertTrue(wizard.getPage() instanceof ValidationSelectionPage);
72      }
73  
74      public void testValidationSelectionPage() throws Exception {
75          ValidationSelectionPage page = (ValidationSelectionPage)wizard.getPage();
76          
77          page.selectExternalSchema();
78          assertFalse(page.isValidating());
79  //        assertNotNull(page.getSchemaLanguage());
80  //        assertTrue(page.getURIs().size() > 0);
81          assertTrue(page.getNext() instanceof SchemaURIsPage);
82          
83          page.selectWellformedness();
84          assertFalse(page.isValidating());
85          assertNull(page.getSchemaLanguage());
86          assertTrue(page.getURIs().size() == 0);
87          assertTrue(page.getNext() instanceof StylesheetSelectionPage);
88  
89          page.selectInternalDTD();
90          assertTrue(page.isValidating());
91          assertNull(page.getSchemaLanguage());
92          assertTrue(page.getURIs().size() == 0);
93          assertTrue(page.getNext() instanceof StylesheetSelectionPage);
94  
95          page.selectInternalXSD();
96          assertTrue(page.isValidating());
97          assertEquals("http://www.w3.org/2001/XMLSchema", page.getSchemaLanguage());
98          assertTrue(page.getURIs().size() == 0);
99          assertTrue(page.getNext() instanceof StylesheetSelectionPage);
100 
101         page.selectInternalDTDExternalSchema();
102         assertTrue(page.isValidating());
103 //        assertNotNull(page.getSchemaLanguage());
104 //        assertTrue(page.getURIs().size() > 0);
105         assertTrue(page.getNext() instanceof SchemaURIsPage);
106     }
107 
108     public void backValidationSelectionPage() throws Exception {
109         wizard.backPage();
110         
111         assertTrue(wizard.getPage() instanceof ValidationSelectionPage);
112     }
113 
114     public void nextSchemaURIsPage() throws Exception {
115         ((ValidationSelectionPage)wizard.getPage()).selectExternalSchema();
116         wizard.nextPage();
117         
118         assertTrue(wizard.getPage() instanceof SchemaURIsPage);
119     }
120 
121     public void backParserPropertiesPage() throws Exception {
122         wizard.backPage();
123         
124         assertTrue(wizard.getPage() instanceof ParserPropertiesPage);
125     }
126 
127     public void backParserSelectionPage() throws Exception {
128         wizard.backPage();
129         
130         assertTrue(wizard.getPage() instanceof ParserSelectionPage);
131     }
132 
133     public void nextDOMParserPage() throws Exception {
134         ((ParserSelectionPage)wizard.getPage()).selectDOM();
135         wizard.nextPage();
136         
137         assertTrue(wizard.getPage() instanceof ParserPropertiesPage);
138     }
139 
140     public void nextStylesheetSelectionPage() throws Exception {
141         wizard.nextPage();
142         
143         assertTrue(wizard.getPage() instanceof StylesheetSelectionPage);
144     }
145 
146     public void nextStylesheetURIsPage() throws Exception {
147         ((StylesheetSelectionPage)wizard.getPage()).selectStylesheetURIs();
148         wizard.nextPage();
149         
150         assertTrue(wizard.getPage() instanceof StylesheetURIsPage);
151     }
152 
153     public void nextAssociatedStylesheetPage() throws Exception {
154         ((StylesheetSelectionPage)wizard.getPage()).selectAssociatedStylesheet();
155         wizard.nextPage();
156         
157         assertTrue(wizard.getPage() instanceof AssociatedStylesheetPage);
158     }
159 
160     public void backStylesheetSelectionPage() throws Exception {
161         wizard.backPage();
162         
163         assertTrue(wizard.getPage() instanceof StylesheetSelectionPage);
164     }
165 
166     public void nextOutputPropertiesSelectionPage() throws Exception {
167         ((StylesheetSelectionPage)wizard.getPage()).selectDefaultStylesheet();
168         wizard.nextPage();
169         
170         assertTrue(wizard.getPage() instanceof OutputPropertiesSelectionPage);
171     }
172 
173     public void nextXMLOutputPropertiesPage() throws Exception {
174         ((OutputPropertiesSelectionPage)wizard.getPage()).selectXMLProperties();
175         wizard.nextPage();
176         
177         assertTrue(wizard.getPage() instanceof XMLOutputPropertiesPage);
178     }
179 
180     public void nextHTMLOutputPropertiesPage() throws Exception {
181         ((OutputPropertiesSelectionPage)wizard.getPage()).selectHTMLProperties();
182         wizard.nextPage();
183         
184         assertTrue(wizard.getPage() instanceof HTMLOutputPropertiesPage);
185     }
186 
187     public void nextTextOutputPropertiesPage() throws Exception {
188         ((OutputPropertiesSelectionPage)wizard.getPage()).selectTextProperties();
189         wizard.nextPage();
190         
191         assertTrue(wizard.getPage() instanceof TextOutputPropertiesPage);
192     }
193 
194     public void nextOtherOutputPropertiesPage() throws Exception {
195         ((OutputPropertiesSelectionPage)wizard.getPage()).selectOtherProperties();
196         wizard.nextPage();
197         
198         assertTrue(wizard.getPage() instanceof OtherOutputPropertiesPage);
199     }
200 
201     public void selectDefaultOutputProperties() throws Exception {
202         ((OutputPropertiesSelectionPage)wizard.getPage()).selectDefaultProperties();
203         
204         assertNull(wizard.getPage().getNext());
205     }
206 
207     public void backOutputPropertiesSelectionPage() throws Exception {
208         wizard.backPage();
209         
210         assertTrue(wizard.getPage() instanceof OutputPropertiesSelectionPage);
211     }
212 
213     public void cancelWizard() throws Exception {
214         wizard.cancel();
215         
216         assertFalse(wizard.isVisible());
217         assertTrue(wizard.isCancelled());
218     }
219 
220     public static Test suite() {
221         TestSuite suite = new TestSuite("New XML Parser Wizard Test");
222         
223         suite.addTest(new NewXSLTransformationWizardTest("openWizard"));
224         suite.addTest(new NewXSLTransformationWizardTest("nextFilterPage"));
225         suite.addTest(new NewXSLTransformationWizardTest("nextParserSelectionPage"));
226         suite.addTest(new NewXSLTransformationWizardTest("backFilterPage"));
227         suite.addTest(new NewXSLTransformationWizardTest("backInputTypePage"));
228         suite.addTest(new NewXSLTransformationWizardTest("nextURIsPage"));
229         suite.addTest(new NewXSLTransformationWizardTest("nextParserSelectionPage"));
230         suite.addTest(new NewXSLTransformationWizardTest("nextSAXParserPage"));
231         suite.addTest(new NewXSLTransformationWizardTest("nextValidationSelectionPage"));
232         suite.addTest(new NewXSLTransformationWizardTest("testValidationSelectionPage"));
233         suite.addTest(new NewXSLTransformationWizardTest("nextSchemaURIsPage"));
234         suite.addTest(new NewXSLTransformationWizardTest("backValidationSelectionPage"));
235         suite.addTest(new NewXSLTransformationWizardTest("backParserPropertiesPage"));
236         suite.addTest(new NewXSLTransformationWizardTest("backParserSelectionPage"));
237         suite.addTest(new NewXSLTransformationWizardTest("nextDOMParserPage"));
238         suite.addTest(new NewXSLTransformationWizardTest("nextValidationSelectionPage"));
239         suite.addTest(new NewXSLTransformationWizardTest("nextSchemaURIsPage"));
240         suite.addTest(new NewXSLTransformationWizardTest("nextStylesheetSelectionPage"));
241         suite.addTest(new NewXSLTransformationWizardTest("nextStylesheetURIsPage"));
242         suite.addTest(new NewXSLTransformationWizardTest("backStylesheetSelectionPage"));
243         suite.addTest(new NewXSLTransformationWizardTest("nextAssociatedStylesheetPage"));
244         suite.addTest(new NewXSLTransformationWizardTest("backStylesheetSelectionPage"));
245         suite.addTest(new NewXSLTransformationWizardTest("nextOutputPropertiesSelectionPage"));
246         suite.addTest(new NewXSLTransformationWizardTest("nextXMLOutputPropertiesPage"));
247         suite.addTest(new NewXSLTransformationWizardTest("backOutputPropertiesSelectionPage"));
248         suite.addTest(new NewXSLTransformationWizardTest("nextHTMLOutputPropertiesPage"));
249         suite.addTest(new NewXSLTransformationWizardTest("backOutputPropertiesSelectionPage"));
250         suite.addTest(new NewXSLTransformationWizardTest("nextTextOutputPropertiesPage"));
251         suite.addTest(new NewXSLTransformationWizardTest("backOutputPropertiesSelectionPage"));
252         suite.addTest(new NewXSLTransformationWizardTest("nextOtherOutputPropertiesPage"));
253         suite.addTest(new NewXSLTransformationWizardTest("backOutputPropertiesSelectionPage"));
254         suite.addTest(new NewXSLTransformationWizardTest("selectDefaultOutputProperties"));
255         suite.addTest(new NewXSLTransformationWizardTest("cancelWizard"));
256 
257         return suite;
258     }
259 }