[jboss-svn-commits] JBL Code SVN: r7301 - in labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb: . actions listeners
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Nov 1 18:08:42 EST 2006
Author: jokum
Date: 2006-11-01 18:08:40 -0500 (Wed, 01 Nov 2006)
New Revision: 7301
Added:
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/MessageBox.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/HttpListenerConfig.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/HttpListenerTest.java
Log:
QA test for HttpListener
Added: 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 2006-11-01 23:07:46 UTC (rev 7300)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/MessageBox.java 2006-11-01 23:08:40 UTC (rev 7301)
@@ -0,0 +1,97 @@
+/*
+ * 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.io.Serializable;
+import java.util.List;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.actions.ActionUtils;
+import org.jboss.soa.esb.message.Message;
+
+import org.jboss.soa.esb.helpers.ConfigTree;
+
+/**
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class MessageBox implements ActionProcessor {
+
+ 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);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Message message) {
+ return "OK" + ActionUtils.getTaskObject(message);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Message message) {
+ return "Error" + ActionUtils.getTaskObject(message);
+ }
+
+}
Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/HttpListenerConfig.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/HttpListenerConfig.xml 2006-11-01 23:07:46 UTC (rev 7300)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/HttpListenerConfig.xml 2006-11-01 23:08:40 UTC (rev 7301)
@@ -0,0 +1,14 @@
+<JBossESB parameterReloadSecs="60000"
+ commandConnFactoryClass="ConnectionFactory"
+ commandJndiType="jboss"
+ commandJndiURL="localhost"
+ commandIsTopic="false"
+ messageSelector="gpMsgSelector='test'"
+ commandJndiName="queue/A"
+ >
+
+ <HttpListenerTest listenerClass="org.jboss.soa.esb.listeners.message.HttpListener" actions="HttpInvocationToFile">
+ <action class="org.jboss.soa.esb.actions.MessageBox" />
+ <action class="org.jboss.soa.esb.actions.routing.EchoRouter"/>
+ </HttpListenerTest>
+</JBossESB>
\ No newline at end of file
Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/HttpListenerTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/HttpListenerTest.java 2006-11-01 23:07:46 UTC (rev 7300)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/HttpListenerTest.java 2006-11-01 23:08:40 UTC (rev 7301)
@@ -0,0 +1,72 @@
+/*
+ * 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;
+
+import junit.framework.TestCase;
+
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.soa.esb.actions.MessageBox;
+import org.jboss.soa.esb.util.ClassUtils;
+import org.jboss.soa.esb.util.ListenerUtils;
+import org.jboss.soa.esb.util.ListenerUtils.ListenersManagerExecThread;
+
+/**
+ * QA Tests for the HttpListener.
+ *
+ */
+public class HttpListenerTest extends TestCase {
+
+ private ListenersManagerExecThread listenersMgr;
+
+ protected void setUp() throws Exception {
+ // Start the listener...
+// Start the listener...
+ System.out.println("-->" + ClassUtils.toResourcePath(getClass().getPackage()) );
+ listenersMgr = ListenerUtils.startListeners("\\org\\jboss\\soa\\esb\\listeners\\HttpListenerConfig.xml");
+ }
+
+ public void test() throws Throwable {
+
+ // There should have been no exceptions...
+ listenersMgr.assertNotInException();
+
+ MessageBox.messages.clear();
+ String locatorURI = "http://localhost:5400";
+ InvokerLocator locator = new InvokerLocator(locatorURI);
+
+ Client remotingClient = new Client(locator);
+ remotingClient.connect();
+
+ remotingClient.invoke("test string", null);
+
+ MessageBox.assertMessageCount(1, 10000);
+
+ // There should have been no exceptions...
+ listenersMgr.assertNotInException();
+
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+}
More information about the jboss-svn-commits
mailing list