Source Code Cross Referenced for ComponentActionDispatcherTest.java in  » Web-Framework » Tapestry » org » apache » tapestry » internal » services » 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 » Tapestry » org.apache.tapestry.internal.services 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright 2007 The Apache Software Foundation
002:        //
003:        // Licensed under the Apache License, Version 2.0 (the "License");
004:        // you may not use this file except in compliance with the License.
005:        // You may obtain a copy of the License at
006:        //
007:        //     http://www.apache.org/licenses/LICENSE-2.0
008:        //
009:        // Unless required by applicable law or agreed to in writing, software
010:        // distributed under the License is distributed on an "AS IS" BASIS,
011:        // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        // See the License for the specific language governing permissions and
013:        // limitations under the License.
014:
015:        package org.apache.tapestry.internal.services;
016:
017:        import static org.easymock.EasyMock.aryEq;
018:        import static org.easymock.EasyMock.eq;
019:
020:        import java.io.IOException;
021:
022:        import org.apache.tapestry.TapestryConstants;
023:        import org.apache.tapestry.internal.InternalConstants;
024:        import org.apache.tapestry.internal.test.InternalBaseTestCase;
025:        import org.apache.tapestry.services.ActionResponseGenerator;
026:        import org.apache.tapestry.services.ComponentActionRequestHandler;
027:        import org.apache.tapestry.services.Dispatcher;
028:        import org.apache.tapestry.services.Request;
029:        import org.apache.tapestry.services.Response;
030:        import org.testng.annotations.Test;
031:
032:        public class ComponentActionDispatcherTest extends InternalBaseTestCase {
033:            @Test
034:            public void no_dot_or_colon_in_path() throws Exception {
035:                ComponentActionRequestHandler handler = newComponentActionRequestHandler();
036:                Request request = mockRequest();
037:                Response response = mockResponse();
038:
039:                train_getPath(request, "/foo/bar/baz");
040:
041:                replay();
042:
043:                Dispatcher dispatcher = new ComponentActionDispatcher(handler);
044:
045:                assertFalse(dispatcher.dispatch(request, response));
046:
047:                verify();
048:            }
049:
050:            protected final ComponentActionRequestHandler newComponentActionRequestHandler() {
051:                return newMock(ComponentActionRequestHandler.class);
052:            }
053:
054:            @Test
055:            public void event_on_page() throws Exception {
056:                test("/foo/MyPage:anevent", "foo/MyPage", "", "anevent");
057:            }
058:
059:            @Test
060:            public void event_on_component_within_page() throws Exception {
061:                test("/foo/MyPage.fred:anevent", "foo/MyPage", "fred",
062:                        "anevent");
063:            }
064:
065:            @Test
066:            public void default_event_with_nested_id() throws Exception {
067:                test("/foo/MyPage.fred", "foo/MyPage", "fred",
068:                        TapestryConstants.ACTION_EVENT);
069:            }
070:
071:            @Test
072:            public void default_event_with_nested_id_and_context()
073:                    throws Exception {
074:                test("/foo/MyPage.fred/fee/fie/foe/fum", "foo/MyPage", "fred",
075:                        TapestryConstants.ACTION_EVENT, "fee", "fie", "foe",
076:                        "fum");
077:            }
078:
079:            @Test
080:            public void default_event_with_context_that_includes_a_colon()
081:                    throws Exception {
082:                test("/foo/MyPage.underdog/a:b:c/d", "foo/MyPage", "underdog",
083:                        TapestryConstants.ACTION_EVENT, "a:b:c", "d");
084:            }
085:
086:            @Test
087:            public void event_on_nested_component_within_page()
088:                    throws Exception {
089:                test("/foo/MyPage.barney.fred:anevent", "foo/MyPage",
090:                        "barney.fred", "anevent");
091:            }
092:
093:            @Test
094:            public void page_event_with_context() throws Exception {
095:                test("/foo/MyPage:trigger/foo", "foo/MyPage", "", "trigger",
096:                        "foo");
097:            }
098:
099:            @Test
100:            public void nested_component_event_with_context() throws Exception {
101:                test("/foo/MyPage.nested:trigger/foo/bar/baz", "foo/MyPage",
102:                        "nested", "trigger", "foo", "bar", "baz");
103:            }
104:
105:            @Test
106:            public void page_activation_context_in_request() throws Exception {
107:                ComponentActionRequestHandler handler = newComponentActionRequestHandler();
108:                Request request = mockRequest();
109:                Response response = mockResponse();
110:                ActionResponseGenerator generator = newMock(ActionResponseGenerator.class);
111:
112:                train_getPath(request, "/mypage:eventname");
113:
114:                train_getParameter(request,
115:                        InternalConstants.PAGE_CONTEXT_NAME, "alpha/beta");
116:
117:                expect(
118:                        handler.handle(eq("mypage"), eq(""), eq("eventname"),
119:                                aryEq(new String[0]), aryEq(new String[] {
120:                                        "alpha", "beta" }))).andReturn(
121:                        generator);
122:
123:                generator.sendClientResponse(response);
124:
125:                replay();
126:
127:                Dispatcher dispatcher = new ComponentActionDispatcher(handler);
128:
129:                assertTrue(dispatcher.dispatch(request, response));
130:
131:                verify();
132:            }
133:
134:            private void test(String requestPath, String logicalPageName,
135:                    String nestedComponentId, String eventType,
136:                    String... context) throws IOException {
137:                ComponentActionRequestHandler handler = newComponentActionRequestHandler();
138:                Request request = mockRequest();
139:                Response response = mockResponse();
140:                ActionResponseGenerator generator = newMock(ActionResponseGenerator.class);
141:
142:                train_getPath(request, requestPath);
143:
144:                train_getParameter(request,
145:                        InternalConstants.PAGE_CONTEXT_NAME, null);
146:
147:                expect(
148:                        handler.handle(eq(logicalPageName),
149:                                eq(nestedComponentId), eq(eventType),
150:                                aryEq(context), aryEq(new String[0])))
151:                        .andReturn(generator);
152:
153:                generator.sendClientResponse(response);
154:
155:                replay();
156:
157:                Dispatcher dispatcher = new ComponentActionDispatcher(handler);
158:
159:                assertTrue(dispatcher.dispatch(request, response));
160:
161:                verify();
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.