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.xslt.XMLOutputPropertiesDialog;
13 import org.xmlhammer.model.tools.xslt.OutputProperty;
14
15 public class XMLOutputPropertiesDialogTest extends TestCase {
16 private static XMLOutputPropertiesDialog dialog = null;
17
18 private XMLOutputPropertiesDialogTest(String test) {
19 super(test);
20 }
21
22 public void openDialog() {
23 dialog = new XMLOutputPropertiesDialog(new JFrame());
24 dialog.setModal(false);
25
26 assertEquals(XMLOutputPropertiesDialog.OK_OPTION, dialog.open());
27 assertTrue(dialog.isVisible());
28 }
29
30 public void setProperties() {
31 List<OutputProperty> list = new ArrayList<OutputProperty>();
32 OutputProperty property = new OutputProperty();
33 property.setName("name1");
34 property.setValue("value1");
35 list.add(property);
36
37 property = new OutputProperty();
38 property.setName("name2");
39 property.setValue("value2");
40 list.add(property);
41
42 dialog.setOutputProperties(list);
43 List<OutputProperty> result = dialog.getOutputProperties();
44
45 assertEquals(2, result.size());
46 assertEquals("value1", result.get(0).getValue());
47 assertEquals("value2", result.get(1).getValue());
48
49 dialog.setVisible(false);
50 dialog.dispose();
51 dialog = null;
52 }
53
54 public static Test suite() {
55 TestSuite suite = new TestSuite("XMLOutputPropertiesDialog");
56
57 suite.addTest(new XMLOutputPropertiesDialogTest("openDialog"));
58 suite.addTest(new XMLOutputPropertiesDialogTest("setProperties"));
59 return suite;
60 }
61 }