Source Code Cross Referenced for TestEngineGlobals.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: TestEngineGlobals.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.engine;
009:
010:        import javax.servlet.http.Cookie;
011:
012:        import com.meterware.httpunit.*;
013:        import com.uwyn.rife.TestCaseServerside;
014:        import com.uwyn.rife.engine.exceptions.GlobalExitOverriddenException;
015:        import com.uwyn.rife.engine.exceptions.IncookieUnknownException;
016:        import com.uwyn.rife.engine.exceptions.OutcookieUnknownException;
017:        import com.uwyn.rife.tools.HttpUtils;
018:
019:        public class TestEngineGlobals extends TestCaseServerside {
020:            public TestEngineGlobals(int siteType, String name) {
021:                super (siteType, name);
022:            }
023:
024:            public void testGlobalVars() throws Exception {
025:                setupSite("site/globals.xml");
026:                WebConversation conversation = new WebConversation();
027:                WebRequest request = null;
028:                WebResponse response = null;
029:
030:                request = new GetMethodWebRequest(
031:                        "http://localhost:8181/globals/source");
032:                request.setParameter("switch", "1");
033:                response = conversation.getResponse(request);
034:                assertEquals("value2a|value2b|value2c,value1", response
035:                        .getText());
036:
037:                request = new GetMethodWebRequest(
038:                        "http://localhost:8181/globals/source");
039:                request.setParameter("switch", "2");
040:                response = conversation.getResponse(request);
041:                assertEquals("value1,value2a|value2b|value2c", response
042:                        .getText());
043:            }
044:
045:            public void testGlobalVarsInjection() throws Exception {
046:                setupSite("site/globals.xml");
047:                WebConversation conversation = new WebConversation();
048:                WebRequest request = null;
049:                WebResponse response = null;
050:
051:                request = new GetMethodWebRequest(
052:                        "http://localhost:8181/globals/injection");
053:                request.setParameter("switch", "1");
054:                try {
055:                    response = conversation.getResponse(request);
056:                } catch (Throwable e) {
057:                    getLogSink().getInternalException().printStackTrace();
058:                }
059:                assertEquals("value2a|value2b|value2c,value1", response
060:                        .getText());
061:
062:                request = new GetMethodWebRequest(
063:                        "http://localhost:8181/globals/injection");
064:                request.setParameter("switch", "2");
065:                response = conversation.getResponse(request);
066:                assertEquals("value1,value2a|value2b|value2c", response
067:                        .getText());
068:            }
069:
070:            public void testGlobalVarsGroup() throws Exception {
071:                setupSite("site/globals.xml");
072:                WebConversation conversation = new WebConversation();
073:                WebRequest request = null;
074:                WebResponse response = null;
075:
076:                request = new GetMethodWebRequest(
077:                        "http://localhost:8181/globals/group/source");
078:                request.setParameter("switch", "1");
079:                response = conversation.getResponse(request);
080:                assertEquals(
081:                        "value4a|value4b|value4c,value3,value2a|value2b|value2c,value1",
082:                        response.getText());
083:
084:                request = new GetMethodWebRequest(
085:                        "http://localhost:8181/globals/group/source");
086:                request.setParameter("switch", "2");
087:                response = conversation.getResponse(request);
088:                assertEquals(
089:                        "value1,value2a|value2b|value2c,value3,value4a|value4b|value4c",
090:                        response.getText());
091:            }
092:
093:            public void testGlobalVarsGroupIsolation() throws Exception {
094:                setupSite("site/globals.xml");
095:                WebConversation conversation = new WebConversation();
096:                WebRequest request = null;
097:                WebResponse response = null;
098:
099:                request = new GetMethodWebRequest(
100:                        "http://localhost:8181/globals/group/isolation_source");
101:                request.setParameter("switch", "1");
102:                response = conversation.getResponse(request);
103:                assertEquals("value1|value2|value5", response.getText());
104:
105:                request = new GetMethodWebRequest(
106:                        "http://localhost:8181/globals/group/isolation_source");
107:                request.setParameter("switch", "2");
108:                response = conversation.getResponse(request);
109:                assertEquals("value1|default value 2 local|null", response
110:                        .getText());
111:            }
112:
113:            public void testGlobalDefaultVars() throws Exception {
114:                setupSite("site/global_defaults.xml");
115:                WebConversation conversation = new WebConversation();
116:                WebRequest request = null;
117:                WebResponse response = null;
118:
119:                request = new GetMethodWebRequest(
120:                        "http://localhost:8181/globals/defaults");
121:                response = conversation.getResponse(request);
122:                assertEquals("the first value" + "2rda-2rdd-2rdc-2rdb",
123:                        response.getText());
124:
125:                request = new GetMethodWebRequest(
126:                        "http://localhost:8181/globals/defaults");
127:                request.setParameter("global1", "a new global value");
128:                response = conversation.getResponse(request);
129:                assertEquals("a new global value" + "2rda-2rdd-2rdc-2rdb",
130:                        response.getText());
131:
132:                request = new GetMethodWebRequest(
133:                        "http://localhost:8181/globals/defaults");
134:                request.setParameter("input1", "1");
135:                response = conversation.getResponse(request);
136:                assertEquals("the first value" + "2rda-2rdd-2rdc-2rdb"
137:                        + "the first value" + "2rda-2rdd-2rdc-2rdb"
138:                        + "the element config value", response.getText());
139:            }
140:
141:            public void testGlobalExits() throws Exception {
142:                setupSite("site/globals.xml");
143:                WebConversation conversation = new WebConversation();
144:                WebRequest request = null;
145:                WebResponse response = null;
146:
147:                request = new GetMethodWebRequest(
148:                        "http://localhost:8181/globals/source");
149:                request.setParameter("switch", "3");
150:                response = conversation.getResponse(request);
151:                assertEquals("global exit : value1,value2a|value2b|value2c",
152:                        response.getText());
153:
154:                request = new GetMethodWebRequest(
155:                        "http://localhost:8181/globals/source");
156:                request.setParameter("switch", "4");
157:                request.setParameter("reflected", "reflected_value");
158:                request.setParameter("reflected_overridden", "reflected_value");
159:                request.setParameter("not_reflected", "not_reflected_value");
160:                response = conversation.getResponse(request);
161:                assertEquals("reflected" + "reflected_value"
162:                        + "reflected_value_overridden" + "null", response
163:                        .getText());
164:            }
165:
166:            public void testGlobalExitsConflict() throws Exception {
167:                setupSite("site/global_conflict_exit.xml");
168:                WebConversation conversation = new WebConversation();
169:                WebRequest request = null;
170:
171:                request = new GetMethodWebRequest(
172:                        "http://localhost:8181/subsite");
173:                try {
174:                    conversation.getResponse(request);
175:                } catch (Throwable e) {
176:                    Throwable e2 = getLogSink().getInternalException();
177:                    assertTrue(e2 instanceof  GlobalExitOverriddenException);
178:                    assertEquals(((GlobalExitOverriddenException) e2)
179:                            .getGlobalExitName(), "globalexit1");
180:                }
181:            }
182:
183:            public void testGlobalExitsGroup() throws Exception {
184:                setupSite("site/globals.xml");
185:                WebConversation conversation = new WebConversation();
186:                WebRequest request = null;
187:                WebResponse response = null;
188:
189:                request = new GetMethodWebRequest(
190:                        "http://localhost:8181/globals/group/source");
191:                request.setParameter("switch", "3");
192:                response = conversation.getResponse(request);
193:                assertEquals("global exit : value1,value2a|value2b|value2c",
194:                        response.getText());
195:
196:                request = new GetMethodWebRequest(
197:                        "http://localhost:8181/globals/group/source");
198:                request.setParameter("switch", "4");
199:                response = conversation.getResponse(request);
200:                assertEquals("reflective1", response.getText());
201:
202:                request = new GetMethodWebRequest(
203:                        "http://localhost:8181/globals/group/source");
204:                request.setParameter("switch", "5");
205:                response = conversation.getResponse(request);
206:                assertEquals(
207:                        "global exit : value1,value2a|value2b|value2c,value3,value4a|value4b|value4c",
208:                        response.getText());
209:
210:                request = new GetMethodWebRequest(
211:                        "http://localhost:8181/globals/group/source");
212:                request.setParameter("switch", "6");
213:                response = conversation.getResponse(request);
214:                assertEquals("reflective2", response.getText());
215:            }
216:
217:            public void testGlobalVarsSubmission() throws Exception {
218:                setupSite("site/globals.xml");
219:                WebConversation conversation = new WebConversation();
220:                WebRequest request = null;
221:                WebResponse response = null;
222:
223:                request = new GetMethodWebRequest(
224:                        "http://localhost:8181/globals/submission");
225:                request.setParameter("globalvar1", "var one");
226:                request.setParameter("globalvar2", new String[] { "var two a",
227:                        "var two b" });
228:                response = conversation.getResponse(request);
229:                WebForm form = response.getForms()[0];
230:                response = form.submit();
231:                assertEquals("value1,value2a|value2b|value2c,one param",
232:                        response.getText());
233:            }
234:
235:            public void testGlobalVarsInputsOverriding() throws Exception {
236:                setupSite("site/globals.xml");
237:                WebConversation conversation = new WebConversation();
238:                WebRequest request = null;
239:                WebResponse response = null;
240:
241:                request = new GetMethodWebRequest(
242:                        "http://localhost:8181/globalvars/inputs/source");
243:                request.setParameter("globalvar1", "global var one");
244:                request.setParameter("globalvar2", new String[] {
245:                        "global var two a", "global var two b",
246:                        "global var two c" });
247:                request.setParameter("input1", "input var one");
248:                request.setParameter("input2", "input var two");
249:                response = conversation.getResponse(request);
250:                assertEquals(
251:                        "global var one,global var two a|global var two b|global var two c,output input var one:outit,output input var two",
252:                        response.getText());
253:            }
254:
255:            public void testGlobalExitToRootArrival() throws Exception {
256:                setupSite("site/globals.xml");
257:                WebConversation conversation = new WebConversation();
258:                WebRequest request = null;
259:                WebResponse response = null;
260:
261:                request = new GetMethodWebRequest(
262:                        "http://localhost:8181/globals/globalexit_to_root_arrival");
263:                request.setParameter("globalvar1", "global var one");
264:                request.setParameter("globalvar2", new String[] {
265:                        "global var two a", "global var two b",
266:                        "global var two c" });
267:                request.setParameter("input1", "input var one");
268:                request.setParameter("input2", "input var two");
269:                response = conversation.getResponse(request);
270:                assertEquals(
271:                        "global var one,global var two a|global var two b|global var two c,output input var one:outit,output input var two",
272:                        response.getText());
273:            }
274:
275:            public void testGlobalsBeanNormal() throws Exception {
276:                setupSite("site/globals.xml");
277:                WebConversation conversation = new WebConversation();
278:                WebRequest request = new GetMethodWebRequest(
279:                        "http://localhost:8181/globals/bean/normal");
280:                WebResponse response = null;
281:
282:                response = conversation.getResponse(request);
283:                assertEquals(
284:                        "the string,the stringbuffer,23154,893749,u,false,true,false,false,21,34878.34,25435.98,3434.76,6534.8,34347897,2335454,32,12",
285:                        response.getText());
286:            }
287:
288:            public void testGlobalsBeanPrefix() throws Exception {
289:                setupSite("site/globals.xml");
290:                WebConversation conversation = new WebConversation();
291:                WebRequest request = new GetMethodWebRequest(
292:                        "http://localhost:8181/globals/bean/prefix");
293:                WebResponse response = null;
294:
295:                response = conversation.getResponse(request);
296:                assertEquals(
297:                        "the string,the stringbuffer,23154,893749,u,false,true,false,false,21,34878.34,25435.98,3434.76,6534.8,34347897,2335454,32,12",
298:                        response.getText());
299:            }
300:
301:            public void testNamedGlobalBeanNormal() throws Exception {
302:                setupSite("site/globals.xml");
303:                WebConversation conversation = new WebConversation();
304:                WebRequest request = new GetMethodWebRequest(
305:                        "http://localhost:8181/globals/namedbean/normal");
306:                WebResponse response = null;
307:
308:                response = conversation.getResponse(request);
309:                assertEquals(
310:                        "the string,the stringbuffer,23154,893749,u,null,true,false,0,21,34878.34,25435.98,3434.76,6534.8,34347897,2335454,32,12",
311:                        response.getText());
312:            }
313:
314:            public void testNamedGlobalBeanPrefix() throws Exception {
315:                setupSite("site/globals.xml");
316:                WebConversation conversation = new WebConversation();
317:                WebRequest request = new GetMethodWebRequest(
318:                        "http://localhost:8181/globals/namedbean/prefix");
319:                WebResponse response = null;
320:
321:                response = conversation.getResponse(request);
322:                assertEquals(
323:                        "the string,the stringbuffer,23154,893749,u,null,true,false,0,21,34878.34,25435.98,3434.76,6534.8,34347897,2335454,32,12",
324:                        response.getText());
325:            }
326:
327:            public void testGlobalExitSnapback() throws Exception {
328:                setupSite("site/globals.xml");
329:                WebConversation conversation = new WebConversation();
330:                WebRequest request = null;
331:                WebResponse response = null;
332:
333:                request = new GetMethodWebRequest(
334:                        "http://localhost:8181/globals/snapback/source");
335:                request.setParameter("activate_exit", "1");
336:                response = conversation.getResponse(request);
337:
338:                assertEquals("this is the output of SnapbackPassthrough"
339:                        + "the content of SnapbackSource", response.getText());
340:            }
341:
342:            public void testGlobalCookiesValid() throws Exception {
343:                setupSite("site/globals.xml");
344:
345:                HttpUtils.Page page = null;
346:
347:                // initial page that accepts and overrides cookies
348:
349:                page = new HttpUtils.Request(
350:                        "http://localhost:8181/globals/globalcookie/valid/source")
351:                        .cookie("cookie1", "cookie1").cookie("cookie2",
352:                                "cookie2").cookie("cookie3", "cookie3")
353:                        .retrieve();
354:                // check if the correct cookies were returned
355:                assertTrue(page.checkReceivedCookies(new Cookie[] {
356:                        new Cookie("cookie1", "cookie4"),
357:                        new Cookie("cookie2", "cookie5"),
358:                        new Cookie("cookie3", "cookie6"), }));
359:
360:                // new page with cookie context
361:                page = new HttpUtils.Request(
362:                        "http://localhost:8181/globals/globalcookie/valid/destination")
363:                        .cookie("cookie1", "cookie7").cookie("cookie2",
364:                                "cookie8").cookie("cookie3", "cookie9")
365:                        .retrieve();
366:                assertEquals("cookie7,cookie8,cookie9", page.getContent());
367:            }
368:
369:            public void testGlobalCookiesInvalid() throws Exception {
370:                setupSite("site/globals.xml");
371:
372:                HttpUtils.Page page = null;
373:
374:                try {
375:                    page = new HttpUtils.Request(
376:                            "http://localhost:8181/globals/globalcookie/invalid/source")
377:                            .cookie("cookie1", "this is the first cookie")
378:                            .cookie("cookie2", "this is the second cookie")
379:                            .cookie("cookie3", "this is the third cookie")
380:                            .retrieve();
381:                    fail();
382:                    assertNotNull(page);
383:                } catch (Exception e) {
384:                    assertTrue(getLogSink().getInternalException() instanceof  IncookieUnknownException);
385:
386:                    IncookieUnknownException e2 = (IncookieUnknownException) getLogSink()
387:                            .getInternalException();
388:                    assertEquals("cookie3", e2.getIncookieName());
389:                }
390:
391:                try {
392:                    page = new HttpUtils.Request(
393:                            "http://localhost:8181/globals/globalcookie/invalid/source2")
394:                            .cookie("cookie1", "this is the first cookie")
395:                            .cookie("cookie2", "this is the second cookie")
396:                            .retrieve();
397:                    fail();
398:                } catch (Exception e) {
399:                    assertTrue(getLogSink().getInternalException() instanceof  OutcookieUnknownException);
400:
401:                    OutcookieUnknownException e2 = (OutcookieUnknownException) getLogSink()
402:                            .getInternalException();
403:                    assertEquals("cookie3", e2.getOutcookieName());
404:                }
405:            }
406:
407:            public void testGlobalCookiesDefault() throws Exception {
408:                setupSite("site/globals.xml");
409:
410:                HttpUtils.Page page = HttpUtils
411:                        .retrievePage("http://localhost:8181/globals/globalcookie/defaults");
412:
413:                assertEquals("defcookie1 : the first cookie"
414:                        + "defcookie3 : the element config value", page
415:                        .getContent());
416:
417:                // check if the correct cookies were returned
418:                assertTrue(page.checkReceivedCookies(new Cookie[] {
419:                        new Cookie("defcookie4",
420:                                "the%20element%20config%20value"),
421:                        new Cookie("defcookie5", "the%20fifth%20cookie") }));
422:            }
423:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.