[jboss-svn-commits] JBL Code SVN: r6241 - labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Sep 15 11:43:53 EDT 2006


Author: tfennelly
Date: 2006-09-15 11:43:51 -0400 (Fri, 15 Sep 2006)
New Revision: 6241

Added:
   labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/MessageBox.java
Log:
cleaning up the SQLTable poller stuff.

Added: labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/MessageBox.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/MessageBox.java	2006-09-15 15:43:09 UTC (rev 6240)
+++ labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/MessageBox.java	2006-09-15 15:43:51 UTC (rev 6241)
@@ -0,0 +1,87 @@
+/*
+ * 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 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;
+
+/**
+ * 
+ * @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>(); 
+    
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+     */
+    public Object process(Object message) throws ActionProcessingException {
+        logger.info("MessageBox received message: " + message);
+        messages.add(message);
+        
+        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(Object message) {
+        return "OK" + message;
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+     */
+    public Serializable getErrorNotification(Object message) {
+        return "Error" + message;
+    }
+
+}




More information about the jboss-svn-commits mailing list