[jboss-svn-commits] JBL Code SVN: r6695 - in labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb: actions listeners

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Oct 8 15:30:54 EDT 2006


Author: jokum
Date: 2006-10-08 15:30:52 -0400 (Sun, 08 Oct 2006)
New Revision: 6695

Added:
   labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/actions/EchoRouter.java
   labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ComplexObject.java
   labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/HttpListenerUnitTest.java
   labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/HttpListenerUnitTest.xml
Log:
HttpListener test added

Added: labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/actions/EchoRouter.java
===================================================================
--- labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/actions/EchoRouter.java	2006-10-08 19:30:15 UTC (rev 6694)
+++ labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/actions/EchoRouter.java	2006-10-08 19:30:52 UTC (rev 6695)
@@ -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.actions;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * Echo object processor.
+ * 
+ * This processor implementation echoes the message being send to this processor.
+ * 
+ * @author <a href="mailto:johan.kumps at telenet.be">Johan Kumps</a>
+ */
+public class EchoRouter implements ActionProcessor {
+	
+	private Logger logger = Logger.getLogger(this.getClass());
+
+	/**
+	 * Public constructor.
+	 * 
+	 * @param actionName
+	 *            Action name.
+	 * @param properties
+	 *            Action Properties.
+	 * @throws ConfigurationException
+	 *             Action not properly configured.
+	 */
+	public EchoRouter(String actionName, List<KeyValuePair> properties)
+			throws ConfigurationException {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+	 */
+	public Message process(Message message) throws ActionProcessingException {
+		this.logger.info("EchoRouter echoing " + message);		
+		return message;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+	 */
+	public Serializable getOkNotification(Message message) {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+	 */
+	public Serializable getErrorNotification(Message message) {
+		return null;
+	}
+
+}

Added: labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ComplexObject.java
===================================================================
--- labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ComplexObject.java	2006-10-08 19:30:15 UTC (rev 6694)
+++ labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ComplexObject.java	2006-10-08 19:30:52 UTC (rev 6695)
@@ -0,0 +1,67 @@
+package org.jboss.soa.esb.listeners;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
+ */
+public class ComplexObject implements Serializable
+{
+   public int i = 42;
+   public String s = "test";
+   public boolean b = true;
+   public byte[] bytes = new byte[0];
+
+   public ComplexObject()
+   {
+
+   }
+
+   public ComplexObject(int i, String s, boolean b)
+   {
+      this.i = i;
+      this.s = s;
+      this.b = b;
+   }
+
+   public ComplexObject(int i, String s, boolean b, int byteSize)
+   {
+      this(i, s, b);
+      bytes = new byte[byteSize];
+   }
+
+   public void setBytes(byte[] bytes)
+   {
+      this.bytes = bytes;
+   }
+
+   public int getSize()
+   {
+      return bytes.length;
+   }
+
+   public String toString()
+   {
+      return "ComplexObject (i = " + i + ", s = " + s + ", b = " + b + ", bytes.length = " + bytes.length + ")";
+   }
+
+   public boolean equals(Object o)
+   {
+      if(o instanceof ComplexObject)
+      {
+         ComplexObject co = (ComplexObject) o;
+         if(co.i == i && co.s.equals(s) && co.b == b)
+         {
+            return true;
+         }
+         else
+         {
+            return false;
+         }
+      }
+      else
+      {
+         return false;
+      }
+   }
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/HttpListenerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/HttpListenerUnitTest.java	2006-10-08 19:30:15 UTC (rev 6694)
+++ labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/HttpListenerUnitTest.java	2006-10-08 19:30:52 UTC (rev 6695)
@@ -0,0 +1,114 @@
+/*
+ * 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.IOException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.soa.esb.helpers.DomElement;
+import org.xml.sax.SAXException;
+
+/**
+ * Test the HttpListener
+ * 
+ * @author <a href="mailto:johan.kumps at telenet.be">Johan Kumps</a>
+ */
+public class HttpListenerUnitTest extends TestCase {
+
+	/** The Logger. */
+	protected Logger log = Logger.getLogger(getClass());
+
+	/**
+	 * Test basic construction.
+	 * 
+	 * @throws Exception
+	 */
+	 public void test_Empty_Construction() throws Exception {
+		log.info("Constructing instance of HttpListener");
+		// This should fail
+		@SuppressWarnings("unused")
+		HttpListener httpListener = null;
+		try {
+			httpListener = new HttpListener(null, null, null);
+			fail("HttpListener should fail with empty constructor string");
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public void test_Construction() throws Exception {
+
+		DomElement domElement = DomElement.fromInputStream(getClass()
+				.getResourceAsStream("HttpListenerUnitTest.xml"));
+
+		log.info("Loaded - " + domElement.toXml());
+	}
+	
+	public void test_Invocation() throws Exception {
+		
+		Thread test = new Thread(){
+			public void run(){
+				DomElement domElement;
+				try {
+					domElement = domElement = DomElement.fromInputStream(getClass()
+								.getResourceAsStream("HttpListenerUnitTest.xml"));
+					GpListener gpListener = new GpListener(domElement);
+					gpListener.run();
+				} catch (SAXException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				} catch (Exception e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		};
+		test.start();
+
+		ComplexObject testObject = new ComplexObject(2, "foo", true);
+
+		String locatorURI = "http://localhost:5400";
+		InvokerLocator locator = new InvokerLocator(locatorURI);
+
+		Client remotingClient = new Client(locator);
+		remotingClient.connect();
+
+		Object response;
+		try {
+			response = remotingClient.invoke(testObject, null);
+			Assert.assertEquals(testObject, response);
+		} catch (Throwable e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+	}
+
+}

Added: labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/HttpListenerUnitTest.xml
===================================================================
--- labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/HttpListenerUnitTest.xml	2006-10-08 19:30:15 UTC (rev 6694)
+++ labs/jbossesb/workspace/jokum/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/HttpListenerUnitTest.xml	2006-10-08 19:30:52 UTC (rev 6695)
@@ -0,0 +1,13 @@
+<JBossESB parameterReloadSecs="9999">	
+	<HttpListenerTest listenerClass="org.jboss.soa.esb.listeners.HttpListener" actions="HttpInvocationToFile, Echo" maxThreads="35"/>
+	<Actions>
+		<Action name="HttpInvocationToFile" processor="ObjectToFileWriter">
+			<property name="file" value="file:///D:/"/>
+		</Action>
+		<Action name="Echo" processor="EchoRouter"/>
+		<ProcessorAliases>
+			<Alias name="EchoRouter" class="org.jboss.soa.esb.actions.EchoRouter"/>
+			<Alias name="ObjectToFileWriter" class="org.jboss.soa.esb.actions.routing.ObjectToFileWriter"/>
+		</ProcessorAliases>
+	</Actions>
+</JBossESB>




More information about the jboss-svn-commits mailing list