Source Code Cross Referenced for WebFlowSellItemTest.java in  » Net » Terracotta » com » tctest » spring » integrationtests » tests » 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 » Net » Terracotta » com.tctest.spring.integrationtests.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:
005:        package com.tctest.spring.integrationtests.tests;
006:
007:        import com.meterware.httpunit.WebConversation;
008:        import com.meterware.httpunit.WebResponse;
009:        import com.tc.test.server.appserver.deployment.AbstractTwoServerDeploymentTest;
010:        import com.tc.test.server.appserver.deployment.DeploymentBuilder;
011:        import com.tc.test.server.appserver.deployment.WebApplicationServer;
012:        import com.tctest.spring.integrationtests.SpringTwoServerTestSetup;
013:
014:        import java.io.ByteArrayInputStream;
015:        import java.util.Collections;
016:        import java.util.HashMap;
017:        import java.util.Iterator;
018:        import java.util.Map;
019:        import java.util.Properties;
020:
021:        import junit.framework.Test;
022:
023:        /**
024:         * Test Spring WebFlow Sellitem test
025:         * 
026:         * LKC-2369: Nested lock exception with TCSpring clustering of sample apps
027:         * https://jira.terracotta.lan/jira/browse/LKC-2369
028:         */
029:        public class WebFlowSellItemTest extends
030:                AbstractTwoServerDeploymentTest {
031:
032:            public static Test suite() {
033:                return new WebFlowTestSetup();
034:            }
035:
036:            protected void tearDown() throws Exception {
037:                super .tearDown();
038:                stopAllWebServers();
039:            }
040:
041:            public void testSellitem() throws Exception {
042:
043:                server0.start();
044:                server1.start();
045:
046:                WebConversation webConversation1 = new WebConversation();
047:                // XXX interleave servers when LKC-2369 is fixed
048:                executeConversation(webConversation1, server0, server1,
049:                        server1, server0);
050:
051:                // XXX Uncomment when LKC-2369 is fixed 
052:                WebConversation webConversation2 = new WebConversation();
053:                executeConversation(webConversation2, server0, server1,
054:                        server0, server1);
055:
056:            }
057:
058:            private void executeConversation(WebConversation webConversation1,
059:                    WebApplicationServer s1, WebApplicationServer s2,
060:                    WebApplicationServer s3, WebApplicationServer s4)
061:                    throws Exception {
062:                // priceAndItemCountForm.jsp
063:                Properties response1 = request(s1, webConversation1, null, null);
064:                assertProperty(response1, "form", "priceAndItemCountForm");
065:                assertProperty(response1, "flowExecutionKey");
066:                assertProperty(response1, "price");
067:                assertProperty(response1, "itemCount");
068:
069:                String flowExecutionKey2 = response1
070:                        .getProperty("flowExecutionKey");
071:
072:                Map map2 = new HashMap();
073:                map2.put("price", "101.5");
074:                map2.put("itemCount", "500");
075:                map2.put("_eventId_submit", "Next");
076:                // categoryForm.jsp
077:                Properties response2 = request(s2, webConversation1,
078:                        flowExecutionKey2, map2);
079:                assertProperty(response2, "form", "categoryForm");
080:                assertProperty(response2, "flowExecutionKey");
081:                assertProperty(response2, "price", "101.5");
082:                assertProperty(response2, "itemCount", "500");
083:
084:                String flowExecutionKey3 = response2
085:                        .getProperty("flowExecutionKey");
086:
087:                Map map3 = new HashMap();
088:                map3.put("shipping", "true");
089:                map3.put("category", "B");
090:                map3.put("_eventId_submit", "Next");
091:                // shippingDetailsForm.jsp
092:                Properties response3 = request(s3, webConversation1,
093:                        flowExecutionKey3, map3);
094:                assertProperty(response3, "form", "shippingDetailsForm");
095:                assertProperty(response3, "flowExecutionKey");
096:                assertProperty(response2, "price", "101.5");
097:                assertProperty(response2, "itemCount", "500");
098:                assertProperty(response3, "category", "B");
099:                assertProperty(response3, "shipping", "true");
100:
101:                String flowExecutionKey4 = response3
102:                        .getProperty("flowExecutionKey");
103:
104:                Map map4 = new HashMap();
105:                map4.put("_eventId_submit", "Next");
106:                map4.put("statusValue", "E");
107:                // costOverview
108:                Properties response4 = request(s4, webConversation1,
109:                        flowExecutionKey4, map4);
110:                assertProperty(response4, "form", "costOverview");
111:                // assertProperty(response4, "flowExecutionKey");
112:                assertProperty(response4, "totalCost");
113:            }
114:
115:            private void assertProperty(Properties properties, String name) {
116:                assertNotNull("No properties returned; " + properties,
117:                        properties);
118:                String value = properties.getProperty(name);
119:                assertNotNull("Missing property " + name + "; " + properties,
120:                        value);
121:                assertTrue("Expecting non-empty " + name + "; " + properties,
122:                        value.trim().length() > 0);
123:            }
124:
125:            private void assertProperty(Properties properties, String name,
126:                    String expected) {
127:                assertNotNull("No properties returned; " + properties,
128:                        properties);
129:                String value = properties.getProperty(name);
130:                assertEquals("Invalid " + name + "; " + properties, expected,
131:                        value);
132:            }
133:
134:            private Properties request(WebApplicationServer server,
135:                    WebConversation conversation, String flowExecutionKey,
136:                    Map map) throws Exception {
137:                String params = "";
138:                if (map == null) {
139:                    params += "_eventId=submit";
140:                } else {
141:                    for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
142:                        Map.Entry entry = (Map.Entry) it.next();
143:                        params += "&" + entry.getKey() + "=" + entry.getValue();
144:                    }
145:                }
146:                if (flowExecutionKey != null) {
147:                    params += "&_flowExecutionKey=" + flowExecutionKey.trim();
148:                } else {
149:                    params += "&_flowId=sellitem";
150:                }
151:
152:                WebResponse response = server.ping("/sellitem/pos.htm?"
153:                        + params, conversation);
154:
155:                Properties properties = new Properties();
156:                properties.load(new ByteArrayInputStream(response.getText()
157:                        .getBytes("ASCII")));
158:                logger.info("*** " + properties);
159:                return properties;
160:            }
161:
162:            private static class WebFlowTestSetup extends
163:                    SpringTwoServerTestSetup {
164:
165:                public WebFlowTestSetup() {
166:                    super (WebFlowSellItemTest.class,
167:                            "/tc-config-files/sellitem-tc-config.xml",
168:                            "sellitem");
169:                    setStart(false);
170:                }
171:
172:                protected void configureWar(DeploymentBuilder builder) {
173:                    // .addDirectoryOrJARContainingClass(WebFlowTestSetup.class)
174:                    // .addDirectoryContainingResource("/tc-config-files/sellitem-tc-config.xml")
175:                    builder
176:                            .addDirectoryContainingResource("/com/tctest/spring/sellitem-ctx.xml");
177:
178:                    builder
179:                            .addDirectoryOrJARContainingClass(org.apache.taglibs.standard.Version.class); // standard-1.0.6.jar
180:                    builder
181:                            .addDirectoryOrJARContainingClass(javax.servlet.jsp.jstl.core.Config.class); // jstl-1.0.jar
182:                    // .addDirectoryOrJARContainingClass(org.springframework.webflow.registry.XmlFlowRegistryFactoryBean.class)  // spring-webflow-1.0-rc3.jar
183:                    builder
184:                            .addDirectoryOrJARContainingClass(org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean.class); // spring-webflow-1.0-rc4.jar
185:                    builder
186:                            .addDirectoryOrJARContainingClass(org.springframework.binding.convert.Converter.class); // spring-binding-1.0-rc3.jar
187:                    builder
188:                            .addDirectoryOrJARContainingClass(org.apache.commons.codec.StringDecoder.class); // commons-codec-1.3.jar
189:                    builder.addDirectoryOrJARContainingClass(ognl.Ognl.class); // ognl-2.7.jar
190:                    builder
191:                            .addDirectoryOrJARContainingClass(EDU.oswego.cs.dl.util.concurrent.ReentrantLock.class); // concurrent-1.3.4.jar for SWF on jdk1.4
192:
193:                    builder
194:                            .addDirectoryOrJARContainingClass(org.hsqldb.jdbcDriver.class); // hsqldb*.jar
195:
196:                    builder.addResource("/web-resources/sellitem",
197:                            "categoryForm.jsp", "WEB-INF/jsp");
198:                    builder.addResource("/web-resources/sellitem",
199:                            "costOverview.jsp", "WEB-INF/jsp");
200:                    builder.addResource("/web-resources/sellitem", "error.jsp",
201:                            "WEB-INF/jsp");
202:                    builder.addResource("/web-resources/sellitem",
203:                            "includeTop.jsp", "WEB-INF/jsp");
204:                    builder.addResource("/web-resources/sellitem",
205:                            "priceAndItemCountForm.jsp", "WEB-INF/jsp");
206:                    builder.addResource("/web-resources/sellitem",
207:                            "shippingDetailsForm.jsp", "WEB-INF/jsp");
208:                    builder.addResource("/web-resources", "weblogic.xml",
209:                            "/WEB-INF");
210:
211:                    builder.addResource("/com/tctest/spring", "sellitem.xml",
212:                            "WEB-INF");
213:                    builder.addResource("/com/tctest/spring",
214:                            "sellitem-shipping.xml", "WEB-INF");
215:                    builder.addResource("/com/tctest/spring",
216:                            "sellitem-beans.xml", "WEB-INF");
217:                    builder.addResource("/com/tctest/spring",
218:                            "sellitem-servlet.xml", "WEB-INF");
219:
220:                    builder
221:                            .addServlet(
222:                                    "sellitem",
223:                                    "*.htm",
224:                                    org.springframework.web.servlet.DispatcherServlet.class,
225:                                    Collections
226:                                            .singletonMap(
227:                                                    "contextConfigLocation",
228:                                                    "/WEB-INF/sellitem-servlet.xml\n"
229:                                                            + "classpath:com/tctest/spring/sellitem-ctx.xml"),
230:                                    true);
231:                }
232:
233:                //    protected void setUp() throws Exception {
234:                //      super.setUp();
235:                //
236:                //      Deployment deployment2 = makeDeploymentBuilder("sellitem.war")
237:                //          .addDirectoryOrJARContainingClass(WebFlowTestSetup.class)
238:                //          .addDirectoryContainingResource("/tc-config-files/sellitem-tc-config.xml")
239:                //          .addDirectoryContainingResource("/com/tctest/spring/sellitem-ctx.xml")
240:                //          
241:                //          .addDirectoryOrJARContainingClass(org.apache.taglibs.standard.Version.class)  // standard-1.0.6.jar
242:                //          .addDirectoryOrJARContainingClass(javax.servlet.jsp.jstl.core.Config.class)  // jstl-1.0.jar
243:                //          // .addDirectoryOrJARContainingClass(org.springframework.webflow.registry.XmlFlowRegistryFactoryBean.class)  // spring-webflow-1.0-rc3.jar
244:                //          .addDirectoryOrJARContainingClass(org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean.class)  // spring-webflow-1.0-rc4.jar
245:                //          .addDirectoryOrJARContainingClass(org.springframework.binding.convert.Converter.class)  // spring-binding-1.0-rc3.jar
246:                //          .addDirectoryOrJARContainingClass(org.apache.commons.codec.StringDecoder.class)  // commons-codec-1.3.jar
247:                //          .addDirectoryOrJARContainingClass(ognl.Ognl.class)  // ognl-2.7.jar
248:                //          .addDirectoryOrJARContainingClass(EDU.oswego.cs.dl.util.concurrent.ReentrantLock.class)  // concurrent-1.3.4.jar for SWF on jdk1.4
249:                //
250:                //          .addDirectoryOrJARContainingClass(org.hsqldb.jdbcDriver.class)  // hsqldb*.jar
251:                //          
252:                //          .addResource("/web-resources/sellitem", "categoryForm.jsp", "WEB-INF/jsp")
253:                //          .addResource("/web-resources/sellitem", "costOverview.jsp", "WEB-INF/jsp")
254:                //          .addResource("/web-resources/sellitem", "error.jsp", "WEB-INF/jsp")
255:                //          .addResource("/web-resources/sellitem", "includeTop.jsp", "WEB-INF/jsp")
256:                //          .addResource("/web-resources/sellitem", "priceAndItemCountForm.jsp", "WEB-INF/jsp")
257:                //          .addResource("/web-resources/sellitem", "shippingDetailsForm.jsp", "WEB-INF/jsp")
258:                //          .addResource("/web-resources", "weblogic.xml", "/WEB-INF")
259:                //          
260:                //          .addResource("/com/tctest/spring", "sellitem.xml", "WEB-INF")
261:                //          .addResource("/com/tctest/spring", "sellitem-shipping.xml", "WEB-INF")
262:                //          .addResource("/com/tctest/spring", "sellitem-beans.xml", "WEB-INF")
263:                //          .addResource("/com/tctest/spring", "sellitem-servlet.xml", "WEB-INF")
264:                //          
265:                //          .addServlet("sellitem", "*.htm", org.springframework.web.servlet.DispatcherServlet.class, 
266:                //              Collections.singletonMap("contextConfigLocation", 
267:                //                  "/WEB-INF/sellitem-servlet.xml\n" +
268:                //                  "classpath:com/tctest/spring/sellitem-ctx.xml"), true)
269:                //          .makeDeployment();
270:                //      
271:                //      server1 = createServer(deployment2);
272:                //      server2 = createServer(deployment2);
273:                //    }
274:                //
275:                //    private WebApplicationServer createServer(Deployment deployment) throws Exception {
276:                //      return sm.makeWebApplicationServer("/tc-config-files/sellitem-tc-config.xml")
277:                //          .addWarDeployment(deployment, "sellitem");
278:                //    }
279:
280:            }
281:
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.