Source Code Cross Referenced for TestConfigurationProvider.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » 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 » J2EE » webwork 2.2.6 » com.opensymphony.webwork 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2003 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork;
006:
007:        import com.opensymphony.webwork.dispatcher.ServletDispatcherResult;
008:        import com.opensymphony.webwork.interceptor.TokenInterceptor;
009:        import com.opensymphony.webwork.interceptor.TokenSessionStoreInterceptor;
010:        import com.opensymphony.xwork.Action;
011:        import com.opensymphony.xwork.ActionChainResult;
012:        import com.opensymphony.xwork.config.Configuration;
013:        import com.opensymphony.xwork.config.ConfigurationProvider;
014:        import com.opensymphony.xwork.config.entities.ActionConfig;
015:        import com.opensymphony.xwork.config.entities.PackageConfig;
016:        import com.opensymphony.xwork.config.entities.ResultConfig;
017:        import com.opensymphony.xwork.config.entities.InterceptorMapping;
018:        import com.opensymphony.xwork.interceptor.ParametersInterceptor;
019:
020:        import java.util.ArrayList;
021:        import java.util.HashMap;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        /**
026:         * TestConfigurationProvider provides a simple configuration class without the need for xml files, etc. for simple testing.
027:         *
028:         * @author $author$
029:         */
030:        public class TestConfigurationProvider implements  ConfigurationProvider {
031:
032:            public static final String TEST_ACTION_NAME = "testAction";
033:            public static final String EXECUTION_COUNT_ACTION_NAME = "executionCountAction";
034:            public static final String TOKEN_ACTION_NAME = "tokenAction";
035:            public static final String TOKEN_SESSION_ACTION_NAME = "tokenSessionAction";
036:            public static final String TEST_NAMESPACE = "/testNamespace";
037:            public static final String TEST_NAMESPACE_ACTION = "testNamespaceAction";
038:
039:            /**
040:             * Allows the configuration to clean up any resources used
041:             */
042:            public void destroy() {
043:            }
044:
045:            /**
046:             * Initializes the configuration object.
047:             */
048:            public void init(Configuration configurationManager) {
049:                PackageConfig defaultPackageConfig = new PackageConfig();
050:
051:                HashMap results = new HashMap();
052:
053:                HashMap successParams = new HashMap();
054:                successParams.put("propertyName", "executionCount");
055:                successParams.put("expectedValue", "1");
056:
057:                ResultConfig successConfig = new ResultConfig(Action.SUCCESS,
058:                        TestResult.class.getName(), successParams);
059:
060:                results.put(Action.SUCCESS, successConfig);
061:
062:                List interceptors = new ArrayList();
063:
064:                ActionConfig executionCountActionConfig = new ActionConfig(
065:                        null, ExecutionCountTestAction.class, null, results,
066:                        interceptors);
067:                defaultPackageConfig
068:                        .addActionConfig(EXECUTION_COUNT_ACTION_NAME,
069:                                executionCountActionConfig);
070:
071:                results = new HashMap();
072:
073:                successParams = new HashMap();
074:                successParams.put("location", "success.jsp");
075:
076:                successConfig = new ResultConfig(Action.SUCCESS,
077:                        ServletDispatcherResult.class.getName(), successParams);
078:
079:                results.put(Action.SUCCESS, successConfig);
080:
081:                interceptors.add(new InterceptorMapping("params",
082:                        new ParametersInterceptor()));
083:
084:                ActionConfig testActionConfig = new ActionConfig(null,
085:                        TestAction.class, null, results, interceptors);
086:                defaultPackageConfig.addActionConfig(TEST_ACTION_NAME,
087:                        testActionConfig);
088:
089:                interceptors = new ArrayList();
090:                interceptors.add(new InterceptorMapping("token",
091:                        new TokenInterceptor()));
092:
093:                results = new HashMap();
094:
095:                ActionConfig tokenActionConfig = new ActionConfig(null,
096:                        TestAction.class, null, results, interceptors);
097:                defaultPackageConfig.addActionConfig(TOKEN_ACTION_NAME,
098:                        tokenActionConfig);
099:
100:                interceptors = new ArrayList();
101:                interceptors.add(new InterceptorMapping("token-session",
102:                        new TokenSessionStoreInterceptor()));
103:
104:                results = new HashMap();
105:
106:                successParams = new HashMap();
107:                successParams.put("actionName", EXECUTION_COUNT_ACTION_NAME);
108:
109:                successConfig = new ResultConfig(Action.SUCCESS,
110:                        ActionChainResult.class.getName(), successParams);
111:
112:                results.put(Action.SUCCESS, successConfig);
113:
114:                // empty results for token session unit test
115:                results = new HashMap();
116:                ActionConfig tokenSessionActionConfig = new ActionConfig(null,
117:                        TestAction.class, null, results, interceptors);
118:                defaultPackageConfig.addActionConfig(TOKEN_SESSION_ACTION_NAME,
119:                        tokenSessionActionConfig);
120:
121:                configurationManager.addPackageConfig("defaultPackage",
122:                        defaultPackageConfig);
123:
124:                Map testActionTagResults = new HashMap();
125:                testActionTagResults.put(Action.SUCCESS, new ResultConfig(
126:                        Action.SUCCESS, TestActionTagResult.class.getName(),
127:                        new HashMap()));
128:                testActionTagResults.put(Action.INPUT, new ResultConfig(
129:                        Action.INPUT, TestActionTagResult.class.getName(),
130:                        new HashMap()));
131:                ActionConfig testActionTagActionConfig = new ActionConfig(
132:                        (String) null, TestAction.class, (Map) null,
133:                        testActionTagResults, new ArrayList());
134:                defaultPackageConfig.addActionConfig("testActionTagAction",
135:                        testActionTagActionConfig);
136:
137:                PackageConfig namespacePackageConfig = new PackageConfig();
138:                namespacePackageConfig.setNamespace(TEST_NAMESPACE);
139:                namespacePackageConfig.addParent(defaultPackageConfig);
140:
141:                ActionConfig namespaceAction = new ActionConfig(null,
142:                        TestAction.class, null, null, null);
143:                namespacePackageConfig.addActionConfig(TEST_NAMESPACE_ACTION,
144:                        namespaceAction);
145:
146:                configurationManager.addPackageConfig("namespacePackage",
147:                        namespacePackageConfig);
148:            }
149:
150:            /**
151:             * Tells whether the ConfigurationProvider should reload its configuration
152:             *
153:             * @return
154:             */
155:            public boolean needsReload() {
156:                return false;
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.