View Javadoc

1   package org.xmlhammer.gui.dialog;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import javax.swing.JFrame;
7   
8   import junit.framework.Test;
9   import junit.framework.TestCase;
10  import junit.framework.TestSuite;
11  
12  import org.xmlhammer.gui.util.ParametersDialog;
13  import org.xmlhammer.model.project.Parameter;
14  
15  public class ParametersDialogTest extends TestCase {
16      private static ParametersDialog dialog = null;
17  
18      private ParametersDialogTest(String test) {
19          super(test);
20      }
21  
22      public void openDialog() {
23          dialog = new ParametersDialog(new JFrame());
24          dialog.setModal(false);
25  
26          assertEquals(ParametersDialog.OK_OPTION, dialog.open());
27          assertTrue(dialog.isVisible());
28      }
29      
30      public void setParameters() {
31          List<Parameter> parameters = new ArrayList<Parameter>();
32          
33          Parameter param1 = new Parameter();
34          param1.setName("name1");
35          param1.setValue("value1");
36          
37          Parameter param2 = new Parameter();
38          param2.setName("name2");
39          param2.setValue("value2");
40  
41          parameters.add(param1);
42          parameters.add(param2);
43          
44          dialog.setParameters(parameters);
45          List<Parameter> result = dialog.getParameters();
46          
47          assertEquals("value1", result.get(0).getValue());
48          assertEquals("value2", result.get(1).getValue());
49  
50          dialog.setVisible(false);
51          dialog.dispose();
52          dialog = null;
53      }
54      
55      public static Test suite() {
56          TestSuite suite = new TestSuite("Parameters Dialog");
57          
58          suite.addTest(new ParametersDialogTest("openDialog"));
59          suite.addTest(new ParametersDialogTest("setParameters"));
60          return suite;
61      }
62  }