Author: vhalbert(a)redhat.com
Date: 2009-09-21 16:31:03 -0400 (Mon, 21 Sep 2009)
New Revision: 1435
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/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.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/connection/JEEConnection.java
Log:
Teiid 773 - setting up the xa transaction tests
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-21
20:30:36 UTC (rev 1434)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-09-21
20:31:03 UTC (rev 1435)
@@ -30,28 +30,29 @@
public abstract class ConnectionStrategy {
- public static final String DS_USER = "user"; //$NON-NLS-1$
-
- // need both user variables because Teiid uses 'user' and connectors use
'username'
- public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
- public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD;
//$NON-NLS-1$
-
- // the driver is only used for making direct connections to the source, the
- // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE driver class
- public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
-
- public static final String DS_URL = JDBCPropertyNames.URL; //$NON-NLS-1$
- public static final String DS_SERVERNAME = "servername"; //$NON-NLS-1$
- public static final String DS_SERVERPORT = "portnumber"; //$NON-NLS-1$
- public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
- public static final String DS_DATABASENAME = "databasename"; //$NON-NLS-1$
- public static final String DS_APPLICATION_NAME = "application-name";
//$NON-NLS-1$
-
- public static final String PROCESS_BATCH = "process-batch"; //$NON-NLS-1$
- public static final String CONNECTOR_BATCH = "connector-batch";
//$NON-NLS-1$
- public static final String JNDINAME_USERTXN = "usertxn-jndiname";
//$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'
+// public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+// public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD;
//$NON-NLS-1$
+//
+// // the driver is only used for making direct connections to the source, the
+// // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE driver
class
+// public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
+// public static final String DS_DATASOURCE = "datasource"; //$NON-NLS-1$
+//
+// public static final String DS_URL = JDBCPropertyNames.URL; //$NON-NLS-1$
+// public static final String DS_SERVERNAME = "servername"; //$NON-NLS-1$
+// public static final String DS_SERVERPORT = "portnumber"; //$NON-NLS-1$
+//
+// public static final String DS_DATABASENAME = "databasename";
//$NON-NLS-1$
+// public static final String DS_APPLICATION_NAME = "application-name";
//$NON-NLS-1$
+//
+ public static final String JNDINAME_USERTXN = "usertxn-jndiname";
//$NON-NLS-1$
+
+ public static final String PROCESS_BATCH = "process-batch"; //$NON-NLS-1$
+ public static final String CONNECTOR_BATCH = "connector-batch"; //$NON-NLS-1$
+
public static final String AUTOCOMMIT = "autocommit"; //$NON-NLS-1$
public static final String TXN_AUTO_WRAP = ExecutionProperties.PROP_TXN_AUTO_WRAP;
@@ -205,6 +206,7 @@
org.teiid.test.framework.datasource.DataSource ds =
DataSourceMgr.getInstance().getDatasource(useName, m.getName());
if (ds != null) {
+ System.out.println("Setting up Connector Binding of Type: " +
ds.getConnectorType()); //$NON-NLS-1$
AdminOptions ao = new AdminOptions(AdminOptions.OnConflict.OVERWRITE);
ao.addOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR);
@@ -222,6 +224,7 @@
} catch (QueryTestFailedException qt) {
throw qt;
} catch (Exception t) {
+ t.printStackTrace();
throw new QueryTestFailedException(t);
}
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-21
20:30:36 UTC (rev 1434)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-21
20:31:03 UTC (rev 1435)
@@ -18,7 +18,7 @@
private static ConnectionStrategyFactory _instance = null;
private ConnectionStrategy strategy = null;
- private static Map<String, ConnectionStrategy> sources = null;
+ private Map<String, ConnectionStrategy> sources = null;
private ConnectionStrategyFactory(){
@@ -27,17 +27,17 @@
public static synchronized ConnectionStrategyFactory getInstance() {
if (_instance == null) {
_instance = new ConnectionStrategyFactory();
- try {
- _instance.initialize();
- } catch (QueryTestFailedException e) {
+
+ _instance. init();
// TODO Auto-generated catch block
- throw new TransactionRuntimeException(e);
- }
+// _instance = null;
+// throw new TransactionRuntimeException(e);
+// }
}
return _instance;
}
- private static void init() {
+ private void init() {
if (sources == null) {
sources = new HashMap<String, ConnectionStrategy>();
}
@@ -75,15 +75,13 @@
}
- public ConnectionStrategy getConnectionStrategy() {
+ public synchronized ConnectionStrategy getConnectionStrategy() throws
QueryTestFailedException {
+ if (strategy == null) {
+ this.strategy = create(ConfigPropertyLoader.getProperties());
+ }
return this.strategy;
}
- private void initialize() throws QueryTestFailedException {
- init();
- this.strategy = create(ConfigPropertyLoader.getProperties());
-
- }
private ConnectionStrategy create(Properties props) throws QueryTestFailedException
{
@@ -116,11 +114,10 @@
return strategy;
}
- public synchronized static ConnectionStrategy createDriverStrategy(String
identifier, Properties props) throws QueryTestFailedException {
+ public synchronized ConnectionStrategy createDriverStrategy(String identifier,
Properties props) throws QueryTestFailedException {
if (identifier == null) {
return new DriverConnection(props);
}
- init();
ConnectionStrategy strategy = null;
if (sources.containsKey(identifier)) {
@@ -134,11 +131,10 @@
}
- public synchronized static ConnectionStrategy createDataSourceStrategy(String
identifier, Properties props) throws QueryTestFailedException {
+ public synchronized ConnectionStrategy createDataSourceStrategy(String identifier,
Properties props) throws QueryTestFailedException {
if (identifier == null) {
return new DataSourceConnection(props);
}
- init();
ConnectionStrategy strategy = null;
if (sources.containsKey(identifier)) {
@@ -152,12 +148,11 @@
}
- public synchronized static ConnectionStrategy createJEEStrategy(String identifier,
Properties props) throws QueryTestFailedException {
+ public synchronized ConnectionStrategy createJEEStrategy(String identifier,
Properties props) throws QueryTestFailedException {
if (identifier == null) {
return new JEEConnection(props);
}
- init();
ConnectionStrategy strategy = null;
if (sources.containsKey(identifier)) {
strategy = sources.get(identifier);
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-09-21
20:30:36 UTC (rev 1434)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-09-21
20:31:03 UTC (rev 1435)
@@ -37,7 +37,7 @@
+ " has no datasource properties");
}
- return ConnectionStrategyFactory.createDriverStrategy(identifier,
+ return ConnectionStrategyFactory.getInstance().createDriverStrategy(identifier,
sourceProps).getConnection();
}
@@ -69,7 +69,7 @@
+ " has no datasource properties");
}
- return ConnectionStrategyFactory.createDataSourceStrategy(
+ return ConnectionStrategyFactory.getInstance().createDataSourceStrategy(
identifier, sourceProps).getXAConnection();
}
throw new RuntimeException("No Connection by name :" + identifier);
//$NON-NLS-1$
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-09-21
20:30:36 UTC (rev 1434)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-09-21
20:31:03 UTC (rev 1435)
@@ -11,18 +11,41 @@
import javax.sql.XAConnection;
import javax.sql.XADataSource;
+import org.teiid.connector.jdbc.JDBCPropertyNames;
+import org.teiid.jdbc.TeiidDataSource;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.EmbeddedDataSource;
import com.metamatrix.jdbc.MMDataSource;
+import com.metamatrix.jdbc.api.ExecutionProperties;
/**
*
*/
public class DataSourceConnection extends ConnectionStrategy {
+
+ public static final String DS_USER = "user"; //$NON-NLS-1$
+
+ // need both user variables because Teiid uses 'user' and connectors use
'username'
+ public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+ public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD;
//$NON-NLS-1$
+
+ // the driver is only used for making direct connections to the source, the
+ // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE driver class
+ public static final String DS_DATASOURCE = "datasource"; //$NON-NLS-1$
+
+ public static final String DS_SERVERNAME = "servername"; //$NON-NLS-1$
+ public static final String DS_SERVERPORT = "portnumber"; //$NON-NLS-1$
+ public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
+ public static final String DS_DATABASENAME = "databasename";
//$NON-NLS-1$
+ public static final String DS_APPLICATION_NAME = "application-name";
//$NON-NLS-1$
+
+// public static final String JNDINAME_USERTXN = "usertxn-jndiname";
//$NON-NLS-1$
+
+
private String driver = null;
private String username = null;
private String pwd = null;
@@ -56,9 +79,9 @@
this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
- driver = this.getEnvironment().getProperty(DS_DRIVER);
+ driver = this.getEnvironment().getProperty(DS_DATASOURCE);
if (driver == null || driver.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_DRIVER + " was
not specified");
+ throw new TransactionRuntimeException("Property " + DS_DATASOURCE + "
was not specified");
}
this.username = this.getEnvironment().getProperty(DS_USER);
@@ -103,8 +126,11 @@
}
private XAConnection createConnection() throws SQLException, InstantiationException,
IllegalAccessException, ClassNotFoundException {
- BaseDataSource dataSource =
(BaseDataSource)Class.forName(this.driver).newInstance();
+ System.out.println("Creating Datasource Connection: \"" +
this.serverName + " - " + this.databaseName + "\"");
//$NON-NLS-1$ //$NON-NLS-2$
+
+ BaseDataSource dataSource =
(BaseDataSource)Class.forName(this.driver).newInstance();
+
dataSource.setDatabaseName(this.databaseName);
if (this.applName != null) {
dataSource.setApplicationName(this.applName);
@@ -113,8 +139,8 @@
if (dataSource instanceof EmbeddedDataSource) {
((EmbeddedDataSource)dataSource).setBootstrapFile(this.serverName);
} else {
- ((MMDataSource)dataSource).setServerName(this.serverName);
- ((MMDataSource)dataSource).setPortNumber(Integer.parseInt(this.portNumber));
+ ((TeiidDataSource)dataSource).setServerName(this.serverName);
+
((TeiidDataSource)dataSource).setPortNumber(Integer.parseInt(this.portNumber));
}
if (this.username != null) {
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-21
20:30:36 UTC (rev 1434)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-09-21
20:31:03 UTC (rev 1435)
@@ -9,16 +9,33 @@
import java.sql.SQLException;
import java.util.Properties;
+import org.teiid.connector.jdbc.JDBCPropertyNames;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+
/**
* The DriverConnection strategy that can get connections in standalone mode
* or embedded mode.
*/
public class DriverConnection extends ConnectionStrategy{
+
+ public static final String DS_USER = "user"; //$NON-NLS-1$
+
+ // need both user variables because Teiid uses 'user' and connectors use
'username'
+ public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+ public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD;
//$NON-NLS-1$
+
+ // the driver is only used for making direct connections to the source, the
+ // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE driver class
+ public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
+
+ public static final String DS_URL = JDBCPropertyNames.URL; //$NON-NLS-1$
+ public static final String DS_APPLICATION_NAME = "application-name";
//$NON-NLS-1$
+
private String url = null;
private String driver = null;
@@ -90,7 +107,7 @@
private Connection getJDBCConnection(String driver, String url, String user, String
passwd) throws QueryTestFailedException {
- System.out.println("Creating Connection: \"" + url +
"\""); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("Creating Driver Connection: \"" + url +
"\""); //$NON-NLS-1$ //$NON-NLS-2$
Connection conn;
try {
@@ -104,6 +121,9 @@
} catch (SQLException e) {
throw new QueryTestFailedException(e);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new QueryTestFailedException(t.getMessage());
}
return conn;
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java 2009-09-21
20:30:36 UTC (rev 1434)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java 2009-09-21
20:31:03 UTC (rev 1435)
@@ -21,6 +21,8 @@
*/
public class JEEConnection extends ConnectionStrategy{
+ public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
+
private String jndi_name = null;
@@ -57,7 +59,7 @@
public void validate() {
// TODO Auto-generated method stub
- jndi_name = getEnvironment().getProperty(ConnectionStrategy.DS_JNDINAME);
+ jndi_name = getEnvironment().getProperty(DS_JNDINAME);
if (jndi_name == null || jndi_name.length() == 0) {
throw new TransactionRuntimeException("Property " + DS_JNDINAME + "
was not specified");
}