Source Code Cross Referenced for TestEngineExits.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » engine » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.engine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: TestEngineExits.java 3693 2007-03-14 10:55:56Z gbevin $
007:         */
008:        package com.uwyn.rife.engine;
009:
010:        import com.meterware.httpunit.*;
011:
012:        import com.uwyn.rife.TestCaseServerside;
013:        import com.uwyn.rife.tools.StringUtils;
014:        import com.uwyn.rife.tools.SwallowingLogFormatter;
015:        import java.util.HashMap;
016:        import java.util.logging.Formatter;
017:        import java.util.logging.Handler;
018:        import java.util.logging.Logger;
019:
020:        public class TestEngineExits extends TestCaseServerside {
021:            public TestEngineExits(int siteType, String name) {
022:                super (siteType, name);
023:            }
024:
025:            public void testContextIndependence() throws Exception {
026:                WebConversation conversation = new WebConversation();
027:                WebRequest request = null;
028:                WebResponse response = null;
029:
030:                setupSite("site/exits.xml");
031:                request = new GetMethodWebRequest(
032:                        "http://localhost:8181/exits/simple/source");
033:                response = conversation.getResponse(request);
034:
035:                assertEquals("destination", response.getText());
036:
037:                setupSite("/PREFIX", "site/exits.xml");
038:                request = new GetMethodWebRequest(
039:                        "http://localhost:8181/PREFIX/exits/simple/source");
040:                response = conversation.getResponse(request);
041:
042:                assertEquals("destination", response.getText());
043:            }
044:
045:            public void testExitSimple() throws Exception {
046:                setupSite("site/exits.xml");
047:                WebConversation conversation = new WebConversation();
048:                WebRequest request = new GetMethodWebRequest(
049:                        "http://localhost:8181/exits/simple/source");
050:                WebResponse response = conversation.getResponse(request);
051:                assertEquals("destination", response.getText());
052:            }
053:
054:            public void testExitSelective() throws Exception {
055:                setupSite("site/exits.xml");
056:                WebConversation conversation = new WebConversation();
057:                WebRequest request = null;
058:                WebResponse response = null;
059:
060:                request = new GetMethodWebRequest(
061:                        "http://localhost:8181/exits/selective/source");
062:                request.setParameter("switch", "1");
063:                response = conversation.getResponse(request);
064:                assertEquals("destination1", response.getText());
065:
066:                request = new GetMethodWebRequest(
067:                        "http://localhost:8181/exits/selective/source");
068:                request.setParameter("switch", "2");
069:                response = conversation.getResponse(request);
070:                assertEquals("destination2", response.getText());
071:
072:                request = new GetMethodWebRequest(
073:                        "http://localhost:8181/exits/selective/source");
074:                request.setParameter("switch", "3");
075:                response = conversation.getResponse(request);
076:                assertEquals("destination3", response.getText());
077:            }
078:
079:            public void testExistsDirectlink() throws Exception {
080:                setupSite("site/exits.xml");
081:                WebConversation conversation = new WebConversation();
082:                WebRequest request = new GetMethodWebRequest(
083:                        "http://localhost:8181/exits/directlink/source");
084:                WebResponse response = conversation.getResponse(request);
085:                WebLink direct_link = response.getLinkWith("direct link");
086:                direct_link.click();
087:                response = conversation.getCurrentPage();
088:                assertEquals("this isgreat", response.getText());
089:            }
090:
091:            public void testExitFlowlinkSpecific() throws Exception {
092:                setupSite("site/exits.xml");
093:                WebConversation conversation = new WebConversation();
094:                WebRequest request = null;
095:                WebResponse response = null;
096:                WebLink direct_link = null;
097:
098:                request = new GetMethodWebRequest(
099:                        "http://localhost:8181/exits/flowlinkspecific/source");
100:                request.setParameter("exitselector", "exit1");
101:                response = conversation.getResponse(request);
102:                assertEquals("output1 value" + "output3 value", response
103:                        .getText());
104:
105:                request = new GetMethodWebRequest(
106:                        "http://localhost:8181/exits/flowlinkspecific/source");
107:                request.setParameter("exitselector", "exit2");
108:                response = conversation.getResponse(request);
109:                assertEquals("output2 value" + "output3 value", response
110:                        .getText());
111:
112:                request = new GetMethodWebRequest(
113:                        "http://localhost:8181/exits/flowlinkspecific/source");
114:                request.setParameter("exitselector", "exit1");
115:                request.setParameter("type", "directlink");
116:                response = conversation.getResponse(request);
117:                direct_link = response.getLinkWith("link");
118:                direct_link.click();
119:                response = conversation.getCurrentPage();
120:                assertEquals("output1 value" + "output3 value", response
121:                        .getText());
122:
123:                request = new GetMethodWebRequest(
124:                        "http://localhost:8181/exits/flowlinkspecific/source");
125:                request.setParameter("exitselector", "exit2");
126:                request.setParameter("type", "directlink");
127:                response = conversation.getResponse(request);
128:                direct_link = response.getLinkWith("link");
129:                direct_link.click();
130:                response = conversation.getCurrentPage();
131:                assertEquals("output2 value" + "output3 value", response
132:                        .getText());
133:            }
134:
135:            public void testExitAutolink() throws Exception {
136:                setupSite("site/exits.xml");
137:                WebConversation conversation = new WebConversation();
138:                WebRequest request = null;
139:                WebResponse response = null;
140:                WebLink direct_link = null;
141:
142:                request = new GetMethodWebRequest(
143:                        "http://localhost:8181/exits/autolink/source");
144:                response = conversation.getResponse(request);
145:                assertEquals(
146:                        "output1 value,output2 value,null\n"
147:                                + "stringvalue1,stringvalue2,stringvalue3,MONDAY,20070313081228000+0100\n"
148:                                + "null,null,null,null,null\n", response
149:                                .getText());
150:
151:                request = new GetMethodWebRequest(
152:                        "http://localhost:8181/exits/autolink/source");
153:                request.setParameter("type", "directlink");
154:                response = conversation.getResponse(request);
155:                direct_link = response.getLinkWith("link");
156:                direct_link.click();
157:                response = conversation.getCurrentPage();
158:                assertEquals(
159:                        "output1 value,output2 value,null\n"
160:                                + "stringvalue1,stringvalue2,stringvalue3,MONDAY,20070313081228000+0100\n"
161:                                + "null,null,null,null,null\n", response
162:                                .getText());
163:            }
164:
165:            public void testExitAutolinkAnnotations() throws Exception {
166:                setupSite("site/exits.xml");
167:                WebConversation conversation = new WebConversation();
168:                WebRequest request = null;
169:                WebResponse response = null;
170:                WebLink direct_link = null;
171:
172:                request = new GetMethodWebRequest(
173:                        "http://localhost:8181/autolinkannotationsource");
174:                response = conversation.getResponse(request);
175:                assertEquals(
176:                        "output1 value,output2 value,null\n"
177:                                + "stringvalue1,stringvalue2,stringvalue3,TUESDAY,20070313082332000+0100\n"
178:                                + "null,null,null,null,null\n", response
179:                                .getText());
180:
181:                request = new GetMethodWebRequest(
182:                        "http://localhost:8181/autolinkannotationsource");
183:                request.setParameter("type", "directlink");
184:                response = conversation.getResponse(request);
185:                direct_link = response.getLinkWith("link");
186:                direct_link.click();
187:                response = conversation.getCurrentPage();
188:                assertEquals(
189:                        "output1 value,output2 value,null\n"
190:                                + "stringvalue1,stringvalue2,stringvalue3,TUESDAY,20070313082332000+0100\n"
191:                                + "null,null,null,null,null\n", response
192:                                .getText());
193:            }
194:
195:            public void testExitsGeneratedUrl() throws Exception {
196:                setupSite("site/exits.xml");
197:
198:                WebConversation conversation = new WebConversation();
199:                WebRequest request = null;
200:                WebResponse response = null;
201:
202:                request = new GetMethodWebRequest(
203:                        "http://localhost:8181/exits/generatedurl/source");
204:                response = conversation.getResponse(request);
205:                WebLink exit1_link = response.getLinkWith("exit1");
206:                response = exit1_link.click();
207:                assertEquals("the first,the second", response.getText());
208:
209:                request = new GetMethodWebRequest(
210:                        "http://localhost:8181/exits/generatedurl/source");
211:                response = conversation.getResponse(request);
212:                WebLink exit2_link = response.getLinkWith("exit2");
213:                response = exit2_link.click();
214:                assertEquals("the second,the third", response.getText());
215:
216:                request = new GetMethodWebRequest(
217:                        "http://localhost:8181/exits/generatedurl/source?switch=overridden");
218:                response = conversation.getResponse(request);
219:                WebLink exit1_link_overridden = response.getLinkWith("exit1");
220:                response = exit1_link_overridden.click();
221:                assertEquals("the overridden first,the second", response
222:                        .getText());
223:
224:                request = new GetMethodWebRequest(
225:                        "http://localhost:8181/exits/generatedurl/source?switch=overridden");
226:                response = conversation.getResponse(request);
227:                WebLink exit2_link_overridden = response.getLinkWith("exit2");
228:                response = exit2_link_overridden.click();
229:                assertEquals("the second,the overridden third", response
230:                        .getText());
231:            }
232:
233:            public void testExitsGeneratedUrlOverflow() throws Exception {
234:                setupSite("site/exits.xml");
235:
236:                // setup swallowing log formatters
237:                HashMap<Handler, Formatter> formatters = new HashMap<Handler, Formatter>();
238:                SwallowingLogFormatter formatter = new SwallowingLogFormatter();
239:                Logger logger = Logger.getLogger("");
240:                for (Handler handler : logger.getHandlers()) {
241:                    formatters.put(handler, handler.getFormatter());
242:                    handler.setFormatter(formatter);
243:                }
244:
245:                try {
246:                    WebConversation conversation = new WebConversation();
247:                    WebRequest request = null;
248:                    WebResponse response = null;
249:
250:                    request = new GetMethodWebRequest(
251:                            "http://localhost:8181/exits/generatedurloverflow/source");
252:                    response = conversation.getResponse(request);
253:                    WebLink exit1_link = response.getLinkWith("exit1");
254:                    assertTrue(exit1_link
255:                            .getURLString()
256:                            .startsWith(
257:                                    "/exits/generatedurloverflow/destination;jsessionid="));
258:                    assertTrue(exit1_link.getURLString().indexOf("?stateid=") != -1);
259:                    response = exit1_link.click();
260:                    assertEquals("the first,"
261:                            + StringUtils.repeat("abcdefghijklmnopqrstuvwxyz",
262:                                    76) + "012345678", response.getText());
263:
264:                    assertEquals(1, formatter.getRecords().size());
265:                    assertEquals(
266:                            "The exit 'exit1' of element '.GENERATEDURLOVERFLOW_SOURCE' generated an URL whose length of 2049 exceeds the maximum length of 2048 bytes, using session state store instead. The generated URL was '/exits/generatedurloverflow/destination?input1=the+first&input2="
267:                                    + StringUtils.repeat(
268:                                            "abcdefghijklmnopqrstuvwxyz", 76)
269:                                    + "012345678" + "'.", formatter
270:                                    .getRecords().get(0).getMessage());
271:                } finally {
272:                    // restore the previous formatters
273:                    for (Handler handler : logger.getHandlers()) {
274:                        handler.setFormatter(formatters.get(handler));
275:                    }
276:                }
277:            }
278:
279:            public void testExitsGeneratedForm() throws Exception {
280:                setupSite("site/exits.xml");
281:                WebConversation conversation = new WebConversation();
282:                WebRequest request = null;
283:                WebResponse response = null;
284:
285:                request = new GetMethodWebRequest(
286:                        "http://localhost:8181/exits/generatedform/source");
287:                response = conversation.getResponse(request);
288:                WebForm exit1_form = response.getFormWithName("test1");
289:                response = exit1_form.submit();
290:                assertEquals("another first,another second", response.getText());
291:
292:                request = new GetMethodWebRequest(
293:                        "http://localhost:8181/exits/generatedform/source?setoutputs=false");
294:                response = conversation.getResponse(request);
295:                WebForm exit1_form_nooutputs = response
296:                        .getFormWithName("test1");
297:                response = exit1_form_nooutputs.submit();
298:                assertEquals("null,null", response.getText());
299:
300:                request = new GetMethodWebRequest(
301:                        "http://localhost:8181/exits/generatedform/source");
302:                response = conversation.getResponse(request);
303:                WebForm exit2_form = response.getFormWithName("test2");
304:                response = exit2_form.submit();
305:                assertEquals("another second,another third", response.getText());
306:            }
307:
308:            public void testExitSnapback() throws Exception {
309:                setupSite("site/exits.xml");
310:                WebConversation conversation = new WebConversation();
311:                WebRequest request = null;
312:                WebResponse response = null;
313:
314:                request = new GetMethodWebRequest(
315:                        "http://localhost:8181/exits/snapback/simple");
316:                request.setParameter("activate_exit", "1");
317:                response = conversation.getResponse(request);
318:
319:                assertEquals(
320:                        "this is the output of simple snapback passthrough"
321:                                + "the content of simple snapback source",
322:                        response.getText());
323:            }
324:
325:            public void testExitSnapbackDatalinks() throws Exception {
326:                setupSite("site/exits.xml");
327:                WebConversation conversation = new WebConversation();
328:                WebRequest request = null;
329:                WebResponse response = null;
330:
331:                request = new GetMethodWebRequest(
332:                        "http://localhost:8181/exits/snapback/datalinks");
333:                request.setParameter("submission", "activate_exit");
334:                request.setParameter("param1", "param1value");
335:                response = conversation.getResponse(request);
336:
337:                assertEquals(
338:                        "this is the output of datalinks snapback passthrough"
339:                                + "param1value"
340:                                + "the content of datalinks snapback source"
341:                                + "passthrough value 1" + "passthrough value 2",
342:                        response.getText());
343:            }
344:
345:            public void testExitBeanNormal() throws Exception {
346:                setupSite("site/exits.xml");
347:                WebConversation conversation = new WebConversation();
348:                WebRequest request = null;
349:                WebResponse response = null;
350:
351:                request = new GetMethodWebRequest(
352:                        "http://localhost:8181/exits/bean/normal");
353:                request.setParameter("selector", "first");
354:                response = conversation.getResponse(request);
355:
356:                assertEquals(
357:                        "stringvalue1,stringvalue2,stringvalue3,MONDAY,20070313083217000+0100"
358:                                + "MONDAY,20070313083217000+0100,null,null,null",
359:                        response.getText());
360:            }
361:
362:            public void testExitBeanDifferent() throws Exception {
363:                setupSite("site/exits.xml");
364:                WebConversation conversation = new WebConversation();
365:                WebRequest request = null;
366:                WebResponse response = null;
367:
368:                request = new GetMethodWebRequest(
369:                        "http://localhost:8181/exits/bean/different");
370:                request.setParameter("selector", "second");
371:                response = conversation.getResponse(request);
372:
373:                assertEquals("null,null,null,TUESDAY,20070421083217000+0200"
374:                        + "TUESDAY,20070421083217000+0200,null,null,null",
375:                        response.getText());
376:            }
377:
378:            public void testExitBeanSnapback() throws Exception {
379:                setupSite("site/exits.xml");
380:                WebConversation conversation = new WebConversation();
381:                WebRequest request = null;
382:                WebResponse response = null;
383:
384:                request = new GetMethodWebRequest(
385:                        "http://localhost:8181/exits/bean/snapback");
386:                request.setParameter("selector", "exit");
387:                response = conversation.getResponse(request);
388:
389:                assertEquals(
390:                        "stringvalue1,stringvalue2,stringvalue3,SUNDAY,20070313082712000+0100",
391:                        response.getText());
392:            }
393:
394:            public void testExitBeanPrefixSame() throws Exception {
395:                setupSite("site/exits.xml");
396:                WebConversation conversation = new WebConversation();
397:                WebRequest request = null;
398:                WebResponse response = null;
399:
400:                request = new GetMethodWebRequest(
401:                        "http://localhost:8181/exits/bean/prefix/same");
402:                response = conversation.getResponse(request);
403:
404:                assertEquals(
405:                        "stringvalue1,stringvalue2,stringvalue3,WEDNESDAY,20070313081324000+0100"
406:                                + "null,null,null,null,null", response
407:                                .getText());
408:            }
409:
410:            public void testExitBeanPrefixDifferent() throws Exception {
411:                setupSite("site/exits.xml");
412:                WebConversation conversation = new WebConversation();
413:                WebRequest request = null;
414:                WebResponse response = null;
415:
416:                request = new GetMethodWebRequest(
417:                        "http://localhost:8181/exits/bean/prefix/different");
418:                response = conversation.getResponse(request);
419:
420:                assertEquals("null,null,null,null,null"
421:                        + "null,null,null,null,null", response.getText());
422:            }
423:
424:            public void testExitRedirect() throws Exception {
425:                setupSite("site/exits.xml");
426:                WebConversation conversation = new WebConversation();
427:                WebRequest request = null;
428:                WebResponse response = null;
429:
430:                request = new GetMethodWebRequest(
431:                        "http://localhost:8181/exits/redirect/source");
432:                request.setParameter("switch", "intern");
433:                response = conversation.getResponse(request);
434:                assertEquals("this is" + "great" + "/exits/redirect/source"
435:                        + "switch=intern", response.getText());
436:
437:                request = new GetMethodWebRequest(
438:                        "http://localhost:8181/exits/redirect/source");
439:                request.setParameter("switch", "redirect");
440:                response = conversation.getResponse(request);
441:                assertEquals("this is" + "great"
442:                        + "/exits/redirect/destination"
443:                        + "input1=this+is&input2=great", response.getText());
444:            }
445:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.