Source Code Cross Referenced for WebFlowTestBase.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
003:         * notice. All rights reserved.
004:         */
005:
006:        package com.tctest.spring.integrationtests.tests;
007:
008:        import com.meterware.httpunit.WebConversation;
009:        import com.meterware.httpunit.WebResponse;
010:        import com.tc.test.server.appserver.deployment.AbstractTwoServerDeploymentTest;
011:        import com.tc.test.server.appserver.deployment.DeploymentBuilder;
012:        import com.tc.test.server.appserver.deployment.WebApplicationServer;
013:        import com.tctest.spring.bean.WebFlowBean;
014:        import com.tctest.spring.integrationtests.SpringTwoServerTestSetup;
015:
016:        import java.util.Collections;
017:
018:        /**
019:         * Test Spring WebFlow fail-over
020:         *
021:         * LKC-1175: Test: Spring WebFlow fail-over https://jira.terracotta.lan/jira/browse/LKC-1175
022:         *
023:         * Test startup Test fail-over More??
024:         *
025:         * Spring Webflow flows are stateful (by nature), they are backed up by the HttpContext so it will be a no brainer to
026:         * support. Need to work out config, if it is needed and if so what it should be.
027:         *
028:         * 1. ContinuationFlowExecutionRepositoryFactory 2. DefaultFlowExecutionRepositoryFactory 3.
029:         * SingleKeyFlowExecutionRepositoryFactory (extends 2)
030:         */
031:        public class WebFlowTestBase extends AbstractTwoServerDeploymentTest {
032:
033:            public WebFlowTestBase() {
034:                // this.disableAllUntil("2006-12-01");
035:            }
036:
037:            protected void tearDown() throws Exception {
038:                super .tearDown();
039:                stopAllWebServers();
040:            }
041:
042:            protected void checkWebFlow(String controller, boolean withStepBack)
043:                    throws Exception {
044:                server0.start();
045:
046:                WebConversation webConversation1 = new WebConversation();
047:
048:                Response response1 = request(server0, webConversation1, null,
049:                        null, controller);
050:                assertTrue("Expecting non-empty flow execution key; "
051:                        + response1, response1.flowExecutionKey.length() > 0);
052:                assertEquals("", response1.result);
053:
054:                server1.start();
055:
056:                Response response2 = request(server1, webConversation1,
057:                        response1.flowExecutionKey, "valueA", controller);
058:                assertTrue("Expecting non-empty flow execution key; "
059:                        + response2, response2.flowExecutionKey.length() > 0);
060:                assertEquals("Invalid state; " + response2, WebFlowBean.STATEB,
061:                        response2.result);
062:                assertEquals("valueA", response2.valueA);
063:
064:                Response response3 = request(server0, webConversation1,
065:                        response2.flowExecutionKey, "valueB", controller);
066:                assertTrue("Expecting non-empty flow execution key; "
067:                        + response3, response3.flowExecutionKey.length() > 0);
068:                assertEquals("Invalid state; " + response3, WebFlowBean.STATEC,
069:                        response3.result);
070:                assertEquals("Invalid value; " + response3, "valueB",
071:                        response3.valueB);
072:
073:                server0.stop();
074:                server1.stop(); // both servers are down
075:
076:                server0.start();
077:
078:                if (withStepBack) {
079:                    // step back
080:                    Response response3a = request(server0, webConversation1,
081:                            response2.flowExecutionKey, "valueB1", controller);
082:                    assertTrue("Expecting non-empty flow execution key; "
083:                            + response3a,
084:                            response3a.flowExecutionKey.length() > 0);
085:                    assertEquals("Invalid state; " + response3a,
086:                            WebFlowBean.STATEC, response3a.result);
087:                    assertEquals("Invalid value; " + response3a, "valueB1",
088:                            response3a.valueB);
089:                }
090:
091:                // throw away the step back and continue
092:                Response response4 = request(server0, webConversation1,
093:                        response3.flowExecutionKey, "valueC", controller);
094:                assertTrue("Expecting non-empty flow execution key; "
095:                        + response4, response4.flowExecutionKey.length() > 0);
096:                assertEquals("Invalid state; " + response4, WebFlowBean.STATED,
097:                        response4.result);
098:                assertEquals("Invalid value; " + response4, "valueC",
099:                        response4.valueC);
100:
101:                server1.start();
102:
103:                Response response5 = request(server1, webConversation1,
104:                        response4.flowExecutionKey, "valueD", controller);
105:                // flowExecutionKey is empty since flow is completed
106:                assertEquals("Invalid state; " + response5,
107:                        WebFlowBean.COMPLETE, response5.result);
108:                assertEquals("Invalid value; " + response5, "valueD",
109:                        response5.valueD);
110:            }
111:
112:            private Response request(WebApplicationServer server,
113:                    WebConversation conversation, String flowExecutionKey,
114:                    String value, String controllerName) throws Exception {
115:                String params = "_eventId=submit";
116:                if (value != null) {
117:                    params += "&value=" + value;
118:                }
119:                if (flowExecutionKey != null) {
120:                    params += "&_flowExecutionKey=" + flowExecutionKey.trim();
121:                } else {
122:                    params += "&_flowId=webflow";
123:                }
124:
125:                WebResponse response = server.ping("/webflow/" + controllerName
126:                        + "?" + params, conversation);
127:                return new Response(response.getText().trim());
128:            }
129:
130:            // public void DONTtestHighlow() throws Exception {
131:            // if(server1.isStopped()) {
132:            // server1.start();
133:            // }
134:            //
135:            // WebConversation webConversation1 = new WebConversation();
136:            //
137:            // String flowExecutionKey = null;
138:            // int lowGuess = 0;
139:            // int highGuess = 100;
140:            // int n = 0;
141:            // while(n<100) {
142:            // int guess = (highGuess-lowGuess)/2 + lowGuess;
143:            // String response = takeGuess(server1, webConversation1, guess, flowExecutionKey);
144:            // String[] params = response.split(";");
145:            // assertTrue("Expected at least two parameters: "+response, params.length>1);
146:            //
147:            // if(HigherLowerGame.CORRECT.equals(params[0])) {
148:            // break;
149:            // } else if(HigherLowerGame.TOO_HIGH.equals(params[0])) {
150:            // highGuess = guess;
151:            // } else if(HigherLowerGame.TOO_LOW.equals(params[0])) {
152:            // lowGuess = guess;
153:            // } else if(HigherLowerGame.INVALID.equals(params[0])) {
154:            // fail("Invalid execution "+params[1]);
155:            // }
156:            //
157:            // flowExecutionKey = params[1];
158:            // }
159:            // assertTrue("Too many iterations", n<100);
160:            // }
161:
162:            // private String takeGuess(WebApplicationServer server, WebConversation conversation, int newGuess, String
163:            // flowExecutionKey) throws Exception {
164:            // String params = "guess="+newGuess;
165:            // if(flowExecutionKey!=null) {
166:            // params += "&_flowExecutionKey="+flowExecutionKey.trim();
167:            // } else {
168:            // params += "&_flowId=higherlower";
169:            // }
170:            // params += "&_eventId=submit";
171:            //
172:            // WebResponse response = server.ping("/higherlower/higherlower.htm?"+params, conversation);
173:            // return response.getText().trim();
174:            // }
175:
176:            static class WebFlowTestSetup extends SpringTwoServerTestSetup {
177:
178:                public WebFlowTestSetup(Class testClass) {
179:                    super (testClass, "/tc-config-files/webflow-tc-config.xml",
180:                            "webflow");
181:                    setStart(false);
182:                }
183:
184:                protected void configureWar(DeploymentBuilder builder) {
185:                    builder
186:                            // .addDirectoryOrJARContainingClass(WebFlowTestSetup.class)
187:                            // .addDirectoryContainingResource("/tc-config-files/webflow-tc-config.xml")
188:
189:                            .addDirectoryOrJARContainingClass(
190:                                    org.apache.taglibs.standard.Version.class)
191:                            // standard-1.0.6.jar
192:                            .addDirectoryOrJARContainingClass(
193:                                    javax.servlet.jsp.jstl.core.Config.class)
194:                            // jstl-1.0.jar
195:                            // .addDirectoryOrJARContainingClass(org.springframework.webflow.registry.XmlFlowRegistryFactoryBean.class) //
196:                            // spring-webflow-1.0-rc3.jar
197:                            .addDirectoryOrJARContainingClass(
198:                                    org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean.class)
199:                            // spring-webflow-1.0-rc4.jar
200:                            .addDirectoryOrJARContainingClass(
201:                                    org.springframework.binding.convert.Converter.class)
202:                            // spring-binding-1.0-rc3.jar
203:                            .addDirectoryOrJARContainingClass(
204:                                    org.apache.commons.codec.StringDecoder.class)
205:                            // commons-codec-1.3.jar
206:                            .addDirectoryOrJARContainingClass(ognl.Ognl.class)
207:                            // ognl-2.7.jar
208:                            .addDirectoryOrJARContainingClass(
209:                                    EDU.oswego.cs.dl.util.concurrent.ReentrantLock.class)
210:                            // concurrent-1.3.4.jar for SWF on jdk1.4
211:
212:                            .addResource("/web-resources", "webflow.jsp",
213:                                    "WEB-INF")
214:                            .addResource("/com/tctest/spring", "webflow.xml",
215:                                    "WEB-INF")
216:                            .addResource("/com/tctest/spring",
217:                                    "webflow-beans.xml", "WEB-INF")
218:                            .addResource("/com/tctest/spring",
219:                                    "webflow-servlet.xml", "WEB-INF")
220:                            .addResource("/web-resources", "weblogic.xml",
221:                                    "WEB-INF")
222:
223:                            .addServlet(
224:                                    "webflow",
225:                                    "*.htm",
226:                                    org.springframework.web.servlet.DispatcherServlet.class,
227:                                    Collections.singletonMap(
228:                                            "contextConfigLocation",
229:                                            "/WEB-INF/webflow-servlet.xml"),
230:                                    true);
231:
232:                }
233:
234:                // protected void setUp() throws Exception {
235:                // super.setUp();
236:                //
237:                // try {
238:                //
239:                // Deployment deployment2 = makeDeploymentBuilder("webflow.war")
240:                // .addDirectoryOrJARContainingClass(WebFlowTestSetup.class)
241:                // .addDirectoryContainingResource("/tc-config-files/webflow-tc-config.xml")
242:                //
243:                // .addDirectoryOrJARContainingClass(org.apache.taglibs.standard.Version.class) // standard-1.0.6.jar
244:                // .addDirectoryOrJARContainingClass(javax.servlet.jsp.jstl.core.Config.class) // jstl-1.0.jar
245:                // // .addDirectoryOrJARContainingClass(org.springframework.webflow.registry.XmlFlowRegistryFactoryBean.class) //
246:                // spring-webflow-1.0-rc3.jar
247:                // .addDirectoryOrJARContainingClass(org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean.class)
248:                // // spring-webflow-1.0-rc4.jar
249:                // .addDirectoryOrJARContainingClass(org.springframework.binding.convert.Converter.class) //
250:                // spring-binding-1.0-rc3.jar
251:                // .addDirectoryOrJARContainingClass(org.apache.commons.codec.StringDecoder.class) // commons-codec-1.3.jar
252:                // .addDirectoryOrJARContainingClass(ognl.Ognl.class) // ognl-2.7.jar
253:                // .addDirectoryOrJARContainingClass(EDU.oswego.cs.dl.util.concurrent.ReentrantLock.class) // concurrent-1.3.4.jar
254:                // for SWF on jdk1.4
255:                //
256:                // .addResource("/web-resources", "webflow.jsp", "WEB-INF")
257:                // .addResource("/com/tctest/spring", "webflow.xml", "WEB-INF")
258:                // .addResource("/com/tctest/spring", "webflow-beans.xml", "WEB-INF")
259:                // .addResource("/com/tctest/spring", "webflow-servlet.xml", "WEB-INF")
260:                // .addResource("/web-resources", "weblogic.xml", "WEB-INF")
261:                //
262:                // .addServlet("webflow", "*.htm", org.springframework.web.servlet.DispatcherServlet.class,
263:                // Collections.singletonMap("contextConfigLocation", "/WEB-INF/webflow-servlet.xml"), true)
264:                // .makeDeployment();
265:                //
266:                // server1 = createServer()
267:                // .addWarDeployment(deployment2, "webflow");
268:                //
269:                // server2 = createServer()
270:                // .addWarDeployment(deployment2, "webflow");
271:                // } catch (Exception ex) {
272:                // ex.printStackTrace();
273:                // }
274:                // }
275:                //
276:                // private WebApplicationServer createServer() throws Exception {
277:                // return sm.makeWebApplicationServer("/tc-config-files/webflow-tc-config.xml");
278:                // }
279:
280:            }
281:
282:            private static class Response {
283:                public final String text;
284:                public final String flowExecutionKey;
285:                public final String result;
286:                public final String valueA;
287:                public final String valueB;
288:                public final String valueC;
289:                public final String valueD;
290:
291:                public Response(String text) {
292:                    this .text = text;
293:
294:                    String[] values = text.split(";");
295:                    assertTrue("Expected at least two parameters; " + text,
296:                            values.length > 1);
297:
298:                    this .result = values[0];
299:                    this .flowExecutionKey = values[1];
300:                    this .valueA = values.length > 2 ? values[2] : null;
301:                    this .valueB = values.length > 3 ? values[3] : null;
302:                    this .valueC = values.length > 4 ? values[4] : null;
303:                    this .valueD = values.length > 5 ? values[5] : null;
304:                }
305:
306:                public String toString() {
307:                    return text;
308:                }
309:
310:            }
311:
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.