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 LocalTransactionTest.java as an example 
			
-	Test should extend org.teiid.test.testcases.BaseAbstractTransactionTestCase


-	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
													
													
	By default, the datasource assigned to a model will be (somewhat) random when starting the test process.  Once the
	data source is associated with a model, it will be used for the duration of all tests being performed.   To override
	this behavior, the -Dusedatasources option can be used.  
	
	If the -Dusedatasources option is used, then there is an implied model-to-datasource assignment.
			To understand how this assignment will be made, find the config properties file being
			loaded for this test (default is the default-config.properties) and look for
			the model-to-order mapping(s)
			
			The default Transaction.vdb has 2 models:  pm1 and pm2
			
			example:  pm1:1
					  pm2:2
					  
			Therefore, the model-to-order mapping will map to the relative order specified in the usedatasources property.
			
			example:  -Dusedatasources=oracle,postgres
			
					This will result in model 	pm1 --> oracle
												pm2 --> postgres

	To EXCLUDE a test from using a specific database type, call addProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "postgres");
	during setup()
	
	NOTE:  The EXCLUDE option excludes based on db.type, where "usedatasources" specifies the actual datasource (not by type)
	

==========================================
Setting up a Datasource to be used during Testing
==========================================

NOTE:  2 Datasource directories, each containing a connection.properties file, are required in order to run the integration tests.
		Each data source can be pointing to the same database instance, but the schemas must be different.

1.	DEFINE DATASOURCE:
	To define a datasource, see the readme.txt in src/main/resources/datasources regarding defining a datasource

2.	CREATE TABLES IN A DATASOURCE
	Options are to setup all data sources at once or setup a single data source.

		a.  to setup all data sources at one time, run:   
				mvn pre-integration-test -Psetupdatasources 
				
		b.	to setup a specific data source, 
				run: mvn pre-integration-test -Ddatasource=<datasourcedir> -Psingledatasource  
				
				where <datasourcedir> is the name of the directory for the datasource
					
				Example:
		
					mvn pre-integration-test -Ddatasource=oracle -Psingledatasource 

==========================================
Executing the db integration tests
==========================================

The default setup of the pom.xml is to only compile and assemble the teiid-ctc-test-client jar.  The following are different profile
options for running tests:

	a.	Run All Tests:  Run all tests with no regard to which specific datasource to use (only those with connections.properties file are considered):  

			run:	mvn install -Prunalltests
			
	b.	Run a Single Test:  Run one test class with no regard to which specific datasource to use

			run: 	mvn install -Prunsingletest -Dclassname=<classname>      

					Example:   mvn install -Prunsingletest -Dclassname=OffWrapTransactionTests
		


==========================================
Executing the db integration tests - using the -Dusedatasources  option
==========================================

When running tests, by default, the process will randomly select which defined datasources it will use and to which model they will be mapped.
To control which datasources to use, add the -Dusedatasources  option when running either "run" profile (e.g., runalltests or runsingletest).
	
	a.	Example
	
			run:	mvn install -Prunalltests -Dusedatasources=<comma seperated datasource names>

			Example:  mvn install -Prunalltests -Dusedatasources=oracle,sqlserver
			
			
			



 