Source Code Cross Referenced for MockActionMapping.java in  » Testing » mockrunner-0.4 » com » mockrunner » mock » web » 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 » Testing » mockrunner 0.4 » com.mockrunner.mock.web 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package com.mockrunner.mock.web;
02:
03:        import java.util.HashMap;
04:        import java.util.Iterator;
05:        import java.util.Map;
06:
07:        import org.apache.struts.action.ActionForward;
08:        import org.apache.struts.action.ActionMapping;
09:
10:        /**
11:         * Mock implementation of <code>ActionMapping</code>.
12:         */
13:        public class MockActionMapping extends ActionMapping {
14:            private Map forwards;
15:
16:            public MockActionMapping() {
17:                super ();
18:                forwards = new HashMap();
19:            }
20:
21:            /**
22:             * Clears all specified forwards.
23:             */
24:            public void clearForwards() {
25:                forwards.clear();
26:            }
27:
28:            /**
29:             * Always return a valid <code>ActionForward</code>
30:             * since we do not care if it exists in the
31:             * struts-config. If an <code>ActionForward</code>
32:             * was defined using {@link #addForward},
33:             * this <code>ActionForward</code> will be returned.
34:             * Otherwise a new <code>ActionForward</code>
35:             * (with equal name and path) will be returned.
36:             * @param name the name
37:             * @return the corresponding <code>ActionForward</code>
38:             */
39:            public ActionForward findForward(String name) {
40:                Iterator iterator = forwards.keySet().iterator();
41:                while (iterator.hasNext()) {
42:                    String key = (String) iterator.next();
43:                    if (key.equals(name)) {
44:                        return (ActionForward) forwards.get(key);
45:                    }
46:                }
47:                return new MockActionForward(name, name, false);
48:            }
49:
50:            /**
51:             * Adds an <code>ActionForward</code>
52:             * with the specified name and path.
53:             * @param forwardName the name of the forward
54:             * @param forwardPath the path of the forward
55:             */
56:            public void addForward(String forwardName, String forwardPath) {
57:                ActionForward forward = new MockActionForward(forwardName,
58:                        forwardPath, false);
59:                forwards.put(forwardName, forward);
60:            }
61:
62:            /**
63:             * Sets multiple <code>ActionForward</code> objects
64:             * with equal name and path.
65:             * @param forwardNames the forward names
66:             */
67:            public void setupForwards(String[] forwardNames) {
68:                if (null == forwardNames)
69:                    return;
70:                for (int ii = 0; ii < forwardNames.length; ii++) {
71:                    String name = forwardNames[ii];
72:                    ActionForward forward = new MockActionForward(name, name,
73:                            false);
74:                    forwards.put(name, forward);
75:                }
76:            }
77:
78:            /**
79:             * Returns all forward names (set using {@link #addForward}
80:             * or {@link #setupForwards}).
81:             * @return the forward names
82:             */
83:            public String[] findForwards() {
84:                return (String[]) forwards.keySet().toArray(
85:                        new String[forwards.size()]);
86:            }
87:
88:            /**
89:             * Always return a valid <code>ActionForward</code>.
90:             * The input parameter of this mapping will be used
91:             * as the name and path for the <code>ActionForward</code>.
92:             */
93:            public ActionForward getInputForward() {
94:                return new MockActionForward(getInput(), getInput(), false);
95:            }
96:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.