Author: dennyxu
Date: 2010-02-08 04:37:50 -0500 (Mon, 08 Feb 2010)
New Revision: 20171
Added:
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/MyJMSListenerAction.java
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SendEsbMessage.java
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SendJMSMessage.java
Log:
JBIDE-5572:Add unit tests for ESB
Added:
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/MyJMSListenerAction.java
===================================================================
---
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/MyJMSListenerAction.java
(rev 0)
+++
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/MyJMSListenerAction.java 2010-02-08
09:37:50 UTC (rev 20171)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.helloworld;
+
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+
+public class MyJMSListenerAction extends AbstractActionLifecycle
+{
+
+ protected ConfigTree _config;
+
+ public MyJMSListenerAction(ConfigTree config) { _config = config; }
+
+
+ public Message displayMessage(Message message) throws Exception{
+
+
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+ System.out.println("Body: " + message.getBody().get()) ;
+
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+ return message;
+
+ }
+
+
+}
\ No newline at end of file
Added:
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SendEsbMessage.java
===================================================================
---
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SendEsbMessage.java
(rev 0)
+++
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SendEsbMessage.java 2010-02-08
09:37:50 UTC (rev 20171)
@@ -0,0 +1,59 @@
+/*
+ * 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.samples.quickstart.helloworld.test;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.client.ServiceInvoker;
+
+/**
+ * Standalone class with to send ESB messages to a 'known' [category,name].
+ * <p/> arg0 - service category
+ * <br/>arg1 - service name
+ * <br/>arg2 - Text of message to send
+ *
+ * @author <a
href="mailto:schifest@heuristica.com.ar">schifest@heuristica.com.ar</a>
+ * @since Version 4.0
+ *
+ */
+public class SendEsbMessage
+{
+ public static void main(String args[]) throws Exception
+ {
+// Setting the ConnectionFactory such that it will use scout
+
System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
+
+ if (args.length < 3)
+ {
+ System.out.println("Usage SendEsbMessage <category> <name>
<text to send>");
+ }
+
+ Message esbMessage = MessageFactory.getInstance().getMessage();
+
+ esbMessage.getBody().add(args[2]);
+
+ new ServiceInvoker(args[0], args[1]).deliverAsync(esbMessage);
+
+ }
+
+}
Added:
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SendJMSMessage.java
===================================================================
---
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SendJMSMessage.java
(rev 0)
+++
trunk/esb/tests/org.jboss.tools.esb.project.core.test/projects/esbTestProject/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SendJMSMessage.java 2010-02-08
09:37:50 UTC (rev 20171)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.helloworld.test;
+
+import java.util.Properties;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class SendJMSMessage {
+ QueueConnection conn;
+ QueueSession session;
+ Queue que;
+
+
+ public void setupConnection() throws JMSException, NamingException
+ {
+ Properties properties1 = new Properties();
+ properties1.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.jnp.interfaces.NamingContextFactory");
+ properties1.put(Context.URL_PKG_PREFIXES,
+ "org.jboss.naming:org.jnp.interfaces");
+ properties1.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
+ InitialContext iniCtx = new InitialContext(properties1);
+
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ que = (Queue) iniCtx.lookup("queue/quickstart_helloworld_Request_gw");
+ session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ System.out.println("Connection Started");
+ }
+
+ public void stop() throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public void sendAMessage(String msg) throws JMSException {
+
+ QueueSender send = session.createSender(que);
+ ObjectMessage tm = session.createObjectMessage(msg);
+
+ send.send(tm);
+ send.close();
+ }
+
+
+ public static void main(String args[]) throws Exception
+ {
+ SendJMSMessage sm = new SendJMSMessage();
+ sm.setupConnection();
+ sm.sendAMessage(args[0]);
+ sm.stop();
+
+ }
+
+}