Author: vhalbert(a)redhat.com
Date: 2009-09-30 12:04:29 -0400 (Wed, 30 Sep 2009)
New Revision: 1497
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/ConfigPropertyNames.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
Log:
Teiid 773 - changed the following:
- the testcase will not use system property to pass in overrides/additions to the loaded
config.properties file. Now will use an addProperty() method provided on the abstract
testcase that will apply the properties per test.
- remove the datasource_mapping.xml. There is no need to distinquish between xa and
nonxa connector types. The connector type will be specified in the
connection.properties file.
- if using the -DuserDataSources property to control datasource, it will imply order
based on whats specified. The config.properties file will now map the model to order
(i.e., pm1:1), where this order determines which datasource it will correspond to based on
the userDataSources property. This mapping is done so that the nightly testing process
can control which datasources are being used and can ensure retestability.
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-30
16:04:02 UTC (rev 1496)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-30
16:04:29 UTC (rev 1497)
@@ -2,64 +2,98 @@
import java.util.Properties;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.util.PropUtils;
+import com.metamatrix.common.util.PropertiesUtils;
-public class ConfigPropertyLoader {
-
-
- /**
- * The default config file to use when #CONFIG_FILE system property isn't set
- */
- 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(ConfigPropertyNames.CONFIG_FILE);
- if (filename == null) {
- filename = DEFAULT_CONFIG_FILE_NAME;
- }
-
- loadProperties(filename); }
-
- public static String getProperty(String key) {
- return getProperties().getProperty(key);
- }
-
- public synchronized static Properties getProperties() {
- if (props == null) {
- loadConfigurationProperties();
+/**
+ * The ConfigProperteryLoader will load the configuration properties to be used by a
test.
+ *
+ * @author vanhalbert
+ *
+ */
+public class ConfigPropertyLoader {
+
+ /**
+ * The default config file to use when #CONFIG_FILE system property isn't
+ * set
+ */
+ protected static final String DEFAULT_CONFIG_FILE_NAME =
"default-config.properties";
+
+ private Properties props = null;
+
+ private ConfigPropertyLoader() {
+ }
+
+ public static synchronized ConfigPropertyLoader createInstance() {
+ ConfigPropertyLoader _instance = null;
+ _instance = new ConfigPropertyLoader();
+ try {
+ _instance.loadConfigurationProperties();
+ } catch (TransactionRuntimeException e) {
+ throw e;
}
- return props;
+
+ return _instance;
+ }
+
+ private void loadConfigurationProperties() {
+ String filename = System.getProperty(ConfigPropertyNames.CONFIG_FILE);
+ if (filename == null) {
+ filename = DEFAULT_CONFIG_FILE_NAME;
}
-
- private static void loadProperties(String filename) {
- props =PropUtils.loadProperties("/"+ filename, System.getProperties());
- }
+ loadProperties(filename);
- public static void cleanup() {
- Properties p = System.getProperties();
- p.remove(ConfigPropertyNames.CONFIG_FILE);
- p.remove(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
-
- }
- 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");
+ Properties p = System.getProperties();
+ p.remove(ConfigPropertyNames.CONFIG_FILE);
+ p.remove(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
+ p.remove(ConfigPropertyNames.USE_DATASOURCES_PROP);
+ p.remove(ConfigPropertyNames.CONNECTION_TYPE);
+ p.remove(ConfigPropertyNames.TRANSACTION_TYPE);
- }
- if (p.getProperty("test") == null) {
- throw new RuntimeException("Failed to pickup system property");
- }
- System.out.println("Loaded Config Properties " + p.toString());
+
+ }
+
+ public String getProperty(String key) {
+ return getProperties().getProperty(key);
+ }
+
+ public void setProperty(String key, String value) {
+ props.setProperty(key, value);
+ }
+
+ public Properties getProperties() {
+ return props;
+ }
+
+ private void loadProperties(String filename) {
+
+ Properties sysprops = PropertiesUtils.clone(System.getProperties());
+
+ props = PropUtils
+ .loadProperties("/" + filename, sysprops);
+
+ }
+
+ public static void main(String[] args) {
+ System.setProperty("test", "value");
+
+ ConfigPropertyLoader _instance = ConfigPropertyLoader.createInstance();
+ Properties p = _instance.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());
+
+ }
+
}
Modified:
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 2009-09-30
16:04:02 UTC (rev 1496)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-09-30
16:04:29 UTC (rev 1497)
@@ -1,5 +1,7 @@
package org.teiid.test.framework;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+
/**
* The following properties can be set in 2 ways:
* <li>set as a System property(..)</li>
@@ -64,6 +66,11 @@
public static final String CONNECTION_TYPE = "connection-type";
//$NON-NLS-1$
+ /**
+ * {@see #CONNECTION_TYPE} regarding setting the specific connection type to use
+ * @author vanhalbert
+ *
+ */
public interface CONNECTION_TYPES {
// used to create the jdb driver
@@ -75,5 +82,22 @@
}
+
+ /**
+ * Connection Props are the {@link CONNECTION_STRATEGY} execution options
+ * @author vanhalbert
+ *
+ */
+ public interface CONNECTION_STRATEGY_PROPS {
+ public static final String TXN_AUTO_WRAP = ExecutionProperties.PROP_TXN_AUTO_WRAP;
+ public static final String AUTOCOMMIT = "autocommit"; //$NON-NLS-1$
+ public static final String FETCH_SIZE = ExecutionProperties.PROP_FETCH_SIZE;
+ public static final String EXEC_IN_BATCH = "execute.in.batch"; //$NON-NLS-1$
+ public static final String CONNECTOR_BATCH = "connector-batch";
//$NON-NLS-1$
+ public static final String PROCESS_BATCH = "process-batch"; //$NON-NLS-1$
+ public static final String JNDINAME_USERTXN = "usertxn-jndiname";
//$NON-NLS-1$
+
+ }
+
}
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-30
16:04:02 UTC (rev 1496)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-30
16:04:29 UTC (rev 1497)
@@ -8,6 +8,7 @@
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+import org.teiid.test.framework.datasource.DataSourceFactory;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -16,20 +17,26 @@
private boolean debug = false;
+ protected ConfigPropertyLoader config = null;
protected Properties props;
protected ConnectionStrategy connStrategy;
+ protected DataSourceFactory dsfactory;
- protected TransactionContainer(){
-
+ protected TransactionContainer(ConfigPropertyLoader propertyconfig){
+ this.config = propertyconfig;
}
protected void setUp(TransactionQueryTest test) throws QueryTestFailedException {
- this.connStrategy =
ConnectionStrategyFactory.getInstance().getConnectionStrategy();
+ this.dsfactory = new DataSourceFactory(config);
+
+ this.connStrategy = ConnectionStrategyFactory.createConnectionStrategy(config,
dsfactory);
this.props = new Properties();
this.props.putAll(this.connStrategy.getEnvironment());
+
+ test.setConnectionStrategy(connStrategy);
- test.setDataSources(connStrategy.getDataSources());
- test.setupDataSources();
+ test.setupDataSource();
+
}
@@ -50,8 +57,14 @@
try {
test.cleanup();
} finally {
+
+ // cleanup all defined datasources for the last test and
+ // any overrides regarding inclusions and exclusions.
+ this.dsfactory.cleanup();
+
+
// cleanup all connections created for this test.
- ConnectionStrategyFactory.destroyInstance();
+ connStrategy.shutdown();
}
}
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java 2009-09-30
16:04:02 UTC (rev 1496)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java 2009-09-30
16:04:29 UTC (rev 1497)
@@ -6,7 +6,9 @@
import javax.sql.XAConnection;
+import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.datasource.DataSource;
+import org.teiid.test.framework.exception.QueryTestFailedException;
/**
* The TransactionQueryTest interface represents the transaction test framework from
which
@@ -31,18 +33,8 @@
*/
void setConnection(Connection conn);
-
+
/**
- * Called by the @link TransactionContainer to set the datasoures used to create the
connector bindings and
- * used to create direct connection to the sources.
- * @param datasources
- *
- * @since
- */
- void setDataSources(Map<String, DataSource> datasources);
-
-
- /**
* Returns the connection being used in the test.
* @return
*
@@ -62,7 +54,16 @@
*/
void setExecutionProperties(Properties props) ;
+
/**
+ * Called to set the current connection strategy being used.
+ * @param connStrategy
+ *
+ * @since
+ */
+ void setConnectionStrategy(ConnectionStrategy connStrategy);
+
+ /**
* The test case has to specify how many sources its using so that the correct
* data setup is performed.
* @return int is the number of datasources in use
@@ -77,12 +78,12 @@
/**
* Called by the {@link TransactionContainer} prior to testcase processing so that
- * the datasources can be setup for the specific testcase.
+ * the responsibility for performing datasource setup can be done
*
*
* @since
*/
- void setupDataSources();
+ void setupDataSource() throws QueryTestFailedException;
/**
Show replies by date