teiid SVN: r1680 - trunk/test-integration/db.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-17 13:59:48 -0500 (Thu, 17 Dec 2009)
New Revision: 1680
Modified:
trunk/test-integration/db/howto
Log:
Teiid 781 - adding option to kit the ctc-client so that this doesn't have to be rebuilt for every platform that we want to test on (build once - test everywhere)
Modified: trunk/test-integration/db/howto
===================================================================
--- trunk/test-integration/db/howto 2009-12-17 18:49:48 UTC (rev 1679)
+++ trunk/test-integration/db/howto 2009-12-17 18:59:48 UTC (rev 1680)
@@ -61,10 +61,10 @@
Options are to setup all data sources at once or setup a single data source.
a. to setup all data sources at one time, run:
- mvn -Psetupdatasources
+ mvn pre-integration-test -Psetupdatasources
b. to setup a specific data source,
- run: mvn -Ddatasource=<datasourcedir> -Psingledatasource
+ run: mvn pre-integration-test -Ddatasource=<datasourcedir> -Psingledatasource
where <datasourcedir> is the name of the directory for the datasource
15 years
teiid SVN: r1679 - trunk/test-integration/db.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-17 13:49:48 -0500 (Thu, 17 Dec 2009)
New Revision: 1679
Modified:
trunk/test-integration/db/howto
trunk/test-integration/db/pom.xml
Log:
Teiid 781 - adding option to kit the ctc-client so that this doesn't have to be rebuilt for every platform that we want to test on (build once - test everywhere)
Modified: trunk/test-integration/db/howto
===================================================================
--- trunk/test-integration/db/howto 2009-12-16 22:35:48 UTC (rev 1678)
+++ trunk/test-integration/db/howto 2009-12-17 18:49:48 UTC (rev 1679)
@@ -20,8 +20,9 @@
you want the connection for
- By default, the datasource assigned to a model will be (somewhat) random. There is not coding to
- specifically control this assignment, as long as the -Dusedatasources option is not used.
+ By default, the datasource assigned to a model will be (somewhat) random when starting the test process. Once the
+ data source is associated with a model, it will be used for the duration of all tests being performed. To override
+ this behavior, the -Dusedatasources option can be used.
If the -Dusedatasources option is used, then there is an implied model-to-datasource assignment.
To understand how this assignment will be made, find the config properties file being
@@ -50,38 +51,61 @@
Setting up a Datasource to be used during Testing
==========================================
+NOTE: 2 Datasource directories, each containing a connection.properties file, are required in order to run the integration tests.
+ Each data source can be pointing to the same database instance, but the schemas must be different.
+
1. DEFINE DATASOURCE:
To define a datasource, see the readme.txt in src/main/resources/datasources regarding defining a datasource
-2. CREATE TABLES
- To create the tables on the defined datasource, run the maven profile to execute the process to create the required tables:
- a. to setup all sources at one time, run:
- mvn pre-integration-test -P setupdatasources -Dmaven.test.skip=true
- b. to setup a specific source,
- run: mvn pre-integration-test -Ddatasource=<datasourcedir> -Psingledatasource -Dmaven.test.skip=true
- where <datasourcedir> is the name of the directory for the datasource
+2. CREATE TABLES IN A DATASOURCE
+ Options are to setup all data sources at once or setup a single data source.
+
+ a. to setup all data sources at one time, run:
+ mvn -Psetupdatasources
+ b. to setup a specific data source,
+ run: mvn -Ddatasource=<datasourcedir> -Psingledatasource
+ where <datasourcedir> is the name of the directory for the datasource
+
Example:
- mvn pre-integration-test -Ddatasource=oracle -Psingledatasource -Dmaven.test.skip=true
+ mvn -Ddatasource=oracle -Psingledatasource
==========================================
Executing the db integration tests
==========================================
-The default profile in the pom.xml is set to compile and run the test. The following are options for running tests:
+The default setup of the pom.xml is to only compile and assemble the teiid-ctc-test-client jar. The following are different profile
+options for running tests:
- a. Run with no regard to which specific datasource to use (only those with connections.properties file are considered):
- run: mvn install
- b. To run the tests, but specify which datasource(s) to use:
- run: mvn clean install -Dusedatasources=<comma seperated datasource names>
- Example: mvn clean install -Dusedatasources=oracle,sqlserver
+ a. Run All Tests: Run all tests with no regard to which specific datasource to use (only those with connections.properties file are considered):
+
+ run: mvn install -Prunalltests
+ b. Run a Single Test: Run one test class with no regard to which specific datasource to use
+
+ run: mvn install -Prunsingletest -Dclassname=<classname>
+
+ Example: mvn install -Prunsingletest -Dclassname=OffWrapTransactionTests
+
+
+
+==========================================
+Executing the db integration tests - using the -Dusedatasources option
+==========================================
+
+When running tests, by default, the process will randomly select which defined datasources it will use and to which model they will be mapped.
+To control which datasources to use, add the -Dusedatasources option when running either "run" profile (e.g., runalltests or runsingletest).
+
+ a. Example
+
+ run: mvn install -Prunalltests -Dusedatasources=<comma seperated datasource names>
+
+ Example: mvn install -Prunalltests -Dusedatasources=oracle,sqlserver
- c. To run a single class of tests, run the "singleclass" profile
- run: mvn clean install -Psingleclass -Dclassname=<classname> ====> don't add .java to classname
+
Modified: trunk/test-integration/db/pom.xml
===================================================================
--- trunk/test-integration/db/pom.xml 2009-12-16 22:35:48 UTC (rev 1678)
+++ trunk/test-integration/db/pom.xml 2009-12-17 18:49:48 UTC (rev 1679)
@@ -238,15 +238,11 @@
</dependencies>
+
-
<profiles>
<profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
-
+ <id>runalltests</id>
<build>
<plugins>
<!-- Specify the compiler options and settings -->
@@ -260,11 +256,12 @@
<showWarnings>false</showWarnings>
</configuration>
</plugin>
+
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
- <additionalClasspathElement>${basedir}/lib/classes12_g.jar</additionalClasspathElement>
+ <additionalClasspathElement>${basedir}/lib/ojdbc6.jar</additionalClasspathElement>
<additionalClasspathElement>${basedir}/lib/sqljdbc4.jar</additionalClasspathElement>
<additionalClasspathElement>${basedir}/lib/db2jcc4.jar</additionalClasspathElement>
<additionalClasspathElement>${basedir}/lib/jbedsp-datadirect.jar</additionalClasspathElement>
@@ -280,9 +277,7 @@
<value>${datasourceloc}</value>
</property>
</systemProperties>
-
-
-
+
<!--
<forkMode>always</forkMode>
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
@@ -324,12 +319,8 @@
</profile>
<profile>
- <id>singleclass</id>
- <activation>
- <property>
- <name>classname</name>
- </property>
- </activation>
+ <id>runsingletest</id>
+
<build>
<plugins>
<!-- Specify the compiler options and settings -->
@@ -343,11 +334,12 @@
<showWarnings>false</showWarnings>
</configuration>
</plugin>
+
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <configuration>
+ <configuration>
<additionalClasspathElements>
- <additionalClasspathElement>${basedir}/lib/classes12_g.jar</additionalClasspathElement>
+ <additionalClasspathElement>${basedir}/lib/ojdbc6.jar</additionalClasspathElement>
<additionalClasspathElement>${basedir}/lib/sqljdbc4.jar</additionalClasspathElement>
<additionalClasspathElement>${basedir}/lib/db2jcc4.jar</additionalClasspathElement>
<additionalClasspathElement>${basedir}/lib/jbedsp-datadirect.jar</additionalClasspathElement>
@@ -363,20 +355,15 @@
</property>
</systemProperties>
+<!--
+ <forkMode>always</forkMode>
- <forkMode>always</forkMode>
-<!--
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
-->
<includes>
<include>**/${classname}.java</include>
</includes>
- <excludes>
- <exclude>**/*Abstract*TestCase.java</exclude>
- <exclude>**/*Abstract*Test.java</exclude>
- <!-- hack to prevent anonymous inner classes in Tests from being run as tests -->
- <exclude>**/Test*$*.java</exclude>
- </excludes>
+
</configuration>
</plugin>
@@ -390,18 +377,13 @@
<build>
<plugins>
- <!-- Specify the compiler options and settings -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- <showDeprecation>false</showDeprecation>
- <showWarnings>false</showWarnings>
- </configuration>
- </plugin>
-
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@@ -446,18 +428,14 @@
</activation>
<build>
<plugins>
- <!-- Specify the compiler options and settings -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- <showDeprecation>false</showDeprecation>
- <showWarnings>false</showWarnings>
- </configuration>
- </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@@ -500,7 +478,7 @@
<profile>
- <id>testclient</id>
+ <id>runclienttests</id>
<activation>
<property>
<name>scenario.dir</name>
@@ -518,6 +496,13 @@
<showWarnings>false</showWarnings>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@@ -555,6 +540,65 @@
</profile>
+ <profile>
+ <id>assemble</id>
+<!-- assemble will compile, but not run the tests prior to assemblying the kit -->
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <!-- Specify the compiler options and settings -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <showDeprecation>false</showDeprecation>
+ <showWarnings>false</showWarnings>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>${apache.ant.version}</version>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <!-- assemble all the console artifacts that make up the console kit -->
+ <id>assemble-artifacts</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="product.version" value="${project.version}" />
+ <!-- location to assemble the console artifacts -->
+ <property name="relative.artifact.dir" value="target/distribution/artifacts/teiid-ctc-test-client-${project.version}"></property>
+ <ant antfile="src/assembly/assemble-ctc-client.xml"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
15 years
teiid SVN: r1678 - trunk/test-integration/db/src/main/java/org/teiid/test/client.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-16 17:35:48 -0500 (Wed, 16 Dec 2009)
New Revision: 1678
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
Log:
Teiid-909 - changed to use the PropertiesUtils.resolveNestedProperties, removed duplicate logic
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2009-12-16 22:25:58 UTC (rev 1677)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2009-12-16 22:35:48 UTC (rev 1678)
@@ -90,8 +90,6 @@
try {
-// testScenarios();
-
runScenario();
} catch (Throwable t) {
@@ -243,44 +241,11 @@
Properties or = new Properties();
Properties configprops = ConfigPropertyLoader.getInstance().getProperties();
-
- Iterator it = props.keySet().iterator();
- while (it.hasNext()) {
- String key = (String) it.next();
- String value = props.getProperty( key );
- String newValue = value;
- int loc = value.indexOf("${");
- boolean sub = true;
- while (loc > -1) {
-
- int endidx = newValue.indexOf("}", loc);
- String prop_name = newValue.substring(loc + 2, endidx );
-
- String prop_value = or.getProperty(prop_name);
- if (prop_value == null) {
- prop_value = configprops.getProperty(prop_name);
- }
- if (prop_value != null) {
-
- newValue = StringUtil.replace(newValue, "${" + prop_name + "}", prop_value);
- sub = true;
-
- }
- if (newValue.length() > loc + 1 ) {
- loc = newValue.indexOf("${", loc + 1);
- } else {
- loc = -1;
- }
-
-
- }
- if (sub) {
- or.setProperty(key, newValue);
- }
-
- }
+ configprops.putAll(props);
+ or = PropertiesUtils.resolveNestedProperties(configprops);
+
return or;
}
15 years
teiid SVN: r1677 - in trunk/common-core/src: test/java/com/metamatrix/common/util and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-16 17:25:58 -0500 (Wed, 16 Dec 2009)
New Revision: 1677
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
Log:
Teiid-909 - added logic to check for the case when the key is also in the value as ${key}. If found, then bypass resolving this property.
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-12-16 21:23:17 UTC (rev 1676)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-12-16 22:25:58 UTC (rev 1677)
@@ -820,12 +820,22 @@
String nestedkey = value.substring(start+2, end);
String nestedvalue = original.getProperty(nestedkey);
- // this will handle case where we did not resolve, mark it blank
- if (nestedvalue == null) {
- throw new MetaMatrixRuntimeException(CorePlugin.Util.getString("PropertiesUtils.failed_to_resolve_property", nestedkey)); //$NON-NLS-1$
- }
- value = value.substring(0,start)+nestedvalue+value.substring(end+1);
- modified = true;
+ // in cases where the key and the nestedkey are the same, this has to be bypassed
+ // because it will cause an infinite loop, and because there will be no value
+ // for the nestedkey that doesnt contain ${..} in the value
+ if (key.equals(nestedkey)) {
+ matched = false;
+
+ } else {
+
+
+ // this will handle case where we did not resolve, mark it blank
+ if (nestedvalue == null) {
+ throw new MetaMatrixRuntimeException(CorePlugin.Util.getString("PropertiesUtils.failed_to_resolve_property", nestedkey)); //$NON-NLS-1$
+ }
+ value = value.substring(0,start)+nestedvalue+value.substring(end+1);
+ modified = true;
+ }
}
}
if(modified) {
Modified: trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2009-12-16 21:23:17 UTC (rev 1676)
+++ trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2009-12-16 22:25:58 UTC (rev 1677)
@@ -651,6 +651,15 @@
} catch(RuntimeException e) {
// pass
}
+
+
+ // JIRA: TEIID-909 - The resolveNestedProperties logic goes in a loop when the key is also in the value as ${key}.
+ Properties dups = new Properties();
+ dups.setProperty("usethis", "${usethis}");
+
+ dups = PropertiesUtils.resolveNestedProperties(dups);
+
+
}
15 years
teiid SVN: r1676 - trunk/client-jdbc/src/main/java/com/metamatrix/jdbc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-16 16:23:17 -0500 (Wed, 16 Dec 2009)
New Revision: 1676
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
Log:
TEIID-906 changing the update count to 0
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-12-16 21:16:05 UTC (rev 1675)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-12-16 21:23:17 UTC (rev 1676)
@@ -414,7 +414,7 @@
String key = match.group(1);
String value = match.group(2);
this.driverConnection.getConnectionProperties().setProperty(key, value);
- this.updateCounts = new int[] {1};
+ this.updateCounts = new int[] {0};
return;
}
}
15 years
teiid SVN: r1675 - branches/JCA.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-16 16:16:05 -0500 (Wed, 16 Dec 2009)
New Revision: 1675
Removed:
branches/JCA/txn-jbossts/
Log:
TEIID-833: Transaction provider is now provided by the container. No longer need JBossTM specifically.
15 years
teiid SVN: r1674 - branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-16 13:37:06 -0500 (Wed, 16 Dec 2009)
New Revision: 1674
Modified:
branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java
Log:
TEIID-907: fixing some compilation issues with template
Modified: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java 2009-12-16 17:40:05 UTC (rev 1673)
+++ branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java 2009-12-16 18:37:06 UTC (rev 1674)
@@ -12,7 +12,6 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
-import java.util.Random;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.DataNotAvailableException;
@@ -31,9 +30,7 @@
import org.teiid.connector.language.IParameter.Direction;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.query.optimizer.relational.rules.NewCalculateCostUtil;
-
/**
* Execution of a command. This may be select, update or procedure command.
*/
@@ -88,7 +85,7 @@
@Override
public List<?> next() throws ConnectorException, DataNotAvailableException {
- // create and return one row at a time for your
+ // create and return one row at a time for your resultset.
return row;
}
@@ -121,7 +118,7 @@
//TODO: initiate the "abort" of execution
}
- private List<Class<?>> determineOutputTypes(ICommand command) throws ConnectorException {
+ private List determineOutputTypes(ICommand command) throws ConnectorException {
// Get select columns and lookup the types in metadata
if(command instanceof IQueryCommand) {
IQueryCommand query = (IQueryCommand) command;
@@ -149,6 +146,10 @@
// TODO: this method is provided for example purposes only for creating a dummy row.
private Object getValue(Class type) {
+ Calendar cal = Calendar.getInstance();
+ cal.clear();
+ cal.set(1969, 11, 31, 18, 0, 0);
+
if(type.equals(java.lang.String.class)) {
return "some string value";
} else if(type.equals(java.lang.Integer.class)) {
15 years
teiid SVN: r1673 - in branches/JCA: connectors and 19 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-16 12:40:05 -0500 (Wed, 16 Dec 2009)
New Revision: 1673
Added:
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecManagedConnectionFactory.java
branches/JCA/connectors/sandbox/connector-exec/src/main/rar/
branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/
branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectManagedConnectionFactory.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSourceFactory.java
branches/JCA/connectors/sandbox/connector-object/src/main/rar/
branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/
branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooManagedConnectionFactory.java
branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/
branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/
branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/ra.xml
Removed:
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java
Modified:
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
branches/JCA/connectors/pom.xml
branches/JCA/connectors/sandbox/connector-exec/pom.xml
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java
branches/JCA/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java
branches/JCA/connectors/sandbox/connector-object/pom.xml
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java
branches/JCA/connectors/sandbox/connector-yahoo/pom.xml
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java
Log:
TEIID-861: Adding sandbox connectors as JCA connectors
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -5,8 +5,6 @@
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import com.metamatrix.core.util.ReflectionHelper;
-
public abstract class BasicConnector implements Connector {
protected ConnectorEnvironment config;
@@ -30,19 +28,9 @@
public ConnectorCapabilities getCapabilities() throws ConnectorException {
if (capabilities == null) {
// create Capabilities
- String className = this.config.getCapabilitiesClass();
- try {
- if (className != null && className.length() > 0) {
- capabilities = (ConnectorCapabilities) ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
- } else {
- capabilities = getDefaultCapabilities().newInstance();
- }
-
- return capabilities;
- } catch (Exception e) {
- throw new ConnectorException(e);
- }
+ capabilities = BasicManagedConnectionFactory.getInstance(ConnectorCapabilities.class, this.config.getCapabilitiesClass(), getDefaultCapabilities());
}
return capabilities;
}
+
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -244,4 +244,22 @@
public void setOverrideCapabilitiesFile(String propsFile) {
this.overrideCapabilitiesFile = propsFile;
}
+
+ public static <T> T getInstance(Class<T> clazz, String className, Class defaultClass) throws ConnectorException {
+ try {
+ if (className == null) {
+ if (defaultClass == null) {
+ throw new ConnectorException("Neither class name or default class specified to create an instance");
+ }
+ return clazz.cast(defaultClass.newInstance());
+ }
+ return clazz.cast(ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader()));
+ } catch (MetaMatrixCoreException e) {
+ throw new ConnectorException(e);
+ } catch (IllegalAccessException e) {
+ throw new ConnectorException(e);
+ } catch(InstantiationException e) {
+ throw new ConnectorException(e);
+ }
+ }
}
Modified: branches/JCA/connectors/pom.xml
===================================================================
--- branches/JCA/connectors/pom.xml 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/pom.xml 2009-12-16 17:40:05 UTC (rev 1673)
@@ -88,11 +88,12 @@
<module>connector-salesforce</module>
<module>salesforce-api</module>
<module>connector-xml-common</module>
+ <module>sandbox</module>
<!--
<module>connector-xml</module>
- <module>sandbox</module>
+
-->
</modules>
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/sandbox/connector-exec/pom.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/pom.xml 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-exec/pom.xml 2009-12-16 17:40:05 UTC (rev 1673)
@@ -10,6 +10,8 @@
<groupId>org.jboss.teiid.connectors.sandbox</groupId>
<name>Exec Connector</name>
<description>This connector executes Admin API calls and System.exec calls through the connector using SQL representation</description>
+ <packaging>rar</packaging>
+
<dependencies>
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -29,7 +31,30 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-internal</artifactId>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -33,8 +33,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import java.util.Random;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Location;
@@ -43,9 +41,7 @@
import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
import org.apache.tools.ant.taskdefs.PumpStreamHandler;
import org.apache.tools.ant.types.Commandline.Argument;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicExecution;
@@ -61,18 +57,10 @@
*/
public class ExecAntExecution extends BasicExecution implements ResultSetExecution {
- private static final Random random = new Random(System.currentTimeMillis());
-
private static String INSTALL_DIR = ".";//$NON-NLS-1$
- private static final String WIN_EXEC = "win.executable"; //$NON-NLS-1$
- private static final String UNIX_EXEC = "unix.executable"; //$NON-NLS-1$
-
- private static final String DEFAUTL_WIN_EXEC = "cmd.exe"; //$NON-NLS-1$
- private static final String DEFAUTL_UNIX_EXEC = "/bin/sh"; //$NON-NLS-1$
-
// Connector resources
- private ConnectorEnvironment env;
+ private ExecManagedConnectionFactory config;
private List responses = new ArrayList();
private String execcommand;
private boolean isWin = false;
@@ -86,34 +74,28 @@
private List exclusionList;
private IQuery query;
- public ExecAntExecution(IQuery query, ConnectorEnvironment env, RuntimeMetadata metadata, ConnectorLogger logger, List exclusionThese) {
- this.env = env;
+ public ExecAntExecution(IQuery query, ExecManagedConnectionFactory env, RuntimeMetadata metadata, List exclusionThese) {
+ this.config = env;
this.query = query;
if (exclusionThese != null)
exclusionList = exclusionThese;
else
exclusionList = Collections.EMPTY_LIST;
- Properties props = env.getProperties();
if (OSPlatformUtil.isWindows()) {
- execcommand = props.getProperty(WIN_EXEC, DEFAUTL_WIN_EXEC);
- Assertion.isNotNull(execcommand, WIN_EXEC+ " property was not defined for os type"); //$NON-NLS-1$
+ execcommand = this.config.getWinExec();
+ Assertion.isNotNull(execcommand, "windows Exce property was not defined for os type"); //$NON-NLS-1$
isWin = true;
} else {
- execcommand = props.getProperty(UNIX_EXEC, DEFAUTL_UNIX_EXEC);
- Assertion.isNotNull(execcommand, UNIX_EXEC + " property was not defined for os type"); //$NON-NLS-1$
+ execcommand = this.config.getUnixExec();
+ Assertion.isNotNull(execcommand, " Unix exec property was not defined for os type"); //$NON-NLS-1$
}
}
- /*
- * @see com.metamatrix.data.SynchQueryExecution#execute(com.metamatrix.data.language.IQuery,
- * int)
- */
- public void execute()
- throws ConnectorException {
+ public void execute() throws ConnectorException {
- env.getLogger().logTrace("Exec executing command: " + query); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Exec executing command: " + query); //$NON-NLS-1$
org.teiid.connector.language.ICriteria crit = query.getWhere();
if (crit == null)
throw new ConnectorException(ExecPlugin.Util
@@ -135,7 +117,7 @@
try {
execute(command);
} catch (Exception e) {
- env.getLogger().logError("Execution Error", e); //$NON-NLS-1$
+ this.config.getLogger().logError("Execution Error", e); //$NON-NLS-1$
throw new ConnectorException(e);
}
}
@@ -157,8 +139,7 @@
ExecuteMMTask task = createClass();
- env.getLogger().logTrace(
- "Exec: " + execcommand + " command: " + command); //$NON-NLS-1$ //$NON-NLS-2$
+ this.config.getLogger().logTrace("Exec: " + execcommand + " command: " + command); //$NON-NLS-1$ //$NON-NLS-2$
Project p = new Project();
p.init();
@@ -317,13 +298,13 @@
new InputStreamReader(baise));
while ((oneline = ereader.readLine()) != null) {
if (first) {
- env.getLogger().logError("Error Message:"); //$NON-NLS-1$
+ config.getLogger().logError("Error Message:"); //$NON-NLS-1$
first = false;
}
List row = new ArrayList(1);
row.add(oneline);
responseRows.add(row);
- env.getLogger().logError(oneline);
+ config.getLogger().logError(oneline);
}
ereader.close();
} finally {
Modified: branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -23,9 +23,7 @@
package com.metamatrix.connector.exec;
import java.util.List;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicConnection;
@@ -36,19 +34,15 @@
public class ExecConnection extends BasicConnection {
- ConnectorEnvironment env;
-
- // Connector logger
- ConnectorLogger logger;
+ ExecManagedConnectionFactory config;
private List exclusionList;
/**
* Constructor.
* @param env
*/
- ExecConnection(ConnectorEnvironment env, List exclusionThese) throws ConnectorException {
- this.env = env;
- this.logger = env.getLogger();
+ public ExecConnection(ExecManagedConnectionFactory env, List exclusionThese) {
+ this.config = env;
this.exclusionList = exclusionThese;
}
@@ -56,12 +50,12 @@
public ResultSetExecution createResultSetExecution(IQueryCommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new ExecAntExecution((IQuery)command, env, metadata, logger, exclusionList);
+ return new ExecAntExecution((IQuery)command, this.config, metadata, exclusionList);
}
@Override
public void close() {
- logger.logDetail("Exec Connection is successfully closed."); //$NON-NLS-1$
+ this.config.getLogger().logDetail("Exec Connection is successfully closed."); //$NON-NLS-1$
}
}
Modified: branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -32,61 +32,36 @@
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.basic.BasicConnector;
/**
- * Implementation of text connector.
+ * Implementation of Exec connector.
*/
public class ExecConnector extends BasicConnector {
- private ConnectorLogger logger;
- private ConnectorEnvironment env;
- private boolean start = false;
+ private ExecManagedConnectionFactory config;
private List exclusionList= Collections.EMPTY_LIST;
- private String exclusionFile;
- /**
- * Initialization with environment.
- */
@Override
- public void start( ConnectorEnvironment environment ) throws ConnectorException {
- logger = environment.getLogger();
- this.env = environment;
+ public void initialize(ConnectorEnvironment config ) throws ConnectorException {
+ super.initialize(config);
+ this.config = (ExecManagedConnectionFactory)config;
- exclusionFile = environment.getProperties().getProperty("exclusionFile"); //$NON-NLS-1$
- if(exclusionFile != null && exclusionFile.trim().length() > 0)
- {
- loadExclusionFile(exclusionFile);
+ if(this.config.getExclusionFile() != null) {
+ loadExclusionFile(this.config.getExclusionFile());
}
-
- // logging
- logger = environment.getLogger();
- start = true;
- logger.logInfo("Exec Connector is started."); //$NON-NLS-1$
}
- public void stop() {
- if(!start){
- return;
- }
-
- start = false;
- logger.logInfo("Exec Connector is stoped."); //$NON-NLS-1$
- }
@Override
- public ConnectorCapabilities getCapabilities() {
- return new ExecCapabilities();
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return ExecCapabilities.class;
+ }
+
+ @Override
+ public Connection getConnection() throws ConnectorException {
+ return new ExecConnection(this.config, exclusionList);
}
-
- /*
- * @see com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
- public Connection getConnection(ExecutionContext context) throws ConnectorException {
- return new ExecConnection(this.env, exclusionList);
- }
protected void loadExclusionFile(String file) throws ConnectorException {
try {
@@ -96,7 +71,7 @@
String key;
for (Iterator it = props.keySet().iterator(); it.hasNext(); exclusionList.add(((String) props.get(key)).trim().toLowerCase())) {
key = (String) it.next();
- logger.logInfo("Exec Connector - exclude: " + props.get(key));//$NON-NLS-1$
+ this.config.getLogger().logInfo("Exec Connector - exclude: " + props.get(key));//$NON-NLS-1$
}
} catch (IOException err) {
Added: branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecManagedConnectionFactory.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecManagedConnectionFactory.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.exec;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class ExecManagedConnectionFactory extends BasicManagedConnectionFactory {
+ private static final long serialVersionUID = -6043344027191788677L;
+
+ private String exclusionFile;
+ private String winExec;
+ private String unixExec;
+
+ public String getExclusionFile() {
+ return exclusionFile;
+ }
+
+ public void setExclusionFile(String exclusionFile) {
+ this.exclusionFile = exclusionFile;
+ }
+
+ public String getWinExec() {
+ return winExec;
+ }
+
+ public void setWinExec(String winExec) {
+ this.winExec = winExec;
+ }
+
+ public String getUnixExec() {
+ return unixExec;
+ }
+
+ public void setUnixExec(String unixExec) {
+ this.unixExec = unixExec;
+ }
+
+}
Added: branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/connectors/sandbox/connector-exec/src/main/rar/META-INF/ra.xml 2009-12-16 17:40:05 UTC (rev 1673)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid Exec Connector</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>com.metamatrix.connector.exec.ExecManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.exec.ExecConnector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector Capabilities</description>
+ <config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.exec.ExecCapabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never changes.</description>
+ <config-property-name>Immutable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+ <config-property-name>ExceptionOnMaxRows</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- Exec Specific properties -->
+
+ <config-property>
+ <description>Exclusion File</description>
+ <config-property-name>exclusionFile</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Windows Exec</description>
+ <config-property-name>WinExec</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>cmd.exe</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Unix Exec</description>
+ <config-property-name>UnixExec</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>/bin/sh</config-property-value>
+ </config-property>
+
+ <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+ <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+ <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Modified: branches/JCA/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -28,18 +28,17 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.ResultSetExecution;
-import junit.framework.TestCase;
-
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.core.util.UnitTestUtil;
-/**
- */
public class TestsExec extends TestCase {
private List expectedResults;
@@ -56,14 +55,13 @@
public void tearDown(){
if(this.connector != null){
- this.connector.stop();
this.connector = null;
}
expectedResults = null;
}
- private void executeCommand(Properties props) throws ConnectorException{
- ConnectorHost host = new ConnectorHost(new FakeExecConnector(), props, vdbFile, false);
+ private void executeCommand(ExecManagedConnectionFactory config) throws ConnectorException{
+ ConnectorHost host = new ConnectorHost(new FakeExecConnector(), config, vdbFile);
List results = host.executeCommand(command); //$NON-NLS-1$
if (results != null && !results.isEmpty()) {
for (Iterator it=results.iterator(); it.hasNext();) {
@@ -78,17 +76,12 @@
executeCommand(getConnectorProperties());
}
- private Properties getConnectorProperties()
- {
- Properties props = new Properties();
- props.setProperty("win.executable", "cmd.exe");//$NON-NLS-1$ //$NON-NLS-2$
-
- props.setProperty("CapabilitiesClass", "com.metamatrix.connector.exec.ExecCapabilities"); //$NON-NLS-1$ //$NON-NLS-2$
- props.setProperty("ConnectorClass", "com.metamatrix.connector.exec.ExecConnnector"); //$NON-NLS-1$ //$NON-NLS-2$
- props.setProperty("ServiceClassName", "com.metamatrix.server.connector.service.ConnectorService"); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- return props;
+ private ExecManagedConnectionFactory getConnectorProperties(){
+ ExecManagedConnectionFactory config = Mockito.mock(ExecManagedConnectionFactory.class);
+ Mockito.stub(config.getWinExec()).toReturn("cmd.exe");
+ Mockito.stub(config.getUnixExec()).toReturn("/bin/sh");
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+ return config;
}
//actual tests
@@ -107,13 +100,13 @@
List row1 = new ArrayList();
row1.add("filename"); //$NON-NLS-1$
expectedResults.add(row1);
- Properties prop = getConnectorProperties();
+
String f = UnitTestUtil.getTestDataPath() + File.separator+ "exclusionFile.properties"; //$NON-NLS-1$
- prop.setProperty("exclusionFile", f);//$NON-NLS-1$
- prop.setProperty("ConnectorClass", "com.metamatrix.connector.exec.TestExecConnnector"); //$NON-NLS-1$ //$NON-NLS-2$
-
+ ExecManagedConnectionFactory config = getConnectorProperties();
+ Mockito.stub(config.getExclusionFile()).toReturn(f);
+
try {
- executeCommand(prop);
+ executeCommand(config);
fail("rm was in the exclusion file, should not have run"); //$NON-NLS-1$
} catch (ConnectorException ce) {
//System.out.print("Passed: " + ce.getMessage()); //$NON-NLS-1$
Modified: branches/JCA/connectors/sandbox/connector-object/pom.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/pom.xml 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/pom.xml 2009-12-16 17:40:05 UTC (rev 1673)
@@ -10,6 +10,7 @@
<artifactId>connector-object</artifactId>
<groupId>org.jboss.teiid.connectors.sandbox</groupId>
<name>Object Connector</name>
+ <packaging>rar</packaging>
<description>This is generic connector that can be used to wrap
any JAVA API, and turn it into connector</description>
<dependencies>
@@ -24,15 +25,33 @@
<scope>provided</scope>
</dependency>
+
<dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.6.5</version>
- </dependency>
- <dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-internal</artifactId>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -43,48 +43,22 @@
*/
public class ObjectConnection extends BasicConnection {
-// private static final String DEFAULT_TRANSLATOR = "com.metamatrix.connector.object.extension.source.BasicSourceTranslator";//$NON-NLS-1$
-
private ISourceTranslator translator;
- private IObjectSource api;
+ private IObjectSource objectSource;
+ private ObjectManagedConnectionFactory env;
-
- private ConnectorEnvironment env;
- // Connector logger
- ConnectorLogger logger;
-
- /**
- * Constructor.
- * @param env
- * @throws AdminException
- */
- public ObjectConnection(ConnectorEnvironment environment, IObjectSource objectSource) throws ConnectorException {
+ public ObjectConnection(ObjectManagedConnectionFactory environment, IObjectSource objectSource, ISourceTranslator translator) {
if (objectSource == null) {
ArgCheck.isNotNull(objectSource, "ObjectSource is null");//$NON-NLS-1$
}
- this.api = objectSource;
+ this.objectSource = objectSource;
this.env = environment;
- this.logger = environment.getLogger();
-
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- this.translator = ObjectConnectorUtil.createTranslator(environment, loader);
- } catch (ClassNotFoundException e1) {
- throw new ConnectorException(e1);
- } catch (InstantiationException e2) {
- throw new ConnectorException(e2);
- } catch (IllegalAccessException e3) {
- throw new ConnectorException(e3);
- }
-
-
+ this.translator = translator;
}
@Override
- public ProcedureExecution createProcedureExecution(IProcedure command,
- ExecutionContext executionContext, RuntimeMetadata metadata)
+ public ProcedureExecution createProcedureExecution(IProcedure command, ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
return new ObjectProcedureExecution(command, getObjectSource(), translator, metadata, env);
}
@@ -94,7 +68,7 @@
* @since 4.3
*/
public IObjectSource getObjectSource() {
- return api;
+ return objectSource;
}
/**
@@ -103,15 +77,10 @@
*/
public void close() {
try {
- api.closeSource();
+ objectSource.closeSource();
} catch(Exception e) {
}
-
- translator=null;
- logger =null;
- api=null;
- env=null;
}
/**
@@ -119,12 +88,6 @@
* @since 4.3
*/
public boolean isAlive() {
- return api.isAlive();
+ return objectSource.isAlive();
}
-
- @Override
- public void closeCalled() {
-
- }
-
}
Modified: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -26,81 +26,40 @@
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.basic.BasicConnector;
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
-import com.metamatrix.connector.object.util.ObjectConnectorUtil;
+import com.metamatrix.connector.object.extension.IObjectSourceFactory;
+import com.metamatrix.connector.object.extension.ISourceTranslator;
+import com.metamatrix.connector.object.extension.source.BasicSourceTranslator;
/**
- * Implmentation of the connector interface.
+ * Implementation of the connector interface.
*/
public class ObjectConnector extends BasicConnector {
- private ConnectorLogger logger;
- private ConnectorEnvironment env;
- private boolean start = false;
- private SourceConnectionFactory factory;
- private ConnectorCapabilities capabilities;
+ private ObjectManagedConnectionFactory config;
+ IObjectSourceFactory objectSourceFactory;
- /**
- * Initialization with environment.
- */
- public void start( ConnectorEnvironment environment ) throws ConnectorException {
- logger = environment.getLogger();
- this.env = environment;
-
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- this.capabilities = ObjectConnectorUtil.createCapabilities(environment, loader);
- factory = ObjectConnectorUtil.createFactory(this.env, loader);
- } catch (ClassNotFoundException e1) {
- throw new ConnectorException(e1);
- } catch (InstantiationException e2) {
- throw new ConnectorException(e2);
- } catch (IllegalAccessException e3) {
- throw new ConnectorException(e3);
- }
-
- //test connection
- getConnection(null);
-
- start = true;
- logger.logInfo(ObjectPlugin.Util.getString("ObjectConnector.Connector_started_4"));//$NON-NLS-1$
+ @Override
+ public void initialize(ConnectorEnvironment environment) throws ConnectorException {
+ this.config = (ObjectManagedConnectionFactory)environment;
+ this.objectSourceFactory = BasicManagedConnectionFactory.getInstance(IObjectSourceFactory.class, this.config.getObjectSourceFactoryClass(), null);
}
- public void stop() {
- if(!start){
- return;
- }
-
- env = null;
- start = false;
-
- logger.logInfo(ObjectPlugin.Util.getString("ObjectConnector.Connector_stopped_3"));//$NON-NLS-1$
-
- logger = null;
- }
-
- /*
- * @see com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
+
@Override
- public Connection getConnection(final ExecutionContext context) throws ConnectorException {
- return factory.createConnection(factory.createIdentity(context));
+ public Connection getConnection()throws ConnectorException {
+ ISourceTranslator translator = BasicManagedConnectionFactory.getInstance(ISourceTranslator.class, this.config.getExtensionResultsTranslationClass(), BasicSourceTranslator.class);
+ translator.initialize(this.config);
+
+ return new ObjectConnection(config, objectSourceFactory.getObjectSource(this.config), translator);
}
@Override
- public ConnectorCapabilities getCapabilities() {
- return capabilities;
- }
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return ObjectConnectorCapabilities.class;
+ }
- @Override
- public ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException {
- return factory.createIdentity(context);
- }
-
}
Added: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectManagedConnectionFactory.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectManagedConnectionFactory.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.object;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class ObjectManagedConnectionFactory extends BasicManagedConnectionFactory {
+
+ private static final long serialVersionUID = -6901150512654296254L;
+ private String extensionResultsTranslationClass;
+ private String objectSourceFactoryClass;
+
+ public String getObjectSourceFactoryClass() {
+ return objectSourceFactoryClass;
+ }
+
+ public void setObjectSourceFactoryClass(String objectSourceFactoryClass) {
+ this.objectSourceFactoryClass = objectSourceFactoryClass;
+ }
+
+ private String databaseTimeZone;
+ private boolean trimStrings;
+
+ public String getExtensionResultsTranslationClass() {
+ return extensionResultsTranslationClass;
+ }
+
+ public void setExtensionResultsTranslationClass(String extensionResultsTranslationClass) {
+ this.extensionResultsTranslationClass = extensionResultsTranslationClass;
+ }
+
+ public String getDatabaseTimeZone() {
+ return databaseTimeZone;
+ }
+
+ public void setDatabaseTimeZone(String databaseTimeZone) {
+ this.databaseTimeZone = databaseTimeZone;
+ }
+
+ public boolean isTrimStrings() {
+ return trimStrings;
+ }
+
+ public void setTrimStrings(Boolean trimStrings) {
+ this.trimStrings = trimStrings.booleanValue();
+ }
+}
Modified: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -24,13 +24,11 @@
import java.util.List;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ProcedureExecution;
import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.IParameter;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -64,23 +62,17 @@
public ObjectProcedureExecution(IProcedure procedure, IObjectSource sourceapi,
ISourceTranslator translator,
RuntimeMetadata metadata,
- ConnectorEnvironment environment) {
+ ObjectManagedConnectionFactory environment) {
this.procedure = procedure;
this.metadata = metadata;
this.logger = environment.getLogger();
this.api = sourceapi;
this.translator = translator;
this.metadata = metadata;
-
- String propStr = environment.getProperties().getProperty(ObjectPropertyNames.TRIM_STRINGS);
- if(propStr != null){
- trimString = Boolean.valueOf(propStr).booleanValue();
- }
-
+ this.trimString = environment.isTrimStrings();
}
-
/**
* @see org.teiid.connector.api.ProcedureExecution#execute(org.teiid.connector.language.IProcedure, int)
* @since 4.2
Deleted: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -1,42 +0,0 @@
-package com.metamatrix.connector.object;
-
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.SingleIdentity;
-
-public interface SourceConnectionFactory {
-
- /**
- * Set the environment that this factory is being run in - typically used
- * to obtain properties when creating connections and to log messages as
- * necessary.
- * @param env The environment passed to the connector by the connector manager
- */
- void initialize(ConnectorEnvironment env) throws ConnectorException;
-
- /**
- * Create the source-specific connection based on an identity.
- * @param id The identity object
- * @return The source-specific connection
- * @throws ConnectorException If an error occurs while creating the connection
- */
- Connection createConnection(ConnectorIdentity id) throws ConnectorException;
-
- /**
- * Create an identity object based on a security context. This method determines
- * how different security contexts are treated within the connection pool. For
- * example, using a {@link SingleIdentity} specifies that ALL contexts are treated
- * equally and thus use the same pool. A {@link CredentialMapIdentity} specifies that contexts
- * are differentiated based on user name, thus creating a per-user pool of connections.
- * Implementors of this class may use a different implementation of the
- * {@link ConnectorIdentity} interface to similarly affect pooling.
- * @param context The context provided by the Connector Manager
- * @return The associated connector identity
- * @throws ConnectorException If an error occurs while creating the identity
- */
- ConnectorIdentity createIdentity(ExecutionContext context) throws ConnectorException;
-
-}
Added: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSourceFactory.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSourceFactory.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSourceFactory.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.object.extension;
+
+import org.teiid.connector.api.ConnectorException;
+
+import com.metamatrix.connector.object.ObjectManagedConnectionFactory;
+
+public interface IObjectSourceFactory {
+ IObjectSource getObjectSource(ObjectManagedConnectionFactory config) throws ConnectorException ;
+}
Modified: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -26,13 +26,14 @@
import java.util.TimeZone;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.language.ICommand;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.object.ObjectManagedConnectionFactory;
+
/**
* Specify source-specific behavior for translating results.
*/
@@ -44,7 +45,7 @@
* @param env The connector environment
* @throws ConnectorException If an error occurs during initialization
*/
- void initialize(ConnectorEnvironment env) throws ConnectorException;
+ void initialize(ObjectManagedConnectionFactory env) throws ConnectorException;
/**
* Determine the time zone the database is located in. Typically, this time zone is
Deleted: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.object.extension.source;
-
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.SingleIdentity;
-
-import com.metamatrix.connector.object.ObjectConnection;
-import com.metamatrix.connector.object.SourceConnectionFactory;
-import com.metamatrix.connector.object.extension.IObjectSource;
-
-/**
- * Represents a base factory class for the creation of the source connection. Subclasses
- * are expected to implement the #getObjectSource method to provide the source specific
- * implmentation to interact with the source.
- */
-public abstract class BaseSourceConnectionFactory implements SourceConnectionFactory {
-
- private ConnectorEnvironment environment;
-
- /**
- *
- */
- public BaseSourceConnectionFactory() {
- super();
- }
-
- public void initialize(ConnectorEnvironment env) throws ConnectorException {
- this.environment = env;
- }
-
- protected ConnectorEnvironment getEnvironment() {
- return environment;
- }
-
-
- /**
- * @see com.metamatrix.data.pool.SourceConnectionFactory#createConnection(org.teiid.connector.api.ConnectorIdentity)
- * @since 4.3
- */
- public final Connection createConnection(ConnectorIdentity id) throws ConnectorException {
-
- // must pass the factory to the object source because the factory
- // is used to close the connection
- IObjectSource objectSource = getObjectSource(id);
-
- return new ObjectConnection(getEnvironment(), objectSource);
-
- }
-
- protected abstract IObjectSource getObjectSource(final ConnectorIdentity id) throws ConnectorException ;
-
-
- /**
- * @see com.metamatrix.data.pool.SourceConnectionFactory#createIdentity(com.metamatrix.data.api.SecurityContext)
- * @since 4.3
- */
- public ConnectorIdentity createIdentity(ExecutionContext context) throws ConnectorException {
- return new SingleIdentity();
- }
-
-}
Modified: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -26,14 +26,13 @@
import java.util.TimeZone;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.object.ObjectPropertyNames;
+import com.metamatrix.connector.object.ObjectManagedConnectionFactory;
import com.metamatrix.connector.object.extension.IObjectCommand;
import com.metamatrix.connector.object.extension.ISourceTranslator;
import com.metamatrix.connector.object.extension.IValueRetriever;
@@ -53,12 +52,11 @@
/**
* @see com.metamatrix.connector.jdbc.extension.ResultsTranslator#initialize(com.metamatrix.data.ConnectorEnvironment)
*/
- public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ public void initialize(ObjectManagedConnectionFactory env) throws ConnectorException {
this.typeFacility = env.getTypeFacility();
-
- String timeZone = env.getProperties().getProperty(ObjectPropertyNames.DATABASE_TIME_ZONE);
+ String timeZone = env.getDatabaseTimeZone();
if(timeZone != null && timeZone.trim().length() > 0) {
this.dbmsTimeZone = TimeZone.getTimeZone(timeZone);
Modified: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -22,10 +22,6 @@
package com.metamatrix.connector.object.util;
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IMetadataReference;
@@ -33,9 +29,6 @@
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.object.ObjectPlugin;
-import com.metamatrix.connector.object.ObjectPropertyNames;
-import com.metamatrix.connector.object.SourceConnectionFactory;
-import com.metamatrix.connector.object.extension.ISourceTranslator;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -43,11 +36,8 @@
* @since 4.3
*/
public class ObjectConnectorUtil {
- private static final String DEFAULT_TRANSLATOR = "com.metamatrix.connector.object.extension.source.BasicSourceTranslator";//$NON-NLS-1$
- private static final String DEFAULT_CAPABILITIES = "com.metamatrix.connector.object.ObjectConnectorCapabilities";//$NON-NLS-1$
-
- public static final String getMetadataObjectNameInSource(final RuntimeMetadata metadata, final ICommand command, IMetadataReference reference) throws ConnectorException {
+ public static final String getMetadataObjectNameInSource(final RuntimeMetadata metadata, final ICommand command, IMetadataReference reference) throws ConnectorException {
if(reference == null) {
return null;
}
@@ -58,64 +48,6 @@
}
return null;
}
- throw new MetaMatrixRuntimeException(
- ObjectPlugin.Util.getString("ObjectConnector.Could_not_resolve_name_for_query___1", //$NON-NLS-1$
- new Object[] {command.toString()}));
-
+ throw new MetaMatrixRuntimeException(ObjectPlugin.Util.getString("ObjectConnector.Could_not_resolve_name_for_query___1",new Object[] { command.toString() }));
}
-
- public static final SourceConnectionFactory createFactory(final ConnectorEnvironment environment, ClassLoader loader)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException, ConnectorException {
- if (environment == null || loader == null || environment.getProperties() == null) {
- return null;
- }
-
- Properties props = environment.getProperties();
- String scfClassName = props.getProperty(ObjectPropertyNames.EXT_CONNECTION_FACTORY_CLASS);
-
- //create source connection factory
- Class scfClass = loader.loadClass(scfClassName);
- SourceConnectionFactory adminFactory = (SourceConnectionFactory) scfClass.newInstance();
- adminFactory.initialize(environment);
-
- return adminFactory;
-
- }
-
- public static final ISourceTranslator createTranslator(final ConnectorEnvironment environment, ClassLoader loader)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException, ConnectorException {
-
- //create ResultsTranslator
- ISourceTranslator translator = null;
- String className = environment.getProperties().getProperty(ObjectPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS);
- if (className == null) {
- environment.getLogger().logInfo( ObjectPlugin.Util.getString("ObjectConnector.Property_{0}_is_not_defined_use_default", new Object[] {ObjectPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS, DEFAULT_TRANSLATOR} )); //$NON-NLS-1$
- className = DEFAULT_TRANSLATOR;
- }
-
- Class sourceTransClass = loader.loadClass(className);
- translator = (ISourceTranslator) sourceTransClass.newInstance();
- translator.initialize(environment);
-
- return translator;
-
- }
-
-
- public static final ConnectorCapabilities createCapabilities(final ConnectorEnvironment environment, ClassLoader loader)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException, ConnectorException {
-
- //create Capabilities
- ConnectorCapabilities capabilities;
- String className = environment.getProperties().getProperty(ObjectPropertyNames.EXT_CAPABILITY_CLASS);
- if(className == null){
- environment.getLogger().logInfo( ObjectPlugin.Util.getString("ObjectConnector.Property_{0}_is_not_defined_use_default", new Object[] {ObjectPropertyNames.EXT_CAPABILITY_CLASS, DEFAULT_CAPABILITIES} )); //$NON-NLS-1$
- className = DEFAULT_CAPABILITIES;
- }
- Class capabilitiesClass = loader.loadClass(className);
- capabilities = (ConnectorCapabilities) capabilitiesClass.newInstance();
-
- return capabilities;
- }
-
}
Added: branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/rar/META-INF/ra.xml 2009-12-16 17:40:05 UTC (rev 1673)
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid Object Connector</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>com.metamatrix.connector.object.ObjectManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.object.ObjectConnector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector Capabilities</description>
+ <config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.object.ObjectConnectorCapabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never changes.</description>
+ <config-property-name>Immutable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+ <config-property-name>ExceptionOnMaxRows</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- Object Specific properties -->
+
+ <config-property>
+ <description>Object Source Factory Class</description>
+ <config-property-name>ObjectSourceFactoryClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Results Translation Class</description>
+ <config-property-name>ExtensionResultsTranslationClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.object.extension.source.BasicSourceTranslator</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Database Timezone</description>
+ <config-property-name>DatabaseTimeZone</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Trim Result Strings</description>
+ <config-property-name>TrimStrings</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+
+ <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+ <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+ <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Modified: branches/JCA/connectors/sandbox/connector-yahoo/pom.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/pom.xml 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-yahoo/pom.xml 2009-12-16 17:40:05 UTC (rev 1673)
@@ -10,7 +10,7 @@
<groupId>org.jboss.teiid.connectors.sandbox</groupId>
<name>Yahoo Connector</name>
<description>Test connector used to query ticker symbols from Yahoo website</description>
-
+ <packaging>rar</packaging>
<dependencies>
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -22,5 +22,27 @@
<artifactId>teiid-common-core</artifactId>
<scope>provided</scope>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.yahoo;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
@@ -37,26 +36,18 @@
*/
public class YahooConnection extends BasicConnection {
- private ConnectorEnvironment env;
+ private YahooManagedConnectionFactory config;
- /**
- *
- */
- public YahooConnection(ConnectorEnvironment env) {
- this.env = env;
+ public YahooConnection(YahooManagedConnectionFactory env) {
+ this.config = env;
}
@Override
- public ResultSetExecution createResultSetExecution(IQueryCommand command,
- ExecutionContext executionContext, RuntimeMetadata metadata)
+ public ResultSetExecution createResultSetExecution(IQueryCommand command, ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new YahooExecution((IQuery)command, env, metadata);
+ return new YahooExecution((IQuery)command, config, metadata);
}
-
- /*
- * @see com.metamatrix.data.Connection#close()
- */
public void close() {
// nothing to do
}
Modified: branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -22,48 +22,28 @@
package com.metamatrix.connector.yahoo;
-import org.teiid.connector.api.*;
+import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.basic.BasicConnector;
public class YahooConnector extends BasicConnector {
- private ConnectorEnvironment env;
+ private YahooManagedConnectionFactory config;
- static final ConnectorCapabilities CAPABILITIES = new YahooCapabilities();
-
- /**
- *
- */
- public YahooConnector() {
- super();
- }
-
- /*
- * @see com.metamatrix.data.Connector#initialize(com.metamatrix.data.ConnectorEnvironment)
- */
@Override
- public void start(ConnectorEnvironment environment) throws ConnectorException {
- this.env = environment;
+ public void initialize(ConnectorEnvironment environment) throws ConnectorException {
+ this.config = (YahooManagedConnectionFactory)environment;
}
- /*
- * @see com.metamatrix.data.Connector#stop()
- */
@Override
- public void stop() {
- // nothing to do
+ public Connection getConnection() throws ConnectorException {
+ return new YahooConnection(this.config);
}
-
- /*
- * @see com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
+
@Override
- public Connection getConnection(ExecutionContext context) throws ConnectorException {
- return new YahooConnection(env);
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return YahooCapabilities.class;
}
-
- @Override
- public ConnectorCapabilities getCapabilities() {
- return CAPABILITIES;
- }
}
Modified: branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2009-12-16 00:07:07 UTC (rev 1672)
+++ branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -35,11 +35,9 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
@@ -59,8 +57,6 @@
* Represents the execution of a command.
*/
public class YahooExecution extends BasicExecution implements ResultSetExecution {
- public static final String HTTP_PROXY_HOST = "HttpProxyHost"; //$NON-NLS-1$
- public static final String HTTP_PROXY_PORT = "HttpProxyPort"; //$NON-NLS-1$
public static final String JAVA_PROP_HTTP_PROXY_HOST = "http.proxyHost"; //$NON-NLS-1$
public static final String JAVA_PROP_HTTP_PROXY_PORT = "http.proxyPort"; //$NON-NLS-1$
@@ -69,7 +65,7 @@
private static SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mma"); //$NON-NLS-1$
// Connector resources
- private ConnectorEnvironment env;
+ private YahooManagedConnectionFactory config;
private RuntimeMetadata metadata;
private IQuery command;
@@ -85,8 +81,8 @@
/**
*
*/
- public YahooExecution(IQuery query, ConnectorEnvironment env, RuntimeMetadata metadata) {
- this.env = env;
+ public YahooExecution(IQuery query, YahooManagedConnectionFactory env, RuntimeMetadata metadata) {
+ this.config = env;
this.metadata = metadata;
this.query = query;
}
@@ -97,13 +93,13 @@
@Override
public void execute() throws ConnectorException {
// Log our command
- env.getLogger().logTrace("Yahoo executing command: " + command); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Yahoo executing command: " + command); //$NON-NLS-1$
// Build url
String yahooUrl = translateIntoUrl(query);
// Execute url to get results
- this.results = executeUrl(yahooUrl, this.env.getLogger());
+ this.results = executeUrl(yahooUrl, this.config.getLogger());
// Determine needed columns in results
this.neededColumns = getNeededColumns(query.getSelect(), this.metadata);
@@ -307,16 +303,16 @@
}
private void setProxy() {
- Properties props = env.getProperties();
- String proxyHost = props.getProperty(HTTP_PROXY_HOST);
- String proxyPort = props.getProperty(HTTP_PROXY_PORT);
+ String proxyHost = this.config.getHttpProxyHost();
+ String proxyPort = this.config.getHttpProxyPort();
+
previousHttpProxyHost = System.getProperty(JAVA_PROP_HTTP_PROXY_HOST);
previousHttpProxyPort = System.getProperty(JAVA_PROP_HTTP_PROXY_PORT);
if(proxyHost != null) {
System.setProperty(JAVA_PROP_HTTP_PROXY_HOST, proxyHost);
if(proxyPort == null) {
- env.getLogger().logWarning(YahooPlugin.Util.getString("YahooConnector.proxyPortNotSet"));//$NON-NLS-1$
+ this.config.getLogger().logWarning(YahooPlugin.Util.getString("YahooConnector.proxyPortNotSet"));//$NON-NLS-1$
}else {
System.setProperty(JAVA_PROP_HTTP_PROXY_PORT, proxyPort);
}
Added: branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooManagedConnectionFactory.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooManagedConnectionFactory.java 2009-12-16 17:40:05 UTC (rev 1673)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.yahoo;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class YahooManagedConnectionFactory extends BasicManagedConnectionFactory {
+
+ private static final long serialVersionUID = -8938107803750844843L;
+
+ private String httpProxyHost;
+ private String httpProxyPort;
+
+ public String getHttpProxyHost() {
+ return httpProxyHost;
+ }
+
+ public void setHttpProxyHost(String httpProxyHost) {
+ this.httpProxyHost = httpProxyHost;
+ }
+
+ public String getHttpProxyPort() {
+ return httpProxyPort;
+ }
+
+ public void setHttpProxyPort(String httpProxyPort) {
+ this.httpProxyPort = httpProxyPort;
+ }
+
+
+}
Added: branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/connectors/sandbox/connector-yahoo/src/main/rar/META-INF/ra.xml 2009-12-16 17:40:05 UTC (rev 1673)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid Yahoo Connector</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>com.metamatrix.connector.yahoo.YahooManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.yahoo.YahooConnector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector Capabilities</description>
+ <config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.yahoo.YahooCapabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never changes.</description>
+ <config-property-name>Immutable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+ <config-property-name>ExceptionOnMaxRows</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- Yahoo Specific properties -->
+
+ <config-property>
+ <description>HttpProxyHost</description>
+ <config-property-name>HttpProxyHost</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>HttpProxyPort</description>
+ <config-property-name>HttpProxyPort</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+ <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+ <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
15 years
teiid SVN: r1672 - in trunk/test-integration/db/src: main/java/org/teiid/test/framework and 4 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-15 19:07:07 -0500 (Tue, 15 Dec 2009)
New Revision: 1672
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
Removed:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
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/TestLogger.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/DataSourceConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
Log:
Teiid 897 - changes to autowrap mode
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -25,12 +25,11 @@
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.transaction.AutoWrapTransaction;
import org.teiid.test.framework.transaction.JNDITransaction;
import org.teiid.test.framework.transaction.LocalTransaction;
import org.teiid.test.framework.transaction.OffWrapTransaction;
import org.teiid.test.framework.transaction.OnWrapTransaction;
-import org.teiid.test.framework.transaction.OptimisticWrapTransaction;
-import org.teiid.test.framework.transaction.PessimisticWrapTransaction;
import org.teiid.test.framework.transaction.XATransaction;
@@ -58,8 +57,7 @@
public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
public static final String OFFWRAP_TRANSACTION = "offwrap"; //$NON-NLS-1$
public static final String ONWRAP_TRANSACTION = "onwrap"; //$NON-NLS-1$
- public static final String OPTIMISTICWRAP_TRANSACTION = "optwrap"; //$NON-NLS-1$
- public static final String PESSIMISTICWRAP_TRANSACTION = "pesswrap"; //$NON-NLS-1$
+ public static final String AUTOWRAP_TRANSACTION = "autowrap"; //$NON-NLS-1$
}
@@ -92,13 +90,9 @@
else if (type.equalsIgnoreCase(TRANSACTION_TYPES.ONWRAP_TRANSACTION)) {
transacton = new OnWrapTransaction();
}
- else if (type.equalsIgnoreCase(TRANSACTION_TYPES.OPTIMISTICWRAP_TRANSACTION)) {
- transacton = new OptimisticWrapTransaction();
- }
- else if (type.equalsIgnoreCase(TRANSACTION_TYPES.PESSIMISTICWRAP_TRANSACTION)) {
- transacton = new PessimisticWrapTransaction();
+ else if (type.equalsIgnoreCase(TRANSACTION_TYPES.AUTOWRAP_TRANSACTION)) {
+ transacton = new AutoWrapTransaction();
-
} else {
throw new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE );
}
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-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -60,12 +60,10 @@
}
_instance = new ConfigPropertyLoader();
- try {
- _instance.initialize();
- } catch (TransactionRuntimeException e) {
- throw e;
- }
+ _instance.initialize();
+
+
return _instance;
}
@@ -148,8 +146,12 @@
Properties p = new Properties();
p.putAll(System.getProperties());
- p.putAll(props);
- p.putAll(overrides);
+ if (props != null) {
+ p.putAll(props);
+ }
+ if (overrides != null) {
+ p.putAll(overrides);
+ }
return p;
}
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-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -120,11 +120,10 @@
}
public interface TXN_AUTO_WRAP_OPTIONS {
- public static final String AUTO_WRAP_OFF = "OFF"; //$NON-NLS-1$
- public static final String AUTO_WRAP_ON = "ON"; //$NON-NLS-1$
- public static final String AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"; //$NON-NLS-1$
- public static final String AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"; //$NON-NLS-1$
-
+ public static final String AUTO_WRAP_OFF = ExecutionProperties.TXN_WRAP_OFF; //$NON-NLS-1$
+ public static final String AUTO_WRAP_ON = ExecutionProperties.TXN_WRAP_ON; //$NON-NLS-1$
+ public static final String AUTO_WRAP_AUTO = ExecutionProperties.TXN_WRAP_AUTO; //$NON-NLS-1$
+
}
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -38,17 +38,17 @@
public static final Level DEBUG = Level.FINEST;
public static final Level IMPORTANT = Level.FINE;
- private static final Logger LOGGER = Logger.getLogger("org.teiid.test");
+ // private static final Logger LOGGER = Logger.getLogger("org.teiid.test");
static {
BasicConfigurator.configure(new ConsoleAppender());
- LOGGER.setLevel(INFO);
+// LOGGER.setLevel(INFO);
}
public static final void setLogLevel(Level level) {
- LOGGER.setLevel(level);
+// LOGGER.setLevel(level);
}
public static final void logDebug(String msg) {
@@ -75,11 +75,11 @@
}
private static final void log(Level javaLevel, Object msg, Throwable t) {
-// System.out.println(msg);
- if (LOGGER.isLoggable(javaLevel)) {
-
- LOGGER.log(javaLevel, msg.toString(), t);
- }
+ System.out.println(msg);
+// if (LOGGER.isLoggable(javaLevel)) {
+//
+// LOGGER.log(javaLevel, msg.toString(), t);
+// }
}
}
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-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -130,26 +130,28 @@
if (this.isDataStoreDisabled()) {
return;
}
-
- com.metamatrix.jdbc.MMConnection c = null;
+
try {
// the the driver strategy is going to be used to connection directly to the connector binding
// source, then no administration can be done
-
+ Admin admin = null;
+
java.sql.Connection conn = getConnection();
+
if ( conn instanceof com.metamatrix.jdbc.MMConnection) {
- c = (com.metamatrix.jdbc.MMConnection) conn;
+ com.metamatrix.jdbc.MMConnection c = (com.metamatrix.jdbc.MMConnection) conn;
+ admin = (Admin)c.getAdminAPI();
+ } else if (conn instanceof com.metamatrix.jdbc.api.Connection) {
+ com.metamatrix.jdbc.api.Connection c = (com.metamatrix.jdbc.api.Connection) conn;
+ admin = (Admin)c.getAdminAPI();
} else {
TestLogger.log("ConnectionStrategy configuration: connection is not of type MMConnection and therefore no vdb setup will be performed");
return;
}
+
+ setupVDBConnectorBindings(admin);
- Admin admin = (Admin)c.getAdminAPI();
-
- setupVDBConnectorBindings(admin);
-
-
// admin.restart();
int sleep = 5;
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-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -107,7 +107,7 @@
public Connection getConnection() throws QueryTestFailedException {
try {
- return getXAConnection().getConnection();
+ return getXAConnection().getConnection();
} catch (QueryTestFailedException qtf) {
throw qtf;
} catch (Exception e) {
@@ -137,9 +137,9 @@
DataSource ds = (DataSource)Class.forName(this.driver).newInstance();
if (ds instanceof BaseDataSource) {
+
BaseDataSource dataSource = (BaseDataSource) ds;
- //Class.forName(this.driver).newInstance();
-
+
dataSource.setDatabaseName(this.databaseName);
if (this.applName != null) {
dataSource.setApplicationName(this.applName);
@@ -158,6 +158,7 @@
dataSource.setPassword(this.pwd);
}
+
return ((XADataSource) dataSource).getXAConnection(this.username,
this.pwd);
} else {
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTestCase;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/**
+ * This transction is only valid when
+ * AutoCommit = ON
+ * txnAutoWrap = Optimistic.
+ */
+public class AutoWrapTransaction extends TransactionContainer {
+ public AutoWrapTransaction() {
+ super();
+ }
+
+ public void before(TransactionQueryTestCase test) {
+ test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_AUTO);
+
+ }
+
+ public void after(TransactionQueryTestCase test) {
+
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework.transaction;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTestCase;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
-
-
-/**
- * This transction is only valid when
- * AutoCommit = ON
- * txnAutoWrap = Optimistic.
- */
-public class OptimisticWrapTransaction extends TransactionContainer {
- public OptimisticWrapTransaction() {
- super();
- }
-
- public void before(TransactionQueryTestCase test) {
- test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OPTIMISTIC);
-
- }
-
- public void after(TransactionQueryTestCase test) {
-
- }
-}
Deleted: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework.transaction;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTestCase;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
-
-
-/**
- * This transaction type only is valid when
- * AutoCommit = ON
- * txnAutoWrap = PESSIMISTIC
- */
-public class PessimisticWrapTransaction extends TransactionContainer {
- public PessimisticWrapTransaction() {
- super();
- }
-
- public void before(TransactionQueryTestCase test) {
- test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_PESSIMISTIC);
-
- }
-
- public void after(TransactionQueryTestCase test) {
-
- }
-
-
-}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -5,6 +5,7 @@
import java.util.Properties;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
public class PropUtils {
@@ -25,10 +26,10 @@
}
else {
- throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
+ throw new TransactionRuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
}
} catch (IOException e) {
- throw new RuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
+ throw new TransactionRuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
} finally {
try {
in.close();
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -0,0 +1,492 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.AutoWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * The main thing to test in this is, when the single source should is involved it should work
+ * fine, when multiple sources involved it should fail.
+ */
+public class AutoWrapTransactionTests extends BaseAbstractTransactionTestCase {
+
+ public AutoWrapTransactionTests(String testName) {
+ super(testName);
+ }
+
+ protected TransactionContainer getTransactionContainter() {
+ return new AutoWrapTransaction();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Single Source - Rows below 500 (for insert/update/delete)
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 102");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+ for (int i = 100; i < 120; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(20);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(20);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceBatchCommand() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ for (int i = 200; i < 205; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 205");
+ test.assertRowCount(5);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 205");
+ test.assertRowCount(5);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdateRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommandsRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+
+ for (int i = 300; i < 310; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // this will make it rollback
+ execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results (since they are not bundled in single command they should be treated individually)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 300 and e1 < 310");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 >= 300 and e1 < 310");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceBatchCommandRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ for (int i = 400; i < 410; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+
+ // this will make it rollback
+ list.add("insert into pm1.g2 (e1, e2) values(9999, '9999')");
+
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results (all commands will trated as single under single transaction)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 400 and e1 < 410");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 400 and e1 < 410");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Multiple Sources - Rows from 500
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+
+ public void after() {
+ // selects are special case as they will not fail to use multiple sources. The transaction
+ // source count only starts when there are updates to db, so this is OK
+ if (exceptionOccurred()) {
+ fail("should not have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ Integer value = new Integer(500);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourcesBatchCommand() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ list.add("delete from pm2.g2 where pm2.g2.e1 >= 100");
+ list.add("delete from pm2.g1 where pm2.g1.e1 >= 100");
+
+ for (int i = 200; i < 210; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1");
+ }
+
+ public void after() {
+ if (exceptionOccurred()) {
+ fail("should not have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualProceduralSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.p1");
+ }
+ // if vm.p1 needs a transaction, depends on transformation
+ //
+ public void after() {
+ if (exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualProcedure() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.p2 where vm.p2.e1 = ? and vm.p2.e2 = ?", new Object[] {new Integer(200), "200"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ public void testMultipleSourceVirtualProceduralSelectWithUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("exec vm.p2(?, ?)", new Object[] {new Integer(200), "200"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from vm.g1 where vm.g1.pm1e1 > 100");
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -1,491 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import java.util.ArrayList;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.query.AbstractQueryTransactionTest;
-import org.teiid.test.framework.query.QueryExecution;
-import org.teiid.test.framework.transaction.OptimisticWrapTransaction;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * The main thing to test in this is, when the single source should is involved it should work
- * fine, when multiple sources involved it should fail.
- */
-public class OptimisticWrapTransactionTests extends BaseAbstractTransactionTestCase {
-
- public OptimisticWrapTransactionTests(String testName) {
- super(testName);
- }
-
- protected TransactionContainer getTransactionContainter() {
- return new OptimisticWrapTransaction();
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////
- // Single Source - Rows below 500 (for insert/update/delete)
- ///////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Sources = 1
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from pm1.g1 where pm1.g1.e1 < 100");
- assertRowCount(100);
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 1
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourcePreparedUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 = 102");
- test.assertRowCount(1);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceMultipleCommands() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
- execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
-
- execute("select * from pm1.g1");
- assertRowCount(100);
- for (int i = 100; i < 120; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 120");
- test.assertRowCount(20);
- test.execute("select * from g2 where e1 >= 100 and e1 < 120");
- test.assertRowCount(20);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceBatchCommand() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- for (int i = 200; i < 205; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
- }
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 205");
- test.assertRowCount(5);
- test.execute("select * from g2 where e1 >= 200 and e1 < 205");
- test.assertRowCount(5);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourcePreparedUpdateRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceMultipleCommandsRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
- execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
-
- execute("select * from pm1.g1");
- assertRowCount(100);
-
- for (int i = 300; i < 310; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
-
- // this will make it rollback
- execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results (since they are not bundled in single command they should be treated individually)
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 300 and e1 < 310");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 >= 300 and e1 < 310");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceBatchCommandRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- for (int i = 400; i < 410; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
- }
-
- // this will make it rollback
- list.add("insert into pm1.g2 (e1, e2) values(9999, '9999')");
-
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results (all commands will trated as single under single transaction)
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 400 and e1 < 410");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 400 and e1 < 410");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////
- // Multiple Sources - Rows from 500
- ///////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
- assertRowCount(100);
- }
-
- public void after() {
- // selects are special case as they will not fail to use multiple sources. The transaction
- // source count only starts when there are updates to db, so this is OK
- if (exceptionOccurred()) {
- fail("should not have failed to involve multiple sources under optimistic txn");
- }
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- Integer value = new Integer(500);
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourcesBatchCommand() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- list.add("delete from pm2.g2 where pm2.g2.e1 >= 100");
- list.add("delete from pm2.g1 where pm2.g1.e1 >= 100");
-
- for (int i = 200; i < 210; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
-
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
- }
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.g1");
- }
-
- public void after() {
- if (exceptionOccurred()) {
- fail("should not have failed to involve multiple sources under optimistic txn");
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualProceduralSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.p1");
- }
-
- public void after() {
- if (exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualProcedure() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.p2 where vm.p2.e1 = ? and vm.p2.e2 = ?", new Object[] {new Integer(200), "200"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- public void testMultipleSourceVirtualProceduralSelectWithUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("exec vm.p2(?, ?)", new Object[] {new Integer(200), "200"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("delete from vm.g1 where vm.g1.pm1e1 > 100");
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-}
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import java.util.ArrayList;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.query.AbstractQueryTransactionTest;
-import org.teiid.test.framework.query.QueryExecution;
-import org.teiid.test.framework.transaction.PessimisticWrapTransaction;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-public class PessimisticWrapTransactionTests extends CommonTransactionTests {
-
- public PessimisticWrapTransactionTests(String testName) {
- super(testName);
- }
-
- protected TransactionContainer getTransactionContainter() {
- return new PessimisticWrapTransaction();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- for (int i = 200; i < 210; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
-
- // try to rollback, however since this pessimistic above two are already commited
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 210");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testSingleSourceBatchCommandReferentialIntegrityRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- for (int i = 200; i < 210; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- }
-
- // try to rollback, since we are in single batch it must rollback
- list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public boolean exceptionExpected() {
- return true;
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 210");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceBulkRowInsertRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- ArrayList list = new ArrayList();
- public void testCase() throws Exception {
- for (int i = 100; i < 120; i++) {
- list.add("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values("+i+",'"+i+"',"+i+",'"+i+"')");
- }
- list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
-
- // force the rollback by trying to insert an invalid row.
- list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
-
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public boolean exceptionExpected() {
- return true;
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.closeConnection();
-
- test = new QueryExecution(userTxn.getSource("pm2"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.closeConnection();
- }
-}
15 years