Contents
Abstract
So, you want to be able to get QFTest to talk to your MySQL database server during test execution; just a small matter of getting the Jython client to play ball - easy when you know how.
This shows how to add MySQL support to the QFTest Jython client. It requires the installation of MySQL Connector/J on to the host system and a small amount of hacking of the QFTest code.
MySQL Connector/J
From the package information for libmysql-java:
MySQL Connector/J is a JDBC-3.0 Type 4 driver, which means that
it is pure Java, implements version 3.0 of the JDBC
specification, and communicates directly with the MySQL server
using the MySQL protocol.
Sounds ideal, so let's go ahead and install it.
Installation
Firstly, download and install the latest MySQL Connector/J or install it through your usual package management system. Next, link to the installed jar files (mysql-connector-java-5.1.10.jar and mysql-5.1.10.jar) in /usr/share/java to your QFTest installation library directory; in my case /usr/share/qfest/qftest-3.4.7/lib/.
$ sudo ln -s /usr/share/java/mysql-5.1.10.jar mysql.jar
$ sudo ln -s /usr/share/java/mysql-connector-java-5.1.10.jar \
> mysql-connector-java.jar
Now to check that the links are correctly in place:
$ ls -al /usr/share/qftest/qftest-3.4.7/lib/ \
> | awk '/mysql/ {print $8$9$10}'
mysql-connector-java.jar -> /usr/share/java/mysql-connector-java-5.1.10.jar
mysql.jar -> /usr/share/java/mysql-5.1.10.jar
Next you need to edit the fixcp file at /usr/share/qftest/qftest-n.n.n/bin/ as this file is in charge of specifying the libraries to be used by QFTest at load time.
Change the lines:
15 # libjars for server and client
16 libjars="bsf gnu groovy-all jansi jline jniwrapper jython png"
To:
15 # EXTRA JARS FOR MYSQL
16 mysqljars="mysql-connector-java mysql"
17 # libjars for server and client
18 libjars="$mysqljars bsf gnu groovy-all jansi jline jniwrapper jython png"
Checking
Run the qftest shell file with debug arguments to see if the new libs are loading:
$ sh qftest -dbg
You should see something such as the following (some elements truncated with [...]):
-------------------------------------------
This is qftest
Java executable: java
Java arguments:
qftest arguments:
[...]
libjars: mysql-connector-java mysql bsf gnu groovy-all jansi jline
jniwrapper jython png commons jide-oss junit jxl looks poi truezip
libdir: /usr/share/qftest/qftest-3.4.7/lib
qflibdir: /usr/share/qftest/qftest-3.4.7/qflib
plugindir: /usr/share/qftest/plugin
Logging internal output to /usr/share/qftest/log/qftest.log
executing "java" -Xbootclasspath/p
[...]
/usr/share/qftest/qftest-3.4.7/lib/jide-oss.jar:/usr/share/qftest/
qftest-3.4.7/lib/mysql.jar:/usr/share/qftest/qftest-3.4.7/lib/
mysql-connector-java.jar:
[...]
de.qfs.apps.qftest.start.QFTest
-shellarg=-c
-shell=/bin/sh
"-options=/usr/share/qftest/qftest-3.4.7/bin/qftest.options"
"-logfile=/usr/share/qftest/log/qftest.log"
-------------------------------------------
Essentially, you are looking to see the two mysql jars are amongst all the jars listed in the output above.
Testing
Fire up QFTest, open a Jython terminal window and run the following:
Jython 2.5.1+ (Release_2_5_1:13409M, Mrz 9 2011, 15:05:52)
[OpenJDK Server VM (Sun Microsystems Inc.)] on java1.6.0_22
>>> from com.ziclix.python.sql import zxJDBC
>>> conn = zxJDBC.connect('jdbc:mysql://testing.local', 'user', 'passwd', \
... 'com.mysql.jdbc.Driver')
>>> print conn
<PyConnection object at 0x1 user='user@10.10.10.88', url='jdbc:mysql://testing.local'>
>>>
Comments
comments powered by Disqus