KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > ui > DoubleSelectTest


1 package com.opensymphony.webwork.views.jsp.ui;
2
3 import com.opensymphony.webwork.TestAction;
4 import com.opensymphony.webwork.views.jsp.AbstractUITagTest;
5
6 import java.util.ArrayList JavaDoc;
7 import java.util.Collection JavaDoc;
8 import java.util.List JavaDoc;
9
10 /**
11  * @author <a HREF="mailto:m.bogaert@memenco.com">Mathias Bogaert</a>
12  * @version $Revision: 1.4 $
13  */

14 public class DoubleSelectTest extends AbstractUITagTest {
15
16     public void testDouble() throws Exception JavaDoc {
17         TestAction testAction = (TestAction) action;
18
19         Region antwerp = new Region("Antwerp", "AN");
20         Region gent = new Region("Gent", "GN");
21         Region brugge = new Region("Brugge", "BRG");
22         ArrayList JavaDoc belgiumRegions = new ArrayList JavaDoc();
23         belgiumRegions.add(antwerp);
24         belgiumRegions.add(gent);
25         belgiumRegions.add(brugge);
26         Country belgium = new Country("Belgium", "BE", belgiumRegions);
27
28         Region paris = new Region("Paris", "PA");
29         Region bordeaux = new Region("Bordeaux", "BOR");
30         ArrayList JavaDoc franceRegions = new ArrayList JavaDoc();
31         franceRegions.add(paris);
32         franceRegions.add(bordeaux);
33         Country france = new Country("France", "FR", franceRegions);
34
35         Collection JavaDoc collection = new ArrayList JavaDoc(2);
36         collection.add("AN");
37         testAction.setCollection(collection);
38
39         List JavaDoc countries = new ArrayList JavaDoc();
40         countries.add(belgium);
41         countries.add(france);
42
43         testAction.setList2(countries);
44
45         DoubleSelectTag tag = new DoubleSelectTag();
46         tag.setPageContext(pageContext);
47         tag.setLabel("mylabel");
48         tag.setName("foo");
49         tag.setDoubleName("region");
50
51         tag.setList("list2");
52         tag.setDoubleList("regions");
53
54         tag.setListKey("iso");
55         tag.setDoubleListKey("key");
56         tag.setListValue("name");
57         tag.setDoubleListValue("name");
58
59         tag.setFormName("inputForm");
60
61         tag.setOnmousedown("window.status='onmousedown';");
62         tag.setOnmousemove("window.status='onmousemove';");
63         tag.setOnmouseout("window.status='onmouseout';");
64         tag.setOnmouseover("window.status='onmouseover';");
65         tag.setOnmouseup("window.status='onmouseup';");
66
67         tag.doStartTag();
68         tag.doEndTag();
69
70         verify(SelectTag.class.getResource("DoubleSelect-1.txt"));
71     }
72
73     public class Country {
74         String JavaDoc name;
75         String JavaDoc iso;
76         Collection JavaDoc regions;
77
78         public Country(String JavaDoc name, String JavaDoc iso, Collection JavaDoc regions) {
79             this.name = name;
80             this.iso = iso;
81             this.regions = regions;
82         }
83
84         public String JavaDoc getName() {
85             return name;
86         }
87
88         public String JavaDoc getIso() {
89             return iso;
90         }
91
92         public Collection JavaDoc getRegions() {
93             return regions;
94         }
95     }
96
97     public class Region {
98         String JavaDoc name;
99         String JavaDoc key;
100
101         public Region(String JavaDoc name, String JavaDoc key) {
102             this.name = name;
103             this.key = key;
104         }
105
106         public String JavaDoc getName() {
107             return name;
108         }
109
110         public String JavaDoc getKey() {
111             return key;
112         }
113     }
114 }
115
Popular Tags