Database Connectivity in junit plugin test

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Database Connectivity in junit plugin test

Postby Evelin » Sat Aug 28, 2010 1:53 am

I want to connect to a mysql db for reporting the passes/failures of automation suite.
I am not able to do so when I run test case as junit-plugin test.
I tried with a simple testfile to check this connectivity.
If I run the test case as a simple junit test , the connection is established.
The same code fails to connect to db when I run it as a junit-plugin test.
I have to run my automation suite as junit-plugin test itself. Help appreciated.

This is the test case that I used for checking connection.

public class sampltest extends UITestCaseSWT {
public void testconnection()
ResultsManager rm = new ResultsManager();

Result manager class functions:

public class ResultsManager {
Connection c = null;
Statement stmnt1,stmnt = null;
ResultSet rs = null;

public void createMySQLConnection()
try {
c = DriverManager.getConnection("jdbc:mysql://<ip>:<port>",
"username", "pwd");

System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
stmnt = c.createStatement();

catch(Exception e)
System.err.println("Exception: " + e.getStackTrace());
try {
if(c != null)
} catch(SQLException e1) {

public void closeConnection()
try {
} catch (SQLException e) {
// TODO Auto-generated catch block

I get this Exception when I run the above as junit-plugin test.

Exception: [Ljava.lang.StackTraceElement;@711407
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at ResultsManager.createMySQLConnection(
at sampltest.testconnection(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at junit.framework.TestCase.runTest(
at junit.framework.TestCase.runBare(
at com.windowtester.runtime.common.UITestCaseCommon.access$0(
at com.windowtester.runtime.common.UITestCaseCommon$
at com.windowtester.runtime.common.UITestCaseCommon$
at com.windowtester.internal.runtime.junit.core.SequenceRunner$

I have added the mysql driver jar in the library.The connection is successfully established when the test is run as junit test and fails when run as junit-plugin test.Any pointers on what is going wrong here will be really really helpful.

Posts: 1
Joined: Sat Aug 28, 2010 1:34 am

Re: Database Connectivity in junit plugin test

Postby keertip » Tue Sep 07, 2010 12:44 pm

Are the plugins needed for mysql access included in the Plug-ins tab in the JUnit Plug-in test launch configuration? From the error message, looks like the plugins are not in the launch configuration.
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest