Source Code Cross Referenced for AbstractDeploymentTest.java in  » Net » Terracotta » com » tc » test » server » appserver » deployment » 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 » Net » Terracotta » com.tc.test.server.appserver.deployment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package com.tc.test.server.appserver.deployment;
006:
007:        import org.apache.commons.logging.Log;
008:        import org.apache.commons.logging.LogFactory;
009:
010:        import com.tc.test.TCTestCase;
011:        import com.tc.test.TestConfigObject;
012:        import com.tc.test.server.appserver.AppServerFactory;
013:        import com.tc.test.server.util.TcConfigBuilder;
014:
015:        import java.util.ArrayList;
016:        import java.util.Date;
017:        import java.util.HashMap;
018:        import java.util.Iterator;
019:        import java.util.List;
020:        import java.util.Map;
021:
022:        public abstract class AbstractDeploymentTest extends TCTestCase {
023:
024:            protected Log logger = LogFactory.getLog(getClass());
025:
026:            private ServerManager serverManager;
027:            private WatchDog watchDog;
028:
029:            Map disabledVariants = new HashMap();
030:            List disabledJavaVersion = new ArrayList();
031:
032:            private static final int TIMEOUT_DEFAULT = 30 * 60;
033:
034:            public AbstractDeploymentTest() {
035:                int id = AppServerFactory.getCurrentAppServerId();
036:                boolean glassFishOrJetty = (id == AppServerFactory.GLASSFISH || id == AppServerFactory.JETTY);
037:                if (isSessionTest() && glassFishOrJetty) {
038:                    disableAllUntil(new Date(Long.MAX_VALUE));
039:                }
040:            }
041:
042:            protected void beforeTimeout() throws Throwable {
043:                getServerManager().timeout();
044:            }
045:
046:            protected boolean shouldKillAppServersEachRun() {
047:                return true;
048:            }
049:
050:            protected boolean isSessionTest() {
051:                return true;
052:            }
053:
054:            public void runBare() throws Throwable {
055:
056:                if (shouldDisable()) {
057:                    return;
058:                }
059:
060:                watchDog = new WatchDog(getTimeout());
061:                try {
062:                    watchDog.startWatching();
063:                    super .runBare();
064:                } finally {
065:                    watchDog.stopWatching();
066:                }
067:            }
068:
069:            protected ServerManager getServerManager() {
070:                if (serverManager == null) {
071:                    try {
072:                        serverManager = ServerManagerUtil.startAndBind(
073:                                getClass(), isWithPersistentStore());
074:                    } catch (Exception e) {
075:                        throw new RuntimeException(
076:                                "Unable to create server manager; "
077:                                        + e.toString(), e);
078:                    }
079:                }
080:                return serverManager;
081:            }
082:
083:            protected int getTimeout() {
084:                String timeout = TestConfigObject.getInstance()
085:                        .springTestsTimeout();
086:                if (timeout == null) {
087:                    return TIMEOUT_DEFAULT;
088:                } else {
089:                    return Integer.parseInt(timeout);
090:                }
091:            }
092:
093:            protected void tearDown() throws Exception {
094:                if (shouldKillAppServersEachRun()) {
095:                    ServerManagerUtil.stopAllWebServers(serverManager);
096:                }
097:                super .tearDown();
098:            }
099:
100:            /**
101:             * tcConfig: resource path to tc-config.xml
102:             */
103:            protected WebApplicationServer makeWebApplicationServer(
104:                    String tcConfig) throws Exception {
105:                return getServerManager().makeWebApplicationServer(tcConfig);
106:            }
107:
108:            protected WebApplicationServer makeWebApplicationServer(
109:                    TcConfigBuilder configBuilder) throws Exception {
110:                return getServerManager().makeWebApplicationServer(
111:                        configBuilder);
112:            }
113:
114:            protected void restartDSO() throws Exception {
115:                getServerManager().restartDSO(isWithPersistentStore());
116:            }
117:
118:            protected DeploymentBuilder makeDeploymentBuilder(String warFileName) {
119:                return getServerManager().makeDeploymentBuilder(warFileName);
120:            }
121:
122:            // XXX: This causes the bad war file name which breaks WLS tests
123:            // protected DeploymentBuilder makeDeploymentBuilder() throws IOException {
124:            // return serverManager.makeDeploymentBuilder();
125:            // }
126:
127:            protected void waitForSuccess(int timeoutInSeconds,
128:                    TestCallback callback) throws Throwable {
129:                long startingTime = System.currentTimeMillis();
130:                long timeout = timeoutInSeconds * 1000;
131:                while (true) {
132:                    try {
133:                        logger.debug("checking");
134:                        callback.check();
135:                        logger.debug("check passed");
136:                        return;
137:                    } catch (Throwable e) {
138:                        logger.debug("check failed");
139:                        if ((System.currentTimeMillis() - startingTime) >= timeout) {
140:                            logger.debug("check timed out", e);
141:                            throw e;
142:                        }
143:                    }
144:                    logger.debug("check sleeping");
145:                    Thread.sleep(100L);
146:                }
147:            }
148:
149:            protected void stopAllWebServers() {
150:                ServerManagerUtil.stopAllWebServers(getServerManager());
151:            }
152:
153:            public boolean isWithPersistentStore() {
154:                return false;
155:            }
156:
157:            protected final boolean cleanTempDir() {
158:                return false;
159:            }
160:
161:            protected void disableVariant(String variantName,
162:                    String variantValue) {
163:                List variantList = (List) disabledVariants.get(variantName);
164:                if (variantList == null) {
165:                    variantList = new ArrayList();
166:                    disabledVariants.put(variantName, variantList);
167:                }
168:                variantList.add(variantValue);
169:            }
170:
171:            protected void disableForJavaVersion(String version) {
172:                this .disabledJavaVersion.add(version);
173:            }
174:
175:            void disableAllTests() {
176:                this .disableAllUntil(new Date(Long.MAX_VALUE));
177:            }
178:
179:            public boolean shouldDisable() {
180:                return isAllDisabled() || shouldDisableForJavaVersion()
181:                        || shouldDisableForVariants();
182:            }
183:
184:            private boolean shouldDisableForVariants() {
185:                for (Iterator iter = disabledVariants.entrySet().iterator(); iter
186:                        .hasNext();) {
187:                    Map.Entry entry = (Map.Entry) iter.next();
188:                    String variantName = (String) entry.getKey();
189:                    List variants = (List) entry.getValue();
190:                    String selected = getServerManager().getTestConfig()
191:                            .selectedVariantFor(variantName);
192:                    if (variants.contains(selected)) {
193:                        logger.warn("Test " + getName() + " is disabled for "
194:                                + variantName + " = " + selected);
195:                        return true;
196:                    }
197:                }
198:                return false;
199:            }
200:
201:            private boolean shouldDisableForJavaVersion() {
202:                String currentVersion = System.getProperties().getProperty(
203:                        "java.version");
204:                for (Iterator iter = disabledJavaVersion.iterator(); iter
205:                        .hasNext();) {
206:                    String version = (String) iter.next();
207:                    if (currentVersion.matches(version)) {
208:                        logger.warn("Test " + getName() + " is disabled for "
209:                                + version);
210:                        return true;
211:                    }
212:                }
213:                return false;
214:            }
215:
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.