Source Code Cross Referenced for SelectTest.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » views » jsp » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » webwork 2.2.6 » com.opensymphony.webwork.views.jsp.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2003 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.views.jsp.ui;
006:
007:        import com.opensymphony.webwork.TestAction;
008:        import com.opensymphony.webwork.views.jsp.AbstractUITagTest;
009:
010:        import java.math.BigDecimal;
011:        import java.util.ArrayList;
012:        import java.util.Collection;
013:        import java.util.List;
014:
015:        /**
016:         * @author Matt Ho <a href="mailto:matt@enginegreen.com">&lt;matt@enginegreen.com&gt;</a>
017:         * @author tm_jee
018:         * @author Rene Gielen
019:         * @version $Id: SelectTest.java 2724 2006-09-19 16:44:28Z tmjee $
020:         */
021:        public class SelectTest extends AbstractUITagTest {
022:
023:            public void testHeaderCanBePreselected() throws Exception {
024:                SelectTag tag = new SelectTag();
025:                tag.setPageContext(pageContext);
026:                tag.setLabel("myLabel");
027:                tag.setList("#{1:'Cat',2:'Dog'}");
028:                tag.setName("myPet");
029:                tag.setHeaderKey("-1");
030:                tag.setHeaderValue("--- Please Select ---");
031:                tag.setValue("%{'-1'}");
032:
033:                tag.doStartTag();
034:                tag.doEndTag();
035:
036:                verify(SelectTag.class.getResource("Select-8.txt"));
037:            }
038:
039:            /**
040:             * Tests WW-455: Select tag template does not work properly for Object like BigDecimal.
041:             */
042:            public void testBigDecimal() throws Exception {
043:                BigDecimalObject hello = new BigDecimalObject("hello",
044:                        new BigDecimal(1));
045:                BigDecimalObject foo = new BigDecimalObject("foo",
046:                        new BigDecimal(2));
047:
048:                TestAction testAction = (TestAction) action;
049:
050:                Collection collection = new ArrayList(2);
051:                // expect strings to be returned, we're still dealing with HTTP here!
052:                collection.add("hello");
053:                collection.add("foo");
054:                testAction.setCollection(collection);
055:
056:                List list2 = new ArrayList();
057:                list2.add(hello);
058:                list2.add(foo);
059:                list2.add(new BigDecimalObject("<cat>", new BigDecimal(1.500)));
060:                testAction.setList2(list2);
061:
062:                SelectTag tag = new SelectTag();
063:                tag.setPageContext(pageContext);
064:                tag.setLabel("mylabel");
065:                tag.setName("collection");
066:                tag.setList("list2");
067:                tag.setListKey("name");
068:                tag.setListValue("bigDecimal");
069:                tag.setMultiple("true");
070:                tag.setTitle("mytitle");
071:                tag.setOnmousedown("alert('onmousedown');");
072:                tag.setOnmousemove("alert('onmousemove');");
073:                tag.setOnmouseout("alert('onmouseout');");
074:                tag.setOnmouseover("alert('onmouseover');");
075:                tag.setOnmouseup("alert('onmouseup');");
076:
077:                tag.doStartTag();
078:                tag.doEndTag();
079:
080:                verify(SelectTag.class.getResource("Select-3.txt"));
081:            }
082:
083:            public class BigDecimalObject {
084:                private String name;
085:                private BigDecimal bigDecimal;
086:
087:                public BigDecimalObject(String name, BigDecimal bigDecimal) {
088:                    this .name = name;
089:                    this .bigDecimal = bigDecimal;
090:                }
091:
092:                public String getName() {
093:                    return name;
094:                }
095:
096:                public BigDecimal getBigDecimal() {
097:                    return bigDecimal;
098:                }
099:            }
100:
101:            public void testNullList() throws Exception {
102:                TestAction testAction = (TestAction) action;
103:                testAction.setList2(null);
104:
105:                SelectTag tag = new SelectTag();
106:                tag.setName("collection");
107:                tag.setList("list2");
108:                tag.setLabel("tmjee_name");
109:
110:                tag.setPageContext(pageContext);
111:                try {
112:                    tag.doStartTag();
113:                    tag.doEndTag();
114:                    fail("exception should have been thrown value of select tag is null");
115:                } catch (Exception e) {
116:                    assertTrue(true);
117:                }
118:            }
119:
120:            public void testEmptyList() throws Exception {
121:                TestAction testAction = (TestAction) action;
122:                testAction.setList2(new ArrayList());
123:
124:                SelectTag tag = new SelectTag();
125:                tag.setName("collection");
126:                tag.setList("list2");
127:                tag.setLabel("tmjee_name");
128:
129:                tag.setPageContext(pageContext);
130:                tag.doStartTag();
131:                tag.doEndTag();
132:
133:                verify(SelectTag.class.getResource("Select-4.txt"));
134:            }
135:
136:            public void testMultiple() throws Exception {
137:                TestAction testAction = (TestAction) action;
138:                Collection collection = new ArrayList(2);
139:                collection.add("hello");
140:                collection.add("foo");
141:                testAction.setCollection(collection);
142:                testAction.setList(new String[][] { { "hello", "world" },
143:                        { "foo", "bar" }, { "cat", "dog" } });
144:
145:                SelectTag tag = new SelectTag();
146:                tag.setPageContext(pageContext);
147:                tag.setLabel("mylabel");
148:                tag.setName("collection");
149:                tag.setList("list");
150:                tag.setListKey("top[0]");
151:                tag.setListValue("top[1]");
152:                tag.setMultiple("true");
153:                tag.setOnmousedown("alert('onmousedown');");
154:                tag.setOnmousemove("alert('onmousemove');");
155:                tag.setOnmouseout("alert('onmouseout');");
156:                tag.setOnmouseover("alert('onmouseover');");
157:                tag.setOnmouseup("alert('onmouseup');");
158:
159:                tag.doStartTag();
160:                tag.doEndTag();
161:
162:                verify(SelectTag.class.getResource("Select-2.txt"));
163:            }
164:
165:            public void testSimple() throws Exception {
166:                TestAction testAction = (TestAction) action;
167:                testAction.setFoo("hello");
168:                testAction.setList(new String[][] { { "hello", "world" },
169:                        { "foo", "bar" } });
170:
171:                SelectTag tag = new SelectTag();
172:                tag.setPageContext(pageContext);
173:                tag.setEmptyOption("true");
174:                tag.setLabel("mylabel");
175:                tag.setName("foo");
176:                tag.setList("list");
177:                tag.setListKey("top[0]");
178:                tag.setListValue("top[1]");
179:
180:                // header stuff
181:                tag.setHeaderKey("headerKey");
182:                tag.setHeaderValue("headerValue");
183:
184:                // empty option
185:                tag.setEmptyOption("true");
186:
187:                tag.doStartTag();
188:                tag.doEndTag();
189:
190:                verify(SelectTag.class.getResource("Select-1.txt"));
191:            }
192:
193:            public void testExtended() throws Exception {
194:                TestAction testAction = (TestAction) action;
195:                testAction.setFoo("hello");
196:                testAction.setList(new String[][] { { "hello", "world" },
197:                        { "foo", "bar" } });
198:
199:                SelectTag tag = new SelectTag();
200:                tag.setPageContext(pageContext);
201:                tag.setEmptyOption("true");
202:                tag.setLabel("mylabel");
203:                tag.setName("foo");
204:                tag.setList("list");
205:                tag.setListKey("top[0]");
206:                tag.setListValue("%{top[0] + ' - ' + top[1]}");
207:
208:                // header stuff
209:                tag.setHeaderKey("headerKey");
210:                tag.setHeaderValue("%{foo + ': headerValue'}");
211:
212:                // empty option
213:                tag.setEmptyOption("true");
214:
215:                tag.doStartTag();
216:                tag.doEndTag();
217:
218:                verify(SelectTag.class.getResource("Select-7.txt"));
219:            }
220:
221:            public void testGenericSimple() throws Exception {
222:                SelectTag tag = new SelectTag();
223:                prepareTagGeneric(tag);
224:                verifyGenericProperties(tag, "simple", new String[] { "value" });
225:            }
226:
227:            public void testGenericXhtml() throws Exception {
228:                SelectTag tag = new SelectTag();
229:                prepareTagGeneric(tag);
230:                verifyGenericProperties(tag, "xhtml", new String[] { "value" });
231:            }
232:
233:            public void testGenericAjax() throws Exception {
234:                SelectTag tag = new SelectTag();
235:                prepareTagGeneric(tag);
236:                verifyGenericProperties(tag, "ajax", new String[] { "value" });
237:            }
238:
239:            public void testMultipleOn() throws Exception {
240:                SelectTag tag = new SelectTag();
241:                tag.setPageContext(pageContext);
242:                tag.setLabel("media1");
243:                tag.setId("myId");
244:                tag.setEmptyOption("true");
245:                tag.setName("myName");
246:                tag.setMultiple("true");
247:                tag.setList("{'aaa','bbb'}");
248:
249:                tag.doStartTag();
250:                tag.doEndTag();
251:
252:                verify(SelectTag.class.getResource("Select-5.txt"));
253:            }
254:
255:            public void testMultipleOff() throws Exception {
256:                SelectTag tag = new SelectTag();
257:                tag.setPageContext(pageContext);
258:                tag.setLabel("media2");
259:                tag.setId("myId");
260:                tag.setEmptyOption("true");
261:                tag.setName("myName");
262:                tag.setMultiple("false");
263:                tag.setList("{'aaa','bbb'}");
264:
265:                tag.doStartTag();
266:                tag.doEndTag();
267:
268:                verify(SelectTag.class.getResource("Select-6.txt"));
269:            }
270:
271:            private void prepareTagGeneric(SelectTag tag) {
272:                TestAction testAction = (TestAction) action;
273:                ArrayList collection = new ArrayList();
274:                collection.add("foo");
275:                collection.add("bar");
276:                collection.add("baz");
277:
278:                testAction.setCollection(collection);
279:
280:                tag.setList("collection");
281:            }
282:
283:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.