-
Notifications
You must be signed in to change notification settings - Fork 12
Compiling, replacing tokens in connection definition
Jakub Raczek edited this page Mar 14, 2020
·
3 revisions
We attached example of ANT build.xml script to demonstrate one of way how to compiling, replacing tokens in connection definition:
Ant and Maven must be installed first.
In main folder run command
ant -buildfile ./deploy/build.xml compile,tokens.copy.files,testdbq.run -Dconfig=DEV01
compile - compile maven project in \targer folder
testdbq.run - execute tests in \targer folder
Passing values of connection definition from config file by ANT
In folder \deploy run command
ant tokens.copy.files,testdbq.run -Dconfig=DEV01
File cmpSqlResults-config.xml with connection definitions should contain ${tokens} to be replaced by values from config file e.g. DEV01
<datasource maxPollSize="6">
<name>MySQL</name>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://${MYSQLDBSERVER}:3306/${MYSQLDBNAME}</url>
<user>${USERNAME}</user>
<password>${PASSWORD}</password>
</datasource>
Implementation of config file DEV01:
TERADATADBSERVER=TERADATADBSERVERVALUE
TERADATADBNAME=TERADATADBNAMEVALUE
SQL_SERVER=SQL_SERVERVALUE
SQL_SERVERINSTANCE=SQL_SERVERINSTANCEVALUE
SQL_SERVERDBNAME=SQL_SERVERDBNAMEVALUE
MYSQLDBSERVER=MYSQLDBSERVERVALUE
MYSQLDBNAME=MYSQLDBNAMEVALUE
POSTGRESSSQLDBSERVER=POSTGRESSSQLDBSERVERVALUE
POSTGRESSSQLDBNAME=POSTGRESSSQLDBNAMEVALUE
USERNAME=USERNAMEVALUE
PASSWORD=PASSWORDVALUE
Implementation of replacing tokens in ANT build.xml scripts:
<macrodef name="copyfiles">
<attribute name="todir" />
<attribute name="fromdir" />
<attribute name="includefiles" />
<attribute name="flattenfolder" />
<sequential>
<copy todir="@{todir}" failonerror="false" verbose="true" flatten="@{flattenfolder}">
<fileset dir="@{fromdir}" includes="@{includefiles}" />
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile" value=".\Config\${config}" />
<param type="tokenchar" name="begintoken" value="${" />
<param type="tokenchar" name="endtoken" value="}" />
</filterreader>
</filterchain>
</copy>
</sequential>
</macrodef>
<copyfiles fromdir="${sourceFile}\test-definitions" todir="${dist}\test-definitions" includefiles="**/**" flattenfolder="false" />
- Home
- Getting started
- Command line parameters
- Deploying licensed jdbc drivers
- Comparators
- Fetch
- KEY
- Minus
- NMB_OF_RESULTS
- FILE
- OLAP
- Building multilevel tests structure
- TeamCity support
- Test definitions
- Filtering tests for execution
- Test report
- Compiling, replacing tokens in connection definition
- Replacing tokens in SQL queries
- Execute Stored Procedure before test