[jboss-svn-commits] JBL Code SVN: r14511 - in labs/jbossesb/trunk/product/samples/quickstarts/tests: src/org/jboss/soa/esb/quickstart/test and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 23 22:17:27 EDT 2007
Author: ldimaggi at redhat.com
Date: 2007-08-23 22:17:27 -0400 (Thu, 23 Aug 2007)
New Revision: 14511
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/tests/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldSQLActionTest.java
Log:
tests/build.xml - Added createdb and dropdb targets to support HelloWorldSQLAction
test. The test cannot be run unless the target DB is first created. Note that the
test cannot even be deployed unless the DB is first created. (This means that the
test cannot create the DB after it is deployed.)
tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldSQLActionTest.java - Updated
to actually create the DB records to cause the test to run.
Modified: labs/jbossesb/trunk/product/samples/quickstarts/tests/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/tests/build.xml 2007-08-24 02:12:53 UTC (rev 14510)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/build.xml 2007-08-24 02:17:27 UTC (rev 14511)
@@ -80,6 +80,25 @@
<delete dir="output"/>
</target>
+ <target name="dropdb"
+ description="drop database">
+ <echo>Drop database</echo>
+ <exec executable="mysql" >
+ <arg value="--user=root" />
+ <arg value="--password=" />
+ <arg value="--execute=drop database test_sql_gateway" />
+ </exec>
+ </target>
+
+ <target name="createdb"
+ description="createdb">
+ <echo>Create database and test table</echo>
+ <exec executable="mysql" input="create.sql" >
+ <arg value="--user=root" />
+ <arg value="--password=" />
+ </exec>
+ </target>
+
<target name="test" depends="compile, prompt, execute"/>
<target name="all-test" depends="compile, execute"/>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldSQLActionTest.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldSQLActionTest.java 2007-08-24 02:12:53 UTC (rev 14510)
+++ labs/jbossesb/trunk/product/samples/quickstarts/tests/src/org/jboss/soa/esb/quickstart/test/HelloWorldSQLActionTest.java 2007-08-24 02:17:27 UTC (rev 14511)
@@ -4,31 +4,72 @@
import org.jboss.test.JBossTestCase;
+import java.sql.*;
+import java.util.Vector;
+
/**
* Sample client for the jboss container.
- *
+ *
* @author <a href="mailto:tcunning at redhat.com">Tom Cunningham</a>
*/
-public class HelloWorldSQLActionTest
- extends JBossTestCase
-{
- public HelloWorldSQLActionTest(String name)
- {
+public class HelloWorldSQLActionTest extends JBossTestCase {
+ public HelloWorldSQLActionTest(String name) {
super(name);
}
- public void testMessage() throws Exception
- {
+ public void testMessage() throws Exception {
sendMessage();
Thread.sleep(10000); // wait for message to post.
}
- public void sendMessage() throws Exception
- {
- }
+ public void sendMessage() throws Exception {
- public static Test suite() throws Exception
- {
- return getDeploySetup(HelloWorldSQLActionTest.class, "Quickstart_helloworld_file_action.esb");
- }
-}
+ Connection connection = null;
+ try {
+ // Load the JDBC driver
+ String driverName = "org.gjt.mm.mysql.Driver";
+ Class.forName(driverName);
+
+ // Create a connection to the database
+ String serverName = "localhost";
+ String mydatabase = "test_sql_gateway";
+ String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
+ String username = "root";
+ String password = "";
+ connection = DriverManager.getConnection(url, username, password);
+ } catch (ClassNotFoundException e) {
+ // Could not find the database driver
+ } catch (SQLException e) {
+ // Could not connect to the database
+ }
+
+ Vector theRecords = new Vector();
+ theRecords
+ .add("insert into gateway_table values(0,'data 111111 [jbesb-filename]/tmp/HelloWorldSQLActionTest.log[/jbesb-filename] ','p')");
+ theRecords
+ .add("insert into gateway_table values(0,'data 22 [jbesb-filename]/tmp/HelloWorldSQLActionTest.log[/jbesb-filename] ','p')");
+ theRecords
+ .add("insert into gateway_table values(0,'data 333333333333111111 [jbesb-filename]/tmp/HelloWorldSQLActionTest.log[/jbesb-filename] ','p')");
+ theRecords
+ .add("insert into gateway_table values(0,'data d d d d [jbesb-filename]/tmp/HelloWorldSQLActionTest.log[/jbesb-filename] ','p')");
+ theRecords
+ .add("insert into gateway_table values(0,'data last record [jbesb-filename]/tmp/HelloWorldSQLActionTest.log[/jbesb-filename] ','p')");
+
+ for (int i = 0; i < theRecords.size(); i++) {
+
+ try {
+ Statement stmt = connection.createStatement();
+ String sql = (String) theRecords.elementAt(i);
+ stmt.executeUpdate(sql);
+ } catch (SQLException e) {
+ }
+ }
+
+ } /* method */
+
+ public static Test suite() throws Exception {
+ return getDeploySetup(HelloWorldSQLActionTest.class,
+ "Quickstart_helloworld_SQL_action.esb");
+ }/* method */
+
+} /* class */
More information about the jboss-svn-commits
mailing list