Source Code Cross Referenced for MockContainer.java in  » Testing » jakarta-cactus » org » apache » cactus » integration » ant » container » 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 » jakarta cactus » org.apache.cactus.integration.ant.container 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * ========================================================================
003:         * 
004:         * Copyright 2003-2004 The Apache Software Foundation.
005:         *
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         * 
010:         *   http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         * 
018:         * ========================================================================
019:         */
020:        package org.apache.cactus.integration.ant.container;
021:
022:        import java.io.File;
023:
024:        import junit.framework.Assert;
025:
026:        import org.apache.cactus.integration.ant.deployment.DeployableFile;
027:        import org.apache.cactus.integration.ant.util.AntTaskFactory;
028:        import org.apache.commons.logging.Log;
029:        import org.apache.tools.ant.types.Path;
030:        import org.apache.tools.ant.types.Environment.Variable;
031:
032:        /**
033:         * Mock implementation of the {@link Container} interface.
034:         *
035:         * @version $Id: MockContainer.java 239130 2005-01-29 15:49:18Z vmassol $
036:         */
037:        public final class MockContainer implements  Container {
038:            // Instance Variables ------------------------------------------------------
039:
040:            /**
041:             * The dummy server.
042:             */
043:            private MockHttpServer server;
044:
045:            /**
046:             * Whether it is expected that the startUp() method is called.
047:             * <code>null</code> for "Don't care".
048:             */
049:            private Boolean expectedStartUpCalled;
050:
051:            /**
052:             * Whether the startUp() method was called.
053:             */
054:            private boolean startUpCalled;
055:
056:            /**
057:             * Whether it is expected that the shutDown() method is called.
058:             * <code>null</code> for "Don't care".
059:             */
060:            private Boolean expectedShutDownCalled;
061:
062:            /**
063:             * Whether the shutDown() method was called.
064:             */
065:            private boolean shutDownCalled;
066:
067:            // Constructors ------------------------------------------------------------
068:
069:            /**
070:             * Constructor.
071:             * 
072:             * @param theServer The dummy HTTP server
073:             */
074:            public MockContainer(MockHttpServer theServer) {
075:                this .server = theServer;
076:            }
077:
078:            /**
079:             * Constructor.
080:             */
081:            public MockContainer() {
082:            }
083:
084:            // Container Implementation ------------------------------------------------
085:
086:            /**
087:             * @see Container#getName()
088:             */
089:            public String getName() {
090:                return null;
091:            }
092:
093:            /**
094:             * @see Container#getTestContext()
095:             */
096:            public String getTestContext() {
097:                return null;
098:            }
099:
100:            /**
101:             * @see Container#getStartUpWait()
102:             */
103:            public long getStartUpWait() {
104:                return 0;
105:            }
106:
107:            /**
108:             * @see Container#getPort()
109:             */
110:            public int getPort() {
111:                return 0;
112:            }
113:
114:            /**
115:             * @see Container#getToDir()
116:             */
117:            public File getToDir() {
118:                return null;
119:            }
120:
121:            /**
122:             * @see Container#init()
123:             */
124:            public void init() {
125:            }
126:
127:            /**
128:             * @see Container#isEnabled()
129:             */
130:            public boolean isEnabled() {
131:                return false;
132:            }
133:
134:            /**
135:             * @see Container#isExcluded(java.lang.String)
136:             */
137:            public boolean isExcluded(String theTestName) {
138:                return false;
139:            }
140:
141:            /**
142:             * @see Container#setAntTaskFactory(AntTaskFactory)
143:             */
144:            public void setAntTaskFactory(AntTaskFactory theFactory) {
145:            }
146:
147:            /**
148:             * @see Container#setLog(Log)
149:             */
150:            public void setLog(Log theLog) {
151:            }
152:
153:            /**
154:             * @see Container#setDeployableFile
155:             */
156:            public void setDeployableFile(DeployableFile theWarFile) {
157:            }
158:
159:            /**
160:             * @see Container#startUp()
161:             */
162:            public void startUp() {
163:                this .startUpCalled = true;
164:                if (this .server != null) {
165:                    Thread thread = new Thread(this .server);
166:                    thread.start();
167:                }
168:            }
169:
170:            /**
171:             * @see Container#shutDown()
172:             */
173:            public void shutDown() {
174:                this .shutDownCalled = true;
175:                if (this .server != null) {
176:                    this .server.stop();
177:                }
178:            }
179:
180:            /**
181:             * @see Container#getServer()
182:             */
183:            public String getServer() {
184:                return null;
185:            }
186:
187:            /**
188:             * @see Container#getProtocol()
189:             */
190:            public String getProtocol() {
191:                return null;
192:            }
193:
194:            /**
195:             * @see Container#getBaseURL()
196:             */
197:            public String getBaseURL() {
198:                return null;
199:            }
200:
201:            // Public Methods ----------------------------------------------------------
202:
203:            /**
204:             * Sets whether to expect a call to the startUp() method.
205:             *
206:             * @param isExpected Whether a call is expected or not 
207:             */
208:            public void expectStartUpCalled(boolean isExpected) {
209:                this .expectedStartUpCalled = isExpected ? Boolean.TRUE
210:                        : Boolean.FALSE;
211:            }
212:
213:            /**
214:             * Sets whether to expect a call to the shutDown() method.
215:             *
216:             * @param isExpected Whether a call is expected or not 
217:             */
218:            public void expectShutDownCalled(boolean isExpected) {
219:                this .expectedShutDownCalled = isExpected ? Boolean.TRUE
220:                        : Boolean.FALSE;
221:            }
222:
223:            /**
224:             * Verify the mock object's state.
225:             */
226:            public void verify() {
227:                if (this .expectedStartUpCalled != null) {
228:                    Assert
229:                            .assertTrue(
230:                                    "The startUp() method should "
231:                                            + (this .expectedStartUpCalled
232:                                                    .booleanValue() ? ""
233:                                                    : "not ")
234:                                            + "have been called",
235:                                    this .expectedStartUpCalled.booleanValue() == startUpCalled);
236:                }
237:                if (this .expectedShutDownCalled != null) {
238:                    Assert
239:                            .assertTrue(
240:                                    "The shutDown() method should "
241:                                            + (this .expectedShutDownCalled
242:                                                    .booleanValue() ? ""
243:                                                    : "not ")
244:                                            + "have been called",
245:                                    this .expectedShutDownCalled.booleanValue() == shutDownCalled);
246:                }
247:            }
248:
249:            /** 
250:             * @see Container#setSystemProperties(Variable[])
251:             */
252:            public void setSystemProperties(Variable[] theProperties) {
253:                // do nothing
254:            }
255:
256:            /**
257:             * @see Container#getSystemProperties()
258:             */
259:            public Variable[] getSystemProperties() {
260:                throw new RuntimeException("not implemented");
261:            }
262:
263:            /**
264:             * @see Container#setContainerClasspath(Path)
265:             */
266:            public void setContainerClasspath(Path theClasspath) {
267:                // do nothing
268:            }
269:
270:            /**
271:             * @see Container#getContainerClasspath()
272:             */
273:            public Path getContainerClasspath() {
274:                throw new RuntimeException("not implemented");
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.