You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2007/04/26 23:14:38 UTC
svn commit: r532867 -
/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java
Author: jlaskowski
Date: Thu Apr 26 14:14:38 2007
New Revision: 532867
URL: http://svn.apache.org/viewvc?view=rev&rev=532867
Log:
Introduce property constants -> the idea is to build a central place for all configuration data for OpenEJB
Modified:
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java?view=diff&rev=532867&r1=532866&r2=532867
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java Thu Apr 26 14:14:38 2007
@@ -34,28 +34,37 @@
private static TestJms jms;
private static boolean warn = true;
+ // TODO: Move it to a central place where all system properties are managed in a unified way
+ final static String TESTSUITE_PROPERTY_FILENAME = "openejb.testsuite.properties";
+ final static String TEST_SERVER_CLASSNAME = "openejb.test.server";
+ final static String TEST_DATABASE_CLASSNAME = "openejb.test.database";
+ final static String TEST_JMS_CLASSNAME = "openejb.test.jms";
+
public static void init(String propertiesFileName) throws Exception{
Properties props = null;
try{
props = new Properties(System.getProperties());
- warn = props.getProperty("openejb.test.nowarn") != null;
+ warn = props.getProperty("openejb.test.nowarn") == null;
} catch (SecurityException e){
throw new IllegalArgumentException("Cannot access the system properties: "+e.getClass().getName()+" "+e.getMessage());
}
if (propertiesFileName == null) {
try{
- propertiesFileName = System.getProperty("openejb.testsuite.properties");
-
+ propertiesFileName = System.getProperty(TESTSUITE_PROPERTY_FILENAME);
if (propertiesFileName == null) {
- if (warn) System.out.println("Warning: No test suite configuration file specified, assuming system properties contain all needed information. To specify a test suite configuration file by setting its location using the system property \"openejb.testsuite.properties\"");
+ if (warn) {
+ // TODO: Avoid using System.out
+ // TODO: i18n
+ System.out.println("WARNING: No test suite configuration file specified, assuming system properties contain all needed information. To specify a test suite configuration file by setting its location using the system property \"" + TESTSUITE_PROPERTY_FILENAME + "\"");
+ }
} else {
props.putAll( getProperties( propertiesFileName ) );
}
} catch (SecurityException e){
- throw new IllegalArgumentException("Cannot access the system property \"openejb.testsuite.properties\": "+e.getClass().getName()+" "+e.getMessage());
+ throw new IllegalArgumentException("Cannot access the system property \"" + TESTSUITE_PROPERTY_FILENAME + "\": "+e.getClass().getName()+" "+e.getMessage());
}
} else {
props.putAll( getProperties( propertiesFileName ) );
@@ -122,8 +131,11 @@
private static void initServer(Properties props){
try{
- String className = props.getProperty("openejb.test.server");
- if (className == null) throw new IllegalArgumentException("Must specify a test server by setting its class name using the system property \"openejb.test.server\"");
+ String className = props.getProperty(TEST_SERVER_CLASSNAME);
+ if (className == null) {
+ throw new IllegalArgumentException(
+ "Must specify a test server by setting its class name using the system property \"" + TEST_SERVER_CLASSNAME + "\"");
+ }
ClassLoader cl = getContextClassLoader();
Class<?> testServerClass = Class.forName( className, true, cl );
server = (TestServer)testServerClass.newInstance();
@@ -137,8 +149,8 @@
private static void initDatabase(Properties props){
try{
- String className = props.getProperty("openejb.test.database");
- if (className == null) throw new IllegalArgumentException("Must specify a test database by setting its class name using the system property \"openejb.test.database\"");
+ String className = props.getProperty(TEST_DATABASE_CLASSNAME);
+ if (className == null) throw new IllegalArgumentException("Must specify a test database by setting its class name using the system property \"" + TEST_DATABASE_CLASSNAME + "\"");
ClassLoader cl = getContextClassLoader();
Class<?> testDatabaseClass = Class.forName( className , true, cl);
database = (TestDatabase)testDatabaseClass.newInstance();
@@ -151,7 +163,7 @@
private static void initJms(Properties props){
try{
- String className = props.getProperty("openejb.test.jms");
+ String className = props.getProperty(TEST_JMS_CLASSNAME);
if (className == null) className = "org.apache.openejb.test.ActiveMqTestJms";
ClassLoader cl = getContextClassLoader();
Class<?> testJmsClass = Class.forName( className , true, cl);