View Javadoc

1   package org.xmlhammer.gui.dialog;
2   
3   import javax.swing.JFrame;
4   
5   import junit.framework.Test;
6   import junit.framework.TestCase;
7   import junit.framework.TestSuite;
8   
9   import org.xmlhammer.gui.preferences.PropertiesDialog;
10  import org.xmlhammer.model.jaxp.JAXPDocumentBuilderFactory;
11  import org.xmlhammer.model.jaxp.JAXPSAXParserFactory;
12  import org.xmlhammer.model.jaxp.JAXPSchemaFactory;
13  import org.xmlhammer.model.jaxp.JAXPTransformerFactory;
14  import org.xmlhammer.model.jaxp.JAXPXPathFactory;
15  
16  public class PropertiesDialogTest extends TestCase {
17      private static PropertiesDialog dialog = null;
18  
19      private PropertiesDialogTest(String test) {
20          super(test);
21      }
22  
23      public void openDialog() {
24          dialog = new PropertiesDialog(new JFrame(), true, true, true, true, true);
25          dialog.setModal(false);
26  
27          assertEquals(PropertiesDialog.OK_OPTION, dialog.open());
28          assertTrue(dialog.isVisible());
29      }
30  
31     public void setProperties() {
32          dialog.setSAXParserFactory(new JAXPSAXParserFactory());
33          dialog.setDocumentBuilderFactory(new JAXPDocumentBuilderFactory());
34          dialog.setSchemaFactory(new JAXPSchemaFactory());
35          dialog.setTransformerFactory(new JAXPTransformerFactory());
36          dialog.setXPathFactory(new JAXPXPathFactory());
37          
38          assertNotNull(dialog.getSAXParserFactory());
39          assertNotNull(dialog.getDocumentBuilderFactory());
40          assertNotNull(dialog.getSchemaFactory());
41          assertNotNull(dialog.getTransformerFactory());
42          assertNotNull(dialog.getXPathFactory());
43  
44          dialog.setVisible(false);
45          dialog.dispose();
46          dialog = null;
47      }
48     
49     public static Test suite() {
50         TestSuite suite = new TestSuite("PropertiesDialog");
51         
52         suite.addTest(new PropertiesDialogTest("openDialog"));
53         suite.addTest(new PropertiesDialogTest("setProperties"));
54         return suite;
55     }
56  }