[jboss-svn-commits] JBL Code SVN: r13655 - in labs/jbossesb/trunk: product/rosetta/tests/src/org/jboss/soa/esb/actions and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 19 19:22:11 EDT 2007
Author: kurt.stam at jboss.com
Date: 2007-07-19 19:22:11 -0400 (Thu, 19 Jul 2007)
New Revision: 13655
Added:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/Util.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/rosetta/
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/rosetta/pooling/
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingIntegrationTest.java
Removed:
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/MessageBox.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/MessageBox.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/objpersist/DrainQueuesAndTopics.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/MessageAttachmentSerializeTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/MessagePropertiesSerializeTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/Util.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingTest.java
Log:
JBESB-613, moving the unittests from qa over into product as integration tests
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -0,0 +1,270 @@
+/*
+ * 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.actions;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.InputStream;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Properties;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.MalformedEPRException;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.couriers.Courier;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.listeners.StandAloneBootStrapper;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.services.registry.Registry;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.RegistryFactory;
+import org.jboss.soa.esb.testutils.FileUtil;
+import org.jboss.soa.esb.testutils.HsqldbUtil;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * 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 AggregatorIntegrationTest
+{
+ private static Logger logger = Logger.getLogger(AggregatorIntegrationTest.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 = "SplitterService";
+
+ /**
+ * Testing the Content Based Router.
+ */
+ @Test
+ public void sendMessages()
+ {
+ try
+ {
+ sendMessage("<message>First Message</message>");
+ // The second time the rulesEngine should be primed.
+ sendMessage("<message>Second Message</message>");
+ }
+ catch (RegistryException re)
+ {
+ re.printStackTrace();
+ assertTrue(false);
+ }
+ 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 RegistryException
+ * @throws CourierException
+ * @throws MalformedEPRException
+ */
+
+ private static void sendMessage(String body) throws RegistryException, CourierException, MalformedEPRException
+ {
+ Message msg = MessageFactory.getInstance().getMessage();
+ msg.getBody().setByteArray(body.getBytes());
+
+ Registry registry = RegistryFactory.getRegistry();
+ EPR epr = registry.findEPR(SERVICE_CATEGORY_NAME,
+ SERVICE_NAME);
+ Courier courier = CourierFactory.getCourier(epr);
+ courier.deliver(msg);
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(AggregatorIntegrationTest.class);
+ }
+
+ @BeforeClass
+ public static void runBeforeAllTests()
+ {
+ System.setProperty("com.arjuna.common.util.propertyservice.verbosePropertyManager", "on");
+ try
+ {
+ TestEnvironmentUtil.setESBPropertiesFileToUse();
+
+ logger.info(Configuration.dump());
+
+ logger.info(Configuration.getRegistryImplementationClass());
+ // 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-unittest.properties";
+ System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
+ // Read this properties file to get the db connection string
+ Properties props = new Properties();
+ 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))
+ {
+ 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))
+ {
+ 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
+ {
+ Class.forName(mDbDriver);
+ }
+ 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);
+ Statement stmnt = con.createStatement();
+ System.out.println("Dropping the schema if exist");
+ stmnt.execute(sqlDropCmd);
+ System.out.println("Creating the juddi-schema");
+ stmnt.execute(sqlCreateCmd);
+ System.out.println("Adding the jbossesb publisher");
+ stmnt.execute(sqlInsertPubCmd);
+
+ // Now we can bring up the ContentBasedRouter
+ String deploymentConfigFile = TestEnvironmentUtil.getUserDir("product")
+ + "rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml";
+ String validationFileName = TestEnvironmentUtil.getUserDir(
+ "product", "../product")
+ + "/etc/schemas/xml/jbossesb-1.0.1.xsd";
+ // Make sure this file exists
+ File validationFile = new File(validationFileName);
+ 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)
+ {
+ e.printStackTrace();
+ 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
+ {
+ Thread.sleep(2000);
+ // Increase Sleep for debugging
+ _boot.requestEnd();
+ // Give the esb time to finish
+ Thread.sleep(2000);
+ // Cleaning up the generated files
+ String listenerConfigFile = TestEnvironmentUtil.getUserDir("product")
+ + "junit/src/org/jboss/soa/esb/actions/jbossesb-listener.xml";
+ File listenerFile = new File(listenerConfigFile);
+ if (listenerFile.exists())
+ listenerFile.delete();
+ String gatewayConfigFile = TestEnvironmentUtil.getUserDir("product")
+ + "junit/src/org/jboss/soa/esb/actions/jbossesb-gateway.xml";
+ File gatewayFile = new File(gatewayConfigFile);
+ if (gatewayFile.exists())
+ gatewayFile.delete();
+
+ if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
+ {
+ HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
+ }
+ }
+
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml (from rev 13645, labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.xml)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml 2007-07-19 23:22:11 UTC (rev 13655)
@@ -0,0 +1,83 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
+parameterReloadSecs="10">
+
+ <!-- for activemq use:
+ jndi-context-factory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ jndi-URL="tcp://localhost:61616" -->
+
+ <!-- for mq series use:
+ jndi-context-factory="com.ibm.mq.jms.context.WMQInitialContextFactory"
+ jndi-URL="dev37:1414/SYSTEM.DEF.SVRCONN" -->
+
+ <!-- for jbossmq use:
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost" -->
+
+
+ <providers>
+ <jms-provider name="localhost"
+ connection-factory="ConnectionFactory"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost" >
+
+ <jms-bus busid="QueueA">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/A"
+ />
+ </jms-bus>
+ <jms-bus busid="QueueB">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/B"
+ />
+ </jms-bus>
+ </jms-provider>
+ </providers>
+ <services>
+ <service
+ category="Aggregation"
+ name="Aggregrator"
+ description="Aggregates messages">
+ <listeners>
+ <jms-listener name="AggregatorListenQueue" busidref="QueueA"
+ maxThreads="1">
+ </jms-listener>
+ </listeners>
+ <actions>
+ <action class="org.jboss.soa.esb.actions.Aggregator" name="Aggregator">
+ <property name="timeoutInMillies" value="60000"/>
+ </action>
+ <action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="An aggregated message was created" />
+ </action>
+ <!-- add transformation action to aggregate the attachments into 1 message -->
+ </actions>
+ </service>
+ <service
+ category="MessageRouting"
+ name="SplitterService"
+ description="Sends messages to 2 destinations">
+ <listeners>
+ <jms-listener name="SplitterListenQueue"
+ busidref="QueueB"
+ maxThreads="1">
+ </jms-listener>
+ </listeners>
+ <actions>
+ <action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="Hello Static Router" />
+ </action>
+ <action process="split" class="org.jboss.soa.esb.actions.StaticRouter" name="StaticRouter">
+ <property name="destinations">
+ <!-- send 2 copies straight to the aggregator, in reality you would route
+ them through maybe a transformer and another service first -->
+ <route-to service-category="Aggregation" service-name="Aggregrator" />
+ <route-to service-category="Aggregation" service-name="Aggregrator" />
+ </property>
+ </action>
+ </actions>
+ </service>
+ </services>
+</jbossesb>
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -0,0 +1,116 @@
+/*
+ * 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.message;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.message.Attachment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * QA tests for the Message interface and implementations.
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class MessageAttachmentSerializeTest extends TestCase
+{
+
+ protected void setUp() throws Exception
+ {
+ }
+
+ public void runTest() throws Exception
+ {
+ testJavaSerializable();
+ testXml();
+ }
+
+ private static final File TESTFILE = new File("msgAttachment.test");
+ protected void tearDown() throws Exception
+ {
+ TESTFILE.delete();
+ }
+
+ public void testJavaSerializable() throws Exception
+ {
+ org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
+ old = new org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl();
+ populateAttachment(old);
+ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
+ out.writeObject(old);
+ out.close();
+
+ ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
+ org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
+ oNew = (org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl)
+ inp.readObject();
+ inp.close();
+
+ assertEquals(old,oNew);
+ }
+
+ public void testXml() throws Exception
+ {
+ DocumentBuilder oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document oDoc = oDB.newDocument();
+ Element oRoot = oDoc.createElement("root");
+ oDoc.appendChild(oRoot);
+
+ org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl
+ old = new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
+ populateAttachment(old);
+ old.toXML(oRoot);
+
+ org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl
+ oNew = new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
+ oNew.fromXML(oRoot);
+
+ assertEquals(old,oNew);
+
+ Document oD2 = oDB.newDocument();
+ Element oR2 = oD2.createElement("root");
+ oD2.appendChild(oR2);
+ oNew.toXML(oR2);
+
+ String s1 = Util.toString(oRoot);
+ String s2 = Util.toString(oR2);
+ assertEquals(s1,s2);
+ }
+
+ private void populateAttachment(Attachment att)
+ {
+ att.addItem("unnamed att 1");
+ att.put("name 2","N2N2N2N2N2N2N2N2");
+ att.addItem("unn 2");
+ att.put("name 1","named att 111111111111111");
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -0,0 +1,113 @@
+/*
+ * 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.message;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * QA tests for the Message interface and implementations.
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class MessagePropertiesSerializeTest extends TestCase
+{
+
+ protected void setUp() throws Exception
+ {
+ }
+
+ public void runTest() throws Exception
+ {
+ testJavaSerializable();
+ testXml();
+ }
+
+ private static final File TESTFILE = new File("msgProperties.test");
+ protected void tearDown() throws Exception
+ {
+ TESTFILE.delete();
+ }
+
+ public void testJavaSerializable() throws Exception
+ {
+ org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl
+ old = new org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl();
+ populateProperties(old);
+ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
+ out.writeObject(old);
+ out.close();
+
+ ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
+ org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl
+ oNew = (org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl)
+ inp.readObject();
+ inp.close();
+
+ assertEquals(old,oNew);
+ }
+
+ public void testXml() throws Exception
+ {
+ DocumentBuilder oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document oDoc = oDB.newDocument();
+ Element oRoot = oDoc.createElement("root");
+ oDoc.appendChild(oRoot);
+
+ org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl
+ old = new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
+ populateProperties(old);
+ old.toXML(oRoot);
+
+ org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl
+ oNew = new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
+ oNew.fromXML(oRoot);
+
+ assertEquals(old,oNew);
+
+ Document oD2 = oDB.newDocument();
+ Element oR2 = oD2.createElement("root");
+ oD2.appendChild(oR2);
+ oNew.toXML(oR2);
+
+ String s1 = Util.toString(oRoot);
+ String s2 = Util.toString(oR2);
+ assertEquals(s1,s2);
+ }
+
+ private void populateProperties(org.jboss.soa.esb.message.Properties props)
+ {
+ props.setProperty("p1","VALUE OF PROP 1");
+ props.setProperty("p2","VALUE 222");
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/Util.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/Util.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/Util.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -0,0 +1,50 @@
+/*
+ * 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.message;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Element;
+
+public class Util
+{
+ public static String toString(Element elem) throws Exception
+ {
+ DOMSource src = new DOMSource(elem.getOwnerDocument());
+
+ ByteArrayOutputStream oStrm = new ByteArrayOutputStream(5000);
+ StreamResult res = new StreamResult(oStrm);
+
+ Transformer TT = TransformerFactory.newInstance().newTransformer();
+ TT.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ TT.setOutputProperty(OutputKeys.INDENT, "no");
+ TT.transform(src, res);
+ return (oStrm.toString());
+ } // __________________________________
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/Util.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingIntegrationTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingIntegrationTest.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -0,0 +1,127 @@
+/*
+* 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.pooling;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+
+import javax.jms.Session;
+import javax.naming.Context;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool;
+import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.helpers.NamingContext;
+import org.junit.Test;
+
+/**
+ * @author kstam
+ *
+ */
+public class JmsConnectionPoolingIntegrationTest {
+
+ @Test
+ public void testPoolAndConnectionCreation()
+ {
+ JmsConnectionPool jmsConnectionPool = null;
+ try {
+ Properties environment = new Properties();
+ environment.setProperty(Context.PROVIDER_URL, NamingContext.JBOSS_PROVIDER_URL);
+ environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, NamingContext.JBOSS_INITIAL_CONTEXT_FACTORY);
+ environment.setProperty(Context.URL_PKG_PREFIXES, NamingContext.JBOSS_URL_PKG_PREFIX);
+
+ jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment,"ConnectionFactory", JMSEpr.QUEUE_TYPE);
+ assertEquals(0, jmsConnectionPool.getSessionsInPool());
+ //Open 3 concurrent sessions
+ Session session1 = jmsConnectionPool.getQueueSession();
+ assertEquals(1, jmsConnectionPool.getSessionsInPool());
+ Session session2 = jmsConnectionPool.getQueueSession();
+ assertEquals(2, jmsConnectionPool.getSessionsInPool());
+ Session session3 = jmsConnectionPool.getQueueSession();
+ assertEquals(3, jmsConnectionPool.getSessionsInPool());
+ //Close them
+ jmsConnectionPool.closeSession(session1);
+ jmsConnectionPool.closeSession(session2);
+ jmsConnectionPool.closeSession(session3);
+ assertEquals(3, jmsConnectionPool.getSessionsInPool());
+ //destroy this pool
+ jmsConnectionPool.removeSessionPool();
+ assertEquals(0, jmsConnectionPool.getSessionsInPool());
+ assertEquals(0, JmsConnectionPoolContainer.getNumberOfPools());
+
+ //Use it again and add one session
+ jmsConnectionPool.getQueueSession();
+ assertEquals(1, jmsConnectionPool.getSessionsInPool());
+ assertEquals(1, JmsConnectionPoolContainer.getNumberOfPools());
+ //I should be able to remove the entire pool and have it do closing
+ //of the session.
+ jmsConnectionPool.removeSessionPool();
+ } catch (Exception e) {
+ assertTrue(false);
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCreateSecondPool()
+ {
+
+ try {
+ Properties environment = new Properties();
+ environment.setProperty(Context.PROVIDER_URL, NamingContext.JBOSS_PROVIDER_URL);
+ environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, NamingContext.JBOSS_INITIAL_CONTEXT_FACTORY);
+ environment.setProperty(Context.URL_PKG_PREFIXES, NamingContext.JBOSS_URL_PKG_PREFIX);
+ JmsConnectionPool jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory", JMSEpr.QUEUE_TYPE);
+ jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory", JMSEpr.QUEUE_TYPE);
+ //This should be the same pool
+ assertEquals(1, JmsConnectionPoolContainer.getNumberOfPools());
+
+ jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory", JMSEpr.TOPIC_TYPE);
+ //This should be a different pool, so now we should have 2.
+ assertEquals(2, JmsConnectionPoolContainer.getNumberOfPools());
+
+ jmsConnectionPool = JmsConnectionPoolContainer.getPool(null, "ConnectionFactory", JMSEpr.TOPIC_TYPE);
+ //This should be a different pool, so now we should have 3.
+ assertEquals(3, JmsConnectionPoolContainer.getNumberOfPools());
+
+ //Now lets cleanup after ourselves
+ jmsConnectionPool.removeSessionPool();
+ assertEquals(2, JmsConnectionPoolContainer.getNumberOfPools());
+
+ //Let's clean the rest up with a removeAll.
+ JmsConnectionPoolContainer.removeAllPools();
+ assertEquals(0, JmsConnectionPoolContainer.getNumberOfPools());
+ } catch (Exception e) {
+ assertTrue(false);
+ e.printStackTrace();
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(JmsConnectionPoolingIntegrationTest.class);
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingIntegrationTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.java 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,275 +0,0 @@
-/*
- * 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.actions;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.InputStream;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.Properties;
-
-import junit.framework.JUnit4TestAdapter;
-
-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.common.Configuration;
-import org.jboss.soa.esb.couriers.Courier;
-import org.jboss.soa.esb.couriers.CourierException;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.listeners.StandAloneBootStrapper;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.services.registry.Registry;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.RegistryFactory;
-import org.jboss.soa.esb.testutils.FileUtil;
-import org.jboss.soa.esb.testutils.HsqldbUtil;
-import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * 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 AggregatorTest
-{
- private static Logger logger = Logger.getLogger(AggregatorTest.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 = "SplitterService";
-
- /**
- * Testing the Content Based Router.
- */
- @Test
- public void sendMessages()
- {
- try
- {
- sendMessage("<message>First Message</message>");
- // The second time the rulesEngine should be primed.
- sendMessage("<message>Second Message</message>");
- }
- catch (RegistryException re)
- {
- re.printStackTrace();
- assertTrue(false);
- }
- 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 RegistryException
- * @throws CourierException
- * @throws MalformedEPRException
- */
-
- private static void sendMessage(String body) throws RegistryException, CourierException, MalformedEPRException
- {
- Message msg = MessageFactory.getInstance().getMessage();
- msg.getBody().setByteArray(body.getBytes());
-
- Registry registry = RegistryFactory.getRegistry();
- EPR epr = registry.findEPR(SERVICE_CATEGORY_NAME,
- SERVICE_NAME);
- Courier courier = CourierFactory.getCourier(epr);
- courier.deliver(msg);
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(AggregatorTest.class);
- }
-
- @BeforeClass
- public static void runBeforeAllTests()
- {
- System.setProperty("com.arjuna.common.util.propertyservice.verbosePropertyManager", "on");
- try
- {
- DOMConfigurator.configure(TestEnvironmentUtil.getUserDir("product",
- "../product")
- + "etc/test/resources/log4j.xml");
- TestEnvironmentUtil.setESBPropertiesFileToUse("product",
- "../product");
-
- logger.info(Configuration.dump());
-
- logger.info(Configuration.getRegistryImplementationClass());
- // 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
- Properties props = new Properties();
- 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))
- {
- 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))
- {
- 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
- {
- Class.forName(mDbDriver);
- }
- 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);
- Statement stmnt = con.createStatement();
- System.out.println("Dropping the schema if exist");
- stmnt.execute(sqlDropCmd);
- System.out.println("Creating the juddi-schema");
- stmnt.execute(sqlCreateCmd);
- System.out.println("Adding the jbossesb publisher");
- stmnt.execute(sqlInsertPubCmd);
-
- // Now we can bring up the ContentBasedRouter
- String deploymentConfigFile = TestEnvironmentUtil.getUserDir("qa")
- + "junit/src/org/jboss/soa/esb/actions/AggregatorTest.xml";
- String validationFileName = TestEnvironmentUtil.getUserDir(
- "product", "../product")
- + "etc/schemas/xml/jbossesb-1.0.1.xsd";
- // Make sure this file exists
- File validationFile = new File(validationFileName);
- 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)
- {
- e.printStackTrace();
- 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
- {
- Thread.sleep(2000);
- // Increase Sleep for debugging
- _boot.requestEnd();
- // Give the esb time to finish
- Thread.sleep(2000);
- // Cleaning up the generated files
- String listenerConfigFile = TestEnvironmentUtil.getUserDir("qa")
- + "junit/src/org/jboss/soa/esb/actions/jbossesb-listener.xml";
- File listenerFile = new File(listenerConfigFile);
- if (listenerFile.exists())
- listenerFile.delete();
- String gatewayConfigFile = TestEnvironmentUtil.getUserDir("qa")
- + "junit/src/org/jboss/soa/esb/actions/jbossesb-gateway.xml";
- File gatewayFile = new File(gatewayConfigFile);
- if (gatewayFile.exists())
- gatewayFile.delete();
-
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
- {
- HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
- }
- }
-
-}
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.xml 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/AggregatorTest.xml 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,83 +0,0 @@
-<?xml version = "1.0" encoding = "UTF-8"?>
-<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
-parameterReloadSecs="10">
-
- <!-- for activemq use:
- jndi-context-factory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- jndi-URL="tcp://localhost:61616" -->
-
- <!-- for mq series use:
- jndi-context-factory="com.ibm.mq.jms.context.WMQInitialContextFactory"
- jndi-URL="dev37:1414/SYSTEM.DEF.SVRCONN" -->
-
- <!-- for jbossmq use:
- jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
- jndi-URL="localhost" -->
-
-
- <providers>
- <jms-provider name="localhost"
- connection-factory="ConnectionFactory"
- jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
- jndi-URL="localhost" >
-
- <jms-bus busid="QueueA">
- <jms-message-filter
- dest-type="QUEUE"
- dest-name="queue/A"
- />
- </jms-bus>
- <jms-bus busid="QueueB">
- <jms-message-filter
- dest-type="QUEUE"
- dest-name="queue/B"
- />
- </jms-bus>
- </jms-provider>
- </providers>
- <services>
- <service
- category="Aggregation"
- name="Aggregrator"
- description="Aggregates messages">
- <listeners>
- <jms-listener name="AggregatorListenQueue" busidref="QueueA"
- maxThreads="1">
- </jms-listener>
- </listeners>
- <actions>
- <action class="org.jboss.soa.esb.actions.Aggregator" name="Aggregator">
- <property name="timeoutInMillies" value="60000"/>
- </action>
- <action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
- <property name="message" value="An aggregated message was created" />
- </action>
- <!-- add transformation action to aggregate the attachments into 1 message -->
- </actions>
- </service>
- <service
- category="MessageRouting"
- name="SplitterService"
- description="Sends messages to 2 destinations">
- <listeners>
- <jms-listener name="SplitterListenQueue"
- busidref="QueueB"
- maxThreads="1">
- </jms-listener>
- </listeners>
- <actions>
- <action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
- <property name="message" value="Hello Static Router" />
- </action>
- <action process="split" class="org.jboss.soa.esb.actions.StaticRouter" name="StaticRouter">
- <property name="destinations">
- <!-- send 2 copies straight to the aggregator, in reality you would route
- them through maybe a transformer and another service first -->
- <route-to service-category="Aggregation" service-name="Aggregrator" />
- <route-to service-category="Aggregation" service-name="Aggregrator" />
- </property>
- </action>
- </actions>
- </service>
- </services>
-</jbossesb>
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/MessageBox.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/MessageBox.java 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/MessageBox.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,77 +0,0 @@
-/*
- * 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.actions;
-
-import java.util.List;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-
-/**
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class MessageBox extends AbstractActionPipelineProcessor {
-
- private static Logger logger = Logger.getLogger(MessageBox.class);
- public static List<Object> messages = new Vector<Object>();
-
- public MessageBox(ConfigTree config){
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
- */
- public Message process(Message message) throws ActionProcessingException {
- Object oCurr = ActionUtils.getTaskObject(message);
- if (null==oCurr)
- oCurr="<null>";
- logger.info("MessageBox received message: " + message);
- messages.add(oCurr);
- return message;
- }
-
- public static void assertMessageCount(int count, long maxWait) {
- long endTime = System.currentTimeMillis() + maxWait;
-
- while(System.currentTimeMillis() < endTime) {
- if(messages.size() == count) {
- return;
- }
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- logger.error("Thread interupt...", e);
- }
- }
- String errorMsg = "MessageBox failed to receive " + count + " messages. Message count = " + messages.size() + ". Waited for " + maxWait + "ms.";
- logger.error(errorMsg);
- TestCase.fail(errorMsg);
- }
-}
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/MessageBox.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/MessageBox.java 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/MessageBox.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,80 +0,0 @@
-/*
- * 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 java.util.List;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.actions.ActionUtils;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-
-/**
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class MessageBox extends AbstractActionPipelineProcessor {
-
- private static Logger logger = Logger.getLogger(MessageBox.class);
- public static List<Object> messages = new Vector<Object>();
-
- public MessageBox(ConfigTree configTree){
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
- */
- public Message process(Message message) throws ActionProcessingException {
- Object oCurr = ActionUtils.getTaskObject(message);
- if (null==oCurr)
- oCurr="<null>";
- logger.info("MessageBox received message: " + message);
- messages.add(oCurr);
- return message;
- }
-
- public static void assertMessageCount(int count, long maxWait) {
- long endTime = System.currentTimeMillis() + maxWait;
-
- while(System.currentTimeMillis() < endTime) {
- if(messages.size() == count) {
- return;
- }
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- logger.error("Thread interupt...", e);
- }
- }
- String errorMsg = "MessageBox failed to receive " + count + " messages. Message count = " + messages.size() + ". Waited for " + maxWait + "ms.";
- logger.error(errorMsg);
- TestCase.fail(errorMsg);
- }
-}
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/objpersist/DrainQueuesAndTopics.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/objpersist/DrainQueuesAndTopics.java 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/objpersist/DrainQueuesAndTopics.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,126 +0,0 @@
-/*
- * 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 java.util.Properties;
-
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSession;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicConnectionFactory;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
-import javax.naming.Context;
-
-import org.jboss.soa.esb.helpers.NamingContext;
-
-public class DrainQueuesAndTopics
-{
- private static final int MAX_TIMES_NOMSG = 10;
- private Context m_oCtx;
-
- public DrainQueuesAndTopics() throws Exception
- {
- purgeQueueTopic("queue/A");
- purgeQueueTopic("queue/B");
- purgeQueueTopic("topic/testTopic");
- } //__________________________________
-
- public int purgeQueueTopic(String p_sName) throws Exception
- {
- int iRet = 0;
- Properties environment = new Properties();
- environment.setProperty(Context.PROVIDER_URL, NamingContext.JBOSS_PROVIDER_URL);
- environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, NamingContext.JBOSS_INITIAL_CONTEXT_FACTORY);
- environment.setProperty(Context.URL_PKG_PREFIXES, NamingContext.JBOSS_URL_PKG_PREFIX);
- m_oCtx = NamingContext.getServerContext(environment);
-
- System.out.println(p_sName);
- MessageConsumer oCns = null;
- switch(p_sName.toLowerCase().charAt(0))
- { case 't' : oCns = getTopic(p_sName); break;
- case 'q' : oCns = getQueue(p_sName); break;
- }
- if (null==oCns)
- return 0;
-
- for (int iNoRcv=0; iNoRcv < MAX_TIMES_NOMSG; )
- { Message oMsg = oCns.receive(200);
- if (null==oMsg)
- { iNoRcv++;
- System.out.print(".");
- continue;
- }
- iRet++;
- dumpMessage(oMsg);
- iNoRcv = 0;
- }
- System.out.println();
- return iRet;
- } //__________________________________
-
- void dumpMessage(Message pM)
- {
- System.out.println(pM);
- } //__________________________________
-
- QueueReceiver getQueue(String p_sJndi) throws Exception
- {
- QueueConnection oQconn = null;
- QueueSession oQsess = null;
- QueueConnectionFactory qcf = (QueueConnectionFactory) m_oCtx
- .lookup("ConnectionFactory");
-
- oQconn = qcf.createQueueConnection();
- oQsess = oQconn.createQueueSession(false
- ,QueueSession.AUTO_ACKNOWLEDGE);
- javax.jms.Queue oQueue
- = (javax.jms.Queue) m_oCtx.lookup(p_sJndi);
-
- QueueReceiver oRcv = oQsess.createReceiver(oQueue);
- oQconn.start();
- return oRcv;
- } //__________________________________
-
- TopicSubscriber getTopic(String p_sJndi) throws Exception
- {
- TopicConnection oTconn = null;
- TopicSession oTsess = null;
- TopicConnectionFactory qcf = (TopicConnectionFactory) m_oCtx
- .lookup("ConnectionFactory");
-
- oTconn = qcf.createTopicConnection();
- oTsess = oTconn.createTopicSession(false
- ,QueueSession.AUTO_ACKNOWLEDGE);
- Topic oT = (Topic) m_oCtx.lookup(p_sJndi);
-
- TopicSubscriber oRcv = oTsess.createSubscriber(oT);
- oTconn.start();
- return oRcv;
- } //__________________________________
-} //____________________________________________________________________________
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/MessageAttachmentSerializeTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/MessageAttachmentSerializeTest.java 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/MessageAttachmentSerializeTest.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,116 +0,0 @@
-/*
- * 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.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import junit.framework.TestCase;
-
-import org.jboss.soa.esb.message.Attachment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * QA tests for the Message interface and implementations.
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class MessageAttachmentSerializeTest extends TestCase
-{
-
- protected void setUp() throws Exception
- {
- }
-
- public void runTest() throws Exception
- {
- testJavaSerializable();
- testXml();
- }
-
- private static final File TESTFILE = new File("msgAttachment.test");
- protected void tearDown() throws Exception
- {
- TESTFILE.delete();
- }
-
- public void testJavaSerializable() throws Exception
- {
- org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
- old = new org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl();
- populateAttachment(old);
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
- out.writeObject(old);
- out.close();
-
- ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
- org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
- oNew = (org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl)
- inp.readObject();
- inp.close();
-
- assertEquals(old,oNew);
- }
-
- public void testXml() throws Exception
- {
- DocumentBuilder oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document oDoc = oDB.newDocument();
- Element oRoot = oDoc.createElement("root");
- oDoc.appendChild(oRoot);
-
- org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl
- old = new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
- populateAttachment(old);
- old.toXML(oRoot);
-
- org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl
- oNew = new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
- oNew.fromXML(oRoot);
-
- assertEquals(old,oNew);
-
- Document oD2 = oDB.newDocument();
- Element oR2 = oD2.createElement("root");
- oD2.appendChild(oR2);
- oNew.toXML(oR2);
-
- String s1 = Util.toString(oRoot);
- String s2 = Util.toString(oR2);
- assertEquals(s1,s2);
- }
-
- private void populateAttachment(Attachment att)
- {
- att.addItem("unnamed att 1");
- att.put("name 2","N2N2N2N2N2N2N2N2");
- att.addItem("unn 2");
- att.put("name 1","named att 111111111111111");
- }
-}
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/MessagePropertiesSerializeTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/MessagePropertiesSerializeTest.java 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/MessagePropertiesSerializeTest.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,113 +0,0 @@
-/*
- * 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.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import junit.framework.TestCase;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * QA tests for the Message interface and implementations.
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class MessagePropertiesSerializeTest extends TestCase
-{
-
- protected void setUp() throws Exception
- {
- }
-
- public void runTest() throws Exception
- {
- testJavaSerializable();
- testXml();
- }
-
- private static final File TESTFILE = new File("msgProperties.test");
- protected void tearDown() throws Exception
- {
- TESTFILE.delete();
- }
-
- public void testJavaSerializable() throws Exception
- {
- org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl
- old = new org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl();
- populateProperties(old);
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
- out.writeObject(old);
- out.close();
-
- ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
- org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl
- oNew = (org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl)
- inp.readObject();
- inp.close();
-
- assertEquals(old,oNew);
- }
-
- public void testXml() throws Exception
- {
- DocumentBuilder oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document oDoc = oDB.newDocument();
- Element oRoot = oDoc.createElement("root");
- oDoc.appendChild(oRoot);
-
- org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl
- old = new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
- populateProperties(old);
- old.toXML(oRoot);
-
- org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl
- oNew = new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
- oNew.fromXML(oRoot);
-
- assertEquals(old,oNew);
-
- Document oD2 = oDB.newDocument();
- Element oR2 = oD2.createElement("root");
- oD2.appendChild(oR2);
- oNew.toXML(oR2);
-
- String s1 = Util.toString(oRoot);
- String s2 = Util.toString(oR2);
- assertEquals(s1,s2);
- }
-
- private void populateProperties(org.jboss.soa.esb.message.Properties props)
- {
- props.setProperty("p1","VALUE OF PROP 1");
- props.setProperty("p2","VALUE 222");
- }
-}
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/Util.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/Util.java 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/Util.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,50 +0,0 @@
-/*
- * 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;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Element;
-
-public class Util
-{
- public static String toString(Element elem) throws Exception
- {
- DOMSource src = new DOMSource(elem.getOwnerDocument());
-
- ByteArrayOutputStream oStrm = new ByteArrayOutputStream(5000);
- StreamResult res = new StreamResult(oStrm);
-
- Transformer TT = TransformerFactory.newInstance().newTransformer();
- TT.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- TT.setOutputProperty(OutputKeys.INDENT, "no");
- TT.transform(src, res);
- return (oStrm.toString());
- } // __________________________________
-}
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingTest.java 2007-07-19 22:37:54 UTC (rev 13654)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/rosetta/pooling/JmsConnectionPoolingTest.java 2007-07-19 23:22:11 UTC (rev 13655)
@@ -1,127 +0,0 @@
-/*
-* 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.pooling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Properties;
-
-import javax.jms.Session;
-import javax.naming.Context;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool;
-import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.helpers.NamingContext;
-import org.junit.Test;
-
-/**
- * @author kstam
- *
- */
-public class JmsConnectionPoolingTest {
-
- @Test
- public void testPoolAndConnectionCreation()
- {
- JmsConnectionPool jmsConnectionPool = null;
- try {
- Properties environment = new Properties();
- environment.setProperty(Context.PROVIDER_URL, NamingContext.JBOSS_PROVIDER_URL);
- environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, NamingContext.JBOSS_INITIAL_CONTEXT_FACTORY);
- environment.setProperty(Context.URL_PKG_PREFIXES, NamingContext.JBOSS_URL_PKG_PREFIX);
-
- jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment,"ConnectionFactory", JMSEpr.QUEUE_TYPE);
- assertEquals(0, jmsConnectionPool.getSessionsInPool());
- //Open 3 concurrent sessions
- Session session1 = jmsConnectionPool.getQueueSession();
- assertEquals(1, jmsConnectionPool.getSessionsInPool());
- Session session2 = jmsConnectionPool.getQueueSession();
- assertEquals(2, jmsConnectionPool.getSessionsInPool());
- Session session3 = jmsConnectionPool.getQueueSession();
- assertEquals(3, jmsConnectionPool.getSessionsInPool());
- //Close them
- jmsConnectionPool.closeSession(session1);
- jmsConnectionPool.closeSession(session2);
- jmsConnectionPool.closeSession(session3);
- assertEquals(3, jmsConnectionPool.getSessionsInPool());
- //destroy this pool
- jmsConnectionPool.removeSessionPool();
- assertEquals(0, jmsConnectionPool.getSessionsInPool());
- assertEquals(0, JmsConnectionPoolContainer.getNumberOfPools());
-
- //Use it again and add one session
- jmsConnectionPool.getQueueSession();
- assertEquals(1, jmsConnectionPool.getSessionsInPool());
- assertEquals(1, JmsConnectionPoolContainer.getNumberOfPools());
- //I should be able to remove the entire pool and have it do closing
- //of the session.
- jmsConnectionPool.removeSessionPool();
- } catch (Exception e) {
- assertTrue(false);
- e.printStackTrace();
- }
- }
-
- @Test
- public void testCreateSecondPool()
- {
-
- try {
- Properties environment = new Properties();
- environment.setProperty(Context.PROVIDER_URL, NamingContext.JBOSS_PROVIDER_URL);
- environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, NamingContext.JBOSS_INITIAL_CONTEXT_FACTORY);
- environment.setProperty(Context.URL_PKG_PREFIXES, NamingContext.JBOSS_URL_PKG_PREFIX);
- JmsConnectionPool jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory", JMSEpr.QUEUE_TYPE);
- jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory", JMSEpr.QUEUE_TYPE);
- //This should be the same pool
- assertEquals(1, JmsConnectionPoolContainer.getNumberOfPools());
-
- jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory", JMSEpr.TOPIC_TYPE);
- //This should be a different pool, so now we should have 2.
- assertEquals(2, JmsConnectionPoolContainer.getNumberOfPools());
-
- jmsConnectionPool = JmsConnectionPoolContainer.getPool(null, "ConnectionFactory", JMSEpr.TOPIC_TYPE);
- //This should be a different pool, so now we should have 3.
- assertEquals(3, JmsConnectionPoolContainer.getNumberOfPools());
-
- //Now lets cleanup after ourselves
- jmsConnectionPool.removeSessionPool();
- assertEquals(2, JmsConnectionPoolContainer.getNumberOfPools());
-
- //Let's clean the rest up with a removeAll.
- JmsConnectionPoolContainer.removeAllPools();
- assertEquals(0, JmsConnectionPoolContainer.getNumberOfPools());
- } catch (Exception e) {
- assertTrue(false);
- e.printStackTrace();
- }
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(JmsConnectionPoolingTest.class);
- }
-}
More information about the jboss-svn-commits
mailing list