teiid SVN: r1334 - trunk/test-integration/db/src/main/resources/transactions.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:29:01 -0400 (Fri, 11 Sep 2009)
New Revision: 1334
Added:
trunk/test-integration/db/src/main/resources/transactions/transaction.properties
Log:
Teiid 773 - organize integration test
Added: trunk/test-integration/db/src/main/resources/transactions/transaction.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/transactions/transaction.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/transactions/transaction.properties 2009-09-11 19:29:01 UTC (rev 1334)
@@ -0,0 +1,108 @@
+dqp.configFile=../configuration.xml
+#ServerConfig.xml
+vdb.definition=./Transaction.vdb
+dqp.buffer.usedisk=false
+dqp.buffer.processorBatchSize=5
+dqp.buffer.connectorBatchSize=5
+
+xa.enable_recovery=false
+
+teiid.home=target/scratch
+
+processName=integrationTest
+
+#dqp.workdir=./tmp/
+#processName=dqpprocess
+
+#only for testing, as this takes more time to start and shutdown
+#metamatrix.xatxnmgr.enable_recovery=false
+
+
+#
+# This is properties file used for bootstrap Teiid embedded for loading
+#
+
+#Path to the Teiid Configuration file
+#dqp.configFile=./deploy/configuration.xml
+
+# Path to the directory where the VDBs are located, or list of VDBS separated by ";"
+#vdb.definition=./deploy/
+
+#Log file (optional) - will be modified to include the instance name, i.e. teiid_1.log
+dqp.logFile=./teiid.log
+
+#Logging level (CRITICAL=1,ERROR=2,WARNING=3,INFO=4,DETAIL=5) (optional: default 3)
+dqp.logLevel=3
+
+#Extensions directory - where the Connector Binding's classpath jar files are loaded.
+#Use of this property is an implicit declaration that each Connector Binding has its own Class Loader.
+#dqp.extensions=./extensions/
+
+#Path to instance specific temporary information for caching, buffering, and transactions
+dqp.workdir=./work
+
+#Jars to load, which will be available to all services: UDFs, command logging, etc.
+#dqp.extension.CommonClasspath=extensionjar:x.jar,extensionjar:y.jar
+
+#Location of the UDF model
+#dqp.userDefinedFunctionsFile=extensionjar:FunctionDefinition.xmi
+
+#
+# Processor settings
+#
+
+#Process pool maximum thread count. (default 64)
+#ProcessPoolMaxThreads=64
+
+#Query processor time slice, in milliseconds. (default 2000)
+#ProcessorTimeslice=2000
+
+#Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20000)
+#MaxFetchSize=20000
+
+#The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250)
+#MaxPlanCacheSize=250
+
+#
+# BufferManager Settings
+#
+
+#The max size of a batch sent between connector and query service. Should be even multiple of processorBatchSize. (default 2000)
+#dqp.buffer.connectorBatchSize=2000
+
+#The max size of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 2000)
+#dqp.buffer.processorBatchSize=2000
+
+#Defines whether to use disk buffering or not. (default 64)
+#dqp.buffer.useDisk=true
+
+#The numeric memory size in MB, to be used before disk buffering kicks in (default 64)
+#dqp.buffer.memory=64
+
+#
+# Cache Settings
+#
+
+#Maximum number of cached lookup tables. Note: this is a memory based cache. (default 20)
+#MaxCodeTables=50
+
+#Maximum number of records in a single lookup table (default 10000)
+#MaxCodeTableRecords=10000
+
+#Denotes whether or not result set caching is enabled. (default false)
+#ResultSetCacheEnabled=false
+
+#The maximum size in MB the result set cache will be allowed to grow to before objects are removed. 0 indicates no limit. (default 50)
+#ResultSetCacheSize=50
+
+#The maximum time a result set will be kept in cache before being automatically cleared. 0 indicates no limit. (default 3600000)
+#ResultSetCacheMaxAge=3600000
+
+#Defines whether caching is restricted to a specific session ('session') or a specific VDB version ('vdb'). (default vdb)
+#ResultSetCacheScope=vdb
+
+
+
+
+
+
Property changes on: trunk/test-integration/db/src/main/resources/transactions/transaction.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 4 months
teiid SVN: r1332 - trunk/test-integration.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:24:09 -0400 (Fri, 11 Sep 2009)
New Revision: 1332
Modified:
trunk/test-integration/pom.xml
Log:
Teiid 773 - organize integration test
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2009-09-11 19:22:37 UTC (rev 1331)
+++ trunk/test-integration/pom.xml 2009-09-11 19:24:09 UTC (rev 1332)
@@ -14,12 +14,11 @@
server/embedded/connectors.</description>
<properties>
- <apache.ant.version>1.7.0</apache.ant.version>
-
- <!-- Database Driver Versions -->
+ <derby.version>10.2.1.6</derby.version>
<mysql.connector.version>5.1.5</mysql.connector.version>
<postgresql.version>8.3-603.jdbc3</postgresql.version>
- <derby.version>10.2.1.6</derby.version>
+
+ <apache.ant.version>1.7.0</apache.ant.version>
</properties>
<dependencies>
@@ -114,7 +113,6 @@
<groupId>org.jboss.teiid.connectors</groupId>
<artifactId>connector-jdbc</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid.connectors</groupId>
@@ -129,7 +127,7 @@
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${derby.version}</version>
- <scope>test</scope>
+
</dependency>
</dependencies>
15 years, 4 months
teiid SVN: r1331 - trunk/test-integration/db.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:22:37 -0400 (Fri, 11 Sep 2009)
New Revision: 1331
Added:
trunk/test-integration/db/pom.xml
Log:
Teiid 773 - organize integration test
Added: trunk/test-integration/db/pom.xml
===================================================================
--- trunk/test-integration/db/pom.xml (rev 0)
+++ trunk/test-integration/db/pom.xml 2009-09-11 19:22:37 UTC (rev 1331)
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>teiid-test-integration</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>6.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>db</artifactId>
+
+ <name>DB Dependent Integration Tests</name>
+ <groupId>org.jboss.teiid.teiid-test-integration</groupId>
+ <description>Integration tests that require external database dependencies </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>${apache.ant.version}</version>
+ </dependency>
+
+ <!-- external dependencies -->
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${postgresql.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>${mysql.connector.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbyclient</artifactId>
+ <version>${derby.version}</version>
+ </dependency>
+
+ <!-- DBUnit dependencies -->
+
+ <dependency>
+ <groupId>org.dbunit</groupId>
+ <artifactId>dbunit</artifactId>
+ <version>2.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi</artifactId>
+ <version>3.2-FINAL</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <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>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>always</forkMode>
+ <forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
+ <includes>
+ <include>**/*TestCase.java</include>
+ <include>**/*Test.java</include>
+ <include>**/*Tests.java</include>
+ <include>**/Test*.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 -->
+ <include>**/Test*$*.java</include>
+ </excludes>
+
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>setupdatasources</id>
+ <build>
+ <plugins>
+
+ <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>
+ <configuration>
+
+ </configuration>
+ <executions>
+ <execution>
+ <id>singleschema</id>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <tasks>
+ <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+ <property name="relative.resources.dir" value="src/main/resources"></property>
+ <ant antfile="src/main/resources/ddl/manage_schemas.xml" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>singledatasource</id>
+ <activation>
+ <property>
+ <name>datasource</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+
+ <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>
+ <configuration>
+
+ </configuration>
+ <executions>
+ <execution>
+ <id>singleschema</id>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <tasks>
+
+ <property name="single" value="${datasource}"></property>
+ <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+
+ <property name="relative.resources.dir" value="src/main/resources"></property>
+ <ant antfile="src/main/resources/ddl/manage_schemas.xml" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
+
+</project>
\ No newline at end of file
Property changes on: trunk/test-integration/db/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 4 months
teiid SVN: r1330 - trunk/test-integration/db/src.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:22:17 -0400 (Fri, 11 Sep 2009)
New Revision: 1330
Added:
trunk/test-integration/db/src/howto
Log:
Teiid 773 - organize integration test
Added: trunk/test-integration/db/src/howto
===================================================================
--- trunk/test-integration/db/src/howto (rev 0)
+++ trunk/test-integration/db/src/howto 2009-09-11 19:22:17 UTC (rev 1330)
@@ -0,0 +1,47 @@
+This is a howto of the following:
+
+1. Creating unit tests that use 1 or more datasources
+2. Setting up a datasource to be used during testing
+3. Executing the db integration tests
+
+
+==========================================
+Creating Unit Tests
+==========================================
+
+- Unit test should be created under db/src/test/java
+- See LocalTransactionTests.java as an example
+- Test should extend org.teiid.transaction.test.AbstractTransactionTestCase
+
+
+- NOTE: the following is used in a post test phase of validating the data in the datasource
+- when calling: this.getSource("modelname") --- the "modelname" represents the model for which
+ you want the connection for
+
+ INFO: to know which source this model is mapped to, find the config properties file being
+ loaded for this test (default is the default-config.properties) and look for
+ the model-to-datasource mapping(s)
+
+ The default Transaction.vdb has 2 models: pm1 and pm2
+
+
+==========================================
+Setting up a Datasource to be used during Testing
+==========================================
+
+- see the readme.txt in src/main/resources/datasources regarding defining a datasource
+- run the maven profile to create the required tables:
+ a. to setup all sources at one time, run: mvn -P setupdatasources
+ b. to setup a specific source, run: mvn -P singledatasource -Ddatasource=derby
+
+
+==========================================
+Executing the db integration tests
+==========================================
+
+The default profile in the pom.xml is to compile and run the test.
+It does not run and setup a datasource. See above "Setting up a Datasource to be used during Testing".
+
+
+
+
\ No newline at end of file
15 years, 4 months
teiid SVN: r1329 - in trunk/test-integration/db/src/main/resources: datasources and 8 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:20:59 -0400 (Fri, 11 Sep 2009)
New Revision: 1329
Added:
trunk/test-integration/db/src/main/resources/configuration.xml
trunk/test-integration/db/src/main/resources/datasources/datasource_mapping.xml
trunk/test-integration/db/src/main/resources/datasources/derby/example_connection.properties
trunk/test-integration/db/src/main/resources/datasources/readme.txt
trunk/test-integration/db/src/main/resources/ddl/adminparms.txt
trunk/test-integration/db/src/main/resources/ddl/db2/create_tables.sql
trunk/test-integration/db/src/main/resources/ddl/db2/drop_tables.sql
trunk/test-integration/db/src/main/resources/ddl/db2/exec_parms.properties
trunk/test-integration/db/src/main/resources/ddl/derby/create_tables.sql
trunk/test-integration/db/src/main/resources/ddl/derby/drop_tables.sql
trunk/test-integration/db/src/main/resources/ddl/derby/exec_parms.properties
trunk/test-integration/db/src/main/resources/ddl/exec_parms.properties_template
trunk/test-integration/db/src/main/resources/ddl/manage_schemas.xml
trunk/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
trunk/test-integration/db/src/main/resources/ddl/mysql/drop_tables.sql
trunk/test-integration/db/src/main/resources/ddl/mysql/exec_parms.properties
trunk/test-integration/db/src/main/resources/ddl/oracle/create_tables.sql
trunk/test-integration/db/src/main/resources/ddl/oracle/drop_tables.sql
trunk/test-integration/db/src/main/resources/ddl/oracle/exec_parms.properties
trunk/test-integration/db/src/main/resources/ddl/postgres/create_tables.sql
trunk/test-integration/db/src/main/resources/ddl/postgres/drop_tables.sql
trunk/test-integration/db/src/main/resources/ddl/postgres/exec_parms.properties
trunk/test-integration/db/src/main/resources/ddl/run_ddl.xml
trunk/test-integration/db/src/main/resources/default-config.properties
trunk/test-integration/db/src/main/resources/mysql/connection.properties
Log:
Teiid 773 - organize integration test
Added: trunk/test-integration/db/src/main/resources/configuration.xml
===================================================================
--- trunk/test-integration/db/src/main/resources/configuration.xml (rev 0)
+++ trunk/test-integration/db/src/main/resources/configuration.xml 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,458 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ConfigurationDocument>
+ <Header>
+ <ApplicationCreatedBy>Teiid</ApplicationCreatedBy>
+ <ApplicationVersionCreatedBy>6.0</ApplicationVersionCreatedBy>
+ <UserCreatedBy>Configuration</UserCreatedBy>
+ <ConfigurationVersion>6.0</ConfigurationVersion>
+ <MetaMatrixSystemVersion>6.0</MetaMatrixSystemVersion>
+ <Time>2009-03-20T12:23:53.919-06:00</Time>
+ </Header>
+ <Configuration Name="Next Startup" ComponentType="Configuration" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <Properties />
+ </Configuration>
+ <Services>
+ <Service Name="QueryService" ComponentType="QueryService" QueuedService="false" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <Properties>
+ <Property Name="metamatrix.service.essentialservice">false</Property>
+ <Property Name="ProcessPoolMaxThreads">64</Property>
+ <Property Name="ProcessPoolThreadTTL">120000</Property>
+ <Property Name="ServiceClassName">com.metamatrix.server.query.service.QueryService</Property>
+ <Property Name="ProcessorTimeslice">2000</Property>
+ <Property Name="MaxCodeTables">50</Property>
+ <Property Name="MaxCodeTableRecords">10000</Property>
+ <Property Name="MinFetchSize">100</Property>
+ <Property Name="MaxFetchSize">20000</Property>
+ <Property Name="ResultSetCacheEnabled">0</Property>
+ <Property Name="ResultSetCacheMaxSize">0</Property>
+ <Property Name="ResultSetCacheMaxAge">0</Property>
+ <Property Name="ResultSetCacheScope">vdb</Property>
+ <Property Name="MaxPlanCacheSize">100</Property>
+ </Properties>
+ </Service>
+ </Services>
+ <ComponentTypes>
+ <ComponentType Name="Service" ComponentTypeCode="1" Deployable="false" Deprecated="false" Monitorable="false" ParentComponentType="VM" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ServiceClassName" DisplayName="Service Class Name" ShortDescription="" PropertyType="String" IsModifiable="false" IsMasked="false" />
+ <PropertyDefinition Name="metamatrix.service.essentialservice" DisplayName="Essential Service" ShortDescription="Indicates if the service is essential to operation of the Integration Server" DefaultValue="false" PropertyType="Boolean" IsModifable="false" IsMasked="false" />
+ </ComponentType>
+ <ComponentType Name="QueryService" ComponentTypeCode="1" Deployable="true" Deprecated="false" Monitorable="true" SuperComponentType="Service" ParentComponentType="Integration Server" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ </ComponentType>
+ <ComponentType Name="Configuration" ComponentTypeCode="0" Deployable="true" Deprecated="false" Monitorable="false" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ </ComponentType>
+ <!--
+ *************************************************************************************
+ Connector Type (This section gets filled by build process at kit building time)
+ *************************************************************************************
+ -->
+ <ComponentType Name="Connector" ComponentTypeCode="2" Deployable="false" Deprecated="false" Monitorable="true" SuperComponentType="Service" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.916-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.916-06:00">
+ <PropertyDefinition Name="SourceConnectionTestInterval" DisplayName="Data Source Test Connect Interval (seconds)" ShortDescription="How often (in seconds) to create test connections to the underlying datasource to see if it is available." DefaultValue="600" IsRequired="true" PropertyType="Integer" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorClassPath" DisplayName="Class Path" ShortDescription="" />
+ <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system)" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="UsePostDelegation" DisplayName="Use Separate Classloader" ShortDescription="Set to true to indicate that the connector classpath and connector type classpath entries should be loaded by a connector specific post-delegation class loader." PropertyType="Boolean" IsRequired="true" IsExpert="true" DefaultValue="false"/>
+ <PropertyDefinition Name="ExceptionOnMaxRows" DisplayName="Exception on Exceeding Max Rows" ShortDescription="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" DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="metamatrix.service.essentialservice" DisplayName="Essential Service" ShortDescription="Indicates if the service is essential to operation of the Integration Server" DefaultValue="false" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="ServiceMonitoringEnabled" DisplayName="Data Source Monitoring Enabled" ShortDescription="Whether to monitor the underlying data source to see if it is available." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="Immutable" DisplayName="Is Immutable" ShortDescription="True if the source never changes." DefaultValue="false" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorMaxConnections" DisplayName="Maximum Concurrent Connections" ShortDescription="" DefaultValue="20" IsRequired="true" PropertyType="Integer" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" IsRequired="true" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="ServiceClassName" DisplayName="Service Class Name" ShortDescription="" DefaultValue="com.metamatrix.server.connector.service.ConnectorService" IsRequired="true" IsModifiable="false" />
+ <PropertyDefinition Name="MaxResultRows" DisplayName="Maximum Result Rows" ShortDescription="" DefaultValue="10000" IsRequired="true" PropertyType="Integer" IsExpert="true" />
+ <PropertyDefinition Name="SynchWorkers" DisplayName="Synchronous Workers" ShortDescription="Whether worker threads will be bound to connections. Asynch connectors should set this value to false." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="ResultSetCacheEnabled" DisplayName="ResultSet Cache Enabled" ShortDescription="" DefaultValue="false" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="ResultSetCacheMaxSize" DisplayName="ResultSet Cache Maximum Size (megabytes)" ShortDescription="" DefaultValue="20" PropertyType="Integer" IsExpert="true" />
+ <PropertyDefinition Name="ResultSetCacheMaxAge" DisplayName="ResultSet Cache Maximum Age (milliseconds)" ShortDescription="" DefaultValue="3600000" PropertyType="Long" IsExpert="true" />
+ <PropertyDefinition Name="ResultSetCacheScope" DisplayName="ResultSet Cache Scope" ShortDescription="" DefaultValue="vdb" IsExpert="true">
+ <AllowedValue>vdb</AllowedValue>
+ <AllowedValue>session</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Set to true if this is an XA Connector" DefaultValue="false" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="ConnectionPoolEnabled" DisplayName="Connection Pool Enabled" ShortDescription="Enable the use of connection pooling with this connector." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="UseCredentialMap" DisplayName="Requires Credential Map" ShortDescription="Set to true if this connector requires credentials to be passed via a credential map." DefaultValue="false" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="AdminConnectionsAllowed" DisplayName="Admin Connections Allowed" ShortDescription="Whether admin connections without an execution context are allowed." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="com.metamatrix.data.pool.max_connections_for_each_id" DisplayName="Pool Maximum Connections for Each ID" ShortDescription="Set the maximum number of connections for each connector ID for the connection pool" DefaultValue="20" IsRequired="true" PropertyType="Integer" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="com.metamatrix.data.pool.live_and_unused_time" DisplayName="Pool Connection Idle Time (seconds)" ShortDescription="Set the idle time of the connection before it should be closed if pool shrinking is enabled" DefaultValue="60" PropertyType="Integer" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="com.metamatrix.data.pool.wait_for_source_time" DisplayName="Pool Connection Waiting Time (milliseconds)" ShortDescription="Set the time to wait if the connection is not available" DefaultValue="120000" PropertyType="Integer" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="com.metamatrix.data.pool.cleaning_interval" DisplayName="Pool cleaning Interval (seconds)" ShortDescription="Set the interval to cleaning the pool" DefaultValue="60" PropertyType="Integer" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="com.metamatrix.data.pool.enable_shrinking" DisplayName="Enable Pool Shrinking" ShortDescription="Set whether to enable the pool shrinking" DefaultValue="false" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="supportsCompareCriteriaEquals" DisplayName="supportsCompareCriteriaEquals" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsCompareCriteriaOrdered" DisplayName="supportsCompareCriteriaOrdered" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsInCriteria" DisplayName="supportsInCriteria" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="getMaxInCriteriaSize" DisplayName="getMaxInCriteriaSize" ShortDescription="" PropertyType="Integer" IsExpert="true" />
+ <PropertyDefinition Name="supportsIsNullCriteria" DisplayName="supportsIsNullCriteria" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsLikeCriteria" DisplayName="supportsLikeCriteria" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsLikeCriteriaEscapeCharacter" DisplayName="supportsLikeCriteriaEscapeCharacter" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsNotCriteria" DisplayName="supportsNotCriteria" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsOrCriteria" DisplayName="supportsOrCriteria" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsBetweenCriteria" DisplayName="supportsBetweenCriteria" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsSelectDistinct" DisplayName="supportsSelectDistinct" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsSelectExpression" DisplayName="supportsSelectExpression" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsInnerJoins" DisplayName="supportsInnerJoins" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsAliasedGroup" DisplayName="supportsAliasedGroup" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsSelfJoins" DisplayName="supportsSelfJoins" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsOuterJoins" DisplayName="supportsOuterJoins" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsFullOuterJoins" DisplayName="supportsFullOuterJoins" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="getMaxFromGroups" DisplayName="getMaxFromGroups" ShortDescription="" PropertyType="Integer" IsExpert="true" />
+ <PropertyDefinition Name="getSupportedJoinCriteria" DisplayName="getSupportedJoinCriteria" ShortDescription="" PropertyType="String" IsExpert="true" >
+ <AllowedValue>ANY</AllowedValue>
+ <AllowedValue>THETA</AllowedValue>
+ <AllowedValue>EQUI</AllowedValue>
+ <AllowedValue>KEY</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="supportsOrderBy" DisplayName="supportsOrderBy" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsGroupBy" DisplayName="supportsGroupBy" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsFunctionsInGroupBy" DisplayName="supportsFunctionsInGroupBy" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsHaving" DisplayName="supportsHaving" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsAggregatesSum" DisplayName="supportsAggregatesSum" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsAggregatesAvg" DisplayName="supportsAggregatesAvg" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsAggregatesMin" DisplayName="supportsAggregatesMin" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsAggregatesMax" DisplayName="supportsAggregatesMax" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsAggregatesCount" DisplayName="supportsAggregatesCount" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsAggregatesCountStar" DisplayName="supportsAggregatesCountStar" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsAggregatesDistinct" DisplayName="supportsAggregatesDistinct" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsInCriteriaSubquery" DisplayName="supportsInCriteriaSubquery" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsExistsCriteria" DisplayName="supportsExistsCriteria" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsQuantifiedCompareCriteriaSome" DisplayName="supportsQuantifiedCompareCriteriaSome" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsQuantifiedCompareCriteriaAll" DisplayName="supportsQuantifiedCompareCriteriaAll" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsScalarSubqueries" DisplayName="supportsScalarSubqueries" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsCorrelatedSubqueries" DisplayName="supportsCorrelatedSubqueries" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsCaseExpressions" DisplayName="supportsCaseExpressions" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsSearchedCaseExpressions" DisplayName="supportsSearchedCaseExpressions" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="getSupportedFunctions" DisplayName="getSupportedFunctions" ShortDescription="" PropertyType="string" IsExpert="true" />
+ <PropertyDefinition Name="supportsInlineViews" DisplayName="supportsInlineViews" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsSetQueryOrderBy" DisplayName="supportsSetQueryOrderBy" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsUnions" DisplayName="supportsUnions" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsIntersect" DisplayName="supportsIntersect" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsExcept" DisplayName="supportsExcept" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="requiresCriteria" DisplayName="requiresCriteria" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="useAnsiJoin" DisplayName="useAnsiJoin" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsBatchedUpdates" DisplayName="supportsBatchedUpdates" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsBulkUpdate" DisplayName="supportsBulkUpdate" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsInsertWithQueryExpression" DisplayName="supportsInsertWithQueryExpression" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsRowLimit" DisplayName="supportsRowLimit" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="supportsRowOffset" DisplayName="supportsRowOffset" ShortDescription="" PropertyType="Boolean" IsExpert="true" />
+ </ComponentType>
+ <ComponentType Name="JDBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.952-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.952-06:00">
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:" IsRequired="true" PropertyType="String"/>
+ <PropertyDefinition Name="User" DisplayName="User Name" ShortDescription="" />
+ <PropertyDefinition Name="Password" DisplayName="Password" ShortDescription="" IsMasked="true" />
+ <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:connector-jdbc-6.2.0-SNAPSHOT.jar;" IsModifiable="false" />
+ <PropertyDefinition Name="UseBindVariables" DisplayName="Use prepared statements and bind variables" ShortDescription="" DefaultValue="false" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="ExtensionCapabilityClass" DisplayName="Extension Capability Class" ShortDescription="" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.JDBCConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="DatabaseTimeZone" DisplayName="Database time zone" ShortDescription="Time zone of the database, if different than Integration Server" IsExpert="true" />
+ <PropertyDefinition Name="TransactionIsolationLevel" DisplayName="Transaction Isolation Level" ShortDescription="Set the data source transaction isolation level" IsExpert="true" >
+ <AllowedValue>TRANSACTION_READ_UNCOMMITTED</AllowedValue>
+ <AllowedValue>TRANSACTION_READ_COMMITTED</AllowedValue>
+ <AllowedValue>TRANSACTION_SERIALIZABLE</AllowedValue>
+ <AllowedValue>TRANSACTION_NONE</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.translator.Translator" IsExpert="true" />
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" IsRequired="true" />
+ <PropertyDefinition Name="TrimStrings" DisplayName="Trim string flag" ShortDescription="Right Trim fixed character types returned as Strings" DefaultValue="false" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="UseCommentsInSourceQuery" DisplayName="Use informational comments in Source Queries" ShortDescription="This will embed /*comment*/ style comment with session/request id in source SQL query for informational purposes" DefaultValue="false" PropertyType="Boolean" IsExpert="true"/>
+ </ComponentType>
+ <ComponentType Name="Oracle Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="oracle.jdbc.driver.OracleDriver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:oracle:thin:@<host>:1521:<sid>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.oracle.OracleSQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ </ComponentType>
+ <ComponentType Name="Oracle XA Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="oracle.jdbc.xa.client.OracleXADataSource" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:oracle:thin:@<host>:1521:<sid>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.oracle.OracleSQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="DB2 Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.ibm.db2.jcc.DB2Driver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:db2://<server>:50000/<db-name>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.db2.DB2SQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ </ComponentType>
+ <ComponentType Name="DB2 XA Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.ibm.db2.jcc.DB2XADataSource" IsRequired="true" />
+ <PropertyDefinition Name="PortNumber" DisplayName="Port Number" DefaultValue="50000" ShortDescription="" IsRequired="true" PropertyType="Integer" IsMasked="false" />
+ <PropertyDefinition Name="ServerName" DisplayName="Server Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseName" DisplayName="Database Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="DriverType" DisplayName="Driver Type" ShortDescription="" DefaultValue="4" IsRequired="true" PropertyType="Integer" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.db2.DB2SQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="SQL Server Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.microsoft.sqlserver.jdbc.SQLServerDriver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:sqlserver://<host>:1433;databaseName=<db-name>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.sqlserver.SqlServerSQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ </ComponentType>
+ <ComponentType Name="SQL Server XA Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.microsoft.sqlserver.jdbc.SQLServerXADataSource" IsRequired="true" />
+ <PropertyDefinition Name="PortNumber" DisplayName="Port Number" DefaultValue="1433" ShortDescription="" IsRequired="true" PropertyType="Integer" IsMasked="false" />
+ <PropertyDefinition Name="ServerName" DisplayName="Server Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseName" DisplayName="Database Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.sqlserver.SqlServerSQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="MySQL JDBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.mysql.jdbc.Driver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:mysql://<host>:3306/<databaseName>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.mysql.MySQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ </ComponentType>
+ <ComponentType Name="MySQL 5 JDBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.mysql.jdbc.Driver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:mysql://<host>:3306/<databaseName>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.mysql.MySQL5Translator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ </ComponentType>
+ <ComponentType Name="MySQL JDBC XA Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" IsRequired="true" />
+ <PropertyDefinition Name="PortNumber" DisplayName="Port Number" DefaultValue="3306" ShortDescription="" IsRequired="true" PropertyType="Integer" IsMasked="false" />
+ <PropertyDefinition Name="ServerName" DisplayName="Server Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseName" DisplayName="Database Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.mysql.MySQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="MySQL 5 JDBC XA Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" IsRequired="true" />
+ <PropertyDefinition Name="PortNumber" DisplayName="Port Number" DefaultValue="3306" ShortDescription="" IsRequired="true" PropertyType="Integer" IsMasked="false" />
+ <PropertyDefinition Name="ServerName" DisplayName="Server Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseName" DisplayName="Database Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.mysql.MySQL5Translator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="PostgreSQL JDBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="org.postgresql.Driver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:postgresql://<host>:5432/<databaseName>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseVersion" DisplayName="Database Version" ShortDescription="PostgreSQL Version i.e. 8.3" DefaultValue="8.0" PropertyType="String" />
+ </ComponentType>
+ <ComponentType Name="PostgreSQL XA JDBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="org.postgresql.xa.PGXADataSource" IsRequired="true" />
+ <PropertyDefinition Name="PortNumber" DisplayName="Port Number" DefaultValue="5432" ShortDescription="" IsRequired="true" PropertyType="Integer" IsMasked="false" />
+ <PropertyDefinition Name="ServerName" DisplayName="Server Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseName" DisplayName="Database Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ <PropertyDefinition Name="DatabaseVersion" DisplayName="Database Version" ShortDescription="PostgreSQL Version i.e. 8.3" DefaultValue="8.0" PropertyType="String" />
+ </ComponentType>
+ <ComponentType Name="Apache Derby Embedded Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="org.apache.derby.jdbc.EmbeddedDriver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:derby:<databaseName>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.derby.DerbySQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseVersion" DisplayName="Database Version" ShortDescription="Derby Version i.e. 10.3" DefaultValue="10.1" PropertyType="String" />
+ </ComponentType>
+ <ComponentType Name="Apache Derby Network Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="org.apache.derby.jdbc.ClientDriver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:derby://localhost:1527/<path/to/db>" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.derby.DerbySQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseVersion" DisplayName="Database Version" ShortDescription="Derby Version i.e. 10.3" DefaultValue="10.1" PropertyType="String" />
+ </ComponentType>
+ <ComponentType Name="Apache Derby XA Network Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="org.apache.derby.jdbc.ClientXADataSource" IsRequired="true" />
+ <PropertyDefinition Name="PortNumber" DisplayName="Port Number" DefaultValue="1527" ShortDescription="" IsRequired="true" PropertyType="Integer" IsMasked="false" />
+ <PropertyDefinition Name="ServerName" DisplayName="Server Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseName" DisplayName="Database Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.derby.DerbySQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="Teiid 6 JDBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.metamatrix.jdbc.MMDriver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:metamatrix:<vdbName>@mm://<host>:<port>" IsRequired="true" />
+ </ComponentType>
+ <ComponentType Name="JDBC ODBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="sun.jdbc.odbc.JdbcOdbcDriver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:odbc:<data-source-name>[;UID=<xxx> ;PWD=<xxx>]" IsRequired="true" />
+ </ComponentType>
+ <ComponentType Name="MS Access Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="sun.jdbc.odbc.JdbcOdbcDriver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=<data-source-name>" IsRequired="true" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.access.AccessSQLTranslator" IsExpert="true" />
+ </ComponentType>
+ <ComponentType Name="MS Excel Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2006-02-08T11:02:36.029-06:00" CreatedBy="ConfigurationStartup" CreationDate="2006-02-08T11:02:36.029-06:00">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="sun.jdbc.odbc.JdbcOdbcDriver" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:odbc:Driver={MicroSoft Excel Driver (*.xls)};DBQ=<filePathToExcelFile>" IsRequired="true" />
+ </ComponentType>
+ <!--
+ <ComponentType Name="Datadirect DB2 8 Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.928-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.928-06:00">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.metamatrix.jdbcx.db2.DB2DataSource" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:mmx:db2://<host>:50000;DatabaseName=<databasename>;CollectionID=<collectionid>;PackageName=<packagename>" IsRequired="true" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.db2.DB2SQLTranslator" IsExpert="true" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="Datadirect Oracle 9 Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.923-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.923-06:00">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.metamatrix.jdbcx.oracle.OracleDataSource" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:mmx:oracle://<host>:1521;SID=<sid>" IsRequired="true" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.oracle.OracleSQLTranslator" IsExpert="true" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="Datadirect SQL Server 2003 Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.935-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.935-06:00">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.metamatrix.jdbcx.sqlserver.SQLServerDataSource" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:mmx:sqlserver://<host>:1433;DatabaseName=<databasename>" IsRequired="true" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.sqlserver.SqlServerSQLTranslator" IsExpert="true" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="Datadirect Sybase 12 Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.930-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.930-06:00">
+ <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.metamatrix.jdbcx.sybase.SybaseDataSource" IsRequired="true" />
+ <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:mmx:sybase://<host>:5000;DatabaseName=<databasename>" IsRequired="true" />
+ <PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.sybase.SybaseSQLTranslator" IsExpert="true" />
+ <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ <PropertyDefinition Name="SetCriteriaBatchSize" DisplayName="Max Values in IN Predicate" ShortDescription="Max number of values in an IN Predicate. Must be >= 0." DefaultValue="250" PropertyType="Integer" IsExpert="true" />
+ </ComponentType>
+ --> <ComponentType Name="LDAP Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.946-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.946-06:00">
+ <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:connector-ldap-6.2.0-SNAPSHOT.jar;" IsModifiable="false" />
+ <PropertyDefinition Name="SearchDefaultBaseDN" DisplayName="Default Search Base DN" ShortDescription="Default Base DN for LDAP Searches" IsExpert="true" />
+ <PropertyDefinition Name="LdapAdminUserDN" DisplayName="Ldap Admin User DN" ShortDescription="User DN for the LDAP admin account." DefaultValue="cn=<>,ou=<>,dc=<>" IsRequired="true" />
+ <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.ldap.LDAPConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="LdapAdminUserPassword" DisplayName="Ldap Admin Password" ShortDescription="Password of the LDAP admin user account." IsRequired="true" IsMasked="true" />
+ <PropertyDefinition Name="SearchDefaultScope" DisplayName="Default Search Scope" ShortDescription="Default Scope for LDAP Searches" DefaultValue="SUBTREE_SCOPE" IsRequired="true">
+ <AllowedValue>OBJECT_SCOPE</AllowedValue>
+ <AllowedValue>ONELEVEL_SCOPE</AllowedValue>
+ <AllowedValue>SUBTREE_SCOPE</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="RestrictToObjectClass" DisplayName="Restrict Searches To Named Object Class" ShortDescription="Restrict Searches to objectClass named in the Name field for a table" DefaultValue="false" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="LdapTxnTimeoutInMillis" DisplayName="Ldap Transaction Timeout (ms)" ShortDescription="Timeout value for LDAP searches. Defaults to TCP timeout value." />
+ <PropertyDefinition Name="LdapUrl" DisplayName="Ldap URL" ShortDescription="Ldap URL of the server, including port number." DefaultValue="ldap://<ldapServer>:<389>" IsRequired="true" />
+ </ComponentType>
+ <ComponentType Name="Loopback Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.945-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.945-06:00">
+ <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:connector-loopback-6.2.0-SNAPSHOT.jar;" IsModifiable="false" />
+ <PropertyDefinition Name="CapabilitiesClass" DisplayName="Capabilities Class" ShortDescription="" DefaultValue="com.metamatrix.connector.loopback.LoopbackCapabilities" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="WaitTime" DisplayName="Max Random Wait Time" ShortDescription="" DefaultValue="0" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.loopback.LoopbackConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="RowCount" DisplayName="Rows Per Query" ShortDescription="" DefaultValue="1" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ </ComponentType>
+ <ComponentType Name="Salesforce Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedDate="2008-10-31T10:26:19.916-06:00" CreationDate="2008-10-31T10:26:19.916-06:00">
+ <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:connector-salesforce-6.2.0-SNAPSHOT.jar;extensionjar:commons-codec-1.2.jar;extensionjar:commons-discovery-0.2.jar;extensionjar:commons-httpclient-3.0.1.jar;extensionjar:xmlsec-1.3.0.jar;extensionjar:axis-1.3.jar;extensionjar:axis-jaxrpc-1.3.jar;extensionjar:axis-saaj-1.2.jar;extensionjar:axis-schema-1.3.jar;extensionjar:commons-discovery-0.2.jar;extensionjar:jms-1.1.jar;extensionjar:jaxen-1.1.1.jar;extensionjar:nux-1.6.jar;extensionjar:opensaml-1.1b.jar;extensionjar:salesforce-api-6.2.0-SNAPSHOT.jar;extensionjar:jetty-6.1.9.jar;extensionjar:jetty-util-6.1.9.jar;extensionjar:servlet-api-2.5-6.1.9.jar;extensionjar:wsdl4j-1.5.1.jar;extensionjar:wss4j-1.5.0.jar;extensionjar:xalan-2.7.0.jar;extensionjar:xom-1.2.jar" IsModifiable="false" />
+ <PropertyDefinition Name="UsePostDelegation" DisplayName="Use Separate Classloader" ShortDescription="Set to true to indicate that the connector classpath and connector type classpath entries should be loaded by a connector specific post-delegation class loader." PropertyType="Boolean" IsRequired="true" IsExpert="true" DefaultValue="true"/>
+ <PropertyDefinition Name="username" DisplayName="User Name" ShortDescription="Name value for Salesforce authentication" DefaultValue="" IsRequired="true" />
+ <PropertyDefinition Name="ConnectorStateClass" DisplayName="Connector State Class" ShortDescription="" DefaultValue="com.metamatrix.connector.salesforce.ConnectorState" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.salesforce.Connector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="password" DisplayName="Password" ShortDescription="Password value for Salesforce authentication" DefaultValue="" IsRequired="true" IsMasked="true" />
+ <PropertyDefinition Name="URL" DisplayName="Salesforce URL" ShortDescription="URL for connecting to Salesforce" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorCapabilities" DisplayName="Connector Capabilities Class" ShortDescription="The class to use to provide the Connector Capabilities" DefaultValue="com.metamatrix.connector.salesforce.SalesforceCapabilities" IsExpert="true" />
+ </ComponentType>
+ <ComponentType Name="Text File Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.945-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.945-06:00">
+ <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:connector-text-6.2.0-SNAPSHOT.jar;" IsModifiable="false" />
+ <PropertyDefinition Name="PartialStartupAllowed" DisplayName="Partial Startup Allowed" ShortDescription="" DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="DescriptorFile" DisplayName="Text File Descriptor" ShortDescription="" IsRequired="true" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.text.TextConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="EnforceColumnCount" DisplayName="Enforce Column Count" ShortDescription="This forces the number of columns in text file to match what was modeled" DefaultValue="false" PropertyType="Boolean" />
+ <PropertyDefinition Name="DateResultFormatsDelimiter" DisplayName="Date Result Formats Delimiter" ShortDescription="" IsExpert="true" />
+ <PropertyDefinition Name="DateResultFormats" DisplayName="Date Result Formats" ShortDescription="" IsExpert="true" />
+ <PropertyDefinition Name="Immutable" DisplayName="Is Immutable" ShortDescription="True if the source never changes." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
+ </ComponentType>
+ <ComponentType Name="XML Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedDate="2008-10-31T10:26:19.917-06:00" CreationDate="2008-10-31T10:26:19.917-06:00">
+ <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:connector-xml-6.2.0-SNAPSHOT.jar;extensionjar:commons-codec-1.2.jar;extensionjar:commons-discovery-0.2.jar;extensionjar:commons-httpclient-3.0.1.jar;extensionjar:xmlsec-1.3.0.jar;extensionjar:axis-1.3.jar;extensionjar:axis-jaxrpc-1.3.jar;extensionjar:axis-saaj-1.2.jar;extensionjar:axis-schema-1.3.jar;extensionjar:commons-discovery-0.2.jar;extensionjar:jms-1.1.jar;extensionjar:jaxen-1.1.1.jar;extensionjar:nux-1.6.jar;extensionjar:opensaml-1.1b.jar;extensionjar:jetty-6.1.9.jar;extensionjar:jetty-util-6.1.9.jar;extensionjar:servlet-api-2.5-6.1.9.jar;extensionjar:wsdl4j-1.5.1.jar;extensionjar:wss4j-1.5.0.jar;extensionjar:xalan-2.7.0.jar;extensionjar:xom-1.2.jar" IsModifiable="false"/>
+ <PropertyDefinition Name="UsePostDelegation" DisplayName="Use Separate Classloader" ShortDescription="Set to true to indicate that the connector classpath and connector type classpath entries should be loaded by a connector specific post-delegation class loader." PropertyType="Boolean" IsRequired="true" IsExpert="true" DefaultValue="true"/>
+ </ComponentType>
+
+ <ComponentType Name="XML File Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="XML Connector" ParentComponentType="Connectors" LastChangedDate="2008-10-31T10:26:19.917-06:00" CreationDate="2008-10-31T10:26:19.917-06:00">
+ <PropertyDefinition Name="CharacterEncodingScheme" DisplayName="File Encoding Used" ShortDescription="A character-encoding scheme is a mapping between a coded character set and a set of octet (eight-bit byte) sequences. Some samples are UTF-8,ISO-8859-1,UTF-16)" DefaultValue="ISO-8859-1" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.xmlsource.XMLSourceConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="ConnectionType" DisplayName="Type Of XML Connection" ShortDescription="Connection type used to get the XML data" DefaultValue="com.metamatrix.connector.xmlsource.file.FileConnection" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="DirectoryLocation" DisplayName="XML File(s) Directory Location" ShortDescription="" DefaultValue="" IsRequired="true" />
+ </ComponentType>
+ <ComponentType Name="XML SOAP Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="XML Connector" ParentComponentType="Connectors" LastChangedDate="2008-10-31T10:26:19.917-06:00" CreationDate="2008-10-31T10:26:19.917-06:00">
+ <PropertyDefinition Name="AuthPassword" DisplayName="Authentication User Password" ShortDescription="Password value for authentication" DefaultValue="" IsExpert="true" IsMasked="true" />
+ <PropertyDefinition Name="SAMLPropertyFile" DisplayName="SAML Property File (only required when SAML profile used)" ShortDescription="SAML Security property file (saml.properties)" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="wsdl" DisplayName="WSDL File (URL)" ShortDescription="URL to Web Service Definition File" DefaultValue="" IsRequired="true" />
+ <PropertyDefinition Name="AuthUserName" DisplayName="Authentication User Name" ShortDescription="Name value for authentication" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="WSSecurityType" DisplayName="WS-Security Type(UsernameToken, SAML..)" ShortDescription="Type of WS-Security to be used; Combinations of multiple security types can be used with a space in-between. Allowed types are: (UsernameToken, UsernameToken-Digest, SAMLTokenUnsigned, SAMLTokenSigned, Signature, Timestamp, Encrypt)" DefaultValue="" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.xmlsource.XMLSourceConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="EncryptUserName" DisplayName="Encrypt UserName (only if Encrypt profile used)" ShortDescription="The username to be used in the encryption; if blank uses auth username" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="EndPoint" DisplayName="Alternate End Point" ShortDescription="An alternate service endpoint other than one specified in WSDL, to execute the service" DefaultValue="" />
+ <PropertyDefinition Name="SecurityType" DisplayName="WebService Security Used(None, HTTPBasic, WS-Security)" ShortDescription="Type of Authentication to used with the web service; If WS-Secuirty is being used, then WS-Secuirty type must be defined" DefaultValue="None" IsRequired="true" />
+ <PropertyDefinition Name="CryptoPropertyFile" DisplayName="User Crypto Property File (If SAML or Signature profile used)" ShortDescription="The file defines properties of cryptography;defines the certificates;(crypto.properties)" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="ConnectionType" DisplayName="Type Of XML Connection" ShortDescription="Connection type used to get the XML data" DefaultValue="com.metamatrix.connector.xmlsource.soap.SoapConnection" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="EncryptPropertyFile" DisplayName="Encrypt crypto property file (only if Encrypt profile used)" ShortDescription="The file defines properties of cryptography for encryption of the message;(crypto.properties)" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="TrustType" DisplayName="Trust Type:(DirectReference or IssuerSerial)" ShortDescription="Only required for Signature and Signed SAML; The issuer-serial method presumes that all trusted users of the service are known to the service and have pre-registered their certificate chains before using the service. The direct-reference method presumes that the service operator trusts all users with certificates issued by a trusted CA." DefaultValue="DirectReference" IsExpert="true" />
+ </ComponentType>
+ <ComponentType Name="XML-Relational File Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="XML Connector" ParentComponentType="Connectors" LastChangedDate="2008-10-31T10:26:19.918-06:00" CreationDate="2008-10-31T10:26:19.918-06:00">
+ <PropertyDefinition Name="FilePath" DisplayName="File Path" ShortDescription="" IsRequired="true" />
+ <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="CacheEnabled" DisplayName="Enable Document Caching" ShortDescription="" DefaultValue="false" IsRequired="true" PropertyType="Boolean" />
+ <PropertyDefinition Name="SaxFilterProviderClass" DisplayName="XML Filter Provider" ShortDescription="The class the provides extended XML Filters" DefaultValue="com.metamatrix.connector.xml.base.NoExtendedFilters" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.xml.base.XMLConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorStateClass" DisplayName="Connector State Class" ShortDescription="" DefaultValue="com.metamatrix.connector.xml.file.FileConnectorState" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="LogRequestResponseDocs" DisplayName="Log XML Request and Response Documents" ShortDescription="Write the request and response documents to the log at Info level" DefaultValue="false" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="InputStreamFilterClass" DisplayName="Input Stream Filter Class" ShortDescription="The class to use to preprocess raw XML input stream" DefaultValue="com.metamatrix.connector.xml.base.PluggableInputStreamFilterImpl" IsExpert="true" />
+ <PropertyDefinition Name="FileName" DisplayName="File Name" ShortDescription="" DefaultValue="" />
+ <PropertyDefinition Name="QueryPreprocessorClass" DisplayName="Query Preprocessor Class" ShortDescription="The class to use to preprocess the IQuery" DefaultValue="com.metamatrix.connector.xml.base.NoQueryPreprocessing" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorCapabilities" DisplayName="Connector Capabilities Class" ShortDescription="The class to use to provide the Connector Capabilities" DefaultValue="com.metamatrix.connector.xml.base.XMLCapabilities" IsExpert="true" />
+ </ComponentType>
+ <ComponentType Name="XML-Relational HTTP Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="XML Connector" ParentComponentType="Connectors" LastChangedDate="2008-10-31T10:26:19.920-06:00" CreationDate="2008-10-31T10:26:19.921-06:00">
+ <PropertyDefinition Name="SaxFilterProviderClass" DisplayName="XML Filter Provider" ShortDescription="The class the provides extended XML Filters" DefaultValue="com.metamatrix.connector.xml.base.NoExtendedFilters" IsExpert="true" />
+ <PropertyDefinition Name="XMLParmName" DisplayName="XML Parameter Name" ShortDescription="" />
+ <PropertyDefinition Name="RequestTimeout" DisplayName="Request Timeout (in Milliseconds)" ShortDescription="" DefaultValue="10000" IsRequired="true" PropertyType="Integer" />
+ <PropertyDefinition Name="Authenticate" DisplayName="Authentication Required" ShortDescription="" DefaultValue="false" PropertyType="Boolean" IsModifiable="true" />
+ <PropertyDefinition Name="ConnectorStateClass" DisplayName="Connector State Class" ShortDescription="" DefaultValue="com.metamatrix.connector.xml.http.HTTPConnectorState" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="HttpBasicAuthPassword" DisplayName="HTTP Basic Authentication Password" ShortDescription="Password value for HTTP basic authentication" DefaultValue="" IsExpert="true" IsMasked="true" />
+ <PropertyDefinition Name="AccessMethod" DisplayName="Access Method" ShortDescription="" DefaultValue="get" IsRequired="true">
+ <AllowedValue>get</AllowedValue>
+ <AllowedValue>post</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="ProxyUri" DisplayName="Proxy Server URI" ShortDescription="The URI of the proxy server" DefaultValue="" />
+ <PropertyDefinition Name="ConnectorCapabilities" DisplayName="Connector Capabilities Class" ShortDescription="The class to use to provide the Connector Capabilities" DefaultValue="com.metamatrix.connector.xml.base.XMLCapabilities" IsExpert="true" />
+ <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="HttpBasicAuthUserName" DisplayName="HTTP Basic Authentication Name" ShortDescription="Name value for HTTP basic authentication" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.xml.base.XMLConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="Uri" DisplayName="Server URI" ShortDescription="The URI of the HTTP source" IsRequired="true" />
+ <PropertyDefinition Name="UseHttpBasic" DisplayName="Use HTTP Basic authentication" ShortDescription="Use basic HTTP Authentication" DefaultValue="false" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="LogRequestResponseDocs" DisplayName="Log XML Request and Response Documents" ShortDescription="Write the request and response documents to the log at Info level" DefaultValue="false" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="TrustDeserializerClass" DisplayName="Trust Deserializer Class" ShortDescription="The class to use to process trusted payloads and execution payloads" DefaultValue="com.metamatrix.connector.xml.http.DefaultTrustDeserializer" IsExpert="true" />
+ <PropertyDefinition Name="ParameterMethod" DisplayName="Parameter Method" ShortDescription="" DefaultValue="None" IsRequired="true">
+ <AllowedValue>None</AllowedValue>
+ <AllowedValue>Name/Value</AllowedValue>
+ <AllowedValue>XMLRequest</AllowedValue>
+ <AllowedValue>XMLInQueryString</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="InputStreamFilterClass" DisplayName="Input Stream Filter Class" ShortDescription="The class to use to preprocess raw XML input stream" DefaultValue="com.metamatrix.connector.xml.base.PluggableInputStreamFilterImpl" IsExpert="true" />
+ <PropertyDefinition Name="HostnameVerifier" DisplayName="Hostname Verifier" ShortDescription="Class implementing javax.net.ssl.HostnameVerifier. Used to implement a hostname mismatch workaround." IsExpert="true" />
+ <PropertyDefinition Name="QueryPreprocessorClass" DisplayName="Query Preprocessor Class" ShortDescription="The class to use to preprocess the IQuery" DefaultValue="com.metamatrix.connector.xml.base.NoQueryPreprocessing" IsExpert="true" />
+ </ComponentType>
+ <ComponentType Name="XML-Relational SOAP Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="XML Connector" ParentComponentType="Connectors" LastChangedDate="2008-10-31T10:26:19.919-06:00" CreationDate="2008-10-31T10:26:19.919-06:00">
+ <PropertyDefinition Name="AuthPassword" DisplayName="Authentication User Password" ShortDescription="Password value for authentication" DefaultValue="" IsExpert="true" IsMasked="true" />
+ <PropertyDefinition Name="SaxFilterProviderClass" DisplayName="XML Filter Provider" ShortDescription="The class the provides extended XML Filters" DefaultValue="com.metamatrix.connector.xml.base.NoExtendedFilters" IsExpert="true" />
+ <PropertyDefinition Name="AuthUserName" DisplayName="Authentication User Name" ShortDescription="Name value for authentication" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="WSSecurityType" DisplayName="WS-Security Type(UsernameToken, SAML..)" ShortDescription="Type of WS-Security to be used; Combinations of multiple security types can be used with a space in-between. Allowed types are: (UsernameToken, UsernameToken-Digest, SAMLTokenUnsigned, SAMLTokenSigned, Signature, Timestamp, Encrypt)" DefaultValue="" />
+ <PropertyDefinition Name="XMLParmName" DisplayName="XML Parameter Name" ShortDescription="" DefaultValue="" IsModifiable="false" />
+ <PropertyDefinition Name="EncryptUserName" DisplayName="Encrypt UserName (only if Encrypt profile used)" ShortDescription="The username to be used in the encryption; if blank uses auth username" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="ExceptionOnSOAPFault" DisplayName="Exception on SOAP Fault" ShortDescription="Throw connector exception when SOAP fault is returned from source." DefaultValue="true" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="RequestTimeout" DisplayName="Request Timeout (in Milliseconds)" ShortDescription="" DefaultValue="10000" IsRequired="true" PropertyType="Integer" />
+ <PropertyDefinition Name="CryptoPropertyFile" DisplayName="User Crypto Property File (If SAML or Signature profile used)" ShortDescription="The file defines properties of cryptography;defines the certificates;(crypto.properties)" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorStateClass" DisplayName="Connector State Class" ShortDescription="" DefaultValue="com.metamatrix.connector.xml.soap.SOAPConnectorState" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="SOAPAction" DisplayName="SOAP-Action" ShortDescription="Value for SOAP-Action header" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="AccessMethod" DisplayName="Access Method (Get, Post)" ShortDescription="" DefaultValue="post" IsModifiable="false">
+ <AllowedValue>get</AllowedValue>
+ <AllowedValue>post</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="ProxyUri" DisplayName="Proxy Server URI" ShortDescription="The URI of the proxy server" DefaultValue="" />
+ <PropertyDefinition Name="EncryptPropertyFile" DisplayName="Encrypt crypto property file (only if Encrypt profile used)" ShortDescription="The file defines properties of cryptography for encryption of the message;(crypto.properties)" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="ConnectorCapabilities" DisplayName="Connector Capabilities Class" ShortDescription="The class to use to provide the Connector Capabilities" DefaultValue="com.metamatrix.connector.xml.base.XMLCapabilities" IsExpert="true" />
+ <PropertyDefinition Name="SAMLPropertyFile" DisplayName="SAML Property File (only required when SAML profile used)" ShortDescription="SAML Security property file (saml.properties)" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
+ <PropertyDefinition Name="EncodingStyle" DisplayName="Encoding Style (RPC - Encoded, RPC - Literal, Document - Literal, Document - Encoded)" ShortDescription="Encoding Style" DefaultValue="Document - Literal" IsRequired="true">
+ <AllowedValue>RPC - Encoded</AllowedValue>
+ <AllowedValue>RPC - Literal</AllowedValue>
+ <AllowedValue>Document - Literal</AllowedValue>
+ <AllowedValue>Document - Encoded</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.xml.base.XMLConnector" IsRequired="true" IsExpert="true" />
+ <PropertyDefinition Name="Uri" DisplayName="Server URI" ShortDescription="The URI of the HTTP source" IsRequired="true" />
+ <PropertyDefinition Name="SecurityType" DisplayName="WebService Security Used(None, HTTPBasic, WS-Security)" ShortDescription="Type of Authentication to used with the web service; If WS-Secuirty is being used, then WS-Secuirty type must be defined" DefaultValue="None" IsRequired="true" />
+ <PropertyDefinition Name="LogRequestResponseDocs" DisplayName="Log XML Request and Response Documents" ShortDescription="Write the request and response documents to the log at Info level" DefaultValue="false" PropertyType="Boolean" IsExpert="true" />
+ <PropertyDefinition Name="TrustDeserializerClass" DisplayName="Trust Deserializer Class" ShortDescription="The class to use to process trusted payloads and execution payloads" DefaultValue="com.metamatrix.connector.xml.soap.DefaultSoapTrustDeserializer" IsExpert="true" />
+ <PropertyDefinition Name="ParameterMethod" DisplayName="Parameter Method (None, Name/Value, XMLRequest, XMLInQueryString)" ShortDescription="" DefaultValue="XMLRequest" IsModifiable="false">
+ <AllowedValue>None</AllowedValue>
+ <AllowedValue>Name/Value</AllowedValue>
+ <AllowedValue>XMLRequest</AllowedValue>
+ <AllowedValue>XMLInQueryString</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="InputStreamFilterClass" DisplayName="Input Stream Filter Class" ShortDescription="The class to use to preprocess raw XML input stream" DefaultValue="com.metamatrix.connector.xml.base.PluggableInputStreamFilterImpl" IsExpert="true" />
+ <PropertyDefinition Name="HostnameVerifier" DisplayName="Hostname Verifier" ShortDescription="a class implmenting javax.net.ssl.HostnameVerifier. Used to implement a hostname mismatch workaround." IsExpert="true" />
+ <PropertyDefinition Name="TrustType" DisplayName="Trust Type:(DirectReference or IssuerSerial)" ShortDescription="Only required for Signature and Signed SAML; The issuer-serial method presumes that all trusted users of the service are known to the service and have pre-registered their certificate chains before using the service. The direct-reference method presumes that the service operator trusts all users with certificates issued by a trusted CA." DefaultValue="DirectReference" IsExpert="true" />
+ <PropertyDefinition Name="QueryPreprocessorClass" DisplayName="Query Preprocessor Class" ShortDescription="The class to use to preprocess the IQuery" DefaultValue="com.metamatrix.connector.xml.base.NoQueryPreprocessing" IsExpert="true" />
+ </ComponentType>
+
+ </ComponentTypes>
+</ConfigurationDocument>
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/main/resources/configuration.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/datasources/datasource_mapping.xml
===================================================================
--- trunk/test-integration/db/src/main/resources/datasources/datasource_mapping.xml (rev 0)
+++ trunk/test-integration/db/src/main/resources/datasources/datasource_mapping.xml 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ======================================================================
+ Aug 26, 2009 9:05:03 AM
+
+ description: This datasource configuration file is used to define the
+ different datasources that "may be" used during test execution.
+ I say may be used, because these are all the types that are supported
+ by Teiid, but only if the defined "dir" exist under the "datasources"
+ directory that contains a connection.properties file will it actually be used.
+
+ The organization of the datasources splits them between groups XA and Non-XA
+ related transactional types so that when a test is run the process will obtain
+ a connection from a datasoure defined for that group.
+
+ To use a datasource(s) in a test, map the model(s) to a datasource indicated here.
+ The mapping is done in the configuration properties file (see default-config.properties).
+
+ This configuration specifies the following information:
+ - It indicates the location ("dir") to find the datasource connection
+ information that is used to populate the connector bindings and create
+ direct connections to the source
+ - It provides a mapping to the Connector Type that needs
+ to be specified when deploying the ConnectorBinding and assigning it to
+ the mapped model (see default.config.properties)
+
+ NOTE: the name of datasource must be unique across all datasources in the file
+
+ vanhalbert
+ ====================================================================== -->
+
+<datasourceconfig>
+ <datasourcetype name="nonxa">
+ <datasource name="ds_mysql">
+ <property name="dir">mysql</property>
+ <property name="connectortype">MySQL JDBC Connector</property>
+ </datasource>
+ <datasource name="ds_oracle">
+ <property name="dir">oracle</property>
+ <property name="connectortype">Oracle Connector</property>
+ </datasource>
+ <datasource name="ds_db2">
+ <property name="dir">db2</property>
+ <property name="connectortype">DB2 Connector</property>
+ </datasource>
+ <datasource name="ds_postgres">
+ <property name="dir">postgres</property>
+ <property name="connectortype">PostgreSQL JDBC Connector</property>
+ </datasource>
+
+ <datasource name="ds_derby">
+ <property name="dir">derby</property>
+ <property name="connectortype">Apache Derby Network Connector</property>
+ </datasource>
+
+ </datasourcetype>
+
+ <datasourcetype name="xa">
+ <datasource name="ds_mysql_xa">
+ <property name="dir">mysql</property>
+ <property name="connectortype">MySQL JDBC XA Connector</property>
+ </datasource>
+ <datasource name="ds_oracle_xa">
+ <property name="dir">oracle</property>
+ <property name="connectortype">Oracle XA Connector</property>
+ </datasource>
+ <datasource name="ds_db2_xa">
+ <property name="dir">db2</property>
+ <property name="connectortype">DB2 XA Connector</property>
+ </datasource>
+ <datasource name="ds_postgres_xa">
+ <property name="dir">postgres</property>
+ <property name="connectortype">PostgreSQL XA JDBC Connector</property>
+ </datasource>
+
+ </datasourcetype>
+
+</datasourceconfig>
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/main/resources/datasources/datasource_mapping.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/datasources/derby/example_connection.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/datasources/derby/example_connection.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/datasources/derby/example_connection.properties 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,17 @@
+db.type=derby
+driver=org.apache.derby.jdbc.ClientDriver
+URL=jdbc:derby://localhost:1527//(derby location)
+User=
+Password=
+
+servername=localhost
+databasename=
+portnumber=1527
+ds-jndiname=localhost_1527
+
+Immutable=true
+
+
+
+
+
Property changes on: trunk/test-integration/db/src/main/resources/datasources/derby/example_connection.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/datasources/readme.txt
===================================================================
--- trunk/test-integration/db/src/main/resources/datasources/readme.txt (rev 0)
+++ trunk/test-integration/db/src/main/resources/datasources/readme.txt 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,9 @@
+the datasources directory is the location to define each database schema that can be used during the running of the tests
+a datasource here is defined as a unique connection to a specific schema
+
+To setup a datasource, do the following:
+
+1. open datasource_mapping.xml to see the name of the directory ("dir") name to use associated the type of datasource
+1. create the directory, if it doesn't exist
+2. create (or place) a connection.properties file in the newly created directory
+3.
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/main/resources/datasources/readme.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/ddl/adminparms.txt
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/adminparms.txt (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/adminparms.txt 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,57 @@
+sa
+-- DB2 parms
+ (databasename)
+ (username)
+ - On DB2, remember an OS user must be created first with the same name as the db2user
+
+
+-- oracle parms
+(username)
+(password)
+
+-- mysql
+(username)
+(password)
+
+-- postgres
+(username)
+(password)
+
+-- sqlserver
+(username)
+(password)
+-- On sql server, CHECK AND CHANGE THE PATH OF THE DATAFILES TO WHAT YOUR DB IS SETUP WITH
+
+
+SQLSERVER
+slntdb02 2000 (8.00.859) Repositories sa mmsa
+slntds05 2000 (8.00.859) Data Source sa mmsa
+slntdb07 2005 (9.00.1399.06) Repositories sa metamatrix
+ENGNTDBS14 2008 sa metamatrix
+
+ORACLE
+slntdb03, SID=DB03 9i (9.2.0.4.0) Repositories system mmsystem
+slntdb08, SID=DB08 10g (10.1.0.2.0) Repositories system mmsystem
+slntds04, SID=DS04 9i (9.2.0.1.0) Data Source system mmsystem
+slntds08, SID=DS08 10g (10.1.0.2.0) Data Source system mmsystem
+dbo3 machine administrator quad
+ds04 administrator jboss42
+englxdbs11 11 sys mm system mm
+
+DB2
+slntds05, DATABASE=DS05 8.1.11.973(Previously 8.1.8.762) Data Source db2admin mm
+ENGNTDBS12 db2admin mm
+
+SYBASE
+slntds17 12.5.1 Data Source sa metamatrix
+
+MYSQL
+slntds03 4.1.14 Data Source root mmroot
+slwxp174 5 root mmroot
+
+POSTGRESQL
+slntds04 8.3 both metamatrix
+slntds11 8.1.2 Data Source postgres metamatrix
+
+
+* For Oracle system will do to create users, but for admin work I use sys/mmsys as SYSDBA login
Property changes on: trunk/test-integration/db/src/main/resources/ddl/adminparms.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/ddl/db2/create_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/db2/create_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/db2/create_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,13 @@
+
+-- these tables are used by custom junit test for testing transactions
+
+create Table g1 (
+ e1 NUMERIC(5),
+ e2 varchar(50),
+ PRIMARY KEY (e1)
+);
+create Table g2 (
+ e1 NUMERIC(5) REFERENCES g1 (e1),
+ e2 varchar(50)
+);
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/db2/drop_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/db2/drop_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/db2/drop_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,7 @@
+
+-- drop the tables
+
+drop Table g2;
+drop Table g1;
+
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/db2/exec_parms.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/db2/exec_parms.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/db2/exec_parms.properties 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,3 @@
+delim=%
+delimtype=normal
+rdbms.type=db2
Property changes on: trunk/test-integration/db/src/main/resources/ddl/db2/exec_parms.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/ddl/derby/create_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/derby/create_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/derby/create_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,13 @@
+
+-- these tables are used by custom junit test for testing transactions
+
+create Table g1 (
+ e1 NUMERIC(5),
+ e2 varchar(50),
+ PRIMARY KEY (e1)
+);
+create Table g2 (
+ e1 NUMERIC(5) REFERENCES g1 (e1),
+ e2 varchar(50)
+);
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/derby/drop_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/derby/drop_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/derby/drop_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,7 @@
+
+-- drop the tables
+
+drop Table g2;
+drop Table g1;
+
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/derby/exec_parms.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/derby/exec_parms.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/derby/exec_parms.properties 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,3 @@
+delim=;
+delimtype=normal
+rdbms.type=derby
Property changes on: trunk/test-integration/db/src/main/resources/ddl/derby/exec_parms.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/ddl/exec_parms.properties_template
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/exec_parms.properties_template (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/exec_parms.properties_template 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,10 @@
+# These properties are used in the execution of the sql statements
+# using the SQL Ant tasks.
+
+# Each database type in the "ddl" directory must have an exec_parms.properties file.
+
+# For property setting options, see the Sql ant task page at @ http://ant.apache.org/manual/index.html
+
+delim=;
+delimtype=normal
+rdbms.type=oracle
Added: trunk/test-integration/db/src/main/resources/ddl/manage_schemas.xml
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/manage_schemas.xml (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/manage_schemas.xml 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="create_schemas" default="manage.schemas" basedir="../../">
+ <property name="resources.dir" value="${basedir}/${relative.resources.dir}"></property>
+
+ <property name="target.dir" value="${basedir}/target"></property>
+
+ <!--
+ This script triggers the running of the process for creating schemas
+ -->
+
+
+ <target name="manage.schemas" depends="check, init, manage.all.schemas, manage.single.schemas">
+ <echo>Ran create schemas</echo>
+
+ </target>
+
+
+ <target name="check">
+ <echo>Running for USERNAME = ${User}</echo>
+ <echo>Perform check</echo>
+ <condition property="all">
+ <not>
+ <isset property="single"/>
+ </not>
+ </condition>
+
+ </target>
+
+ <target name="init">
+ <mkdir dir="${target.dir}"/>
+ </target>
+
+ <target name="manage.all.schemas" if="all">
+ <echo>Creating all schemas from datasource dir ${resources.dir}</echo>
+ <!--
+ This will process each directory located under the refid location.
+ Its expects the following:
+ - each directory represents one datasource.
+ - connection.properties file must exist in the directory to be used
+ -->
+ <subant genericantfile="${resources.dir}/ddl/run_ddl.xml" inheritall="true" >
+ <dirset dir="${resources.dir}/datasources/" />
+ <property name="sql.ddl.dir" value="${resources.dir}/ddl"/>
+
+ </subant>
+
+ <echo>Completed creating all schemas</echo>
+ </target>
+
+
+ <target name="manage.single.schemas" if="single">
+ <echo>Creating single schema ${single}</echo>
+
+ <available file="${resources.dir}/datasources/${single}" property="dir.exist"/>
+ <fail unless="dir.exist" message="The datasource single was not found at ${resources.dir}/datasources/${single}" />
+
+
+ <ant inheritAll="true" antfile="${resources.dir}/ddl/run_ddl.xml">
+ <property name="basedir" value="${resources.dir}/datasources/${single}"/>
+ <property name="sql.ddl.dir" value="${resources.dir}/ddl"/>
+
+ </ant>
+
+ <echo>Completed creating single schema ${single}</echo>
+
+ </target>
+
+</project>
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/main/resources/ddl/manage_schemas.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,6 @@
+
+-- these tables are used by custom junit test for testing transactions
+
+create Table g1 (e1 NUMERIC(5) PRIMARY KEY, e2 varchar(50));
+create Table g2 (e1 NUMERIC(5) REFERENCES g1 (e1), e2 varchar(50));
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/mysql/drop_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/mysql/drop_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/mysql/drop_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,7 @@
+
+-- drop the tables
+
+drop Table g2;
+drop Table g1;
+
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/mysql/exec_parms.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/mysql/exec_parms.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/mysql/exec_parms.properties 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,3 @@
+delim=;
+delimtype=normal
+rdbms.type=mysql
Property changes on: trunk/test-integration/db/src/main/resources/ddl/mysql/exec_parms.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/ddl/oracle/create_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/oracle/create_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/oracle/create_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,6 @@
+
+-- these tables are used by custom junit test for testing transactions
+
+create Table g1 (e1 number(5) PRIMARY KEY, e2 varchar2(50));
+create Table g2 (e1 number(5) REFERENCES g1, e2 varchar2(50));
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/oracle/drop_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/oracle/drop_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/oracle/drop_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,7 @@
+
+-- drop the tables
+
+drop Table g2;
+drop Table g1;
+
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/oracle/exec_parms.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/oracle/exec_parms.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/oracle/exec_parms.properties 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,3 @@
+delim=;
+delimtype=normal
+rdbms.type=oracle
Property changes on: trunk/test-integration/db/src/main/resources/ddl/oracle/exec_parms.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/ddl/postgres/create_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/postgres/create_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/postgres/create_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,13 @@
+
+-- these tables are used by custom junit test for testing transactions
+
+create Table g1 (
+ e1 NUMERIC(5),
+ e2 VARCHAR(50),
+ PRIMARY KEY (e1)
+);
+create Table g2 (
+ e1 NUMERIC(5) REFERENCES g1 (e1),
+ e2 VARCHAR(50)
+);
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/postgres/drop_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/postgres/drop_tables.sql (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/postgres/drop_tables.sql 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,6 @@
+
+-- drop the tables
+
+drop Table g2;
+drop Table g1;
+
\ No newline at end of file
Added: trunk/test-integration/db/src/main/resources/ddl/postgres/exec_parms.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/postgres/exec_parms.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/postgres/exec_parms.properties 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,3 @@
+delim=;
+delimtype=normal
+rdbms.type=postgres
Property changes on: trunk/test-integration/db/src/main/resources/ddl/postgres/exec_parms.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/ddl/run_ddl.xml
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/run_ddl.xml (rev 0)
+++ trunk/test-integration/db/src/main/resources/ddl/run_ddl.xml 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="run_ddl" default="run.ddl" basedir=".">
+
+
+ <!--
+
+ NOTES:
+ 1. sql.scripts.dir variable must be set to the root directory where the sql script directories are found
+ 2. rdbms.type value must match the folder name (ddl script directory) for its repective scripts in the sql.ddl.dir
+
+ -->
+
+ <target name="run.ddl" if="conn.props.exist" depends="init" >
+ <echo>Loading connection properties ${basedir}/connection.properties</echo>
+ <!--
+ Load the datasource specific connection properties
+ -->
+ <loadproperties srcFile="${basedir}/connection.properties"/>
+
+ <!--
+ Load the ddl specific parms in order to execute the ddl appropriately against the database type
+ -->
+ <loadproperties srcFile="${sql.ddl.dir}/${db.type}/exec_parms.properties"/>
+
+ <antcall target="execute.create.schema" inheritall="true" />
+ <antcall target="execute.create.tables" inheritall="true" />
+
+
+ </target>
+
+ <target name="init">
+ <echo>Initializing at base dir ${basedir}</echo>
+
+ <available file="${sql.ddl.dir}" property="dir.exist"/>
+
+ <fail unless="dir.exist" message="${sql.ddl.dir} does not exist or was not set" />
+
+ <!--
+ ${basedir}/
+ -->
+ <available file="connection.properties" property="conn.props.exist"/>
+
+ <!--
+ due to the ddl supported syntax for certain databases ('if'), there is a need to
+ seperate the drop logic so that it can be executed with the option to not fail
+ if the user/schema doesn't exist. Because we want a failure to occur if the
+ schema cannot be create (don't care if an error occurs when it doesn't exist)
+ -->
+ <!--
+ <property name="drop.script" value="${sql.ddl.dir}/${db.type}/drop_schema.sql" />
+ <available file="${drop.script}" property="drop.exist"/>
+-->
+ <!--
+ <condition property="dont.create.schema">
+ <isfalse value="${create.schema}" />
+ </condition>
+ -->
+
+ <condition property="create.database">
+ <isset property="${adminuser}"/>
+ </condition>
+ <echo>Will only create/drop table be done ${create.database}</echo>
+
+ <!--
+ <condition property="dont.create.schema">
+ <and>
+ <isset property="${create.schema}"/>
+
+ <isfalse value="${create.schema}"/>
+
+ </and>
+ </condition>
+-->
+
+ </target>
+
+
+
+ <target name="execute.create.schema"
+ if="create.database">
+
+ <antcall target="execute.drop.schema" inheritall="true" />
+
+
+ <echo>Executing sql for rdbms ${db.type} using delim ${delim}</echo>
+ <echo>Connecting using url ${adminurl}</echo>
+ <echo>using admin account ${adminuser} and pwd ${adminpassword}</echo>
+
+ <property name="onerror" value="abort" />
+ <property name="autocommit" value="true" />
+
+ <property name="create.script" value="${sql.ddl.dir}/${db.type}/create_schema.sql" />
+
+ <property name="target.create.script" value="${target.dir}/${db.type}_create_schema.sql" />
+
+ <available file="${create.script}" property="create.schema.script.exist"/>
+
+ <fail unless="create.schema.script.exist" message="${create.script} does not exist" />
+
+
+ <antcall target="make.sql.file" inheritall="true" >
+ <param name="script.file" value="${create.script}"/>
+ <param name="target.script.file" value="${target.create.script}"/>
+ </antcall>
+
+ <antcall target="execute.schema.sql" inheritall="true" >
+ <param name="script.file" value="${target.create.script}"/>
+ </antcall>
+
+ </target>
+
+ <target name="execute.drop.schema" >
+
+ <echo>Executing drop sql for rdbms ${db.type} </echo>
+ <property name="onerror" value="continue" />
+ <property name="autocommit" value="true" />
+
+ <property name="drop.schema.script" value="${sql.ddl.dir}/${db.type}/drop_schema.sql" />
+ <available file="${drop.schema.script}" property="create.schema.script.exist"/>
+
+ <fail unless="create.schema.script.exist" message="${drop.schema.script} does not exist" />
+
+
+ <property name="target.drop.schema.script" value="${target.dir}/${db.type}_drop_schema.sql" />
+
+ <antcall target="make.sql.file" inheritall="true" >
+ <param name="script.file" value="${drop.schema.script}"/>
+ <param name="target.script.file" value="${target.drop.schema.script}"/>
+ </antcall>
+
+ <antcall target="execute.schema.sql" inheritall="true" >
+ <param name="script.file" value="${target.drop.schema.script}"/>
+ </antcall>
+
+ </target>
+
+ <target name="execute.create.tables" depends="execute.drop.tables" >
+
+ <echo>Executing sql to load tables for ${db.type} </echo>
+ <echo>Connecting using url ${URL}</echo>
+ <echo>using username ${User} and password ${Password}</echo>
+
+ <property name="create.table.script" value="${sql.ddl.dir}/${db.type}/create_tables.sql" />
+
+ <available file="${create.table.script}" property="create.table.script.exist"/>
+
+ <fail unless="create.table.script.exist" message="${create.table.script} does not exist" />
+
+
+ <property name="onerror" value="abort" />
+ <property name="autocommit" value="true" />
+
+ <antcall target="execute.tables.sql" inheritall="true" >
+ <param name="script.file" value="${create.table.script}"/>
+ </antcall>
+
+ </target>
+
+ <target name="execute.drop.tables" >
+
+ <echo>Executing sql to drop tables for ${db.type} </echo>
+ <echo>Connecting using url ${URL}</echo>
+ <echo>using username ${User} and password ${Password}</echo>
+
+ <property name="drop.table.script" value="${sql.ddl.dir}/${db.type}/drop_tables.sql" />
+
+ <available file="${drop.table.script}" property="drop.table.script.exist"/>
+
+ <fail unless="drop.table.script.exist" message="${drop.table.script} does not exist" />
+
+
+ <property name="onerror" value="continue" />
+ <property name="autocommit" value="true" />
+
+ <antcall target="execute.tables.sql" inheritall="true" >
+ <param name="script.file" value="${drop.table.script}"/>
+ </antcall>
+ </target>
+
+
+ <target name="make.sql.file" >
+
+ <available file="${script.file}" property="script.file.exist"/>
+
+ <fail unless="script.file.exist" message="${script.file} does not exist" />
+
+ <echo>Updating script file ${target.script.file}</echo>
+
+ <delete file="${target.script.file}"/>
+ <copy file="${script.file}" tofile="${target.script.file}"/>
+
+ <replace
+ file="${target.script.file}">
+ <replacefilter
+ token="(username)"
+ value="${username}"/>
+ <replacefilter
+ token="(password)"
+ value="${password}"/>
+ <replacefilter
+ token="(databasename)"
+ value="${databasename}"/>
+ </replace>
+ </target>
+
+ <!--
+ This executes using the admin username and password because
+ it requires specific rights to create schema
+ -->
+ <target name="execute.schema.sql" >
+ <echo>Executing schema script file ${script.file}</echo>
+ <echo>Admin account: ${adminuser} url: ${adminurl}</echo>
+
+ <available file="${script.file}" property="script.file.exist"/>
+
+ <fail unless="script.file.exist" message="${script.file} does not exist" />
+
+ <sql driver="${driver}"
+ url="${adminurl}"
+ userid="${adminuser}"
+ password="${adminpassword}"
+ src="${script.file}"
+ rdbms="${rdbms.type}"
+ delimiter="${delim}"
+ delimitertype="${delimtype}"
+ autocommit="${autocommit}"
+ onerror="${onerror}"
+ classpath="${maven.runtime.classpath}"
+ />
+
+
+ </target>
+
+ <!--
+ This executes using the username and password for the so that tables
+ are created under this user and not the admin
+ -->
+ <target name="execute.tables.sql" >
+ <echo>Executing table script file ${script.file}</echo>
+ <echo>User account: ${User} url: ${URL}</echo>
+ <echo>Classpath: ${maven.runtime.classpath}</echo>
+
+ <available file="${script.file}" property="script.file.exist"/>
+
+ <fail unless="script.file.exist" message="DDL ${script.file} does not exist" />
+
+
+ <sql driver="${driver}"
+ url="${URL}"
+ userid="${User}"
+ password="${Password}"
+ src="${script.file}"
+ rdbms="${rdbms.type}"
+ delimiter="${delim}"
+ delimitertype="${delimtype}"
+ autocommit="${autocommit}"
+ onerror="${onerror}"
+ classpath="${maven.runtime.classpath}"
+ />
+
+ </target>
+
+ <target name="does.user.schema.exist" >
+ <echo>Executing table script file ${script.file}</echo>
+ <echo>User account: ${adminuser} url: ${url}</echo>
+
+ <available file="${script.file}" property="script.file.exist"/>
+
+ <fail unless="script.file.exist" message="DDL ${script.file} does not exist" />
+
+
+ <sql driver="${driver}"
+ url="${URL}"
+ userid="${adminuser}"
+ password="${adminpassword}"
+ src="${script.file}"
+ rdbms="${rdbms.type}"
+ delimiter="${delim}"
+ delimitertype="${delimtype}"
+ autocommit="${autocommit}"
+ onerror="${onerror}"
+ classpath="${maven.runtime.classpath}"
+ />
+
+ </target>
+
+</project>
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/main/resources/ddl/run_ddl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/default-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/default-config.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/default-config.properties 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,67 @@
+##########################################
+# Common Properties for everybody
+##########################################
+#available types (datasource, driver, jndi)
+#connection-type=datasource
+connection-type=driver
+
+process-batch = 20
+connector-batch = 20
+
+# local, xa, jndi
+transaction-type=local
+
+# autocommit applies to local transaction-type only
+# default is true
+autocommit=false
+
+# this is how to submit queries to Teiid
+# default is true
+execute.in.batch=false
+
+
+# AUTO_WRAP_OFF = "OFF"
+# AUTO_WRAP_ON = "ON"
+# AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"
+# AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"
+
+# txnAutoWrap=
+
+##########################################
+# properties for MetaMatrix connection
+##########################################
+driver=com.metamatrix.jdbc.EmbeddedDataSource
+URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties
+User=metamatrixadmin
+Password=mm
+databasename=Transaction
+servername=target/classes/transactions/transaction.properties
+portnumber=0
+application-name=txn-test
+
+# jboss
+# mm.ds-jndiname=java:mmXA
+# usertxn-jndiname=UserTransaction
+
+# weblogic
+mm.ds-jndiname=mmXA
+usertxn-jndiname=java:comp/UserTransaction
+
+# === Mode-to-Datasource Mapping ======
+# <model>=<datasource type name>
+
+# This mapping will be used by the set of testcases that load this config file.
+# These mapping control what datasource is mapped to which model
+#
+# See the resources/datasources/datasource_mapping.xml for the available datasource type names
+#
+# <datasource type name> can be the name of either a datasourcegroup or datasource
+#
+#
+
+pm1=nonxa
+pm2=nonxa
+
+
+
+
Property changes on: trunk/test-integration/db/src/main/resources/default-config.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/resources/mysql/connection.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/mysql/connection.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/mysql/connection.properties 2009-09-11 19:20:59 UTC (rev 1329)
@@ -0,0 +1,22 @@
+db.type=mysql
+driver=com.mysql.jdbc.Driver
+URL=jdbc:mysql://slntds03.mm.atl2.redhat.com:3306/rep_unit_test
+User=rep_unit_test
+#rep_unit_test
+Password=mm
+
+servername=slntds03.mm.atl2.redhat.com
+databasename=rep_unit_test
+portnumber=3306
+ds-jndiname=slntds03_mysql
+
+Immutable=true
+
+#adminuser=root
+#adminpassword=mmroot
+#adminurl=jdbc:mysql://slntds03.mm.atl2.redhat.com:3306
+
+
+
+
+
Property changes on: trunk/test-integration/db/src/main/resources/mysql/connection.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 4 months
teiid SVN: r1328 - in trunk/test-integration/db/src/main: resources and 2 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:20:14 -0400 (Fri, 11 Sep 2009)
New Revision: 1328
Added:
trunk/test-integration/db/src/main/resources/
trunk/test-integration/db/src/main/resources/datasources/
trunk/test-integration/db/src/main/resources/datasources/derby/
trunk/test-integration/db/src/main/resources/ddl/
trunk/test-integration/db/src/main/resources/ddl/db2/
trunk/test-integration/db/src/main/resources/ddl/derby/
trunk/test-integration/db/src/main/resources/ddl/mysql/
trunk/test-integration/db/src/main/resources/ddl/oracle/
trunk/test-integration/db/src/main/resources/ddl/postgres/
trunk/test-integration/db/src/main/resources/mysql/
Log:
Teiid 773 - organize integration test
15 years, 4 months
teiid SVN: r1327 - in trunk/test-integration/db/src/test/java/org/teiid/test: framework/datasource and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:19:36 -0400 (Fri, 11 Sep 2009)
New Revision: 1327
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/Alltaests.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java
Log:
Teiid 773 - organize integration test
Added: trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.sql.Statement;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+import org.teiid.test.framework.datasource.DataSourceSetupFactory;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+
+
+/**
+ * The AbstractQueryTransactionTest is the class that should be extended when
+ * a testcase is being created to validate certain behavior
+ *
+ * @see QueryExecution for use when direct queries to the source are used
+ * to validate the results of the testcase.
+ *
+ */
+public abstract class AbstractQueryTransactionTest extends AbstractQueryTest implements TransactionQueryTest{
+ Properties executionProperties = null;
+ String testname = "NA";
+
+
+ public AbstractQueryTransactionTest() {
+ super();
+ }
+
+ public AbstractQueryTransactionTest(String testname) {
+ super();
+ this.testname = testname;
+ }
+
+ public String getTestName() {
+ return this.testname;
+ }
+
+
+ public void setExecutionProperties(Properties props) {
+ assertNotNull(props);
+ this.executionProperties = props;
+ }
+
+ @Override protected void assignExecutionProperties(Statement stmt) {
+ if (this.executionProperties != null) {
+ if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
+ com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement)stmt;
+ if (this.executionProperties.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP) != null) {
+ statement.setExecutionProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP, this.executionProperties.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP));
+ }
+
+ if (this.executionProperties.getProperty(ExecutionProperties.PROP_FETCH_SIZE) != null) {
+ statement.setExecutionProperty(ExecutionProperties.PROP_FETCH_SIZE, this.executionProperties.getProperty(ExecutionProperties.PROP_FETCH_SIZE));
+ }
+ }
+ }
+
+ }
+
+ public int getNumberRequiredDataSources() {
+ return 1;
+ }
+
+
+ @Override
+ public void setupDataSource() {
+ DataSourceSetup dss = null;
+ try {
+
+ dss = DataSourceSetupFactory.createDataSourceSetup(getNumberRequiredDataSources());
+ dss.setup();
+ } catch(Exception e) {
+ throw new TransactionRuntimeException(e.getMessage());
+ }
+ }
+
+
+
+ /**
+ * Implement testCase(), it is the entry point to the execution of the test.
+ * @throws Exception
+ *
+ * @since
+ */
+ public abstract void testCase() throws Exception;
+
+ /**
+ * Indicates what should be done when a failure occurs in {@link #testCase()}
+ * @return
+ *
+ * @since
+ */
+ public boolean rollbackAllways() {
+ return false;
+ }
+
+ /**
+ * Override <code>before</code> if there is behavior that needs to be performed
+ * prior to {@link #testCase()} being called.
+ *
+ *
+ * @since
+ */
+ public void before() {
+ }
+
+ /**
+ * Override <code>after</code> if there is behavior that needs to be performed
+ * after {@link #testCase()} being called.
+ *
+ *
+ * @since
+ */
+ public void after() {
+ }
+
+
+ public void cleanup() {
+ ConnectionStrategyFactory.destroyInstance();
+
+ this.closeConnection();
+ }
+
+ @Override
+ public XAConnection getXAConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,21 @@
+package org.teiid.test.framework;
+
+import java.sql.Connection;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+/**
+ * The QueryExecution class can be used to query the source directly. The intended use
+ * of this class is for validating results after the execution of a test case.
+ *
+ * @see AbstractQueryTransactionTest regarding creating a testcase to validate behavior.
+ * @author vanhalbert
+ *
+ */
+public class QueryExecution extends AbstractQueryTest {
+
+ public QueryExecution(Connection conn) {
+ super(conn);
+ }
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,28 @@
+package org.teiid.test.framework.datasource;
+
+import org.teiid.test.framework.DataSourceSetup;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+public class DataSourceSetupFactory {
+
+ public static DataSourceSetup createDataSourceSetup(int numOfDataSources) throws QueryTestFailedException {
+ DataSourceSetup dss = null;
+
+ switch (numOfDataSources) {
+ case 1:
+ dss = new SingleDataSourceSetup();
+ break;
+
+ case 2:
+ dss = new TwoDataSourceSetup();
+ break;
+
+ default:
+ throw new QueryTestFailedException("Number of datasources " + numOfDataSources + " is not supported");
+
+ }
+
+ return dss;
+ }
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.datasource;
+
+import org.teiid.test.framework.DataSourceSetup;
+import org.teiid.test.framework.QueryExecution;
+import org.teiid.test.framework.connection.ConnectionUtil;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * This performs the data setup for SingleSource test cases
+ */
+public class SingleDataSourceSetup implements DataSourceSetup {
+
+
+ @Override
+ public void setup() throws Exception {
+ // NOTE: dont close the connections here because in most cases they are reused
+ // to validate the results
+ // The connections will be closed at teardown
+
+ System.out.println("Run SingleDataSourceSetup...");
+
+
+ // Only one of the models are needed because pm1 and pm2 point to the same datasource
+ AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getSource("pm1")); //$NON-NLS-1$
+ test1.execute("delete from g2"); //$NON-NLS-1$
+ test1.execute("delete from g1"); //$NON-NLS-1$
+
+ test1.execute("select * from g1 ");
+ test1.assertRowCount(0);
+ test1.execute("select * from g2 ");
+ test1.assertRowCount(0);
+
+
+
+ String[] sql1 = new String[100];
+
+ for (int i = 0; i < 100; i++) {
+ sql1[i] = "insert into g1 (e1, e2) values("+i+",'"+i+"')" ;
+ }
+
+ test1.executeBatch(sql1);
+
+ String[] sql2 = new String[100];
+
+ for (int i = 0; i < 100; i++) {
+ sql2[i] = "insert into g2 (e1, e2) values("+i+",'"+i+"')" ;
+ }
+
+ test1.executeBatch(sql2);
+
+ test1.execute("select * from g1 ");
+ test1.assertRowCount(100);
+ test1.execute("select * from g2 ");
+ test1.assertRowCount(100);
+
+
+ System.out.println("SingleDataSourceSetup Completed");
+
+
+
+ }
+
+ @Override
+ public int getDataSourceCnt() {
+ // TODO Auto-generated method stub
+ return 1;
+ }
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.datasource;
+
+import org.teiid.test.framework.DataSourceSetup;
+import org.teiid.test.framework.QueryExecution;
+import org.teiid.test.framework.connection.ConnectionUtil;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * This performs the data setup for SingleSource test cases
+ */
+public class TwoDataSourceSetup implements DataSourceSetup {
+
+
+ @Override
+ public void setup() throws Exception {
+ // NOTE: dont close the connections here because in most cases they are reused
+ // to validate the results
+ // The connections will be closed at teardown
+
+
+ System.out.println("Run TwoSource Setup...");
+
+
+ AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getSource("pm1")); //$NON-NLS-1$
+ test1.execute("delete from g2"); //$NON-NLS-1$
+ test1.execute("delete from g1"); //$NON-NLS-1$
+
+ test1.execute("select * from g1 ");
+ test1.assertRowCount(0);
+ test1.execute("select * from g2 ");
+ test1.assertRowCount(0);
+
+ String[] sql1 = new String[100];
+
+ for (int i = 0; i < 100; i++) {
+ sql1[i] = "insert into g1 (e1, e2) values("+i+",'"+i+"')" ;
+ }
+
+ test1.executeBatch(sql1);
+ test1.execute("select * from g1 ");
+ test1.assertRowCount(100);
+ test1.execute("select * from g2 ");
+ test1.assertRowCount(0);
+
+ AbstractQueryTest test2 = new QueryExecution(ConnectionUtil.getSource("pm2")); //$NON-NLS-1$
+ test2.execute("delete from g2"); //$NON-NLS-1$
+ test2.execute("delete from g1"); //$NON-NLS-1$
+
+ test2.execute("select * from g1 ");
+ test2.assertRowCount(0);
+ test2.execute("select * from g2 ");
+ test2.assertRowCount(0);
+
+ String[] sql2 = new String[100];
+
+ for (int i = 0; i < 100; i++) {
+ sql2[i] = "insert into g2 (e1, e2) values("+i+",'"+i+"')" ;
+ }
+
+ test2.executeBatch(sql2);
+ test2.execute("select * from g1 ");
+ test2.assertRowCount(0);
+ test2.execute("select * from g2 ");
+ test2.assertRowCount(100);
+
+ System.out.println("TwoSource Setup Completed");
+
+
+
+ }
+
+ @Override
+ public int getDataSourceCnt() {
+ // TODO Auto-generated method stub
+ return 2;
+ }
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/Alltaests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/Alltaests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/Alltaests.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,32 @@
+/*
+ * Copyright � 2000-2008 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+
+/**
+ * @since 1.0
+ */
+public class Alltaests {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(Alltaests.suite());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("All Integration Tests"); //$NON-NLS-1$
+ //$JUnit-BEGIN$
+ // suite.addTestSuite(LocalTransactionTests.class);
+
+ //$JUnit-END$
+ return suite;
+ }
+
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/Alltaests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+
+
+import java.sql.Connection;
+
+import javax.sql.XAConnection;
+
+import junit.framework.TestCase;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.connection.ConnectionUtil;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.transaction.TransactionFactory;
+
+public class BaseAbstractTransactionTestCase extends TestCase {
+
+
+ public BaseAbstractTransactionTestCase(String name) {
+ super(name);
+ }
+
+ protected TransactionContainer getTransactionContainter() {
+ return TransactionFactory.create();
+ }
+
+
+ public Connection getSource(String identifier) throws QueryTestFailedException {
+ return ConnectionUtil.getSource(identifier);
+ }
+
+ public XAConnection getXASource(String identifier) throws QueryTestFailedException {
+ return ConnectionUtil.getXASource(identifier);
+ }
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,270 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import org.teiid.test.framework.AbstractQueryTransactionTest;
+import org.teiid.test.framework.QueryExecution;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * A common SingleSource test case among many different transaction stuff.
+ */
+public class SingleSourceTransactionTest extends BaseAbstractTransactionTestCase {
+
+ public SingleSourceTransactionTest(String name) {
+ super(name);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // 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("testSingleSourceSelect") {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+
+ public void validateTestCase() throws Exception {
+
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // there is nothing to verify here..
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourceSelect");
+
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceUpdate") {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(100, '100')");
+ }
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 = 100");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourceUpdate");
+
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourcePreparedUpdate") {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
+ }
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 = 102");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourcePreparedUpdate");
+
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommands") {
+ public void testCase() throws Exception {
+
+ 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 < 110; 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()});
+ }
+ }
+
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 >= 100");
+ test.assertRowCount(10);
+ test.closeConnection();
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourceMultipleCommands");
+
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Partial Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePartialProcessing() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourcePartialProcessing") {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 where pm1.g1.e1 < 100 limit 10");
+ assertRowCount(10);
+ }
+
+ public void validateTestCase() throws Exception {
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourcePartialProcessing");
+
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+
+ public void xtestSingleSourceMultipleCommandsExplicitRollback() throws Exception {
+ // now it's empty
+ AbstractQueryTest test = new QueryExecution(this.getSource("pm1"));
+ //getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 220");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 220");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommandsExplicitRollback") {
+ public void testCase() throws Exception {
+ for (int i = 200; i < 220; i++) {
+ execute("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ execute("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+ }
+
+ public boolean rollbackAllways() {
+ return true;
+ }
+
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ //getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 220");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 220");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+
+ System.out.println("Complete testSingleSourceMultipleCommandsExplicitRollback");
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void xtestSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommandsReferentialIntegrityRollback") {
+ public void testCase() throws Exception {
+ for (int i = 200; i < 220; 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()});
+ }
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 220");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete testSingleSourceMultipleCommandsReferentialIntegrityRollback");
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java 2009-09-11 19:19:36 UTC (rev 1327)
@@ -0,0 +1,785 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.teiid.test.framework.AbstractQueryTransactionTest;
+import org.teiid.test.framework.QueryExecution;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * A common SingleSource test case among many different transaction stuff.
+ */
+public class TwoSourceTransactionTest extends BaseAbstractTransactionTestCase {
+
+ public TwoSourceTransactionTest(String name) {
+ super(name);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // 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("testMultipleSourceSelect") {
+ 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 validateTestCase() throws Exception {
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceSelect");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceVirtualSelect") {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
+ assertRowCount(100);
+ }
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+ public void validateTestCase() throws Exception {
+ }
+
+ };
+
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceVirtualSelect");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceUpdate") {
+ public void testCase() throws Exception {
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(500, '500', 500, '500')");
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+ public void validateTestCase() throws Exception {
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e2 = '500'");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ test = new QueryExecution(getSource("pm2"));
+ test.execute("select * from g1 where e2 = '500'");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ };
+
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceUpdate");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelectInto() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceSelectInto") {
+ public void testCase() throws Exception {
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(501, '501', 501, '501')");
+ execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 = 501");
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+ public void validateTestCase() throws Exception {
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e2 = '501'");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ test = new QueryExecution(getSource("pm2"));
+ test.execute("select * from g1 where e2 = '501'");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceSelectInto");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsert() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsert") {
+ public void testCase() throws Exception {
+ for (int i = 100; i < 112; i++) {
+ Integer val = new Integer(i);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ }
+ execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+ public void validateTestCase() throws Exception {
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 112");
+ test.assertRowCount(12);
+ test.closeConnection();
+
+ test = new QueryExecution(getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 112");
+ test.assertRowCount(12);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 112");
+ test.assertRowCount(12);
+ test.closeConnection();
+ }
+
+
+ };
+
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceBulkRowInsert");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePreparedUpdate") {
+ 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 int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+ public void validateTestCase() throws Exception {
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 = 500");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ test = new QueryExecution(getSource("pm2"));
+ test.execute("select * from g1 where e1 = 500");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ };
+
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourcePreparedUpdate");
+
+ }
+
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommands") {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm2.g2 where e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm2.g1 where e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+
+ for (int i = 100; i < 115; 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()});
+
+ execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ execute("update pm1.g1 set e2='blah' where e1 > 100");
+ }
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+ public void validateTestCase() throws Exception {
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 115");
+ test.assertRowCount(15);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 115");
+ test.assertRowCount(15);
+ test.execute("select distinct e2 from g1 where e1 > 100");
+ test.assertResultsSetEquals(new String[] {"e2[varchar]", "blah"});
+ test.closeConnection();
+ }
+
+ };
+
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleCommands");
+
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceMultipleVirtualCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommands") {
+ public void testCase() throws Exception {
+
+ for (int i = 200; i < 207; i++) {
+ Integer val = new Integer(i);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ execute("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ }
+
+ execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 200");
+
+ execute("delete from vm.g2 where vm.g2.pm1e1 >= 205");
+ execute("delete from vm.g1 where vm.g1.pm1e1 >= 205");
+
+ execute("select * from vm.g1 where pm1e1 >= 200 and pm1e1 < 207");
+ assertRowCount(5);
+ }
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 207");
+ test.assertRowCount(5);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 207");
+ test.assertRowCount(5);
+ test.execute("select distinct e2 from g1 where e1 >= 200 and e1 < 207");
+ test.assertResultsSetEquals(new String[] {"e2[varchar]", "blah"});
+ test.closeConnection();
+
+ }
+
+ };
+
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleVirtualCommands");
+
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceMultipleCommandsCancel() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsCancel") {
+
+ public void testCase() throws Exception {
+ Thread t = new Thread("Cancel Thread") {
+ public void run() {
+ try {
+ try {
+ Thread.sleep(500);
+ cancelQuery();
+ } catch (SQLException e) {
+ print(e);
+ // debug(e.getMessage());
+ }
+ } catch (InterruptedException e) {}
+ }
+ };
+ t.start();
+ executeBatch(getMultipleSourceBatch());
+ }
+
+ /**
+ * @see com.metamatrix.transaction.test.framework.AbstractQueryTest#exceptionExpected()
+ */
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+
+ public void validateTestCase() throws Exception {
+ // now verify the results (this may finish under one second, then this test is not valid)
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 600 and e1 < 650");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 600 and e1 < 650");
+ test.assertRowCount(0);
+ test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 650");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ }
+
+ };
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleCommandsCancel");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceTimeout() throws Exception{
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceTimeout") {
+ public void testCase() throws Exception {
+ executeBatch(getMultipleSourceBatch(), 1); // time out after 1 sec
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed with time out exception");
+ }
+ else {
+ assertTrue(getLastException().getMessage().indexOf("Operation timed out before completion") != -1);
+ }
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+
+ public void validateTestCase() throws Exception {
+ // now verify the results (this may finish under one second, then this test is not valid)
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 600 and e1 < 750");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 600 and e1 < 750");
+ test.assertRowCount(0);
+ test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 750");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ };
+ getTransactionContainter().runTransaction(userTxn);
+
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceTimeout");
+
+ }
+
+
+ static String[] getMultipleSourceBatch() {
+ ArrayList<String> list = new ArrayList<String>();
+
+ for (int i = 600; i < 750; 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 pm2.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm2.g2 (e1, e2) values ("+i+",'"+i+"')");
+ }
+
+ list.add("update pm1.g1 set e2='blah' where pm1.g1.e1 >= 600");
+ list.add("update pm2.g1 set e2='blah' where pm2.g1.e1 >= 600");
+
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 610");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 610");
+ list.add("delete from pm2.g2 where pm2.g2.e1 >= 610");
+ list.add("delete from pm2.g1 where pm2.g1.e1 >= 610");
+
+ return(String[])list.toArray(new String[list.size()]);
+ }
+
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Partial Processing, Single Connector Batch
+ * result = commit
+ * Note: This is producing the below error some times; however this is SQL Server issue.
+ * http://support.microsoft.com/?kbid=834849
+ */
+ public void testMultipleSourcePartialProcessingUsingLimit() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePartialProcessingUsingLimit") {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1 where pm1e1 < 100 limit 10");
+ assertRowCount(10);
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+
+ public void validateTestCase() throws Exception {
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourcePartialProcessingUsingLimit");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Partial Processing, Single Connector Batch
+ * result = commit
+ * Note: This is producing the below error some times; however this is SQL Server issue.
+ * http://support.microsoft.com/?kbid=834849
+ */
+ public void testMultipleSourcePartialProcessingUsingMakedep() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePartialProcessingUsingMakedep") {
+ public void testCase() throws Exception {
+ execute("select pm1.g1.e1, pm1.g1.e2 from pm1.g1 LEFT OUTER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e2 = pm2.g1.e2 where pm2.g1.e1 >= 50 and pm2.g1.e1 < 100");
+ assertRowCount(50);
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+
+ public void validateTestCase() throws Exception {
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourcePartialProcessingUsingMakedep");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceMultipleCommandsExplicitRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsExplicitRollback") {
+ public void testCase() throws Exception {
+
+ for (int i = 700; i < 720; 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()});
+
+ execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+ }
+
+ // force the rollback
+ public boolean rollbackAllways() {
+ return true;
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ test = new QueryExecution(getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ }
+
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete testMultipleSourceMultipleCommandsExplicitRollback");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsReferentialIntegrityRollback") {
+ public void testCase() throws Exception {
+
+ for (int i = 700; i < 720; 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()});
+
+ execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ test = new QueryExecution(getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+
+ System.out.println("Complete testMultipleSourceMultipleCommandsReferentialIntegrityRollback");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsertRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsertRollback") {
+ public void testCase() throws Exception {
+ for (int i = 100; i < 120; i++) {
+ Integer val = new Integer(i);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ }
+ execute("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.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ test = new QueryExecution(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();
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+
+ System.out.println("Complete testMultipleSourceBulkRowInsertRollback");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceMultipleVirtualCommandsRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommandsRollback") {
+ public void testCase() throws Exception {
+
+ for (int i = 600; i < 615; i++) {
+ Integer val = new Integer(i);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ execute("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ }
+
+ execute("select * from vm.g1 where pm1e1 >= 600 and pm1e1 < 615");
+ assertRowCount(15);
+
+
+ execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 605");
+
+ execute("delete from vm.g2 where vm.g2.pm1e1 >= 610");
+ execute("delete from vm.g1 where vm.g1.pm1e1 >= 610");
+
+ execute("select * from vm.g1 where pm1e1 >= 600 and pm1e1 < 615");
+ assertRowCount(10);
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+
+
+ public void validateTestCase() throws Exception {
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 600 and e1 < 615");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 600 and e1 < 615");
+ test.assertRowCount(0);
+ test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 615");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+
+ System.out.println("Complete testMultipleSourceMultipleVirtualCommandsRollback");
+
+ }
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 4 months
teiid SVN: r1326 - in trunk/test-integration/db/src: test and 5 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:19:09 -0400 (Fri, 11 Sep 2009)
New Revision: 1326
Added:
trunk/test-integration/db/src/test/
trunk/test-integration/db/src/test/java/
trunk/test-integration/db/src/test/java/org/
trunk/test-integration/db/src/test/java/org/teiid/
trunk/test-integration/db/src/test/java/org/teiid/test/
trunk/test-integration/db/src/test/java/org/teiid/test/framework/
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/
trunk/test-integration/db/src/test/java/org/teiid/transaction/
Log:
Teiid 773 - organize integration test
15 years, 4 months
teiid SVN: r1325 - in trunk/test-integration/db/src/main/java/org/teiid/test: framework/connection and 4 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-11 15:18:01 -0400 (Fri, 11 Sep 2009)
New Revision: 1325
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/TransactionRuntimeException.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java
trunk/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java
trunk/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java
trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
trunk/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java
Log:
Teiid 773 - organize integration test
Added: 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 (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,61 @@
+package org.teiid.test.framework;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+
+public class ConfigPropertyLoader {
+ /**
+ * Specify this property to set a specific configuration to use
+ */
+ public static final String CONFIG_FILE="config";
+
+ /**
+ * The default config file to use when #CONFIG_FILE system property isn't set
+ */
+ private static final String DEFAULT_CONFIG_FILE_NAME="default-config.properties";
+
+ public static Properties loadConfigurationProperties() {
+ return loadConfiguration();
+ }
+
+ private static Properties loadConfiguration() {
+ String filename = System.getProperty(CONFIG_FILE);
+ if (filename == null) {
+ filename = DEFAULT_CONFIG_FILE_NAME;
+ }
+
+ return loadProperties(filename);
+
+ }
+
+ private static Properties loadProperties(String filename) {
+ Properties props = null;
+ try {
+ InputStream in = ConnectionStrategyFactory.class.getResourceAsStream("/"+ filename);
+ if (in != null) {
+ props = new Properties();
+ props.load(in);
+ return props;
+ }
+ else {
+ throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
+ }
+ }
+
+ public static void main(String[] args) {
+ Properties props = ConfigPropertyLoader.loadConfigurationProperties();
+ if (props == null || props.isEmpty()) {
+ throw new RuntimeException("Failed to load config properties file");
+
+ }
+ System.out.println("Loaded Config Properties " + props.toString());
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,11 @@
+package org.teiid.test.framework;
+
+public interface DataSourceSetup {
+
+
+ void setup() throws Exception;
+
+
+ int getDataSourceCnt();
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+import org.teiid.test.framework.datasource.DatasourceMgr;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.connection.ConnectionStrategy;
+
+
+
+
+public abstract class TransactionContainer {
+
+ private boolean debug = false;
+
+ protected Properties props;
+ protected ConnectionStrategy connStrategy;
+
+ protected TransactionContainer(ConnectionStrategy strategy){
+ this.connStrategy = strategy;
+ this.props = new Properties();
+ this.props.putAll(this.connStrategy.getEnvironment());
+
+ }
+
+
+ /**
+ * Returns <code>true</code> if the test <b>CANNOT</b> be run due to not have the right
+ * number of datasources available.
+ *
+ */
+ protected boolean turnOffTest (int numberofDataSources) {
+ boolean rtn = (numberofDataSources > DatasourceMgr.getInstance().numberOfAvailDataSources());
+ if (rtn) {
+ System.out.println("Required Number of DataSources is " + numberofDataSources + " but availables sources is " + DatasourceMgr.getInstance().numberOfAvailDataSources());
+ }
+ return rtn;
+ }
+
+ protected void before(TransactionQueryTest test){}
+
+ protected void after(TransactionQueryTest test) {}
+
+ public void runTransaction(TransactionQueryTest test) {
+
+ if (turnOffTest(test.getNumberRequiredDataSources())) {
+ detail("Transaction test: " + test.getTestName() + " will not be run");
+ return;
+
+ }
+
+ detail("Start transaction test: " + test.getTestName());
+
+ try {
+ test.setupDataSource();
+
+ debug(" setConnection");
+ test.setConnection(getConnection());
+ test.setExecutionProperties(this.props);
+ debug(" before(test)");
+
+ before(test);
+ debug(" test.before");
+
+ test.before();
+
+ debug(" test.testcase");
+
+ // run the test
+ test.testCase();
+
+ }catch(Throwable e) {
+ if (!test.exceptionExpected()) {
+ e.printStackTrace();
+ }
+ throw new TransactionRuntimeException(e.getMessage());
+ }finally {
+ debug(" test.after");
+
+ test.after();
+ debug(" after(test)");
+
+ after(test);
+ debug(" test.cleanup");
+
+ test.cleanup();
+
+ detail("End transaction test: " + test.getTestName());
+
+ }
+
+ try {
+ detail("Start validation: " + test.getTestName());
+
+ test.validateTestCase();
+
+ detail("End validation: " + test.getTestName());
+
+ }catch(Exception e) {
+ throw new TransactionRuntimeException(e);
+ }
+ }
+
+
+ protected Connection getConnection() throws QueryTestFailedException {
+ return this.connStrategy.getConnection();
+ }
+
+ protected XAConnection getXAConnection() throws QueryTestFailedException {
+ return this.connStrategy.getXAConnection();
+ }
+
+
+ public Properties getEnvironmentProperties() {
+ return props;
+ }
+
+ protected void debug(String message) {
+ if (debug) {
+ System.out.println(message);
+ }
+
+ }
+
+ protected void detail(String message) {
+ System.out.println(message);
+ }
+
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,131 @@
+package org.teiid.test.framework;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+/**
+ * The TransactionQueryTest interface represents the transaction test framework from which
+ * the @link TransactionContainer operates.
+ * @author vanhalbert
+ *
+ */
+
+public interface TransactionQueryTest {
+
+ /**
+ * Returns the name of the test so that better tracing of what tests are running/completing.
+ * @return String is test name
+ */
+ String getTestName();
+
+ /**
+ * Called by the @link TransactionContainer to set the Teiid connection to be used in the test.
+ * @param conn
+ *
+ * @since
+ */
+ void setConnection(Connection conn);
+
+
+ /**
+ * Returns the connection being used in the test.
+ * @return
+ *
+ * @since
+ */
+ Connection getConnection();
+
+ XAConnection getXAConnection();
+
+
+ /**
+ * Called to set the properties used to initialize prior
+ * to execution.
+ * @param props
+ *
+ * @since
+ */
+ void setExecutionProperties(Properties props) ;
+
+ /**
+ * The test case has to specify how many sources its using so that the correct
+ * data setup is performed.
+ * @return int is the number of datasources in use
+ *
+ * @since
+ */
+
+ int getNumberRequiredDataSources();
+
+ /**
+ * Called by the {@link TransactionContainer} prior to testcase processing so that
+ * the datasource data can be setup for the specific testcase.
+ *
+ *
+ * @since
+ */
+ void setupDataSource();
+
+
+ /**
+ * Override <code>before</code> if there is behavior that needs to be performed
+ * prior to {@link #testCase()} being called.
+ *
+ *
+ * @since
+ */
+ void before();
+
+ /**
+ * Implement testCase(), it is the entry point to the execution of the test.
+ * @throws Exception
+ *
+ * @since
+ */
+ void testCase() throws Exception;
+
+
+ /**
+ * Override <code>after</code> if there is behavior that needs to be performed
+ * after {@link #testCase()} being called.
+ *
+ *
+ * @since
+ */
+ void after() ;
+
+ /**
+ * Indicates what should be done when a failure occurs in {@link #testCase()}
+ * @return
+ *
+ * @since
+ */
+ boolean rollbackAllways() ;
+
+ boolean exceptionExpected();
+
+ boolean exceptionOccurred();
+
+
+ /**
+ * Called at the end of the test so that the testcase can clean itself up by
+ * releasing any resources, closing any open connections, etc.
+ *
+ *
+ * @since
+ */
+ void cleanup();
+
+ /**
+ * validateTestCase is called after the testcase has been completed. This enables
+ * the validation to be performed as part of the overall testcase.
+ * @throws Exception
+ *
+ * @since
+ */
+ void validateTestCase() throws Exception;
+
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.connection;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+import org.teiid.test.framework.datasource.DataSource;
+import org.teiid.test.framework.datasource.DatasourceMgr;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.VDB;
+import org.teiid.connector.jdbc.JDBCPropertyNames;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+
+
+public abstract class ConnectionStrategy {
+ /**
+ * Connection Type indicates the type of connection (strategy) to use
+ */
+ public static final String CONNECTION_TYPE = "connection-type"; //$NON-NLS-1$
+
+ /**
+ * The connection types that map to connection strategies
+ * ****************************************************************
+ */
+ // used to create the jdb driver
+ public static final String DRIVER_CONNECTION = "driver"; //$NON-NLS-1$
+ // used to create a datasource
+ public static final String DATASOURCE_CONNECTION = "datasource"; //$NON-NLS-1$
+ // used for when embedded is running in an appserver
+ public static final String JNDI_CONNECTION = "jndi"; //$NON-NLS-1$
+ /*
+ * ******************************************************************
+ */
+
+ public static final String DS_USER = "user"; //$NON-NLS-1$
+
+ // need both user variables because Teiid uses 'user' and connectors use 'username'
+ public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+ public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
+
+ // the driver is only used for making direct connections to the source, the
+ // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE driver class
+ public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
+
+ public static final String DS_URL = JDBCPropertyNames.URL; //$NON-NLS-1$
+ public static final String DS_SERVERNAME = "servername"; //$NON-NLS-1$
+ public static final String DS_SERVERPORT = "portnumber"; //$NON-NLS-1$
+ public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
+ public static final String DS_DATABASENAME = "databasename"; //$NON-NLS-1$
+ public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+
+ public static final String PROCESS_BATCH = "process-batch"; //$NON-NLS-1$
+ public static final String CONNECTOR_BATCH = "connector-batch"; //$NON-NLS-1$
+ public static final String JNDINAME_USERTXN = "usertxn-jndiname"; //$NON-NLS-1$
+
+
+ public static final String AUTOCOMMIT = "autocommit"; //$NON-NLS-1$
+
+ public static final String EXEC_IN_BATCH = "execute.in.batch"; //$NON-NLS-1$
+
+
+ public ConnectionStrategy(Properties props) throws QueryTestFailedException {
+ this.env = props;
+
+
+ }
+
+ /*
+ * Lifecycle methods for managing the connection
+ */
+
+ /**
+ * Returns a connection
+ * @return Connection
+ */
+ public abstract Connection getConnection() throws QueryTestFailedException;
+
+ public Connection getAdminConnection() throws QueryTestFailedException{
+ return null;
+ }
+
+ private boolean autoCommit;
+ public boolean getAutocommit() {
+ return autoCommit;
+ }
+
+ public abstract void shutdown();
+
+ public XAConnection getXAConnection() throws QueryTestFailedException {
+ return null;
+ }
+
+
+ private Properties env = null;
+
+
+ public Properties getEnvironment() {
+ return env;
+ }
+
+ class CloseInterceptor implements InvocationHandler {
+
+ Connection conn;
+
+ CloseInterceptor(Connection conn) {
+ this.conn = conn;
+ }
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (method.getName().equals("close")) { //$NON-NLS-1$
+ return null;
+ }
+ try {
+ return method.invoke(this.conn, args);
+ } catch (InvocationTargetException e) {
+ throw e.getTargetException();
+ }
+ }
+ }
+
+
+ void configure() throws QueryTestFailedException {
+
+ String ac = this.env.getProperty(AUTOCOMMIT, "true");
+ this.autoCommit = Boolean.getBoolean(ac);
+
+ com.metamatrix.jdbc.api.Connection 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
+ java.sql.Connection conn = getConnection();
+ if ( conn instanceof com.metamatrix.jdbc.api.Connection) {
+ c = (com.metamatrix.jdbc.api.Connection) conn;
+ } else {
+ return;
+ }
+
+ Admin admin = (Admin)c.getAdminAPI();
+
+ boolean update = false;
+ Properties p = new Properties();
+ if (this.env.getProperty(PROCESS_BATCH) != null) {
+ p.setProperty("metamatrix.buffer.processorBatchSize", this.env.getProperty(PROCESS_BATCH)); //$NON-NLS-1$
+ update = true;
+ }
+
+ if (this.env.getProperty(CONNECTOR_BATCH) != null) {
+ p.setProperty("metamatrix.buffer.connectorBatchSize", this.env.getProperty(CONNECTOR_BATCH)); //$NON-NLS-1$
+ update = true;
+ }
+
+ // update the system.
+// if (update) {
+// admin.s
+// admin.updateSystemProperties(p);
+// }
+ setupVDBConnectorBindings(admin);
+
+ admin.restart();
+
+ System.out.println("Bouncing the system..(wait 15 seconds)"); //$NON-NLS-1$
+ Thread.sleep(1000*15);
+ // Thread.sleep(1000*60);
+ System.out.println("done."); //$NON-NLS-1$
+
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ throw new TransactionRuntimeException(e);
+ } finally {
+ // need to close and flush the connection after restarting
+ this.shutdown();
+
+ }
+ }
+
+ protected void setupVDBConnectorBindings(Admin api) throws QueryTestFailedException {
+
+ try {
+
+ Collection<VDB> vdbs = api.getVDBs("*");
+ if (vdbs == null) {
+ throw new QueryTestFailedException("GetVDBS returned no vdbs available");
+
+ } else if (vdbs.size() != 1) {
+ throw new QueryTestFailedException("GetVDBS returned more than 1 vdb available");
+ }
+ VDB vdb = (VDB) vdbs.iterator().next();
+ Iterator<Model> modelIt = vdb.getModels().iterator();
+ while (modelIt.hasNext() ) {
+ Model m = modelIt.next();
+
+ if (!m.isPhysical()) continue;
+
+ // get the mapping, if defined
+ String mappedName = this.env.getProperty(m.getName());
+
+ String useName = m.getName();
+ if(mappedName != null) {
+ useName = mappedName;
+ }
+
+ org.teiid.test.framework.datasource.DataSource ds = DatasourceMgr.getInstance().getDatasource(useName);
+// Properties sourceProps = DatasourceMgr.getInstance().getDatasourceProperties(useName);
+
+ if (ds != null) {
+
+ AdminOptions ao = new AdminOptions(AdminOptions.OnConflict.OVERWRITE);
+ ao.addOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR);
+
+ api.addConnectorBinding(ds.getName(), ds.getType(), ds.getProperties(), ao);
+
+ api.assignBindingToModel(ds.getName(), vdb.getName(), vdb.getVDBVersion(), m.getName());
+
+ } else {
+ throw new QueryTestFailedException("Error: Unable to create binding to map to model : " + m.getName() + ", the mapped name " + useName + " had no datasource properties defined");
+ }
+
+ }
+
+// Collection<ConnectorBinding> bindings = api.getConnectorBindingsInVDB("*");
+//
+// for (Iterator<ConnectorBinding> it=bindings.iterator(); it.hasNext();) {
+// ConnectorBinding cb = it.next();
+//
+// cb.
+//
+// String mappedName = this.env.getProperty(cb.getName());
+//
+// String useName = cb.getName();
+// if(mappedName != null) {
+// useName = mappedName;
+// }
+//
+// Properties sourceProps = DatasourceMgr.getInstance().getDatasourceProperties(useName);
+//
+// if (sourceProps != null) {
+// Properties newprops = new Properties(cb.getProperties());
+// newprops.putAll(sourceProps);
+// api.updateProperties(cb.getName(), "org.teiid.adminapi.ConnectorBinding", newprops);
+//
+// } else {
+// System.err.println("WARNING: ConnectorBinding : " + cb.getName() + " was not updated, the mapped name " + useName + " had no datasource properties defined");
+// }
+//
+//
+//
+// }
+ } catch (QueryTestFailedException qt) {
+ throw qt;
+ } catch (Exception t) {
+ throw new QueryTestFailedException(t);
+ }
+
+
+ }
+
+
+ /**
+ * The datasource_identifier must match one of the mappings in the file
+ * at {@see} src/main/resources/datasources/datasource_mapping.txt
+ * @param datasource_identifier
+ * @return
+ *
+ * @since
+ */
+// public XAConnection getXASource(String datasource_identifier) {
+// return null;
+// }
+//
+// public Connection getSource(String datasource_identifier) {
+// return null;
+// }
+
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.connection;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+public class ConnectionStrategyFactory {
+
+ /**
+ * Specify this property to set a specific configuration to use
+ */
+ public static final String CONFIG_FILE="config";
+
+ /**
+ * The default config file to use when #CONFIG_FILE system property isn't set
+ */
+ private static final String DEFAULT_CONFIG_FILE_NAME="default-config.properties";
+
+ private static ConnectionStrategyFactory _instance = null;
+ private ConnectionStrategy strategy = null;
+ private Properties config = null;
+ private static Map<String, ConnectionStrategy> sources = null;
+
+
+
+ private ConnectionStrategyFactory(){
+ }
+
+ public static synchronized ConnectionStrategyFactory getInstance() {
+ if (_instance == null) {
+ _instance = new ConnectionStrategyFactory();
+ Properties p = _instance.loadConfiguration();
+ try {
+ _instance.initialize(p);
+ } catch (QueryTestFailedException e) {
+ // TODO Auto-generated catch block
+ throw new TransactionRuntimeException(e);
+ }
+ }
+ return _instance;
+ }
+
+ private static void init() {
+ if (sources == null) {
+ sources = new HashMap<String, ConnectionStrategy>();
+ }
+ }
+
+
+ public static synchronized void destroyInstance() {
+ if (_instance != null) {
+ _instance.shutdown();
+
+ _instance = null;
+
+
+ }
+ }
+
+ private void shutdown() {
+ Properties p = System.getProperties();
+ p.remove(CONFIG_FILE);
+
+
+ for (Iterator it=sources.keySet().iterator(); it.hasNext(); ){
+
+ ConnectionStrategy cs = sources.get(it.next());
+ try {
+ cs.shutdown();
+ } catch (Exception e) {
+
+ }
+
+ }
+ sources.clear();
+ sources = null;
+
+ strategy.shutdown();
+ strategy = null;
+ config = null;
+
+ }
+
+ public Properties getConfiguration() {
+ return this.config;
+ }
+
+ public ConnectionStrategy getConnectionStrategy() {
+ return this.strategy;
+ }
+
+ private Properties loadConfiguration() {
+ init();
+
+ String filename = System.getProperty(CONFIG_FILE);
+ if (filename == null) {
+ filename = DEFAULT_CONFIG_FILE_NAME;
+ }
+
+ return loadProperties(filename);
+
+ }
+
+ private void initialize(Properties props) throws QueryTestFailedException {
+ this.config = props;
+
+ this.strategy = create(props);
+
+ }
+
+ private ConnectionStrategy create(Properties props) throws QueryTestFailedException {
+
+ ConnectionStrategy strategy = null;
+
+ String type = props.getProperty(ConnectionStrategy.CONNECTION_TYPE, ConnectionStrategy.DRIVER_CONNECTION);
+ if (type == null) {
+ throw new RuntimeException("Property " + ConnectionStrategy.CONNECTION_TYPE + " was specified");
+ }
+
+ if (type.equalsIgnoreCase(ConnectionStrategy.DRIVER_CONNECTION)) {
+ strategy = createDriverStrategy(null, props);
+ System.out.println("Created Driver Strategy");
+ }
+ else if (type.equalsIgnoreCase(ConnectionStrategy.DATASOURCE_CONNECTION)) {
+ strategy = createDataSourceStrategy(null, props);
+ System.out.println("Created DataSource Strategy");
+ }
+ else if (type.equalsIgnoreCase(ConnectionStrategy.JNDI_CONNECTION)) {
+ strategy = createJEEStrategy(null, props);
+ System.out.println("Created JEE Strategy");
+ }
+
+ if (strategy == null) {
+ new TransactionRuntimeException("Invalid property value for " + ConnectionStrategy.CONNECTION_TYPE + " is " + type );
+ }
+ // call configure here because this is creating the connection to Teiid
+ // direct connections to the datasource use the static call directly to create strategy and don't need to configure
+ strategy.configure();
+ return strategy;
+ }
+
+ public synchronized static ConnectionStrategy createDriverStrategy(String identifier, Properties props) throws QueryTestFailedException {
+ if (identifier == null) {
+ return new DriverConnection(props);
+ }
+ init();
+
+ ConnectionStrategy strategy = null;
+ if (sources.containsKey(identifier)) {
+ strategy = sources.get(identifier);
+ } else {
+ strategy = new DriverConnection(props);
+ sources.put(identifier, strategy);
+ }
+
+ return strategy;
+
+ }
+
+ public synchronized static ConnectionStrategy createDataSourceStrategy(String identifier, Properties props) throws QueryTestFailedException {
+ if (identifier == null) {
+ return new DataSourceConnection(props);
+ }
+ init();
+
+ ConnectionStrategy strategy = null;
+ if (sources.containsKey(identifier)) {
+ strategy = sources.get(identifier);
+ } else {
+ strategy = new DataSourceConnection(props);
+ sources.put(identifier, strategy);
+ }
+
+ return strategy;
+
+ }
+
+ public synchronized static ConnectionStrategy createJEEStrategy(String identifier, Properties props) throws QueryTestFailedException {
+ if (identifier == null) {
+ return new JEEConnection(props);
+ }
+
+ init();
+ ConnectionStrategy strategy = null;
+ if (sources.containsKey(identifier)) {
+ strategy = sources.get(identifier);
+ } else {
+ strategy = new JEEConnection(props);
+ sources.put(identifier, strategy);
+ }
+
+ return strategy;
+
+ }
+
+ private final Properties loadProperties(String filename) {
+ Properties props = null;
+ try {
+ InputStream in = ConnectionStrategyFactory.class.getResourceAsStream("/"+filename);
+ if (in != null) {
+ props = new Properties();
+ props.load(in);
+ return props;
+ }
+ else {
+ throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
+ }
+ }
+
+ public static void main(String[] args) {
+ ConnectionStrategyFactory cf = ConnectionStrategyFactory.getInstance();
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,81 @@
+package org.teiid.test.framework.connection;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.datasource.DatasourceMgr;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+public class ConnectionUtil {
+ public static final Connection getSource(String identifier)
+ throws QueryTestFailedException {
+ if (identifier != null) {
+ Properties props = ConfigPropertyLoader
+ .loadConfigurationProperties();
+ String mappedName = props.getProperty(identifier);
+
+ if (mappedName == null) {
+ throw new TransactionRuntimeException("Identifier mapping "
+ + identifier
+ + " is not defined in the config properties file");
+ }
+
+ Properties sourceProps;
+ try {
+ sourceProps = DatasourceMgr.getInstance()
+ .getDatasourceProperties(mappedName);
+ } catch (QueryTestFailedException e) {
+ throw new TransactionRuntimeException(e);
+ }
+
+ if (sourceProps == null) {
+ throw new TransactionRuntimeException("Identifier "
+ + identifier + " mapped to " + mappedName
+ + " has no datasource properties");
+ }
+
+ return ConnectionStrategyFactory.createDriverStrategy(identifier,
+ sourceProps).getConnection();
+
+ }
+ throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
+ }
+
+ public static final XAConnection getXASource(String identifier)
+ throws QueryTestFailedException {
+ if (identifier != null) {
+ Properties props = ConfigPropertyLoader
+ .loadConfigurationProperties();
+ String mappedName = props.getProperty(identifier);
+
+ if (mappedName == null) {
+ throw new TransactionRuntimeException("Identifier mapping "
+ + identifier
+ + " is not defined in the config properties file");
+ }
+
+ Properties sourceProps;
+ try {
+ sourceProps = DatasourceMgr.getInstance()
+ .getDatasourceProperties(mappedName);
+ } catch (QueryTestFailedException e) {
+ throw new TransactionRuntimeException(e);
+ }
+
+ if (sourceProps == null) {
+ throw new TransactionRuntimeException("Identifier "
+ + identifier + " mapped to " + mappedName
+ + " has no datasource properties");
+ }
+
+ return ConnectionStrategyFactory.createDataSourceStrategy(
+ identifier, sourceProps).getXAConnection();
+ }
+ throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.connection;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+import javax.sql.XADataSource;
+
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.jdbc.BaseDataSource;
+import com.metamatrix.jdbc.EmbeddedDataSource;
+import com.metamatrix.jdbc.MMDataSource;
+
+/**
+*
+*/
+public class DataSourceConnection extends ConnectionStrategy {
+
+ private String driver = null;
+ private String username = null;
+ private String pwd = null;
+ private String applName = null;
+ private String databaseName = null;
+ private String serverName = null;
+ private String portNumber = null;
+
+
+ private XAConnection xaConnection;
+
+ public DataSourceConnection(Properties props) throws QueryTestFailedException {
+ super(props);
+ }
+
+
+
+ public void validate() {
+ databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
+ if (databaseName == null || databaseName.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_DATABASENAME + " was not specified");
+ }
+
+ serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
+ if (serverName == null || serverName.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_SERVERNAME + " was not specified");
+ }
+
+
+ this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
+
+ this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
+
+ driver = this.getEnvironment().getProperty(DS_DRIVER);
+ if (driver == null || driver.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_DRIVER + " was not specified");
+ }
+
+ this.username = this.getEnvironment().getProperty(DS_USER);
+ this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
+
+ }
+
+//
+// public synchronized XAConnection getXAAdminConnection() throws QueryTestFailedException {
+// if (xaConnection == null) {
+// try {
+// xaConnection = createAdminConnection();
+// } catch (Exception e) {
+// throw new QueryTestFailedException(e);
+// }
+// }
+// return xaConnection;
+// }
+
+
+ public Connection getConnection() throws QueryTestFailedException {
+ try {
+ return getXAConnection().getConnection();
+ } catch (QueryTestFailedException qtf) {
+ throw qtf;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new QueryTestFailedException(e);
+ }
+ }
+
+ public synchronized XAConnection getXAConnection() throws QueryTestFailedException {
+ if (xaConnection == null) {
+ validate();
+ try {
+ xaConnection = createConnection();
+ } catch (Exception e) {
+ throw new QueryTestFailedException(e);
+ }
+ }
+ return xaConnection;
+ }
+
+ private XAConnection createConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
+ BaseDataSource dataSource = (BaseDataSource)Class.forName(this.driver).newInstance();
+
+ dataSource.setDatabaseName(this.databaseName);
+ if (this.applName != null) {
+ dataSource.setApplicationName(this.applName);
+ }
+
+ if (dataSource instanceof EmbeddedDataSource) {
+ ((EmbeddedDataSource)dataSource).setBootstrapFile(this.serverName);
+ } else {
+ ((MMDataSource)dataSource).setServerName(this.serverName);
+ ((MMDataSource)dataSource).setPortNumber(Integer.parseInt(this.portNumber));
+ }
+
+ if (this.username != null) {
+ dataSource.setUser(this.username);
+ dataSource.setPassword(this.pwd);
+ }
+
+
+ return ((XADataSource)dataSource).getXAConnection();
+ }
+
+// private XAConnection createAdminConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
+// BaseDataSource dataSource = (BaseDataSource)Class.forName(this.driver).newInstance();
+//
+// dataSource.setDatabaseName("Admin");
+// if (this.applName != null) {
+// dataSource.setApplicationName(this.applName);
+// }
+//
+// if (dataSource instanceof EmbeddedDataSource) {
+// ((EmbeddedDataSource)dataSource).setBootstrapFile(this.serverName);
+// } else {
+// ((MMDataSource)dataSource).setServerName(this.serverName);
+// ((MMDataSource)dataSource).setPortNumber(Integer.parseInt(this.portNumber));
+// }
+//
+// if (this.username != null) {
+// dataSource.setUser(this.username);
+// dataSource.setPassword(this.pwd);
+// }
+//
+//
+// return ((XADataSource)dataSource).getXAConnection();
+// }
+
+// private static XAConnection getDataSource(String prefix, Properties props) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
+// // depending upon the DataDirect class hirarchy..
+// DataSource dataSource = (DataSource)Class.forName(props.getProperty(DS_DRIVER)).newInstance();
+// PropertiesUtils.setBeanProperties(dataSource, props, prefix);
+//
+// return ((XADataSource)dataSource).getXAConnection();
+// }
+
+
+
+ public void shutdown() {
+ try {
+
+
+ if (this.xaConnection != null) {
+ this.xaConnection.close();
+ }
+ } catch (SQLException e) {
+ // ignore..
+ }
+
+ this.xaConnection = null;
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.connection;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+
+
+/**
+ * The DriverConnection strategy that can get connections in standalone mode
+ * or embedded mode.
+ */
+public class DriverConnection extends ConnectionStrategy{
+
+ private String url = null;
+ private String driver = null;
+ private String username = null;
+ private String pwd = null;
+
+ private Connection connection;
+
+
+ public DriverConnection(Properties props) throws QueryTestFailedException {
+ super(props);
+ }
+
+ public void validate() {
+
+ String urlProp = this.getEnvironment().getProperty(DS_URL);
+ if (urlProp == null || urlProp.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_URL + " was not specified");
+ }
+ StringBuffer urlSB = new StringBuffer(urlProp);
+
+ String appl = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
+ if (appl != null) {
+ urlSB.append(";");
+ urlSB.append("ApplicationName").append("=").append(appl);
+ }
+
+ url = urlSB.toString();
+
+ driver = this.getEnvironment().getProperty(DS_DRIVER);
+ if (driver == null || driver.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_DRIVER + " was not specified");
+ }
+
+ // need both user variables because Teiid uses 'user' and connectors use 'username'
+
+ this.username = this.getEnvironment().getProperty(DS_USER);
+ if (username == null) {
+ this.username = this.getEnvironment().getProperty(DS_USERNAME);
+ }
+ this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
+
+ try {
+ // Load jdbc driver
+ Class.forName(driver);
+ } catch (ClassNotFoundException e) {
+ throw new TransactionRuntimeException(e);
+ }
+
+ }
+
+ public synchronized Connection getConnection() throws QueryTestFailedException {
+ if (this.connection != null) {
+ try {
+ if (!this.connection.isClosed()) {
+ return this.connection;
+ }
+ } catch (SQLException e) {
+
+ }
+
+ }
+
+ validate();
+
+ this.connection = getJDBCConnection(this.driver, this.url, this.username, this.pwd);
+ return this.connection;
+ }
+
+
+ private Connection getJDBCConnection(String driver, String url, String user, String passwd) throws QueryTestFailedException {
+
+ System.out.println("Creating Connection: \"" + url + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Connection conn;
+ try {
+ // Create a connection
+ if (user != null && user.length() > 0) {
+ conn = DriverManager.getConnection(url, user, passwd);
+ } else {
+ conn = DriverManager.getConnection(url);
+ }
+
+
+ } catch (SQLException e) {
+ throw new QueryTestFailedException(e);
+ }
+ return conn;
+
+ }
+
+ public void shutdown() {
+ if (this.connection != null) {
+ try {
+ this.connection.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+
+ this.connection = null;
+
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.connection;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+
+
+/**
+ * JEE (JNDI) Connection Strategy, when the test is run inside an application server. Make
+ * sure all the jndi names are set correctly in the properties file.
+ */
+public class JEEConnection extends ConnectionStrategy{
+
+ private String jndi_name = null;
+
+
+ public JEEConnection(Properties props) throws QueryTestFailedException {
+ super(props);
+ }
+
+ public Connection getConnection() throws QueryTestFailedException {
+ validate();
+ try {
+ InitialContext ctx = new InitialContext();
+ DataSource source = (DataSource)ctx.lookup(jndi_name);
+
+
+ if (source == null) {
+ String msg = "Unable to find jndi source " + jndi_name;//$NON-NLS-1$
+
+ QueryTestFailedException mme = new QueryTestFailedException(msg);//$NON-NLS-1$
+ throw mme;
+ }
+ Connection conn = source.getConnection();
+ return conn;
+ } catch (QueryTestFailedException qtfe) {
+ throw qtfe;
+ } catch (Exception e) {
+ throw new QueryTestFailedException(e);
+ }
+ }
+
+ public void shutdown() {
+ // no connection management here; app server takes care of these..
+ }
+
+ public void validate() {
+ // TODO Auto-generated method stub
+
+ jndi_name = getEnvironment().getProperty(ConnectionStrategy.DS_JNDINAME);
+ if (jndi_name == null || jndi_name.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_JNDINAME + " was not specified");
+ }
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,39 @@
+package org.teiid.test.framework.datasource;
+
+import java.util.Properties;
+
+public class DataSource {
+ public static final String DIRECTORY="dir";
+ public static final String CONNECTOR_TYPE="connectortype";
+
+ private Properties props;
+
+ private String name;
+ private String group;
+
+ public DataSource(String name, String group, Properties properties) {
+ this.name = name;
+ this.group = group;
+ this.props = properties;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public String getType() {
+ return props.getProperty(CONNECTOR_TYPE);
+ }
+
+ public String getProperty(String propName) {
+ return props.getProperty(propName);
+ }
+
+ public Properties getProperties() {
+ return this.props;
+ }
+
+
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.datasource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.common.xml.XMLReaderWriter;
+import com.metamatrix.common.xml.XMLReaderWriterImpl;
+
+/**
+ * The DatasourceMgr is responsible for loading and managing the datasource
+ * mapping properties file {@see #DATASOURCE_MAPPING_FILE} and the mapped
+ * datasource properties files. The {@link #getDatasourceProperties(String)}
+ * returns the properties defined for that datasourceid, which is mapped in the
+ * mnappings file. This mapping allows the test
+ *
+ * @author vanhalbert
+ *
+ */
+public class DatasourceMgr {
+
+ static final String DIRECTORY = "datasources/";
+ static final String DATASOURCE_MAPPING_FILE = "datasource_mapping.xml";
+
+ private static DatasourceMgr _instance = null;
+
+ private Map<String, Map<String, DataSource>>dstypeMap = new HashMap<String, Map<String, DataSource>>();
+
+ private Map<String, DataSource> allDatasourcesMap = new HashMap<String, DataSource>();
+
+ private DatasourceMgr() {
+ }
+
+ public static synchronized DatasourceMgr getInstance() {
+ if (_instance == null) {
+ _instance = new DatasourceMgr();
+ try {
+ _instance.loadDataSourceMappings();
+ } catch (QueryTestFailedException e) {
+ // TODO Auto-generated catch block
+ throw new TransactionRuntimeException(e);
+ } catch (TransactionRuntimeException e) {
+ // TODO Auto-generated catch block
+ throw e;
+ }
+
+ }
+ return _instance;
+ }
+
+ public int numberOfAvailDataSources() {
+ return allDatasourcesMap.size();
+ }
+
+ public org.teiid.test.framework.datasource.DataSource getDatasource(String datasourceid)
+ throws QueryTestFailedException {
+ DataSource ds = null;
+ if (dstypeMap.containsKey(datasourceid)) {
+
+ Map datasources = dstypeMap.get(datasourceid);
+ ds = (DataSource) datasources.values().iterator().next();
+
+ } else {
+ ds = allDatasourcesMap.get(datasourceid);
+ }
+ if (ds == null) {
+ throw new QueryTestFailedException("DatasourceID " + datasourceid
+ + " is not a defined datasource in the mappings file ");
+
+ }
+ return ds;
+
+ }
+
+ public Properties getDatasourceProperties(String datasourceid)
+ throws QueryTestFailedException {
+ DataSource ds = null;
+ if (dstypeMap.containsKey(datasourceid)) {
+
+ Map datasources = dstypeMap.get(datasourceid);
+ ds = (DataSource)datasources.values().iterator().next();
+
+ } else {
+ ds = allDatasourcesMap.get(datasourceid);
+ }
+ if (ds == null) {
+ throw new QueryTestFailedException("DatasourceID " + datasourceid
+ + " is not a defined datasource in the mappings file ");
+
+ }
+ return ds.getProperties();
+
+ }
+
+ private void loadDataSourceMappings()
+ throws QueryTestFailedException {
+
+ Document doc = null;
+ XMLReaderWriter readerWriter = new XMLReaderWriterImpl();
+
+ try {
+ doc = readerWriter.readDocument(getInputStream());
+ } catch (JDOMException e) {
+ e.printStackTrace();
+ throw new TransactionRuntimeException(e);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new TransactionRuntimeException(e);
+ }
+
+ Element root = doc.getRootElement();
+ List<Element> rootElements = root.getChildren();
+ if (rootElements == null || rootElements.size() == 0) {
+ throw new TransactionRuntimeException("No children defined under root element " + DSCONFIG);
+ }
+
+ for (Iterator<Element> it = rootElements.iterator(); it.hasNext();) {
+ Element type = it.next();
+// System.out.println("Loading ds transactional type " + type.getName());
+ String typename = type.getAttributeValue(Property.Attributes.NAME);
+
+ List<Element> typeElements = type.getChildren();
+ if (typeElements != null) {
+ Map<String, DataSource> datasources = new HashMap<String, DataSource>(typeElements.size());
+
+ for (Iterator<Element> typeit = typeElements.iterator(); typeit.hasNext();) {
+ Element e = typeit.next();
+// System.out.println("Loading ds type " + e.getName());
+ addDataSource(e, typename, datasources);
+ }
+ dstypeMap.put(typename, datasources);
+ allDatasourcesMap.putAll(datasources);
+
+ }
+
+
+ }
+
+ if (dstypeMap == null || dstypeMap.isEmpty()) {
+ throw new TransactionRuntimeException(
+ "No Datasources were found in the mappings file");
+ }
+
+ System.out.println("Number of datasource types loaded " + dstypeMap.size());
+ System.out.println("Number of total datasource mappings loaded " + allDatasourcesMap.size());
+
+
+
+ }
+
+ private static void addDataSource(Element element, String type, Map<String, DataSource> datasources) {
+ String name = element.getAttributeValue(Property.Attributes.NAME);
+ Properties props = getProperties(element);
+
+ String dir = props.getProperty(DataSource.DIRECTORY);
+ String dsfile = DIRECTORY + dir + "/connection.properties";
+ Properties dsprops = loadProperties(dsfile);
+ if (dsprops != null) {
+ props.putAll(dsprops);
+ DataSource ds = new DataSource(name,
+ type,
+ props);
+ datasources.put(ds.getName(), ds);
+ System.out.println("Loaded datasource " + ds.getName());
+
+ }
+// else {
+// System.out.println("Did not load datasource " + name);
+// }
+
+ }
+
+
+ private static Properties loadProperties(String filename) {
+ Properties props = null;
+
+ try {
+ InputStream in = DatasourceMgr.class.getResourceAsStream("/"
+ + filename);
+ if (in != null) {
+ props = new Properties();
+ props.load(in);
+ return props;
+ }
+ return null;
+ } catch (IOException e) {
+ throw new TransactionRuntimeException("Error loading properties from file '"
+ + filename + "'" + e.getMessage());
+ }
+ }
+
+ private static Properties getProperties(Element propertiesElement) {
+ Properties props = new Properties();
+
+ List<Element> properties = propertiesElement
+ .getChildren(Property.ELEMENT);
+ Iterator<Element> iterator = properties.iterator();
+ while (iterator.hasNext()) {
+ Element propertyElement = (Element) iterator.next();
+ String propertyName = propertyElement
+ .getAttributeValue(Property.Attributes.NAME);
+ String propertyValue = propertyElement.getText();
+
+ props.setProperty(propertyName, propertyValue);
+
+ }
+ return props;
+ }
+
+ private static InputStream getInputStream() {
+
+ InputStream in = DatasourceMgr.class.getResourceAsStream("/"
+ + DIRECTORY + DATASOURCE_MAPPING_FILE);
+ if (in != null) {
+
+ return in;
+ } else {
+ throw new RuntimeException(
+ "Failed to load datasource mapping file '" + DIRECTORY
+ + DATASOURCE_MAPPING_FILE + "'");
+ }
+
+ }
+
+ static final String DSCONFIG = "datasourceconfig";
+ static final String DATASOURCETYPE = "datasourcetype";
+ static final String DATASOURCE = "datasource";
+
+// static class DS_TYPE {
+//
+// /**
+// * This is the name of the Property Element.
+// */
+// public static final String XA_ELEMENT = "xa"; //$NON-NLS-1$
+// public static final String NONXA_ELEMENT = "nonxa"; //$NON-NLS-1$
+//
+// }
+
+ static class Property {
+
+ /**
+ * This is the name of the Property Element.
+ */
+ public static final String ELEMENT = "property"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that contains
+ * it.
+ */
+ public static class Attributes {
+ public static final String NAME = "name"; //$NON-NLS-1$
+ }
+
+ }
+
+ public static void main(String[] args) {
+ DatasourceMgr mgr = DatasourceMgr.getInstance();
+
+ try {
+ System.out.println("Value for ds_mysql5: "
+ + mgr.getDatasourceProperties("ds_mysql5"));
+ } catch (QueryTestFailedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,358 @@
+/*
+ * Copyright (c) 2000-2005 MetaMatrix, Inc. All rights reserved.
+ */
+package org.teiid.test.framework.exception;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.MetaMatrixExceptionUtil;
+
+/**
+ */
+
+ /**
+ * The QueryTestFailedException is thrown during a test.
+ *
+ * This exception which contains a reference to another exception. This
+ * class can be used to maintain a linked list of exceptions. <p>
+ *
+ * Subclasses of this exception typically only need to implement whatever
+ * constructors they need. <p>
+ */
+public class QueryTestFailedException extends Exception
+ implements Serializable{
+ //############################################################################################################################
+ //# Static Methods #
+ //############################################################################################################################
+
+ /**
+ * @since
+ */
+ private static final long serialVersionUID = -4824998416118801290L;
+
+ /**
+ * Utility method to get the name of a class, without package information.
+ *
+ * @param cls The class to get the name of
+ * @return The name of the class, without package info
+ */
+ public static String getClassShortName( Class<?> cls ) {
+ if ( cls == null ) return ""; //$NON-NLS-1$
+ String className = cls.getName();
+ return className.substring( className.lastIndexOf('.')+1 );
+ }
+
+ //############################################################################################################################
+ //# Variables #
+ //############################################################################################################################
+
+ /** An error code. */
+ private String code;
+
+ /** Exception chained to this one. */
+ private Throwable child;
+
+ private String msg;
+
+ //############################################################################################################################
+ //# Constructors #
+ //############################################################################################################################
+
+ /**
+ * Construct a default instance of this class.
+ */
+ public QueryTestFailedException() {
+ }
+
+ /**
+ * Construct an instance with the specified error message. If the message is actually a key, the actual message will be
+ * retrieved from a resource bundle using the key, the specified parameters will be substituted for placeholders within the
+ * message, and the code will be set to the key.
+ * @param message The error message or a resource bundle key
+ */
+ public QueryTestFailedException(final String message) {
+ setMessage(message, null);
+ }
+
+ /**
+ * Construct an instance with the specified error code and message. If the message is actually a key, the actual message will
+ * be retrieved from a resource bundle using the key, and the specified parameters will be substituted for placeholders within
+ * the message.
+ * @param code The error code
+ * @param message The error message or a resource bundle key
+ */
+ public QueryTestFailedException(final String code, final String message) {
+ setMessage(message, null);
+ // The following setCode call should be executed after setting the message
+ setCode(code);
+ }
+
+ /**
+ * Construct an instance with a linked exception specified. If the exception is a MetaMatrixException or a
+ * {@link MetaMatrixRuntimeException}, then the code will be set to the exception's code.
+ * @param e An exception to chain to this exception
+ */
+ public QueryTestFailedException(final Throwable e) {
+ // This is nasty, but there's no setMessage() routine!
+ this.msg = ( e instanceof java.lang.reflect.InvocationTargetException )
+ ? ((java.lang.reflect.InvocationTargetException)e).getTargetException().getMessage()
+ : (e == null ? null : e.getMessage());
+ setChild( e );
+
+ }
+
+ /**
+ * Construct an instance with the linked exception and error message specified. If the message is actually a key, the error
+ * message will be retrieved from a resource bundle the key, and code will be set to that key. Otherwise, if the specified
+ * exception is a MetaMatrixException or a {@link MetaMatrixRuntimeException}, the code will be set to the exception's code.
+ * @param e The exception to chain to this exception
+ * @param message The error message or a resource bundle key
+ */
+ public QueryTestFailedException(final Throwable e, final String message) {
+ setChild( e );
+ // The following setMessage call should be executed after attempting to set the code from the passed-in exception
+ setMessage(message, null);
+
+ }
+
+
+ /**
+ * Construct an instance with the linked exception, error code, and error message specified. If the message is actually a
+ * key, the error message will be retrieved from a resource bundle using the key.
+ * @param e The exception to chain to this exception
+ * @param code The error code
+ * @param message The error message or a resource bundle key
+ */
+ public QueryTestFailedException(final Throwable e, final String code, final String message) {
+ setChild(e);
+ setMessage(message, null);
+ // The following setCode call should be executed after setting the message
+ setCode(code);
+ }
+
+ //############################################################################################################################
+ //# Methods #
+ //############################################################################################################################
+
+ /**
+ * Get the exception which is linked to this exception.
+ *
+ * @return The linked exception
+ */
+ public Throwable getChild() {
+ return this.child;
+ }
+
+ /**
+ * Get the error code.
+ *
+ * @return The error code
+ */
+ public String getCode() {
+ return this.code;
+ }
+
+ /**
+ * Returns the error message, formatted for output. <P>
+ *
+ * The default formatting provided by this method is to prepend the
+ * error message with the level and the name of the class, and to
+ * append the error code on the end if a non-zero code is defined. <P>
+ *
+ * This method provides a hook for subclasses to override the default
+ * formatting of any one exception.
+ *
+ * @param except The exception to print
+ * @param level The depth of the exception in the chain of exceptions
+ * @return A formatted string for the exception
+ */
+ public String getFormattedMessage(final Throwable throwable, final int level) {
+
+ return ((level != 0) ? ("\n" + level + " ") : "" ) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + "[" + getClassShortName(throwable.getClass()) + "]" //$NON-NLS-1$ //$NON-NLS-2$
+ + ((code != null) ? (' ' + code + ": ") : "") //$NON-NLS-1$//$NON-NLS-2$
+ + (throwable.getMessage() == null ? "" : throwable.getMessage()); //$NON-NLS-1$
+ }
+
+ /**
+ * Get the full error message, including any message(s) from child
+ * exceptions. Messages of any exceptions chained to this exception are
+ * prepended with their "level" in the chain.
+ *
+ * @return The full error message
+ *
+ * @see #getFormattedMessage
+ */
+ public String getFullMessage() {
+ return MetaMatrixExceptionUtil.getLinkedMessages(this, 0 );
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#getMessage()
+ */
+ public String getMessage() {
+ return this.msg;
+ }
+
+ /**
+ * Set the exception which is linked to this exception. <P>
+ *
+ * For the special case of an InvocationTargetException, which is
+ * a wrapped exception provided in the <CODE>java.lang.reflect</CODE>
+ * package, the child is set to the wrapped exception, and the message,
+ * if not yet defined, is set to the message of the wrapped exception.
+ *
+ * @param child The linked exception
+ */
+ public void setChild( Throwable child ) {
+ // Special processing in case this is already a wrapped exception
+ if ( child instanceof java.lang.reflect.InvocationTargetException ) {
+ this.child = ((java.lang.reflect.InvocationTargetException)child).getTargetException();
+ } else {
+ this.child = child;
+ }
+ }
+
+ /**
+ * Set the error code.
+ *
+ * @param code The error code
+ */
+ public void setCode( String code ) {
+ this.code = code;
+ }
+
+ /**
+ * Sets the exception message to the specified text. If the message is actually a resource bundle key, the actual message
+ * will be retrieved using that key, the specified parameters will be substituted for placeholders within the message, and the
+ * code will be set to the key.
+ * @param message The message text or a resource bundle message key.
+ * @param parameters The list of parameters to substitute for placeholders in the retrieved message.
+ * @since 3.1
+ */
+ private void setMessage(final String message, final List parameters) {
+ if (message == null) {
+ this.msg = message;
+ } else {
+ final String msg = message;
+// final String msg = TextManager.INSTANCE.getText(message, parameters);
+ final int len = msg.length();
+ if (msg.startsWith("<") && len >= 2) { //$NON-NLS-1$
+ this.msg = msg.substring(1, len - 1);
+ } else {
+ this.msg = msg;
+ setCode(message);
+ }
+ }
+ }
+
+ /**
+ * Returns a string representation of this class.
+ *
+ * @return String representation of instance
+ */
+ public String toString() {
+ return getFullMessage();
+ }
+
+ // =========================================================================
+ // T E S T M E T H O D S
+ // =========================================================================
+
+ /**
+ * Test program for this class.
+ *
+ * @args The command line arguments
+ */
+
+ /*
+ public static void main( String[] args ) {
+ class TestAppException extends MetaMatrixException {
+ public TestAppException( Throwable e ) {
+ super( e );
+ }
+ public TestAppException( Throwable e, String message ) {
+ super( e, message );
+ }
+ } // END INNER CLASS
+
+ System.out.println( "\n2 MetaMatrixExceptions and 1 Exception..." );
+ try {
+ throw new MetaMatrixException(
+ new MetaMatrixException(
+ new Exception( "Non-chained exception" ),
+ "Nested Error" ),
+ "My App Error" );
+ } catch ( MetaMatrixException e ) {
+ System.out.println( "Message is \n" + e.getMessage() );
+ System.out.println( "Full message is \n" + e.getFullMessage() );
+ }
+
+ System.out.println( "\n2 MetaMatrixExceptions..." );
+ try {
+ throw new MetaMatrixException(
+ new MetaMatrixException( 1001, "Nested Error" ),
+ "My App Error" );
+ } catch ( MetaMatrixException e ) {
+ System.out.println( "Message is \n" + e.getMessage() );
+ System.out.println( "Full message is \n" + e.getFullMessage() );
+ }
+
+ System.out.println( "\n2 MetaMatrixExceptions (1 a subclass)..." );
+ try {
+ throw new TestAppException(
+ new MetaMatrixException( 1001, "Nested Error" ),
+ "My App Error" );
+ } catch ( MetaMatrixException e ) {
+ System.out.println( "Message is \n" + e.getMessage() );
+ System.out.println( "Full message is \n" + e.getFullMessage() );
+ }
+
+ System.out.println( "\n2 exceptions (1 MetaMatrixException, 1 null)..." );
+ try {
+ throw new TestAppException(
+ new MetaMatrixException( null, "Nested Error" ),
+ "My App Error" );
+ } catch ( MetaMatrixException e ) {
+ System.out.println( "Message is \n" + e.getMessage() );
+ System.out.println( "Full message is \n" + e.getFullMessage() );
+ }
+
+ System.out.println( "\n1 MetaMatrixException..." );
+ try {
+ throw new MetaMatrixException( 1002, "My App Error" );
+ } catch ( MetaMatrixException e ) {
+ System.out.println( "Message is \n" + e.getMessage() );
+ System.out.println( "Full message is \n" + e.getFullMessage() );
+ }
+
+ System.out.println( "\n5 MetaMatrixExceptions..." );
+ try {
+ MetaMatrixException root = new MetaMatrixException( 50, "Root" );
+ MetaMatrixException cur = root;
+ MetaMatrixException next;
+ for ( int i = 1; i <= 5; i++ ) {
+ next = new MetaMatrixException( 50+i, "Nested exception " + i );
+ cur.setChild( next );
+ cur = next;
+ }
+ throw root;
+ } catch ( MetaMatrixException e ) {
+ System.out.println( "Message is \n" + e.getMessage() );
+ System.out.println( "Full message is \n" + e.getFullMessage() );
+ }
+
+ System.out.println( "\n1 MetaMatrixException (InvocationTargetException)..." );
+ try {
+ throw new TestAppException(
+ new java.lang.reflect.InvocationTargetException(
+ new java.lang.IllegalArgumentException( "You can't do that!" ) ) );
+ } catch ( MetaMatrixException e ) {
+ System.out.println( "Message is \n" + e.getMessage() );
+ System.out.println( "Full message is \n" + e.getFullMessage() );
+ }
+ }
+ */
+ } // END CLASS
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/TransactionRuntimeException.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/TransactionRuntimeException.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/TransactionRuntimeException.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,23 @@
+package org.teiid.test.framework.exception;
+
+/**
+ * The TransactionRuntimeException is thrown outside of running a test.
+ * When this is thrown, the testing process should stop.
+ *
+ *
+ * @author vanhalbert
+ *
+ */
+public class TransactionRuntimeException extends RuntimeException{
+ /**
+ * @since
+ */
+ private static final long serialVersionUID = 1L;
+
+ public TransactionRuntimeException(Exception e){
+ super(e);
+ }
+ public TransactionRuntimeException(String msg){
+ super(msg);
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/TransactionRuntimeException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import javax.naming.InitialContext;
+import javax.transaction.UserTransaction;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.connection.ConnectionStrategy;
+
+
+
+
+public class JNDITransaction extends TransactionContainer {
+ UserTransaction userTxn = null;
+
+ public JNDITransaction(ConnectionStrategy strategy) {
+ super(strategy);
+ }
+
+ protected void before(TransactionQueryTest test) {
+ if (this.props.getProperty(ConnectionStrategy.JNDINAME_USERTXN) == null) {
+ throw new TransactionRuntimeException("No JNDI name found for the User Transaction to look up in application server");
+ }
+
+ try {
+
+ // begin the transaction
+ InitialContext ctx = new InitialContext();
+ this.userTxn = (UserTransaction)ctx.lookup(this.props.getProperty(ConnectionStrategy.JNDINAME_USERTXN));
+ this.userTxn.begin();
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ }
+ }
+
+ protected void after(TransactionQueryTest test) {
+ try {
+ if (this.userTxn != null) {
+ if (test.rollbackAllways()|| test.exceptionOccurred()) {
+ this.userTxn.rollback();
+ }
+ else {
+ this.userTxn.commit();
+ }
+ this.userTxn = null;
+ }
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ }
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import java.sql.SQLException;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.connection.ConnectionStrategy;
+
+
+
+/**
+ * A transaction which is user controlled.
+ */
+public class LocalTransaction extends TransactionContainer {
+
+ public LocalTransaction(ConnectionStrategy strategy) {
+ super(strategy);
+
+// this.props.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, ConnectionStrategy.AUTO_WRAP_OFF);
+ }
+
+ protected void before(TransactionQueryTest test) {
+ try {
+ test.getConnection().setAutoCommit(this.connStrategy.getAutocommit());
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void after(TransactionQueryTest test) {
+ try {
+ if (test.rollbackAllways()|| test.exceptionOccurred()) {
+ test.getConnection().rollback();
+
+ }
+ else {
+ test.getConnection().commit();
+ }
+ } catch (SQLException e) {
+ throw new TransactionRuntimeException(e);
+ } finally {
+ try {
+ test.getConnection().setAutoCommit(true);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,61 @@
+/*
+ * 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.exception.TransactionRuntimeException;
+import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+
+
+
+public class TransactionFactory {
+
+ public static final String LOCAL_TRANSACTION = "local"; //$NON-NLS-1$
+ public static final String XATRANSACTION = "xa"; //$NON-NLS-1$
+ public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
+// public static final String OFFWRAP_TRANSACTION = "offwrap"; //$NON-NLS-1$
+// public static final String ONWRAP_TRANSACTION = "onwrap"; //$NON-NLS-1$
+
+
+
+ /**
+ * Transaction Type indicates the type of transaction container to use
+ */
+ public static final String TRANSACTION_TYPE = "transaction-type"; //$NON-NLS-1$
+// public static final String AUTOCOMMIT = "autocommit"; //$NON-NLS-1$
+
+
+ private TransactionFactory(){}
+
+
+ public static TransactionContainer create() {
+ TransactionContainer transacton = null;
+
+ ConnectionStrategy connstrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
+
+
+ String type = connstrategy.getEnvironment().getProperty(TRANSACTION_TYPE, LOCAL_TRANSACTION);
+ if (type == null) {
+ throw new RuntimeException("Property " + TRANSACTION_TYPE + " was specified");
+ }
+
+ if (type.equalsIgnoreCase(LOCAL_TRANSACTION)) {
+ transacton = new LocalTransaction(connstrategy);
+ }
+ else if (type.equalsIgnoreCase(XATRANSACTION)) {
+ transacton = new XATransaction(connstrategy);
+ }
+ else if (type.equalsIgnoreCase(JNDI_TRANSACTION)) {
+ transacton = new JNDITransaction(connstrategy);
+
+ } else {
+ new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE );
+ }
+
+ return transacton;
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import java.util.Random;
+
+import javax.transaction.xa.XAResource;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.connection.ConnectionStrategy;
+
+import com.metamatrix.common.xa.MMXid;
+
+public class XATransaction extends TransactionContainer {
+ private static Random RANDOM = new Random();
+ private MMXid xid;
+
+ public XATransaction(ConnectionStrategy strategy) {
+ super(strategy);
+ }
+
+ protected void before(TransactionQueryTest test) {
+ try {
+ xid = createXid();
+ XAResource xaResource = getXAConnection().getXAResource();
+ xaResource.setTransactionTimeout(120);
+ xaResource.start(xid, XAResource.TMNOFLAGS);
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ }
+ }
+
+ public static MMXid createXid() {
+ byte[] gid = new byte[10];
+ byte[] bid = new byte[10];
+ RANDOM.nextBytes(gid);
+ RANDOM.nextBytes(bid);
+ return new MMXid(0, gid, bid);
+ }
+
+ protected void after(TransactionQueryTest test) {
+ boolean delistSuccessful = false;
+ boolean commit = false;
+ try {
+ XAResource xaResource = getXAConnection().getXAResource();
+
+ xaResource.end(xid, XAResource.TMSUCCESS);
+
+ if (!test.exceptionExpected() && xaResource.prepare(xid) == XAResource.XA_OK) {
+ commit = true;
+ }
+ delistSuccessful = true;
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ } finally {
+ try {
+ if (!delistSuccessful || test.rollbackAllways()|| test.exceptionOccurred()) {
+ getXAConnection().getXAResource().rollback(xid);
+ }
+ else if (commit) {
+ getXAConnection().getXAResource().commit(xid, true);
+ }
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ }
+ }
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,534 @@
+/*
+ * 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 org.teiid.test.util;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * This class contains a set of static utility methods for checking method arguments.
+ * It contains many of the common checks that are done, such as checking that an
+ * Object is non-null, checking the range of a value, etc. All of these methods
+ * throw {@link #java.lang.IllegalArgumentException}.
+ */
+public class ArgCheck {
+
+ /**
+ * Can't construct - utility class
+ */
+ private ArgCheck() {
+ }
+
+ /**
+ * Check that the boolean condition is true; throw an
+ * IllegalArgumentException if not.
+ * @param condition The boolean condition to check
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException if condition is false
+ */
+ public static final void isTrue(boolean condition, String message){
+ if(!condition) {
+ throw new IllegalArgumentException(message);
+ }
+ }
+
+ // ########################## int METHODS ###################################
+
+ /**
+ * Check that the value is non-negative (>=0).
+ * @param value Value
+ * @throws IllegalArgumentException If value is negative (<0)
+ */
+ public static final void isNonNegative(int value) {
+ isNonNegative(value,null);
+ }
+
+ /**
+ * Check that the value is non-negative (>=0).
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is negative (<0)
+ */
+ public static final void isNonNegative(int value, String message) {
+ if(value < 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isNonNegativeInt"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the value is non-positive (<=0).
+ * @param value Value
+ * @throws IllegalArgumentException If value is positive (>0)
+ */
+ public static final void isNonPositive(int value) {
+ isNonPositive(value,null);
+ }
+
+ /**
+ * Check that the value is non-positive (<=0).
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is positive (>0)
+ */
+ public static final void isNonPositive(int value, String message) {
+ if(value > 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isNonPositiveInt"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the value is negative (<0).
+ * @param value Value
+ * @throws IllegalArgumentException If value is non-negative (>=0)
+ */
+ public static final void isNegative(int value) {
+ isNegative(value,null);
+ }
+
+ /**
+ * Check that the value is negative (<0).
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is non-negative (>=0)
+ */
+ public static final void isNegative(int value, String message) {
+ if(value >= 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isNegativeInt"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the value is positive (>0).
+ * @param value Value
+ * @throws IllegalArgumentException If value is non-positive (<=0)
+ */
+ public static final void isPositive(int value) {
+ isPositive(value,null);
+ }
+
+ /**
+ * Check that the value is positive (>0).
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is non-positive (<=0)
+ */
+ public static final void isPositive(int value, String message) {
+ if(value <= 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isPositiveInt"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ // ########################## long METHODS ###################################
+
+ /**
+ * Check that the value is non-negative (>=0).
+ * @param value Value
+ * @throws IllegalArgumentException If value is negative (<0)
+ */
+ public static final void isNonNegative(long value) {
+ isNonNegative(value,null);
+ }
+
+ /**
+ * Check that the value is non-negative (>=0).
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is negative (<0)
+ */
+ public static final void isNonNegative(long value, String message) {
+ if(value < 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isNonNegativeInt"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the value is non-positive (<=0).
+ * @param value Value
+ * @throws IllegalArgumentException If value is positive (>0)
+ */
+ public static final void isNonPositive(long value) {
+ isNonPositive(value,null);
+ }
+
+ /**
+ * Check that the value is non-positive (<=0).
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is positive (>0)
+ */
+ public static final void isNonPositive(long value, String message) {
+ if(value > 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isNonPositiveInt"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the value is negative (<0).
+ * @param value Value
+ * @throws IllegalArgumentException If value is non-negative (>=0)
+ */
+ public static final void isNegative(long value) {
+ isNegative(value,null);
+ }
+
+ /**
+ * Check that the value is negative (<0).
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is non-negative (>=0)
+ */
+ public static final void isNegative(long value, String message) {
+ if(value >= 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isNegativeInt"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the value is positive (>0).
+ * @param value Value
+ * @throws IllegalArgumentException If value is non-positive (<=0)
+ */
+ public static final void isPositive(long value) {
+ isPositive(value,null);
+ }
+
+ /**
+ * Check that the value is positive (>0).
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is non-positive (<=0)
+ */
+ public static final void isPositive(long value, String message) {
+ if(value <= 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isPositiveInt"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ // ########################## String METHODS ###################################
+
+ /**
+ * Check that the string is non-null and has length > 0
+ * @param value Value
+ * @throws IllegalArgumentException If value is null or length == 0
+ */
+ public static final void isNotZeroLength(String value) {
+ isNotZeroLength(value,null);
+ }
+
+ /**
+ * Check that the string is non-null and has length > 0
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is null or length == 0
+ */
+ public static final void isNotZeroLength(String value, String message) {
+ isNotNull(value);
+ if(value.length() <= 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isStringNonZeroLength"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ // ########################## Object METHODS ###################################
+
+ /**
+ * Check that the object is non-null
+ * @param value Value
+ * @throws IllegalArgumentException If value is null
+ */
+ public static final void isNotNull(Object value) {
+ isNotNull(value,null);
+ }
+
+ /**
+ * Check that the object is non-null
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is null
+ */
+ public static final void isNotNull(Object value, String message) {
+ if(value == null) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isNonNull"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the object is null
+ * @param value Value
+ * @throws IllegalArgumentException If value is non-null
+ */
+ public static final void isNull(Object value) {
+ isNull(value,null);
+ }
+
+ /**
+ * Check that the object is null
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is non-null
+ */
+ public static final void isNull(Object value, String message) {
+ if(value != null) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isNull"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the object is an instance of the specified Class
+ * @param theClass Class
+ * @param value Value
+ * @throws IllegalArgumentException If value is null
+ */
+ public static final void isInstanceOf(Class theClass, Object value) {
+ isInstanceOf(theClass,value,null);
+ }
+
+ /**
+ * Check that the object is an instance of the specified Class
+ * @param theClass Class
+ * @param value Value
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If value is null
+ */
+ public static final void isInstanceOf(Class theClass, Object value, String message) {
+ isNotNull(value);
+ if( ! theClass.isInstance(value) ) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isInstanceOf "; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ // ########################## COLLECTION METHODS ###################################
+
+ /**
+ * Check that the collection is not empty
+ * @param collection Collection
+ * @throws IllegalArgumentException If collection is null or empty
+ */
+ public static final void isNotEmpty(Collection collection) {
+ isNotEmpty(collection,null);
+ }
+
+ /**
+ * Check that the collection is not empty
+ * @param collection Collection
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If collection is null or empty
+ */
+ public static final void isNotEmpty(Collection collection, String message) {
+ isNotNull(collection);
+ if(collection.isEmpty()) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isCollectionNotEmpty"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the map is not empty
+ * @param map Map
+ * @throws IllegalArgumentException If map is null or empty
+ */
+ public static final void isNotEmpty(Map map) {
+ isNotEmpty(map,null);
+ }
+
+ /**
+ * Check that the map is not empty
+ * @param map Map
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If map is null or empty
+ */
+ public static final void isNotEmpty(Map map, String message) {
+ isNotNull(map);
+ if(map.isEmpty()) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isMapNotEmpty"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the array is not empty
+ * @param array Array
+ * @throws IllegalArgumentException If array is null or empty
+ * @since 3.1
+ */
+ public static final void isNotEmpty(Object[] array) {
+ isNotEmpty(array,null);
+ }
+
+ /**
+ * Check that the array is not empty
+ * @param array Array
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If array is null or empty
+ * @since 3.1
+ */
+ public static final void isNotEmpty(Object[] array, String message) {
+ isNotNull(array);
+ if(array.length == 0) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.isArrayNotEmpty"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the string is not empty
+ * @param string String
+ * @throws IllegalArgumentException If string is null or empty
+ * @since 3.1
+ */
+ public static final void isNotEmpty(String string) {
+ isNotZeroLength(string,null);
+ }
+
+ /**
+ * Check that the string is not empty
+ * @param string String
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If string is null or empty
+ * @since 3.1
+ */
+ public static final void isNotEmpty(String string, String message) {
+ isNotZeroLength(string,message);
+ }
+
+ /**
+ * Asserts that the specified first object is not the same as (==) the specified second object.
+ * @param firstObject The first object to assert as not the same as the second object.
+ * @param firstName The name that will be used within the exception message for the first object, should an exception be
+ * thrown; if null and <code>firstObject</code> is not null, <code>firstObject.toString()</code> will be
+ * used.
+ * @param secondObject The second object to assert as not the same as the first object.
+ * @param secondName The name that will be used within the exception message for the second object, should an exception be
+ * thrown; if null and <code>secondObject</code> is not null, <code>secondObject.toString()</code> will
+ * be used.
+ * @throws IllegalArgumentException If the specified objects are the same.
+ * @since 3.1
+ */
+ public static void isNotSame(final Object firstObject, String firstName, final Object secondObject, String secondName) {
+ if (firstObject == secondObject) {
+ if (firstName == null && firstObject != null) {
+ firstName = firstObject.toString();
+ }
+ if (secondName == null && secondObject != null) {
+ secondName = secondObject.toString();
+ }
+ throw new IllegalArgumentException("ArgCheck.isNotSame"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Check that the collection contains the value
+ * @param collection Collection to check
+ * @param value Value to check for, may be null
+ * @throws IllegalArgumentException If collection is null or doesn't contain value
+ */
+ public static final void contains(Collection collection, Object value) {
+ contains(collection, value, null);
+ }
+
+ /**
+ * Check that the collection contains the value
+ * @param collection Collection to check
+ * @param value Value to check for, may be null
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If collection is null or doesn't contain value
+ */
+ public static final void contains(Collection collection, Object value, String message) {
+ isNotNull(collection);
+ if(! collection.contains(value)) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.contains"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Check that the map contains the key
+ * @param map Map to check
+ * @param key Key to check for, may be null
+ * @throws IllegalArgumentException If map is null or doesn't contain key
+ */
+ public static final void containsKey(Map map, Object key) {
+ containsKey(map, key, null);
+ }
+
+ /**
+ * Check that the map contains the key
+ * @param map Map to check
+ * @param key Key to check for, may be null
+ * @param message Exception message if check fails
+ * @throws IllegalArgumentException If map is null or doesn't contain key
+ */
+ public static final void containsKey(Map map, Object key, String message) {
+ isNotNull(map);
+ if(! map.containsKey(key)) {
+ final String msg = message != null ?
+ message :
+ "ArgCheck.containsKey"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,97 @@
+/*
+ * 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 org.teiid.test.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.CRC32;
+import java.util.zip.Checksum;
+
+/**
+ * This utility class provides mechanisms for computing the checksum.
+ */
+public class ChecksumUtil {
+
+ protected static final int BUFFER_SIZE = 1024;
+
+ /**
+ * Compute and return the checksum (using the default CRC-32 algorithm)
+ * of the contents on the specified stream.
+ * This method closes the stream upon completion.
+ * @param stream the stream containing the contents for which
+ * the checksum is to be computed; may not be null
+ * @return the Checksum for the contents
+ * @throws AssertionError if <code>stream</code> is null
+ * @throws IOException if there is an error reading the stream
+ */
+ public static Checksum computeChecksum( InputStream stream ) throws IOException {
+ Checksum checksum = new CRC32();
+ computeChecksum(stream,checksum);
+ return checksum;
+ }
+
+ /**
+ * Compute the checksum of the contents on the specified stream
+ * using the supplied Checksum algorithm, and modify that
+ * Checksum instance with the checksum value.
+ * This method closes the stream upon completion.
+ * @param stream the stream containing the contents for which
+ * the checksum is to be computed; may not be null
+ * @param algorithm the checksum algorithm to be used.
+ * @return the number of bytes from <code>stream</code>
+ * that were processed
+ * @throws AssertionError if <code>stream</code> or
+ * <code>algorithm</code> is null
+ * @throws IOException if there is an error reading the stream
+ */
+ public static long computeChecksum( InputStream stream, Checksum algorithm ) throws IOException {
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int n = 0;
+ long sizeInBytes = 0;
+
+ // Compute the checksum ...
+ IOException ioe = null;
+ try {
+ while ((n = stream.read(buffer)) > -1){
+ algorithm.update(buffer, 0, n);
+ sizeInBytes += n;
+ }
+ } catch ( IOException e ) {
+ ioe = e;
+ } finally {
+ try {
+ stream.close();
+ } catch ( IOException e ) {
+ //Throw this only if there was no IOException from processing above
+ if ( ioe == null ) {
+ ioe = e;
+ }
+ }
+ }
+ if ( ioe != null ) {
+ throw ioe;
+ }
+ return sizeInBytes;
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,871 @@
+/*
+ * 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 org.teiid.test.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public final class FileUtils {
+
+ public interface Constants {
+ char CURRENT_FOLDER_SYMBOL_CHAR = '.';
+ char DRIVE_SEPARATOR_CHAR = ':';
+ char FILE_EXTENSION_SEPARATOR_CHAR = '.';
+ char FILE_NAME_WILDCARD_CHAR = '*';
+
+ String CURRENT_FOLDER_SYMBOL = String.valueOf(CURRENT_FOLDER_SYMBOL_CHAR);
+ String DRIVE_SEPARATOR = String.valueOf(DRIVE_SEPARATOR_CHAR);
+ String FILE_EXTENSION_SEPARATOR = String.valueOf(FILE_EXTENSION_SEPARATOR_CHAR);
+ String FILE_NAME_WILDCARD = String.valueOf(FILE_NAME_WILDCARD_CHAR);
+ String PARENT_FOLDER_SYMBOL = ".."; //$NON-NLS-1$
+ }
+
+ public static final char SEPARATOR = '/';
+
+ public static int DEFAULT_BUFFER_SIZE = 2048;
+ public static String TEMP_DIRECTORY;
+ public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
+ public static char[] LINE_SEPARATOR_CHARS = LINE_SEPARATOR.toCharArray();
+
+ public final static String JAVA_IO_TEMP_DIR="java.io.tmpdir";//$NON-NLS-1$
+ public final static char[] SUFFIX_class = ".class".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_CLASS = ".CLASS".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_java = ".java".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_JAVA = ".JAVA".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_jar = ".jar".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_JAR = ".JAR".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_zip = ".zip".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_ZIP = ".ZIP".toCharArray(); //$NON-NLS-1$
+
+
+ private static final String TEMP_FILE = "delete.me"; //$NON-NLS-1$
+ private static final String TEMP_FILE_RENAMED = "delete.me.old"; //$NON-NLS-1$
+
+
+
+ static {
+ String tempDirPath = System.getProperty(JAVA_IO_TEMP_DIR);
+ TEMP_DIRECTORY = (tempDirPath.endsWith(File.separator) ? tempDirPath : tempDirPath + File.separator);
+ }
+
+ private FileUtils() {}
+
+ /**<p>
+ * Convert the specified file name to end with the specified extension if it doesn't already end with an extension.
+ * </p>
+ * @param name
+ * The file name.
+ * @param extension
+ * The extension to append to the file name.
+ * @return The file name with an extension.
+ * @since 4.0
+ */
+ public static String toFileNameWithExtension(final String name,
+ final String extension) {
+ return toFileNameWithExtension(name, extension, false);
+ }
+
+ /**<p>
+ * Convert the specified file name to end with the specified extension if it doesn't already end with an extension. If force
+ * is true, the specified extension will be appended to the name if the name doesn't end with that particular extension.
+ * </p>
+ * @param name
+ * The file name.
+ * @param extension
+ * The extension to append to the file name.
+ * @param force
+ * Indicates whether to force the specified extension as the extension of the file name.
+ * @return The file name with an extension.
+ * @since 4.0
+ */
+ public static String toFileNameWithExtension(final String name,
+ final String extension,
+ final boolean force) {
+ if (name == null) {
+ final String msg = "FileUtils.The_name_of_the_file_may_not_be_null"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ if (extension == null) {
+ final String msg = "FileUtils.The_file_extension_may_not_be_null"; //$NON-NLS-1$
+ throw new IllegalArgumentException(msg);
+ }
+ if (name.endsWith(extension)) {
+ return name;
+ }
+ if (!force && name.indexOf(Constants.FILE_EXTENSION_SEPARATOR_CHAR) >= 0) {
+ return name;
+ }
+ final int nameLen = name.length() - 1;
+ final int extLen = extension.length();
+ final boolean nameEndsWithExtChr = (nameLen >= 0 && name.charAt(nameLen) == Constants.FILE_EXTENSION_SEPARATOR_CHAR);
+ final boolean extBeginsWithExtChr = (extLen > 0 && extension.charAt(0) == Constants.FILE_EXTENSION_SEPARATOR_CHAR);
+ if (nameEndsWithExtChr && extBeginsWithExtChr) {
+ return name.substring(0, nameLen) + extension;
+ }
+ if (!nameEndsWithExtChr && !extBeginsWithExtChr) {
+ return name + Constants.FILE_EXTENSION_SEPARATOR + extension;
+ }
+ return name + extension;
+ }
+
+ /**
+ * Determine whether the specified name is valid for a file or folder on the current file system.
+ * @param newName the new name to be checked
+ * @return true if the name is null or contains no invalid characters for a folder or file, or false otherwise
+ */
+ public static boolean isFilenameValid( String newName ) {
+ return true; //TODO: just catch an exception when the file is accessed or created
+ }
+
+ /**
+ * Copy a file. Overwrites the destination file if it exists.
+ * @param fromFileName
+ * @param toFileName
+ * @throws Exception
+ * @since 4.3
+ */
+ public static void copy(String fromFileName, String toFileName) throws IOException {
+ copy(fromFileName, toFileName, true);
+ }
+
+ /**
+ * Copy a file
+ * @param fromFileName
+ * @param toFileName
+ * @param overwrite whether to overwrite the destination file if it exists.
+ * @throws MetaMatrixCoreException
+ * @since 4.3
+ */
+ public static void copy(String fromFileName, String toFileName, boolean overwrite) throws IOException {
+ File toFile = new File(toFileName);
+
+ if (toFile.exists()) {
+ if (overwrite) {
+ toFile.delete();
+ } else {
+ final String msg = "FileUtils.File_already_exists " + toFileName; //$NON-NLS-1$
+ throw new IOException(msg);
+ }
+ }
+
+ File fromFile = new File(fromFileName);
+ if (!fromFile.exists()) {
+ throw new FileNotFoundException("FileUtils.File_does_not_exist " + fromFileName); //$NON-NLS-1$
+ }
+
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(fromFile);
+ write(fis, toFileName);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ }
+
+ /**
+ * Copy recursively the contents of <code>sourceDirectory</code> to
+ * the <code>targetDirectory</code>. Note that <code>sourceDirectory</code>
+ * will <b>NOT</b> be copied. If <code>targetDirectory</code> does not exist, it will be created.
+ * @param sourceDirectory The source directory to copy
+ * @param targetDirectory The target directory to copy to
+ * @throws Exception If the source directory does not exist.
+ * @since 4.3
+ */
+ public static void copyDirectoryContentsRecursively(File sourceDirectory, File targetDirectory) throws Exception {
+ copyRecursively(sourceDirectory, targetDirectory, false);
+ }
+
+ /**
+ * Copy file from orginating directory to the destination directory.
+ *
+ * @param orginDirectory
+ * @param destDirectory
+ * @param fileName
+ * @throws Exception
+ * @since 4.4
+ */
+ public static void copyFile(String orginDirectory,
+ String destDirectory,
+ String fileName) throws Exception {
+
+ copyFile(orginDirectory, fileName, destDirectory, fileName);
+ }
+
+ /**
+ * Copy file from orginating directory to the destination directory.
+ *
+ * @param orginDirectory
+ * @param orginFileName
+ * @param destDirectory
+ * @param destFileName
+ * @throws Exception
+ * @since 4.4
+ */
+ public static void copyFile(String orginDirectory,
+ String orginFileName,
+ String destDirectory,
+ String destFileName) throws Exception {
+
+ FileUtils.copy(orginDirectory + File.separator + orginFileName, destDirectory + File.separator + destFileName);
+ }
+
+ /**
+ * Copy recursively the <code>sourceDirectory</code> and all its contents
+ * to the <code>targetDirectory</code>. If <code>targetDirectory</code>
+ * does not exist, it will be created.
+ * @param sourceDirectory The source directory to copy
+ * @param targetDirectory The target directory to copy to
+ * @throws Exception If the source directory does not exist.
+ * @since 4.3
+ */
+ public static void copyDirectoriesRecursively(File sourceDirectory, File targetDirectory) throws Exception {
+ copyRecursively(sourceDirectory, targetDirectory, true);
+ }
+
+ /**
+ * Copy recursively from the <code>sourceDirectory</code> all its contents
+ * to the <code>targetDirectory</code>. if
+ * <code>includeSourceRoot<code> == <code>true</code>, copy <code>sourceDirectory</code>
+ * itself, else only copy <code>sourceDirectory</code>'s contents.
+ * If <code>targetDirectory</code> does not exist, it will be created.
+ * @param sourceDirectory
+ * @param targetDirectory
+ * @throws FileNotFoundException
+ * @throws Exception
+ * @since 4.3
+ */
+ private static void copyRecursively(File sourceDirectory,
+ File targetDirectory,
+ boolean includeSourceRoot) throws FileNotFoundException,
+ Exception {
+ if (!sourceDirectory.exists()) {
+ throw new FileNotFoundException("FileUtils.File_does_not_exist " + sourceDirectory); //$NON-NLS-1$
+ }
+
+ if (!sourceDirectory.isDirectory()) {
+ throw new FileNotFoundException("FileUtils.Not_a_directory " + sourceDirectory); //$NON-NLS-1$
+ }
+
+ File targetDir = new File(targetDirectory.getAbsolutePath() + File.separatorChar + sourceDirectory.getName());
+ if (includeSourceRoot) {
+ // copy source directory
+ targetDir.mkdir();
+ } else {
+ // copy only source directory contents
+ targetDir = new File(targetDirectory.getAbsolutePath() + File.separatorChar);
+ }
+ File[] sourceFiles = sourceDirectory.listFiles();
+ for (int i = 0; i < sourceFiles.length; i++) {
+ File srcFile = sourceFiles[i];
+ if (srcFile.isDirectory()) {
+ File childTargetDir = new File(targetDir.getAbsolutePath());
+ copyRecursively(srcFile, childTargetDir, true);
+ } else {
+ copy(srcFile.getAbsolutePath(), targetDir.getAbsolutePath() + File.separatorChar + srcFile.getName());
+ }
+ }
+ }
+
+ /**
+ * Write an InputStream to a file.
+ */
+ public static void write(InputStream is, String fileName) throws IOException {
+ File f = new File(fileName);
+ write(is,f);
+ }
+
+ /**
+ * Write an InputStream to a file.
+ */
+ public static void write(InputStream is, File f) throws IOException {
+ write(is, f, DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Write an InputStream to a file.
+ */
+ public static void write(InputStream is, File f, int bufferSize) throws IOException {
+ f.delete();
+ final File parentDir = f.getParentFile();
+ if (parentDir !=null) {
+ parentDir.mkdirs();
+ }
+
+ FileOutputStream fio = null;
+ BufferedOutputStream bos = null;
+ try {
+ fio = new FileOutputStream(f);
+ bos = new BufferedOutputStream(fio);
+ if (bufferSize > 0) {
+ byte[] buff = new byte[bufferSize];
+ int bytesRead;
+
+ // Simple read/write loop.
+ while(-1 != (bytesRead = is.read(buff, 0, buff.length))) {
+ bos.write(buff, 0, bytesRead);
+ }
+ }
+ bos.flush();
+ } finally {
+ if (bos != null) {
+ bos.close();
+ }
+ if (fio != null) {
+ fio.close();
+ }
+ }
+ }
+
+
+ /**
+ * Write an File to an OutputStream
+ * Note: this will not close the outputStream;
+ */
+ public static void write(File f, OutputStream outputStream) throws IOException {
+ write(f, outputStream, DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Write an File to an OutputStream
+ * Note: this will not close the outputStream;
+ */
+ public static void write(File f, OutputStream outputStream, int bufferSize) throws IOException {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(f);
+ write(fis, outputStream, bufferSize);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ }
+
+ /**
+ * Write the given input stream to outputstream
+ * Note: this will not close in/out streams
+ */
+ public static void write(InputStream fis, OutputStream outputStream, int bufferSize) throws IOException {
+ byte[] buff = new byte[bufferSize];
+ int bytesRead;
+
+ // Simple read/write loop.
+ while(-1 != (bytesRead = fis.read(buff, 0, buff.length))) {
+ outputStream.write(buff, 0, bytesRead);
+ }
+ outputStream.flush();
+ }
+
+ /**
+ * Write a byte array to a file.
+ */
+ public static void write(byte[] data, String fileName) throws IOException {
+ ByteArrayInputStream bais = null;
+ InputStream is = null;
+ try {
+ bais = new ByteArrayInputStream(data);
+ is = new BufferedInputStream(bais);
+
+ write(is, fileName);
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ if (bais != null) {
+ bais.close();
+ }
+ }
+ }
+
+ /**
+ * Write a byte array to a file.
+ */
+ public static void write(byte[] data, File file) throws IOException {
+ ByteArrayInputStream bais = null;
+ InputStream is = null;
+ try {
+ bais = new ByteArrayInputStream(data);
+ is = new BufferedInputStream(bais);
+
+ write(is, file);
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ if (bais != null) {
+ bais.close();
+ }
+ }
+ }
+
+ /**
+ * Returns a <code>File</code> array that will contain all the files that
+ * exist in the specified directory or any nested directories
+ * @return File[] of files in the directory
+ */
+ public static File[] findAllFilesInDirectoryRecursively(final String dir) {
+
+ // Recursively navigate through the contents of this directory
+ // gathering up all the files
+ List allFiles = new ArrayList();
+ File directory = new File(dir);
+ addFilesInDirectoryRecursively(directory, allFiles);
+
+ return (File[])allFiles.toArray(new File[allFiles.size()]);
+
+ }
+
+ private static void addFilesInDirectoryRecursively(final File directory, final List allFiles) {
+ File[] files = directory.listFiles();
+ if (files != null) {
+ for (int i=0; i < files.length; i++) {
+ File file = files[i];
+ if (file.isDirectory()) {
+ addFilesInDirectoryRecursively(file, allFiles);
+ } else {
+ allFiles.add(file);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns a <code>File</code> array that will contain all the files that exist in the directory
+ *
+ * @return File[] of files in the directory
+ */
+ public static File[] findAllFilesInDirectory(String dir) {
+
+ // Find all files in the specified directory
+ File modelsDirFile = new File(dir);
+ FileFilter fileFilter = new FileFilter() {
+
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return false;
+ }
+
+ String fileName = file.getName();
+
+ if (fileName == null || fileName.length() == 0) {
+ return false;
+ }
+
+ return true;
+
+ }
+ };
+
+ File[] modelFiles = modelsDirFile.listFiles(fileFilter);
+
+ return modelFiles;
+
+ }
+
+ /**
+ * Returns a <code>File</code> array that will contain all the files that
+ * exist in the directory that have the specified extension.
+ * @return File[] of files having a certain extension
+ */
+ public static File[] findAllFilesInDirectoryHavingExtension(String dir, final String extension) {
+
+ // Find all files in that directory that end in XML and attempt to
+ // load them into the runtime metadata database.
+ File modelsDirFile = new File(dir);
+ FileFilter fileFilter = new FileFilter() {
+ public boolean accept(File file) {
+ if(file.isDirectory()) {
+ return false;
+ }
+
+
+ String fileName = file.getName();
+
+ if (fileName==null || fileName.length()==0) {
+ return false;
+ }
+
+ return (fileName.endsWith(extension));
+ // here we check to see if the file is an .xml file...
+// int index = fileName.lastIndexOf("."); //$NON-NLS-1$
+//
+// if (index<0 || index==fileName.length()) {
+// return false;
+// }
+//
+// if (fileName.substring(index, fileName.length()).equalsIgnoreCase(extension)) {
+// return true;
+// }
+// return false;
+ }
+ };
+
+ File[] modelFiles = modelsDirFile.listFiles(fileFilter);
+
+ return modelFiles;
+
+ }
+
+ /**
+ * @param string
+ * @return
+ */
+ public static String getFilenameWithoutExtension( final String filename ) {
+ if ( filename == null || filename.length() == 0 ) {
+ return filename;
+ }
+ final int extensionIndex = filename.lastIndexOf(Constants.FILE_EXTENSION_SEPARATOR_CHAR);
+ if ( extensionIndex == -1 ) {
+ return filename; // not found
+ }
+ if ( extensionIndex == 0 ) {
+ return ""; //$NON-NLS-1$
+ }
+ return filename.substring(0,extensionIndex);
+ }
+
+ public static String getBaseFileNameWithoutExtension(String path) {
+ return StringUtil.getFirstToken(StringUtil.getLastToken(path, "/"), "."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Obtains the file extension of the specified <code>File</code>. The extension is considered to be all the
+ * characters after the last occurrence of {@link Constants#FILE_EXTENSION_SEPARATOR_CHAR} in the pathname
+ * of the input.
+ * @param theFile the file whose extension is being requested
+ * @return the extension or <code>null</code> if not found
+ * @since 4.2
+ */
+ public static String getExtension(File theFile) {
+ return getExtension(theFile.getPath());
+ }
+
+ /**
+ * Obtains the file extension of the specified file name. The extension is considered to be all the
+ * characters after the last occurrence of {@link Constants#FILE_EXTENSION_SEPARATOR_CHAR}.
+ * @param theFileName the file whose extension is being requested
+ * @return the extension or <code>null</code> if not found
+ * @since 4.2
+ */
+ public static String getExtension(String theFileName) {
+ String result = null;
+ final int index = theFileName.lastIndexOf(Constants.FILE_EXTENSION_SEPARATOR_CHAR);
+
+ // make sure extension char is found and is not the last char in the path
+ if ((index != -1) && ((index + 1) != theFileName.length())) {
+ result = theFileName.substring(index + 1);
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns true iff str.toLowerCase().endsWith(".jar") || str.toLowerCase().endsWith(".zip")
+ * implementation is not creating extra strings.
+ */
+ public final static boolean isArchiveFileName(String name) {
+ int nameLength = name == null ? 0 : name.length();
+ int suffixLength = SUFFIX_JAR.length;
+ if (nameLength < suffixLength) return false;
+
+ // try to match as JAR file
+ for (int i = 0; i < suffixLength; i++) {
+ char c = name.charAt(nameLength - i - 1);
+ int suffixIndex = suffixLength - i - 1;
+ if (c != SUFFIX_jar[suffixIndex] && c != SUFFIX_JAR[suffixIndex]) {
+
+ // try to match as ZIP file
+ suffixLength = SUFFIX_ZIP.length;
+ if (nameLength < suffixLength) return false;
+ for (int j = 0; j < suffixLength; j++) {
+ c = name.charAt(nameLength - j - 1);
+ suffixIndex = suffixLength - j - 1;
+ if (c != SUFFIX_zip[suffixIndex] && c != SUFFIX_ZIP[suffixIndex]) return false;
+ }
+ return true;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns true iff str.toLowerCase().endsWith(".class")
+ * implementation is not creating extra strings.
+ */
+ public final static boolean isClassFileName(String name) {
+ int nameLength = name == null ? 0 : name.length();
+ int suffixLength = SUFFIX_CLASS.length;
+ if (nameLength < suffixLength) return false;
+
+ for (int i = 0; i < suffixLength; i++) {
+ char c = name.charAt(nameLength - i - 1);
+ int suffixIndex = suffixLength - i - 1;
+ if (c != SUFFIX_class[suffixIndex] && c != SUFFIX_CLASS[suffixIndex]) return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns true iff str.toLowerCase().endsWith(".java")
+ * implementation is not creating extra strings.
+ */
+ public final static boolean isJavaFileName(String name) {
+ int nameLength = name == null ? 0 : name.length();
+ int suffixLength = SUFFIX_JAVA.length;
+ if (nameLength < suffixLength) return false;
+
+ for (int i = 0; i < suffixLength; i++) {
+ char c = name.charAt(nameLength - i - 1);
+ int suffixIndex = suffixLength - i - 1;
+ if (c != SUFFIX_java[suffixIndex] && c != SUFFIX_JAVA[suffixIndex]) return false;
+ }
+ return true;
+ }
+
+
+ public static File convertByteArrayToFile(final byte[] contents, final String parentDirectoryPath, final String fileName) {
+ if (contents != null) {
+ FileOutputStream os = null;
+ try {
+ final File temp = new File(parentDirectoryPath,fileName);
+ os = new FileOutputStream(temp);
+ os.write(contents);
+ return temp;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e1) {
+ // do nothing
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static void removeDirectoryAndChildren(File directory) {
+ removeChildrenRecursively(directory);
+ if(!directory.delete()) {
+ directory.deleteOnExit();
+ }
+ }
+
+ public static void removeChildrenRecursively(File directory) {
+ File[] files = directory.listFiles();
+ if(files != null) {
+ for(int i=0; i < files.length; i++) {
+ File file = files[i];
+ if (file.isDirectory()) {
+ removeDirectoryAndChildren(file);
+ } else {
+ if(!file.delete()) {
+ file.deleteOnExit();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Builds a file directory path from a physical location and a location that needs
+ * to be appended to the physical. This is used so that the correct File.separator
+ * is used and that no additional separator is added when not needed.
+ * @param physicalDirectory
+ * @param appendLocation
+ * @return
+ * @since 4.3
+ */
+ public static String buildDirectoryPath(String[] paths) {
+// String physicalDirectory, String appendLocation) {
+
+ if (paths == null || paths.length == 0) {
+ return ""; //$NON-NLS-1$
+ }
+ if (paths.length == 1) {
+ return (paths[0]!=null?paths[0]:"");//$NON-NLS-1$
+ }
+ int l = paths.length;
+ StringBuffer sb = new StringBuffer();
+ for (int cur=0;cur<l; cur++) {
+ int next = cur+1;
+
+ String value = paths[cur]!=null?paths[cur]:"";//$NON-NLS-1$
+ if (value.equals("")) {//$NON-NLS-1$
+ continue;
+ }
+ sb.append(value);
+
+ if (next < l) {
+ String nextValue = paths[next]!=null?paths[next]:"";//$NON-NLS-1$
+ if (value.endsWith(File.separator)) {
+
+ } else if (!nextValue.startsWith(File.separator)) {
+ sb.append(File.separator);
+ }
+
+ }
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Compute checksum for the given file.
+ * @param f The file for which checksum needs to be computed
+ * @return The checksum
+ * @since 4.3
+ */
+ public static long getCheckSum(final File f) throws Exception {
+ ArgCheck.isNotNull(f);
+ FileInputStream is = null;
+ try {
+ is = new FileInputStream(f);
+ return ChecksumUtil.computeChecksum(is).getValue();
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException err1) {
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Test whether it's possible to read and write files in the specified directory.
+ * @param dirPath Name of the directory to test
+ * @throws MetaMatrixException
+ * @since 4.3
+ */
+ public static void testDirectoryPermissions(String dirPath) throws Exception {
+
+ //try to create a file
+ File tmpFile = new File(dirPath + File.separatorChar + TEMP_FILE);
+ boolean success = false;
+ try {
+ success = tmpFile.createNewFile();
+ } catch (IOException e) {
+ }
+ if (!success) {
+ final String msg = "FileUtils.Unable_to_create_file_in " + dirPath; //$NON-NLS-1$
+ throw new Exception(msg);
+ }
+
+
+ //test if file can be written to
+ if (!tmpFile.canWrite()) {
+ final String msg = "FileUtils.Unable_to_write_file_in " + dirPath; //$NON-NLS-1$
+ throw new Exception(msg);
+ }
+
+ //test if file can be read
+ if (!tmpFile.canRead()) {
+ final String msg = "FileUtils.Unable_to_read_file_in " + dirPath; //$NON-NLS-1$
+ throw new Exception(msg);
+ }
+
+ //test if file can be renamed
+ File newFile = new File(dirPath + File.separatorChar + TEMP_FILE_RENAMED);
+ success = false;
+ try {
+ success = tmpFile.renameTo(newFile);
+ } catch (Exception e) {
+ }
+ if (!success) {
+ final String msg = "FileUtils.Unable_to_rename_file_in " + dirPath; //$NON-NLS-1$
+ throw new Exception(msg);
+ }
+
+ //test if file can be deleted
+ success = false;
+ try {
+ success = newFile.delete();
+ } catch (Exception e) {
+ }
+ if (!success) {
+ final String msg = "FileUtils.Unable_to_delete_file_in " + dirPath; //$NON-NLS-1$
+ throw new Exception(msg);
+ }
+ }
+
+ /**
+ * Rename a file.
+ * @param oldFilePath
+ * @param newFilePath
+ * @param overwrite If true, overwrite the old file if it exists. If false, throw an exception if the old file exists.
+ * @throws MetaMatrixCoreException
+ * @since 4.3
+ */
+ public static void rename(String oldFilePath, String newFilePath, boolean overwrite) throws IOException {
+ File oldFile = new File(oldFilePath);
+ File newFile = new File(newFilePath);
+
+ if (newFile.exists()) {
+ if (overwrite) {
+ newFile.delete();
+ } else {
+ final String msg = "FileUtils.File_already_exists " + newFilePath; //$NON-NLS-1$
+ throw new IOException(msg);
+ }
+ }
+
+ boolean renamed = oldFile.renameTo(newFile);
+
+ //Sometimes file.renameTo will silently fail, for example attempting to rename from different UNIX partitions.
+ //Try to copy instead.
+ if (!renamed) {
+ copy(oldFilePath, newFilePath);
+ oldFile.delete();
+ }
+ }
+
+
+
+
+
+ public static void remove(String filePath) throws IOException {
+ File file = new File(filePath);
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,14 @@
+package org.teiid.test.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+
+public class PropUtils {
+
+
+
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java 2009-09-11 19:18:01 UTC (rev 1325)
@@ -0,0 +1,906 @@
+/*
+ * 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.
+ *
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved.
+ * This code is made available under the terms of the Eclipse Public
+ * License, version 1.0.
+ */
+
+package org.teiid.test.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.regex.Pattern;
+
+/**
+ * This is a common place to put String utility methods.
+ */
+public final class StringUtil {
+
+ public interface Constants {
+ char CARRIAGE_RETURN_CHAR = '\r';
+ char LINE_FEED_CHAR = '\n';
+ char NEW_LINE_CHAR = LINE_FEED_CHAR;
+ char SPACE_CHAR = ' ';
+ char DOT_CHAR = '.';
+ char TAB_CHAR = '\t';
+
+ String CARRIAGE_RETURN = String.valueOf(CARRIAGE_RETURN_CHAR);
+ String EMPTY_STRING = ""; //$NON-NLS-1$
+ String DBL_SPACE = " "; //$NON-NLS-1$
+ String LINE_FEED = String.valueOf(LINE_FEED_CHAR);
+ String NEW_LINE = String.valueOf(NEW_LINE_CHAR);
+ String SPACE = String.valueOf(SPACE_CHAR);
+ String DOT = String.valueOf(DOT_CHAR);
+ String TAB = String.valueOf(TAB_CHAR);
+
+ String[] EMPTY_STRING_ARRAY = new String[0];
+
+ // all patterns below copied from Eclipse's PatternConstructor class.
+ final Pattern PATTERN_BACK_SLASH = Pattern.compile("\\\\"); //$NON-NLS-1$
+ final Pattern PATTERN_QUESTION = Pattern.compile("\\?"); //$NON-NLS-1$
+ final Pattern PATTERN_STAR = Pattern.compile("\\*"); //$NON-NLS-1$
+ }
+
+ /**
+ * The String "'"
+ */
+ public static final String SINGLE_QUOTE = "'"; //$NON-NLS-1$
+
+ /**
+ * The name of the System property that specifies the string that should be used to separate
+ * lines. This property is a standard environment property that is usually set automatically.
+ */
+ public static final String LINE_SEPARATOR_PROPERTY_NAME = "line.separator"; //$NON-NLS-1$
+
+ /**
+ * The String that should be used to separate lines; defaults to
+ * {@link #NEW_LINE}
+ */
+ public static final String LINE_SEPARATOR = System.getProperty(LINE_SEPARATOR_PROPERTY_NAME, Constants.NEW_LINE);
+
+ public static final Comparator CASE_INSENSITIVE_ORDER = String.CASE_INSENSITIVE_ORDER;
+
+ public static final Comparator CASE_SENSITIVE_ORDER = new Comparator() {
+ /**
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ * @since 4.2
+ */
+ public int compare(Object o1, Object o2) {
+ if ( o1 == o2 ) {
+ return 0;
+ }
+ return ((String)o1).compareTo((String)o2);
+ }
+ };
+
+ public static String getLineSeparator() {
+ return LINE_SEPARATOR;
+ }
+
+ /**
+ * Utility to return a string enclosed in ''.
+ * Creation date: (12/2/99 12:05:10 PM)
+ */
+ public static String enclosedInSingleQuotes(String aString) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(SINGLE_QUOTE);
+ sb.append(aString);
+ sb.append(SINGLE_QUOTE);
+ return sb.toString();
+ }
+
+ public static String removeChars(final String value, final char[] chars) {
+ final StringBuffer result = new StringBuffer();
+ if (value != null && chars != null && chars.length > 0) {
+ final String removeChars = String.valueOf(chars);
+ for (int i = 0; i < value.length(); i++) {
+ final String character = value.substring(i, i + 1);
+ if (removeChars.indexOf(character) == -1) {
+ result.append(character);
+ }
+ }
+ } else {
+ result.append(value);
+ }
+ return result.toString();
+ }
+
+ /**
+ * Join string pieces and separate with a delimiter. Similar to the perl function of
+ * the same name. If strings or delimiter are null, null is returned. Otherwise, at
+ * least an empty string will be returned.
+ * @see #split
+ *
+ * @param strings String pieces to join
+ * @param delimiter Delimiter to put between string pieces
+ * @return One merged string
+ */
+ public static String join(List strings, String delimiter) {
+ if(strings == null || delimiter == null) {
+ return null;
+ }
+
+ StringBuffer str = new StringBuffer();
+
+ // This is the standard problem of not putting a delimiter after the last
+ // string piece but still handling the special cases. A typical way is to check every
+ // iteration if it is the last one and skip the delimiter - this is avoided by
+ // looping up to the last one, then appending just the last one.
+
+ // First we loop through all but the last one (if there are at least 2) and
+ // put the piece and a delimiter after it. An iterator is used to walk the list.
+ int most = strings.size()-1;
+ if(strings.size() > 1) {
+ Iterator iter = strings.iterator();
+ for(int i=0; i<most; i++) {
+ str.append(iter.next());
+ str.append(delimiter);
+ }
+ }
+
+ // If there is at least one element, put the last one on with no delimiter after.
+ if(strings.size() > 0) {
+ str.append(strings.get(most));
+ }
+
+ return str.toString();
+ }
+
+ /**
+ * Return a stringified version of the array.
+ * @param array the array
+ * @param delim the delimiter to use between array components
+ * @return the string form of the array
+ */
+ public static String toString( final Object[] array, final String delim ) {
+ if ( array == null ) {
+ return ""; //$NON-NLS-1$
+ }
+ if ( array.length == 0 ) {
+ return "[]"; //$NON-NLS-1$
+ }
+ final StringBuffer sb = new StringBuffer();
+ sb.append('[');
+ for (int i = 0; i < array.length; ++i) {
+ if ( i != 0 ) {
+ sb.append(delim);
+ }
+ sb.append(array[i]);
+ }
+ sb.append(']');
+ return sb.toString();
+ }
+
+ /**
+ * Return a stringified version of the array, using a ',' as a delimiter
+ * @param array the array
+ * @return the string form of the array
+ * @see #toString(Object[], String)
+ */
+ public static String toString( final Object[] array ) {
+ return toString(array,","); //$NON-NLS-1$
+ }
+
+ /**
+ * Split a string into pieces based on delimiters. Similar to the perl function of
+ * the same name. The delimiters are not included in the returned strings.
+ * @see #join
+ *
+ * @param str Full string
+ * @param splitter Characters to split on
+ * @return List of String pieces from full string
+ */
+ public static List split(String str, String splitter) {
+ StringTokenizer tokens = new StringTokenizer(str, splitter);
+ ArrayList l = new ArrayList(tokens.countTokens());
+ while(tokens.hasMoreTokens()) {
+ l.add(tokens.nextToken());
+ }
+ return l;
+ }
+
+ /**
+ * Break a string into pieces based on matching the full delimiter string in the text.
+ * The delimiter is not included in the returned strings.
+ * @param target The text to break up.
+ * @param delimiter The sub-string which is used to break the target.
+ * @return List of String from the target.
+ */
+ public static List splitOnEntireString(String target, String delimiter) {
+ ArrayList result = new ArrayList();
+ if (delimiter.length() > 0) {
+ int index = 0;
+ int indexOfNextMatch = target.indexOf(delimiter);
+ while (indexOfNextMatch > -1) {
+ result.add(target.substring(index, indexOfNextMatch));
+ index = indexOfNextMatch + delimiter.length();
+ indexOfNextMatch = target.indexOf(delimiter, index);
+ }
+ if (index <= target.length()) {
+ result.add(target.substring(index));
+ }
+ } else {
+ result.add(target);
+ }
+ return result;
+ }
+
+ /**
+ * Split a string into pieces based on delimiters preserving spaces in
+ * quoted substring as on element in the returned list. The delimiters are
+ * not included in the returned strings.
+ * @see #join
+ *
+ * @param str Full string
+ * @param splitter Characters to split on
+ * @return List of String pieces from full string
+ */
+ public static List splitPreservingQuotedSubstring(String str, String splitter) {
+ ArrayList l = new ArrayList();
+ StringTokenizer tokens = new StringTokenizer(str, splitter);
+ StringBuffer token = new StringBuffer();
+ while(tokens.hasMoreTokens()) {
+ token.setLength(0);
+ token.append(tokens.nextToken());
+ if ( token.charAt(0) == '"' ) {
+ token.deleteCharAt(0);
+ while ( tokens.hasMoreTokens() ) {
+ token.append(Constants.SPACE + tokens.nextToken());
+ if ( token.charAt(token.length() -1) == '"' ) {
+ token.deleteCharAt(token.length() - 1);
+ break;
+ }
+ }
+ }
+ l.add(token.toString().trim());
+ }
+ return l;
+ }
+
+ /*
+ * Replace a single occurrence of the search string with the replace string
+ * in the source string. If any of the strings is null or the search string
+ * is zero length, the source string is returned.
+ * @param source the source string whose contents will be altered
+ * @param search the string to search for in source
+ * @param replace the string to substitute for search if present
+ * @return source string with the *first* occurrence of the search string
+ * replaced with the replace string
+ */
+ public static String replace(String source, String search, String replace) {
+ if (source != null && search != null && search.length() > 0 && replace != null) {
+ int start = source.indexOf(search);
+ if (start > -1) {
+ return new StringBuffer(source).replace(start, start + search.length(), replace).toString();
+ }
+ }
+ return source;
+ }
+
+ /*
+ * Replace all occurrences of the search string with the replace string
+ * in the source string. If any of the strings is null or the search string
+ * is zero length, the source string is returned.
+ * @param source the source string whose contents will be altered
+ * @param search the string to search for in source
+ * @param replace the string to substitute for search if present
+ * @return source string with *all* occurrences of the search string
+ * replaced with the replace string
+ */
+ public static String replaceAll(String source, String search, String replace) {
+ if (source != null && search != null && search.length() > 0 && replace != null) {
+ int start = source.indexOf(search);
+ if (start > -1) {
+ StringBuffer newString = new StringBuffer(source);
+ replaceAll(newString, search, replace);
+ return newString.toString();
+ }
+ }
+ return source;
+ }
+
+ public static void replaceAll(StringBuffer source, String search, String replace) {
+ if (source != null && search != null && search.length() > 0 && replace != null) {
+ int start = source.toString().indexOf(search);
+ while (start > -1) {
+ int end = start + search.length();
+ source.replace(start, end, replace);
+ start = source.toString().indexOf(search, start + replace.length());
+ }
+ }
+ }
+
+ /**
+ * Simple static method to tuncate Strings to given length.
+ * @param in the string that may need tuncating.
+ * @param len the lenght that the string should be truncated to.
+ * @return a new String containing chars with length <= len or <code>null</code>
+ * if input String is <code>null</code>.
+ */
+ public static String truncString(String in, int len) {
+ String out = in;
+ if ( in != null && len > 0 && in.length() > len ) {
+ out = in.substring(0, len);
+ }
+ return out;
+ }
+
+ /**
+ * Simple utility method to wrap a string by inserting line separators creating
+ * multiple lines each with length no greater than the user specified maximum.
+ * The method parses the given string into tokens using a space delimiter then
+ * reassembling the tokens into the resulting string while inserting separators
+ * when required. If the number of characters in a single token is greater
+ * than the specified maximum, the token will not be split but instead the
+ * maximum will be exceeded.
+ * @param str the string that may need tuncating.
+ * @param maxCharPerLine the max number of characters per line
+ * @return a new String containing line separators or the original string
+ * if its length was less than the maximum.
+ */
+ public static String wrap(String str, int maxCharPerLine) {
+ int strLength = str.length();
+ if (strLength > maxCharPerLine) {
+ StringBuffer sb = new StringBuffer(str.length()+(strLength/maxCharPerLine)+1);
+ strLength = 0;
+ List tokens = StringUtil.split(str,Constants.SPACE);
+ Iterator itr = tokens.iterator();
+ while (itr.hasNext()) {
+ String token = (String) itr.next();
+ if ( strLength+token.length() > maxCharPerLine ) {
+// sb.append(getLineSeparator());
+ sb.append(Constants.NEW_LINE);
+ strLength = 0;
+ }
+ sb.append(token);
+ sb.append(Constants.SPACE);
+ strLength += token.length()+1;
+ }
+ return sb.toString();
+ }
+ return str;
+ }
+
+ /**
+ * Return the tokens in a string in a list. This is particularly
+ * helpful if the tokens need to be processed in reverse order. In that case,
+ * a list iterator can be acquired from the list for reverse order traversal.
+ *
+ * @param str String to be tokenized
+ * @param delimiter Characters which are delimit tokens
+ * @return List of string tokens contained in the tokenized string
+ */
+ public static List getTokens(String str, String delimiter) {
+ ArrayList l = new ArrayList();
+ StringTokenizer tokens = new StringTokenizer(str, delimiter);
+ while(tokens.hasMoreTokens()) {
+ l.add(tokens.nextToken());
+ }
+ return l;
+ }
+
+ /**
+ * Return the number of tokens in a string that are seperated by the delimiter.
+ *
+ * @param str String to be tokenized
+ * @param delimiter Characters which are delimit tokens
+ * @return Number of tokens seperated by the delimiter
+ */
+ public static int getTokenCount(String str, String delimiter) {
+ StringTokenizer tokens = new StringTokenizer(str, delimiter);
+ return tokens.countTokens();
+ }
+
+ /**
+ * Return the number of occurrences of token string that occurs in input string.
+ * Note: token is case sensitive.
+ *
+ * @param input
+ * @param token
+ * @return int
+ */
+ public static int occurrences(String input, String token) {
+ int num = 0;
+ int index = input.indexOf(token);
+ while (index >= 0) {
+ num++;
+ index = input.indexOf(token, index+1);
+ }
+ return num;
+ }
+
+ /**
+ * Return the last token in the string.
+ *
+ * @param str String to be tokenized
+ * @param delimiter Characters which are delimit tokens
+ * @return the last token contained in the tokenized string
+ */
+ public static String getLastToken(String str, String delimiter) {
+ if (str == null) {
+ return Constants.EMPTY_STRING;
+ }
+ int beginIndex = 0;
+ if (str.lastIndexOf(delimiter) > 0) {
+ beginIndex = str.lastIndexOf(delimiter)+1;
+ }
+ return str.substring(beginIndex,str.length());
+ }
+
+
+ /**
+ * Return the first token in the string.
+ *
+ * @param str String to be tokenized
+ * @param delimiter Characters which are delimit tokens
+ * @return the first token contained in the tokenized string
+ */
+ public static String getFirstToken(String str, String delimiter) {
+ if (str == null) {
+ return Constants.EMPTY_STRING;
+ }
+ int endIndex = str.indexOf(delimiter);
+ if (endIndex < 0) {
+ endIndex = str.length();
+ }
+ return str.substring(0,endIndex);
+ }
+
+
+ public static String computePluralForm(String str) {
+ return computePluralForm(str, Constants.EMPTY_STRING);
+ }
+
+ public static String computePluralForm(String str, String defaultValue ) {
+ if ( str == null || str.length() == 0 ) {
+ return defaultValue;
+ }
+ String result = str;
+ if ( result.endsWith("es") ) { //$NON-NLS-1$
+ // do nothing
+ } else if ( result.endsWith("ss") || //$NON-NLS-1$
+ result.endsWith("x") || //$NON-NLS-1$
+ result.endsWith("ch") || //$NON-NLS-1$
+ result.endsWith("sh") ) { //$NON-NLS-1$
+ result = result + "es"; //$NON-NLS-1$
+ } else if ( result.endsWith("y") && ! ( //$NON-NLS-1$
+ result.endsWith("ay") || //$NON-NLS-1$
+ result.endsWith("ey") || //$NON-NLS-1$
+ result.endsWith("iy") || //$NON-NLS-1$
+ result.endsWith("oy") || //$NON-NLS-1$
+ result.endsWith("uy") || //$NON-NLS-1$
+ result.equalsIgnoreCase("any") ) ) { //$NON-NLS-1$
+ result = result.substring(0, result.length()-1) + "ies"; //$NON-NLS-1$
+ } else {
+ result += "s"; //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ public static String getStackTrace( final Throwable t ) {
+ final ByteArrayOutputStream bas = new ByteArrayOutputStream();
+ final PrintWriter pw = new PrintWriter(bas);
+ t.printStackTrace(pw);
+ pw.close();
+ return bas.toString();
+ }
+
+ /**
+ * Returns whether the specified text represents a boolean value, i.e., whether it equals "true" or "false"
+ * (case-insensitive).
+ * @since 4.0
+ */
+ public static boolean isBoolean(final String text) {
+ return (Boolean.TRUE.toString().equalsIgnoreCase(text) || Boolean.FALSE.toString().equalsIgnoreCase(text));
+ }
+
+ /**<p>
+ * Returns whether the specified text is either empty or null.
+ * </p>
+ * @param text The text to check; may be null;
+ * @return True if the specified text is either empty or null.
+ * @since 4.0
+ */
+ public static boolean isEmpty(final String text) {
+ return (text == null || text.length() == 0);
+ }
+
+ /**
+ * Returns the index within this string of the first occurrence of the
+ * specified substring. The integer returned is the smallest value
+ * <i>k</i> such that:
+ * <blockquote><pre>
+ * this.startsWith(str, <i>k</i>)
+ * </pre></blockquote>
+ * is <code>true</code>.
+ *
+ * @param text any string.
+ * @param str any string.
+ * @return if the str argument occurs as a substring within text,
+ * then the index of the first character of the first
+ * such substring is returned; if it does not occur as a
+ * substring, <code>-1</code> is returned. If the text or
+ * str argument is null or empty then <code>-1</code> is returned.
+ */
+ public static int indexOfIgnoreCase(final String text, final String str) {
+ if (isEmpty(text)) {
+ return -1;
+ }
+ if (isEmpty(str)) {
+ return -1;
+ }
+ final String lowerText = text.toLowerCase();
+ final String lowerStr = str.toLowerCase();
+ return lowerText.indexOf(lowerStr);
+ }
+
+ /**
+ * Tests if the string starts with the specified prefix.
+ *
+ * @param text the string to test.
+ * @param prefix the prefix.
+ * @return <code>true</code> if the character sequence represented by the
+ * argument is a prefix of the character sequence represented by
+ * this string; <code>false</code> otherwise.
+ * Note also that <code>true</code> will be returned if the
+ * prefix is an empty string or is equal to the text
+ * <code>String</code> object as determined by the
+ * {@link #equals(Object)} method. If the text or
+ * prefix argument is null <code>false</code> is returned.
+ * @since JDK1. 0
+ */
+ public static boolean startsWithIgnoreCase(final String text, final String prefix) {
+ if (isEmpty(text)) {
+ return false;
+ }
+ if (prefix == null) {
+ return false;
+ }
+ int textLength = text.length();
+ int prefixLength = prefix.length();
+ if (prefixLength == 0) {
+ return true;
+ }
+ if (prefixLength > textLength) {
+ return false;
+ }
+ char[] chArray = prefix.toCharArray();
+ for (int i = 0; i != chArray.length; ++i) {
+ char ch1 = chArray[i];
+ char ch2 = text.charAt(i);
+ if (ch1 == ch2 || Character.toLowerCase(ch1) == Character.toLowerCase(ch2)) {
+ // continue
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Tests if the string ends with the specified suffix.
+ *
+ * @param text the string to test.
+ * @param suffix the suffix.
+ * @return <code>true</code> if the character sequence represented by the
+ * argument is a suffix of the character sequence represented by
+ * this object; <code>false</code> otherwise. Note that the
+ * result will be <code>true</code> if the suffix is the
+ * empty string or is equal to this <code>String</code> object
+ * as determined by the {@link #equals(Object)} method. If the text or
+ * suffix argument is null <code>false</code> is returned.
+ */
+ public static boolean endsWithIgnoreCase(final String text, final String suffix) {
+ if (isEmpty(text)) {
+ return false;
+ }
+ if (suffix == null) {
+ return false;
+ }
+ int textLength = text.length();
+ int suffixLength = suffix.length();
+ if (suffixLength == 0) {
+ return true;
+ }
+ if (suffixLength > textLength) {
+ return false;
+ }
+ int offset = textLength - suffixLength;
+ char[] chArray = suffix.toCharArray();
+ for (int i = 0; i != chArray.length; ++i) {
+ char ch1 = chArray[i];
+ char ch2 = text.charAt(offset + i);
+ if (ch1 == ch2 || Character.toLowerCase(ch1) == Character.toLowerCase(ch2)) {
+ // continue
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Determine if the string passed in has all digits as its contents
+ * @param str
+ * @return true if digits; false otherwise
+ */
+ public static boolean isDigits(String str) {
+ for(int i=0; i<str.length(); i++) {
+ if(!StringUtil.isDigit(str.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ //============================================================================================================================
+ // Constructors
+
+ /**<p>
+ * Prevents instantiation.
+ * </p>
+ * @since 4.0
+ */
+ private StringUtil() {
+ }
+
+ /*
+ * Converts user string to regular expres '*' and '?' to regEx variables.
+ * copied from eclipse's PatternConstructor
+ */
+ static String asRegEx(String pattern) {
+ // Replace \ with \\, * with .* and ? with .
+ // Quote remaining characters
+ String result1 = Constants.PATTERN_BACK_SLASH.matcher(pattern).replaceAll(
+ "\\\\E\\\\\\\\\\\\Q"); //$NON-NLS-1$
+ String result2 = Constants.PATTERN_STAR.matcher(result1).replaceAll(
+ "\\\\E.*\\\\Q"); //$NON-NLS-1$
+ String result3 = Constants.PATTERN_QUESTION.matcher(result2).replaceAll(
+ "\\\\E.\\\\Q"); //$NON-NLS-1$
+ return "\\Q" + result3 + "\\E"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Creates a regular expression pattern from the pattern string (which is
+ * our old 'StringMatcher' format). Copied from Eclipse's PatternConstructor class.
+ *
+ * @param pattern
+ * The search pattern
+ * @param isCaseSensitive
+ * Set to <code>true</code> to create a case insensitve pattern
+ * @return The created pattern
+ */
+ public static Pattern createPattern(String pattern, boolean isCaseSensitive) {
+ if (isCaseSensitive)
+ return Pattern.compile(asRegEx(pattern));
+ return Pattern.compile(asRegEx(pattern), Pattern.CASE_INSENSITIVE
+ | Pattern.UNICODE_CASE);
+ }
+
+ /**
+ * Removes extraneous whitespace from a string. By it's nature, it will be trimmed also.
+ * @param raw
+ * @return
+ * @since 5.0
+ */
+ public static String collapseWhitespace(String raw) {
+ StringBuffer rv = new StringBuffer(raw.length());
+
+ StringTokenizer izer = new StringTokenizer(raw, " "); //$NON-NLS-1$
+ while (izer.hasMoreTokens()) {
+ String tok = izer.nextToken();
+ // Added one last check here so we don't append a "space" on the end of the string
+ rv.append(tok);
+ if( izer.hasMoreTokens() ) {
+ rv.append(' ');
+ }
+ } // endwhile
+
+ return rv.toString();
+ }
+
+ /**
+ * If input == null OR input.length() < desiredLength, pad to desiredLength with spaces.
+ * If input.length() > desiredLength, chop at desiredLength.
+ * @param input Input text
+ * @param desiredLength Desired length
+ * @return
+ * @since 5.0
+ */
+ public static String toFixedLength(String input, int desiredLength) {
+ if(input == null) {
+ input = ""; //$NON-NLS-1$
+ }
+
+ if(input.length() == desiredLength) {
+ return input;
+ }
+
+ if(input.length() < desiredLength) {
+ StringBuffer str = new StringBuffer(input);
+ int needSpaces = desiredLength - input.length();
+ for(int i=0; i<needSpaces; i++) {
+ str.append(' ');
+ }
+ return str.toString();
+ }
+
+ // Else too long - chop
+ return input.substring(0, desiredLength);
+ }
+
+
+ public static boolean isLetter(char c) {
+ return isBasicLatinLetter(c) || Character.isLetter(c);
+ }
+ public static boolean isDigit(char c) {
+ return isBasicLatinDigit(c) || Character.isDigit(c);
+ }
+ public static boolean isLetterOrDigit(char c) {
+ return isBasicLatinLetter(c) || isBasicLatinDigit(c) || Character.isLetterOrDigit(c);
+ }
+
+ public static String toUpperCase(String str) {
+ String newStr = convertBasicLatinToUpper(str);
+ if (newStr == null) {
+ return str.toUpperCase();
+ }
+ return newStr;
+ }
+
+ public static String toLowerCase(String str) {
+ String newStr = convertBasicLatinToLower(str);
+ if (newStr == null) {
+ return str.toLowerCase();
+ }
+ return newStr;
+ }
+
+ /**
+ * Create a valid filename from the given String.
+ *
+ * @param str The String to convert to a valid filename.
+ * @param defaultName The default name to use if only special characters exist.
+ * @return String A valid filename.
+ */
+ public static String createFileName(String str) {
+
+ /** Replace some special chars */
+ str = str.replaceAll(" \\| ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ str = str.replaceAll(">", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ str = str.replaceAll(": ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ str = str.replaceAll(" ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ str = str.replaceAll("\\?", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ str = str.replaceAll("/", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /** If filename only contains of special chars */
+ if (str.matches("[_]+")) //$NON-NLS-1$
+ str = "file"; //$NON-NLS-1$
+
+ return str;
+ }
+
+
+ /**
+ * Make the first letter uppercase
+ * @param str
+ * @return The string with the first letter being changed to uppercase
+ * @since 5.5
+ */
+ public static String firstLetterUppercase(String str) {
+ if(str == null || str.length() == 0) {
+ return null;
+ }
+ if(str.length() == 1) {
+ return str.toUpperCase();
+ }
+ return str.substring(0, 1).toUpperCase() + str.substring(1);
+ }
+
+ private static String convertBasicLatinToUpper(String str) {
+ char[] chars = str.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ if (isBasicLatinLowerCase(chars[i])) {
+ chars[i] = (char)('A' + (chars[i] - 'a'));
+ } else if (!isBasicLatinChar(chars[i])) {
+ return null;
+ }
+ }
+ return new String(chars);
+ }
+
+ private static String convertBasicLatinToLower(String str) {
+ char[] chars = str.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ if (isBasicLatinUpperCase(chars[i])) {
+ chars[i] = (char)('a' + (chars[i] - 'A'));
+ } else if (!isBasicLatinChar(chars[i])) {
+ return null;
+ }
+ }
+ return new String(chars);
+ }
+
+ private static boolean isBasicLatinUpperCase(char c) {
+ return c >= 'A' && c <= 'Z';
+ }
+ private static boolean isBasicLatinLowerCase(char c) {
+ return c >= 'a' && c <= 'z';
+ }
+ private static boolean isBasicLatinLetter(char c) {
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+ }
+ private static boolean isBasicLatinDigit(char c) {
+ return c >= '0' && c <= '9';
+ }
+ private static boolean isBasicLatinChar(char c) {
+ return c <= '\u007F';
+ }
+
+ /**
+ * Convert the given value to specified type.
+ * @param value
+ * @param type
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T valueOf(String value, Class type){
+
+ if(type == String.class) {
+ return (T) value;
+ }
+ else if(type == Boolean.class || type == Boolean.TYPE) {
+ return (T) Boolean.valueOf(value);
+ }
+ else if (type == Integer.class || type == Integer.TYPE) {
+ return (T) Integer.decode(value);
+ }
+ else if (type == Float.class || type == Float.TYPE) {
+ return (T) Float.valueOf(value);
+ }
+ else if (type == Double.class || type == Double.TYPE) {
+ return (T) Double.valueOf(value);
+ }
+ else if (type == Long.class || type == Long.TYPE) {
+ return (T) Long.decode(value);
+ }
+ else if (type == Short.class || type == Short.TYPE) {
+ return (T) Short.decode(value);
+ }
+ else if (type.isAssignableFrom(List.class)) {
+ return (T)new ArrayList<String>(Arrays.asList(value.split(","))); //$NON-NLS-1$
+ }
+ else if (type == Void.class) {
+ return null;
+ }
+ else if (type.isEnum()) {
+ return (T)Enum.valueOf(type, value);
+ }
+
+ else if (type.isAssignableFrom(Map.class)) {
+ List<String> l = Arrays.asList(value.split(",")); //$NON-NLS-1$
+ Map m = new HashMap<String, String>();
+ for(String key: l) {
+ int index = key.indexOf('=');
+ if (index != -1) {
+ m.put(key.substring(0, index), key.substring(index+1));
+ }
+ }
+ return (T)m;
+ }
+
+ throw new IllegalArgumentException("Conversion from String to "+ type.getName() + " is not supported"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 4 months