Author: vhalbert(a)redhat.com
Date: 2009-09-20 00:12:21 -0400 (Sun, 20 Sep 2009)
New Revision: 1423
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
Log:
Teiid 773 - organize integration test - refactored properties so that it makes it easier
to for the testcase to specify the property instead of putting it in the config properties
file
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-19
03:29:55 UTC (rev 1422)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-20
04:12:21 UTC (rev 1423)
@@ -7,20 +7,16 @@
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
public class ConfigPropertyLoader {
- /**
- * Specify this property to set a specific configuration to use
- */
- public static final String CONFIG_FILE="config";
/**
* The default config file to use when #CONFIG_FILE system property isn't set
*/
- private static final String
DEFAULT_CONFIG_FILE_NAME="default-config.properties";
+ protected static final String
DEFAULT_CONFIG_FILE_NAME="default-config.properties";
private static Properties props = null;
public synchronized static void loadConfigurationProperties() {
- String filename = System.getProperty(CONFIG_FILE);
+ String filename = System.getProperty(ConfigPropertyNames.CONFIG_FILE);
if (filename == null) {
filename = DEFAULT_CONFIG_FILE_NAME;
}
@@ -36,12 +32,14 @@
}
private static void loadProperties(String filename) {
- props = null;
+ props = System.getProperties();
try {
InputStream in = ConfigPropertyLoader.class.getResourceAsStream("/"+
filename);
if (in != null) {
- props = new Properties();
- props.load(in);
+ Properties lprops = new Properties();
+ lprops.load(in);
+ props.putAll(lprops);
+
}
else {
throw new RuntimeException("Failed to load properties from file
'"+filename+ "' configuration file");
@@ -52,12 +50,17 @@
}
public static void main(String[] args) {
+ System.setProperty("test", "value");
+
ConfigPropertyLoader.loadConfigurationProperties();
Properties p = ConfigPropertyLoader.getProperties();
if (p == null || p.isEmpty()) {
throw new RuntimeException("Failed to load config properties file");
}
+ if (p.getProperty("test") == null) {
+ throw new RuntimeException("Failed to pickup system property");
+ }
System.out.println("Loaded Config Properties " + p.toString());
}
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
(rev 0)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-09-20
04:12:21 UTC (rev 1423)
@@ -0,0 +1,67 @@
+package org.teiid.test.framework;
+
+/**
+ * The following properties can be set in 2 ways:
+ * <li>set as a System property(..)</li>
+ * <li>specify it in the config properties file</li>
+ *
+ * @author vanhalbert
+ *
+ */
+public interface ConfigPropertyNames {
+
+ /**
+ * Specify this as a system property to set a specific configuration to use
+ * otherwise the {@link ConfigPropertyLoader#DEFAULT_CONFIG_FILE_NAME} will be loaded.
+ */
+ public static final String CONFIG_FILE="config";
+
+
+ /**
+ * For Driver/Datasource connection related properties, {@link ConnectionStrategy}.
+ */
+
+
+ /**
+ * Transaction Type indicates the type of transaction container to use
+ * @see TransactionFactory
+ */
+ public static final String TRANSACTION_TYPE = "transaction-type";
//$NON-NLS-1$
+
+ public interface TRANSACTION_TYPES {
+ public static final String LOCAL_TRANSACTION = "local"; //$NON-NLS-1$
+ public static final String XATRANSACTION = "xa"; //$NON-NLS-1$
+ public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
+ }
+
+
+
+ /**
+ * The USE_DATASOURCES_PROP is a comma delimited system property that can be used to
limit the
+ * datasources that are in use for the tests. Use the name defined in the
datasource_mapping.xml.
+ * This enables one to test between certain datasources without having to remove
+ * connection.properties files.
+ */
+ public static final String USE_DATASOURCES_PROP = "usedatasources";
+
+
+ /**
+ * Connection Type indicates the type of connection (strategy) to use
+ * Options are {@link CONNECTION_TYPES}
+ */
+ public static final String CONNECTION_TYPE = "connection-type";
//$NON-NLS-1$
+
+
+ public interface CONNECTION_TYPES {
+
+ // used to create the jdb driver
+ public static final String DRIVER_CONNECTION = "driver"; //$NON-NLS-1$
+ // used to create a datasource
+ public static final String DATASOURCE_CONNECTION = "datasource";
//$NON-NLS-1$
+ // used for when embedded is running in an appserver
+ public static final String JNDI_CONNECTION = "jndi"; //$NON-NLS-1$
+
+
+ }
+
+}
Property changes on:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-09-19
03:29:55 UTC (rev 1422)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-09-20
04:12:21 UTC (rev 1423)
@@ -23,28 +23,13 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+
public abstract class ConnectionStrategy {
- /**
- * Connection Type indicates the type of connection (strategy) to use
- */
- public static final String CONNECTION_TYPE = "connection-type";
//$NON-NLS-1$
- /**
- * The connection types that map to connection strategies
- * ****************************************************************
- */
- // used to create the jdb driver
- public static final String DRIVER_CONNECTION = "driver"; //$NON-NLS-1$
- // used to create a datasource
- public static final String DATASOURCE_CONNECTION = "datasource";
//$NON-NLS-1$
- // used for when embedded is running in an appserver
- public static final String JNDI_CONNECTION = "jndi"; //$NON-NLS-1$
- /*
- * ******************************************************************
- */
-
+
public static final String DS_USER = "user"; //$NON-NLS-1$
// need both user variables because Teiid uses 'user' and connectors use
'username'
@@ -69,6 +54,10 @@
public static final String AUTOCOMMIT = "autocommit"; //$NON-NLS-1$
+ public static final String TXN_AUTO_WRAP = ExecutionProperties.PROP_TXN_AUTO_WRAP;
+
+ public static final String FETCH_SIZE = ExecutionProperties.PROP_FETCH_SIZE;
+
public static final String EXEC_IN_BATCH = "execute.in.batch";
//$NON-NLS-1$
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-19
03:29:55 UTC (rev 1422)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-20
04:12:21 UTC (rev 1423)
@@ -10,27 +10,17 @@
import java.util.Properties;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
public class ConnectionStrategyFactory {
- /**
- * Specify this property to set a specific configuration to use
- */
- public static final String CONFIG_FILE="config";
-
- /**
- * The default config file to use when #CONFIG_FILE system property isn't set
- */
- private static final String
DEFAULT_CONFIG_FILE_NAME="default-config.properties";
-
private static ConnectionStrategyFactory _instance = null;
private ConnectionStrategy strategy = null;
private static Map<String, ConnectionStrategy> sources = null;
-
-
+
private ConnectionStrategyFactory(){
}
@@ -59,14 +49,12 @@
_instance.shutdown();
_instance = null;
-
-
}
}
private void shutdown() {
Properties p = System.getProperties();
- p.remove(CONFIG_FILE);
+ p.remove(ConfigPropertyNames.CONFIG_FILE);
for (Iterator it=sources.keySet().iterator(); it.hasNext(); ){
@@ -101,26 +89,26 @@
ConnectionStrategy strategy = null;
- String type = props.getProperty(ConnectionStrategy.CONNECTION_TYPE,
ConnectionStrategy.DRIVER_CONNECTION);
+ String type = props.getProperty(ConfigPropertyNames.CONNECTION_TYPE,
ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
if (type == null) {
- throw new RuntimeException("Property " +
ConnectionStrategy.CONNECTION_TYPE + " was specified");
+ throw new RuntimeException("Property " +
ConfigPropertyNames.CONNECTION_TYPE + " was specified");
}
- if (type.equalsIgnoreCase(ConnectionStrategy.DRIVER_CONNECTION)) {
+ if
(type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION)) {
strategy = createDriverStrategy(null, props);
System.out.println("Created Driver Strategy");
}
- else if (type.equalsIgnoreCase(ConnectionStrategy.DATASOURCE_CONNECTION)) {
+ else if
(type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION)) {
strategy = createDataSourceStrategy(null, props);
System.out.println("Created DataSource Strategy");
}
- else if (type.equalsIgnoreCase(ConnectionStrategy.JNDI_CONNECTION)) {
+ else if
(type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.JNDI_CONNECTION)) {
strategy = createJEEStrategy(null, props);
System.out.println("Created JEE Strategy");
}
if (strategy == null) {
- new TransactionRuntimeException("Invalid property value for " +
ConnectionStrategy.CONNECTION_TYPE + " is " + type );
+ new TransactionRuntimeException("Invalid property value for " +
ConfigPropertyNames.CONNECTION_TYPE + " is " + type );
}
// call configure here because this is creating the connection to Teiid
// direct connections to the datasource use the static call directly to create
strategy and don't need to configure
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-09-19
03:29:55 UTC (rev 1422)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-09-20
04:12:21 UTC (rev 1423)
@@ -30,6 +30,7 @@
public DriverConnection(Properties props) throws QueryTestFailedException {
super(props);
+ validate();
}
public void validate() {
@@ -81,8 +82,6 @@
}
}
-
- validate();
this.connection = getJDBCConnection(this.driver, this.url, this.username,
this.pwd);
return this.connection;
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-19
03:29:55 UTC (rev 1422)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-20
04:12:21 UTC (rev 1423)
@@ -17,6 +17,8 @@
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.util.StringUtil;
@@ -25,7 +27,7 @@
import com.metamatrix.common.xml.XMLReaderWriterImpl;
/**
- * The DataSourceMgr is responsible for loading and managing the datasource
+ * The DataSourceMgr is responsible for loading and managing datasources defined by the
datasource
* mapping properties file {@see #DATASOURCE_MAPPING_FILE} and the mapped
* datasource properties files. The {@link #getDatasourceProperties(String)}
* returns the properties defined for that datasourceid, which is mapped in the
@@ -36,13 +38,6 @@
*/
public class DataSourceMgr {
- /**
- * The USE_DATASOURCES_PROP is a comma delimited system property that can be used to
limit the
- * datasources that are in use for the tests. Use the name defined in the
datasource_mapping.xml.
- * This enables one to test between certain datasources without having to remove
- * connection.properties files.
- */
- static final String USE_DATASOURCES_PROP = "usedatasources";
static final String RELATIVE_DIRECTORY = "datasources/";
static final String DATASOURCE_MAPPING_FILE = "datasource_mapping.xml";
@@ -220,7 +215,7 @@
throws QueryTestFailedException {
Set<String> limitds = new HashSet<String>();
- String limitdsprop = System.getProperty(USE_DATASOURCES_PROP);
+ String limitdsprop =
ConfigPropertyLoader.getProperty(ConfigPropertyNames.USE_DATASOURCES_PROP);
if (limitdsprop != null && limitdsprop.length() > 0) {
System.out.println("Limit datasources to: " + limitdsprop);
List<String> dss = StringUtil.split(limitdsprop, ",");
@@ -414,7 +409,7 @@
DataSourceMgr.reset();
- System.setProperty(DataSourceMgr.USE_DATASOURCES_PROP, "ds_sqlserver");
+ System.setProperty(ConfigPropertyNames.USE_DATASOURCES_PROP,
"ds_sqlserver");
mgr = DataSourceMgr.getInstance();
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-19
03:29:55 UTC (rev 1422)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-20
04:12:21 UTC (rev 1423)
@@ -5,6 +5,7 @@
package org.teiid.test.framework.transaction;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -14,14 +15,6 @@
public class TransactionFactory {
- public static final String LOCAL_TRANSACTION = "local"; //$NON-NLS-1$
- public static final String XATRANSACTION = "xa"; //$NON-NLS-1$
- public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
-
- /**
- * Transaction Type indicates the type of transaction container to use
- */
- public static final String TRANSACTION_TYPE = "transaction-type";
//$NON-NLS-1$
private TransactionFactory(){}
@@ -37,22 +30,22 @@
ConnectionStrategy connstrategy =
ConnectionStrategyFactory.getInstance().getConnectionStrategy();
- String type = connstrategy.getEnvironment().getProperty(TRANSACTION_TYPE,
LOCAL_TRANSACTION);
+ String type =
connstrategy.getEnvironment().getProperty(ConfigPropertyNames.TRANSACTION_TYPE,
ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION);
if (type == null) {
- throw new RuntimeException("Property " + TRANSACTION_TYPE + " was
specified");
+ throw new RuntimeException("Property " +
ConfigPropertyNames.TRANSACTION_TYPE + " was specified");
}
- if (type.equalsIgnoreCase(LOCAL_TRANSACTION)) {
+ if
(type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
transacton = new LocalTransaction(connstrategy);
}
- else if (type.equalsIgnoreCase(XATRANSACTION)) {
+ else if
(type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.XATRANSACTION)) {
transacton = new XATransaction(connstrategy);
}
- else if (type.equalsIgnoreCase(JNDI_TRANSACTION)) {
+ else if
(type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.JNDI_TRANSACTION)) {
transacton = new JNDITransaction(connstrategy);
} else {
- throw new TransactionRuntimeException("Invalid property value of " +
type + " for " + TRANSACTION_TYPE );
+ throw new TransactionRuntimeException("Invalid property value of " +
type + " for " + ConfigPropertyNames.TRANSACTION_TYPE );
}
return transacton;