org.teiid.test.framework.datasource
Class DataSourceFactory
java.lang.Object
org.teiid.test.framework.datasource.DataSourceFactory
public class DataSourceFactory
- extends java.lang.Object
The DataSourceFactory is responsible for managing the datasources used during a single test.
It ensures the same data source is used in both the connector binding and during validation to ensure validation is performed
against the same datasource the test was performed on.
The following are the available options for controlling which datasources are used during a test:
Control which datasources are used and to which model they are assigned
Use the ConfigPropertyNames.USE_DATASOURCES_PROP
property to specify a comma delimited ordered list to control which data sources to use.
This will enable integration testing to be setup to use well known combinations, to ensure coverage and makes it easier to replicate issues.
This indicates to use only the specified datasources for this test. This option can be used in test cases where only
specific sources are to be used and tested against.
This ordered list will map to the model:order mapping in the config.properties file.
Example: in the config.properties file, the models in the test and their order can be specified:
pm1=1
pm2=2
Then set property: ConfigPropertyNames.USE_DATASOURCES_PROP=oracle,sqlserver
This will use oracle and sqlserver datasources in the test, and when a datasource is requested for model "pm1", the oracle datasource will be returned. And when a data source
for "pm2" is requested, the data source mapped to 2nd ordered datasource of sqlserver will be returned.
Control which datasources of a specific database type to exclude
Use the ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP
property to specify a comma delimited list of DataSourceFactory.DataBaseTypes
to exclude.
This will remove all datasources of a specific database type from the list of available datasources. This option will be applied after
ConfigPropertyNames.USE_DATASOURCES_PROP
option. This is done because there are some test that will not work with certain database
types, and therefore, if the required datasources are not met, the test will be bypassed for execution.
Control for a specfic model, which database type of datasource to be assigned
This option gives the developer even more fine grain control of how datasources are assigned. There are cases where a specific model must be assigned
to a datasource of a specific database type.
To use this option,
- Author:
- vanhalbert
Nested Class Summary |
static interface |
DataSourceFactory.DataBaseTypes
These types match the "ddl" directories for supported database types
and it also found in the datasources connection.properties defined by the DB_TYPE property
These are also the values used to specify the required database types. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DataSourceFactory
public DataSourceFactory(ConfigPropertyLoader config)
getConfigProperties
public java.util.Properties getConfigProperties()
config
protected void config(DataSourceMgr dsmgr)
- config is called at the start / setup of the
TransactionContainer#
test. This is to ensure any exclusions /
inclusions are considered for the next executed set of test.
1st, check for the usedatasource property, if exist, then only add those specific datasources
to the useDataSources, otherwise add all available.
2nd, if the exclude option is used, then remove any excluded datasources from the useDataSources.
- Since:
getNumberAvailableDataSources
public int getNumberAvailableDataSources()
getDatasource
public DataSource getDatasource(java.lang.String modelName)
throws QueryTestFailedException
- Throws:
QueryTestFailedException
cleanup
public void cleanup()
main
public static void main(java.lang.String[] args)
Copyright © 2010. All Rights Reserved.