[jboss-svn-commits] JBL Code SVN: r8881 - in labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb: messagestore and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jan 17 09:41:14 EST 2007
Author: mark.little at jboss.com
Date: 2007-01-17 09:41:14 -0500 (Wed, 17 Jan 2007)
New Revision: 8881
Modified:
labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.java
labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/messagestore/HsqldbUtil.java
labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/objpersist/DrainQueuesAndTopics.java
labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/rosetta/Util.java
labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/util/JMSClientUtil.java
Log:
Modified: labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.java
===================================================================
--- labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.java 2007-01-17 02:13:38 UTC (rev 8880)
+++ labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.java 2007-01-17 14:41:14 UTC (rev 8881)
@@ -1,24 +1,25 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.soa.esb.listeners.message;
import static org.junit.Assert.assertTrue;
@@ -36,6 +37,7 @@
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
@@ -52,59 +54,84 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+
/**
- * Testing the Content Based Router.
+ * Testing the Content Based Router.
*
* @author <a href="mailto:kurt.stam at redhat.com">Kurt Stam</a>
* @author <a href="mailto:schifest at heuristica.com.ar">Esteban</a>
* @since Version 4.0
- *
+ *
*/
-public class CbrListenerTest
+public class CbrListenerTest
{
private static Logger logger = Logger.getLogger(CbrListenerTest.class);
+
private static StandAloneBootStrapper _boot = null;
-
+
private static String mDbDriver;
+
private static String mDbUrl;
+
private static String mDbUsername;
+
private static String mDbPassword;
-
+
private static final String SERVICE_CATEGORY_NAME = "MessageRouting";
+
private static final String SERVICE_NAME = "ContentBasedRouterService";
-
+
/**
* Testing the Content Based Router.
*/
@Test
public void sendMessages()
{
- try {
+ try
+ {
sendMessage("First Message");
- //The second time the rulesEngine should be primed.
+ // The second time the rulesEngine should be primed.
sendMessage("Second Message");
- } catch (RegistryException re) {
+ }
+ catch (RegistryException re)
+ {
re.printStackTrace();
assertTrue(false);
- } catch (CourierException ce) {
+ }
+ catch (CourierException ce)
+ {
ce.printStackTrace();
assertTrue(false);
}
+ catch (MalformedEPRException me)
+ {
+ me.printStackTrace();
+ assertTrue(false);
+ }
}
+
/**
* Sends a message to the CbrJmsQueueListener.
*
- * @param body - a String containing the body of the message.
- * @throws Exception
+ * @param body -
+ * a String containing the body of the message.
+ * @throws RegistryException
+ * @throws CourierException
+ * @throws MalformedEPRException
*/
- private static void sendMessage(String body) throws RegistryException, CourierException{
+
+ private static void sendMessage(String body) throws RegistryException, CourierException, MalformedEPRException
+ {
Message msg = MessageFactory.getInstance().getMessage();
msg.getBody().setContents(body.getBytes());
- msg.getProperties().setProperty(MessageRouter.DELIVER_MESSAGES, Boolean.FALSE);
+ msg.getProperties().setProperty(MessageRouter.DELIVER_MESSAGES,
+ Boolean.FALSE);
Registry registry = RegistryFactory.getRegistry();
- Collection<EPR> eprs = registry.findEPRs(SERVICE_CATEGORY_NAME, SERVICE_NAME);
- for (Iterator<EPR> eprIterator=eprs.iterator();eprIterator.hasNext();){
- //Just use the first EPR in the list.
+ Collection<EPR> eprs = registry.findEPRs(SERVICE_CATEGORY_NAME,
+ SERVICE_NAME);
+ for (Iterator<EPR> eprIterator = eprs.iterator(); eprIterator.hasNext();)
+ {
+ // Just use the first EPR in the list.
EPR epr = eprIterator.next();
Courier courier = CourierFactory.getCourier(epr);
courier.deliver(msg);
@@ -112,52 +139,74 @@
}
}
- public static junit.framework.Test suite() {
+ public static junit.framework.Test suite()
+ {
return new JUnit4TestAdapter(CbrListenerTest.class);
}
-
+
@BeforeClass
public static void runBeforeAllTests()
{
- try {
- DOMConfigurator.configure(TestEnvironmentUtil.getUserDir("product","../product") + "etc/test/resources/log4j.xml");
- TestEnvironmentUtil.setESBPropertiesFileToUse("product","../product");
- //Set the juddi properties file in System so juddi will pick it up later and use the test values.
+ try
+ {
+ DOMConfigurator.configure(TestEnvironmentUtil.getUserDir("product",
+ "../product")
+ + "etc/test/resources/log4j.xml");
+ TestEnvironmentUtil.setESBPropertiesFileToUse("product",
+ "../product");
+ // Set the juddi properties file in System so juddi will pick it up
+ // later and use the test values.
String juddiPropertiesFile = "/org/jboss/soa/esb/services/registry/juddi-qatest.properties";
System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
- //Read this properties file to get the db connection string
+ // Read this properties file to get the db connection string
Properties props = new Properties();
- InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
+ InputStream inStream = Class.class
+ .getResourceAsStream(juddiPropertiesFile);
props.load(inStream);
- mDbDriver = props.getProperty("juddi.jdbcDriver");
- mDbUrl = props.getProperty("juddi.jdbcUrl");
- mDbUsername = props.getProperty("juddi.jdbcUsername");
- mDbPassword = props.getProperty("juddi.jdbcPassword");
-
- String database="not tested yet";
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
+ mDbDriver = props.getProperty("juddi.jdbcDriver");
+ mDbUrl = props.getProperty("juddi.jdbcUrl");
+ mDbUsername = props.getProperty("juddi.jdbcUsername");
+ mDbPassword = props.getProperty("juddi.jdbcPassword");
+
+ String database = "not tested yet";
+ if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
+ {
database = "hsqldb";
- //Bring up hsql on default port 9001
- HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir("product","../product") + "build/hsqltestdb", "juddi");
- } else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
+ // Bring up hsql on default port 9001
+ HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir(
+ "product", "../product")
+ + "build/hsqltestdb", "juddi");
+ }
+ else if ("com.mysql.jdbc.Driver".equals(mDbDriver))
+ {
database = "mysql";
- } //add and test your own database..
-
- //Get the registry-schema create scripts
- String sqlDir = TestEnvironmentUtil.getUserDir("product","../product") + "install/jUDDI-registry/sql/" + database + "/";
- //Drop what is there now, if exists. We want to start fresh.
- String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
- String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
- String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
-
- try {
+ } // add and test your own database..
+
+ // Get the registry-schema create scripts
+ String sqlDir = TestEnvironmentUtil.getUserDir("product",
+ "../product")
+ + "install/jUDDI-registry/sql/" + database + "/";
+ // Drop what is there now, if exists. We want to start fresh.
+ String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir
+ + "drop_database.sql"));
+ String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir
+ + "create_database.sql"));
+ String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir
+ + "insert_publishers.sql"));
+
+ try
+ {
Class.forName(mDbDriver);
- } catch (Exception e) {
- System.out.println("ERROR: failed to load " + database + " JDBC driver.");
+ }
+ catch (Exception e)
+ {
+ System.out.println("ERROR: failed to load " + database
+ + " JDBC driver.");
e.printStackTrace();
return;
}
- java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
+ java.sql.Connection con = DriverManager.getConnection(mDbUrl,
+ mDbUsername, mDbPassword);
Statement stmnt = con.createStatement();
System.out.println("Dropping the schema if exist");
stmnt.execute(sqlDropCmd);
@@ -165,51 +214,63 @@
stmnt.execute(sqlCreateCmd);
System.out.println("Adding the jbossesb publisher");
stmnt.execute(sqlInsertPubCmd);
-
- //Now we can bring up the ContentBasedRouter
+
+ // Now we can bring up the ContentBasedRouter
String deploymentConfigFile = TestEnvironmentUtil.getUserDir("qa")
- + "junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.xml";
- String validationFileName = TestEnvironmentUtil.getUserDir("product","../product")
- + "etc/schemas/xml/jbossesb-1.0.xsd";
- // Make sure this file exists
+ + "junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.xml";
+ String validationFileName = TestEnvironmentUtil.getUserDir(
+ "product", "../product")
+ + "etc/schemas/xml/jbossesb-1.0.xsd";
+ // Make sure this file exists
File validationFile = new File(validationFileName);
- if (!validationFile.exists()){
- System.err.println("Validation file " + validationFile.getAbsolutePath() + " does not exist");
+ if (!validationFile.exists())
+ {
+ System.err.println("Validation file "
+ + validationFile.getAbsolutePath() + " does not exist");
assertTrue(false);
}
- _boot = new StandAloneBootStrapper(deploymentConfigFile, validationFileName);
-
- logger.info("Testing to see if we can instantiate and start ListenerManager");
- } catch (Throwable e) {
+ _boot = new StandAloneBootStrapper(deploymentConfigFile,
+ validationFileName);
+
+ logger
+ .info("Testing to see if we can instantiate and start ListenerManager");
+ }
+ catch (Throwable e)
+ {
e.printStackTrace();
- System.out.println("We should stop testing, since we don't have a db.");
+ System.out
+ .println("We should stop testing, since we don't have a db.");
assertTrue(false);
}
-
-
+
}
-
+
/**
* Shutdown the database
+ *
* @throws Exception
*/
@AfterClass
- public static void runAfterAllTests() throws Exception {
- //Increase Sleep for debugging
+ public static void runAfterAllTests() throws Exception
+ {
+ // Increase Sleep for debugging
_boot.requestEnd();
- //Give the esb time to finish
+ // Give the esb time to finish
Thread.sleep(2000);
- //Cleaning up the generated files
+ // Cleaning up the generated files
String listenerConfigFile = TestEnvironmentUtil.getUserDir("qa")
- + "junit/src/org/jboss/soa/esb/listeners/message/jbossesb-listener.xml";
+ + "junit/src/org/jboss/soa/esb/listeners/message/jbossesb-listener.xml";
File listenerFile = new File(listenerConfigFile);
- if (listenerFile.exists()) listenerFile.delete();
+ if (listenerFile.exists())
+ listenerFile.delete();
String gatewayConfigFile = TestEnvironmentUtil.getUserDir("qa")
- + "junit/src/org/jboss/soa/esb/listeners/message/jbossesb-gateway.xml";
+ + "junit/src/org/jboss/soa/esb/listeners/message/jbossesb-gateway.xml";
File gatewayFile = new File(gatewayConfigFile);
- if (gatewayFile.exists()) gatewayFile.delete();
+ if (gatewayFile.exists())
+ gatewayFile.delete();
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
+ if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
+ {
HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
}
}
Modified: labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/messagestore/HsqldbUtil.java
===================================================================
--- labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/messagestore/HsqldbUtil.java 2007-01-17 02:13:38 UTC (rev 8880)
+++ labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/messagestore/HsqldbUtil.java 2007-01-17 14:41:14 UTC (rev 8881)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.soa.esb.messagestore;
import java.sql.DriverManager;
Modified: labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/objpersist/DrainQueuesAndTopics.java
===================================================================
--- labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/objpersist/DrainQueuesAndTopics.java 2007-01-17 02:13:38 UTC (rev 8880)
+++ labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/objpersist/DrainQueuesAndTopics.java 2007-01-17 14:41:14 UTC (rev 8881)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.soa.esb.objpersist;
import javax.jms.Message;
Modified: labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/rosetta/Util.java
===================================================================
--- labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/rosetta/Util.java 2007-01-17 02:13:38 UTC (rev 8880)
+++ labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/rosetta/Util.java 2007-01-17 14:41:14 UTC (rev 8881)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.soa.esb.rosetta;
import java.io.ByteArrayOutputStream;
Modified: labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/util/JMSClientUtil.java
===================================================================
--- labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/util/JMSClientUtil.java 2007-01-17 02:13:38 UTC (rev 8880)
+++ labs/jbossesb/workspace/mlittle/harden/qa/junit/src/org/jboss/soa/esb/util/JMSClientUtil.java 2007-01-17 14:41:14 UTC (rev 8881)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.soa.esb.util;
import java.io.Serializable;
More information about the jboss-svn-commits
mailing list