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


001:        /*
002:         * Copyright (c) 2002-2006 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.xwork.mock;
006:
007:        import com.opensymphony.xwork.interceptor.Interceptor;
008:        import com.opensymphony.xwork.ActionInvocation;
009:        import junit.framework.Assert;
010:
011:        /**
012:         * Mock for an {@link com.opensymphony.xwork.interceptor.Interceptor}.
013:         *
014:         * @author Jason Carreira
015:         */
016:        public class MockInterceptor implements  Interceptor {
017:
018:            private static final long serialVersionUID = 2692551676567227756L;
019:
020:            public static final String DEFAULT_FOO_VALUE = "fooDefault";
021:
022:            private String expectedFoo = DEFAULT_FOO_VALUE;
023:            private String foo = DEFAULT_FOO_VALUE;
024:            private boolean executed = false;
025:
026:            public boolean isExecuted() {
027:                return executed;
028:            }
029:
030:            public void setExpectedFoo(String expectedFoo) {
031:                this .expectedFoo = expectedFoo;
032:            }
033:
034:            public String getExpectedFoo() {
035:                return expectedFoo;
036:            }
037:
038:            public void setFoo(String foo) {
039:                this .foo = foo;
040:            }
041:
042:            public String getFoo() {
043:                return foo;
044:            }
045:
046:            /**
047:             * Called to let an interceptor clean up any resources it has allocated.
048:             */
049:            public void destroy() {
050:            }
051:
052:            public boolean equals(Object o) {
053:                if (this  == o) {
054:                    return true;
055:                }
056:
057:                if (!(o instanceof  MockInterceptor)) {
058:                    return false;
059:                }
060:
061:                final MockInterceptor testInterceptor = (MockInterceptor) o;
062:
063:                if (executed != testInterceptor.executed) {
064:                    return false;
065:                }
066:
067:                if ((expectedFoo != null) ? (!expectedFoo
068:                        .equals(testInterceptor.expectedFoo))
069:                        : (testInterceptor.expectedFoo != null)) {
070:                    return false;
071:                }
072:
073:                if ((foo != null) ? (!foo.equals(testInterceptor.foo))
074:                        : (testInterceptor.foo != null)) {
075:                    return false;
076:                }
077:
078:                return true;
079:            }
080:
081:            public int hashCode() {
082:                int result;
083:                result = ((expectedFoo != null) ? expectedFoo.hashCode() : 0);
084:                result = (29 * result) + ((foo != null) ? foo.hashCode() : 0);
085:                result = (29 * result) + (executed ? 1 : 0);
086:
087:                return result;
088:            }
089:
090:            /**
091:             * Called after an Interceptor is created, but before any requests are processed using the intercept() methodName. This
092:             * gives the Interceptor a chance to initialize any needed resources.
093:             */
094:            public void init() {
095:            }
096:
097:            /**
098:             * Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the
099:             * request by the DefaultActionInvocation or to short-circuit the processing and just return a String return code.
100:             */
101:            public String intercept(ActionInvocation invocation)
102:                    throws Exception {
103:                executed = true;
104:                Assert.assertNotSame(DEFAULT_FOO_VALUE, foo);
105:                Assert.assertEquals(expectedFoo, foo);
106:
107:                return invocation.invoke();
108:            }
109:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.