Source Code Cross Referenced for JBossTestSetup.java in  » EJB-Server-JBoss-4.2.1 » test » org » jboss » test » 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 » EJB Server JBoss 4.2.1 » test » org.jboss.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.test;
023:
024:        import java.net.MalformedURLException;
025:        import java.net.URL;
026:
027:        import javax.management.MBeanServerConnection;
028:        import javax.management.MalformedObjectNameException;
029:        import javax.management.ObjectName;
030:        import javax.naming.InitialContext;
031:
032:        import junit.extensions.TestSetup;
033:        import junit.framework.Test;
034:
035:        import org.apache.log4j.Category;
036:
037:        /**
038:         * This is a TestSetup class for jboss junit test cases that provides the
039:         * jboss test services. It supplies
040:         * access to log4j logging, the jboss jmx server, jndi, and a method for
041:         * deploying ejb packages. You may supply the name of the machine the jboss
042:         * server is on with the system property jbosstest.server.name (default
043:         * getInetAddress().getLocalHost().getHostName()) and the directory for
044:         * deployable packages with the system property jbosstest.deploy.dir (default
045:         * ../lib).
046:         *
047:         * Should be sublassed to derive junit support for specific services integrated
048:         * into JBoss.
049:         *
050:         * @author    <a href="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
051:         * @author    <a href="mailto:christoph.jung@jboss.org">Christoph G. Jung</a>
052:         * @version   $Revision: 60041 $
053:         */
054:        public class JBossTestSetup extends TestSetup {
055:            protected JBossTestServices delegate;
056:
057:            /**
058:             * Constructor for the JBossTestCase object
059:             */
060:            public JBossTestSetup(Test test) throws Exception {
061:                super (test);
062:                delegate = createTestServices();
063:                delegate.init();
064:            }
065:
066:            protected JBossTestServices createTestServices() {
067:                return new JBossTestServices(getClass().getName());
068:            }
069:
070:            /**
071:             * Gets the InitialContext attribute of the JBossTestCase object
072:             *
073:             * @return   The InitialContext value
074:             */
075:            protected InitialContext getInitialContext() throws Exception {
076:                return delegate.getInitialContext();
077:            }
078:
079:            /**
080:             * Gets the Server attribute of the JBossTestCase object
081:             *
082:             * @return   The Server value
083:             */
084:            protected MBeanServerConnection getServer() throws Exception {
085:                return delegate.getServer();
086:            }
087:
088:            /**
089:             * Gets the Log attribute of the JBossTestCase object
090:             *
091:             * @return   The Log value
092:             */
093:            protected Category getLog() {
094:                return delegate.getLog();
095:            }
096:
097:            /**
098:             * Gets the DeployerName attribute of the JBossTestCase object
099:             *
100:             * @return                                  The DeployerName value
101:             * @exception MalformedObjectNameException  Description of Exception
102:             */
103:            protected ObjectName getDeployerName()
104:                    throws MalformedObjectNameException {
105:                return delegate.getDeployerName();
106:            }
107:
108:            /**
109:             * Returns the deployment directory to use. This does it's best to figure out
110:             * where you are looking. If you supply a complete url, it returns it.
111:             * Otherwise, it looks for jbosstest.deploy.dir or if missing ../lib. Then it
112:             * tries to construct a file url or a url.
113:             *
114:             * @param filename                   name of the file/url you want
115:             * @return                           A more or less canonical string for the url.
116:             * @exception MalformedURLException  Description of Exception
117:             */
118:            protected URL getDeployURL(final String filename)
119:                    throws MalformedURLException {
120:                return delegate.getDeployURL(filename);
121:            }
122:
123:            protected String getResourceURL(final String path) {
124:                ClassLoader loader = Thread.currentThread()
125:                        .getContextClassLoader();
126:                URL resURL = loader.getResource(path);
127:                String resPath = resURL != null ? resURL.toString() : null;
128:                return resPath;
129:            }
130:
131:            /**
132:             * invoke wraps an invoke call to the mbean server in a lot of exception
133:             * unwrapping.
134:             *
135:             * @param name           ObjectName of the mbean to be called
136:             * @param method         mbean method to be called
137:             * @param args           Object[] of arguments for the mbean method.
138:             * @param sig            String[] of types for the mbean methods parameters.
139:             * @return               Object returned by mbean method invocation.
140:             * @exception Exception  Description of Exception
141:             */
142:            protected Object invoke(ObjectName name, String method,
143:                    Object[] args, String[] sig) throws Exception {
144:                return delegate.invoke(name, method, args, sig);
145:            }
146:
147:            /**
148:             * Deploy a package with the main deployer. The supplied name is
149:             * interpreted as a url, or as a filename in jbosstest.deploy.lib or ../lib.
150:             *
151:             * @param name           filename/url of package to deploy.
152:             * @exception Exception  Description of Exception
153:             */
154:            protected void deploy(String name) throws Exception {
155:                delegate.deploy(name);
156:            }
157:
158:            protected void redeploy(String name) throws Exception {
159:                delegate.redeploy(name);
160:            }
161:
162:            /**
163:             * Undeploy a package with the main deployer. The supplied name is
164:             * interpreted as a url, or as a filename in jbosstest.deploy.lib or ../lib.
165:             *
166:             * @param name           filename/url of package to undeploy.
167:             * @exception Exception  Description of Exception
168:             */
169:            protected void undeploy(String name) throws Exception {
170:                delegate.undeploy(name);
171:            }
172:
173:            protected void flushAuthCache() throws Exception {
174:                flushAuthCache("other");
175:            }
176:
177:            protected void flushAuthCache(String domain) throws Exception {
178:                delegate.flushAuthCache(domain);
179:            }
180:
181:            /**
182:             * Validate the java.security.auth.login.config setting, and if not
183:             * found, set it to the security/auth.conf classpath resource value
184:             * if that exists.
185:             * @throws IllegalStateException if neither java.security.auth.login.config
186:             * is set and no security/auth.conf classpath resource exists.
187:             */
188:            protected void initDefaultLoginConfig() {
189:                String authConf = System
190:                        .getProperty("java.security.auth.login.config");
191:                if (authConf == null) {
192:                    try {
193:                        String confURL = getResourceURL("security/auth.conf");
194:                        if (confURL == null)
195:                            throw new IllegalStateException(
196:                                    "No java.security.auth.login.config specified and security/auth.conf not found");
197:                        System.setProperty("java.security.auth.login.config",
198:                                confURL);
199:                    } catch (Exception ignore) {
200:                    }
201:                }
202:            }
203:
204:            /** Restart the connection pool associated with the DefaultDS
205:             * @throws Exception on failure
206:             */
207:            protected void restartDBPool() throws Exception {
208:                delegate.restartDBPool();
209:            }
210:
211:            protected String getJndiURL() {
212:                return delegate.getJndiURL();
213:            }
214:
215:            protected String getJndiInitFactory() {
216:                return delegate.getJndiInitFactory();
217:            }
218:
219:            protected int getThreadCount() {
220:                return delegate.getThreadCount();
221:            }
222:
223:            protected int getIterationCount() {
224:                return delegate.getIterationCount();
225:            }
226:
227:            protected int getBeanCount() {
228:                return delegate.getBeanCount();
229:            }
230:
231:            /**
232:             * Get the JBoss server host from system property "jbosstest.host.name"
233:             * This defaults to "localhost"
234:             */
235:            public String getServerHost() {
236:                return delegate.getServerHost();
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.