[jboss-svn-commits] JBL Code SVN: r11474 - in labs/jbossesb/trunk/product/samples/quickstarts: helloworld_action/src/org/jboss/soa/esb/samples/quickstart/helloworldaction/test and 10 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Apr 29 15:16:22 EDT 2007
Author: sebcao
Date: 2007-04-29 15:16:21 -0400 (Sun, 29 Apr 2007)
New Revision: 11474
Added:
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/org/jboss/soa/esb/samples/quickstart/helloworldaction/test/
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/org/jboss/soa/esb/samples/quickstart/helloworldaction/test/SendJMSMessage.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_db_registration/src/org/jboss/soa/esb/samples/quickstart/helloworlddbregistration/test/
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_db_registration/src/org/jboss/soa/esb/samples/quickstart/helloworlddbregistration/test/SendJMSMessage.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/org/jboss/soa/esb/samples/quickstart/helloworldfileaction/test/
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/org/jboss/soa/esb/samples/quickstart/helloworldfileaction/test/CreateTestFile.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_ftp_action/src/org/jboss/soa/esb/samples/quickstart/helloworldftpaction/test/
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_ftp_action/src/org/jboss/soa/esb/samples/quickstart/helloworldftpaction/test/CreateTestFile.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_sql_action/src/org/jboss/soa/esb/samples/quickstart/helloworldsqlaction/
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_sql_action/src/org/jboss/soa/esb/samples/quickstart/helloworldsqlaction/MyAction.java
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/MyActionHandler.java
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/TestBpmProcessor.java
Log:
JBESB-403
Added: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/org/jboss/soa/esb/samples/quickstart/helloworldaction/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/org/jboss/soa/esb/samples/quickstart/helloworldaction/test/SendJMSMessage.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/org/jboss/soa/esb/samples/quickstart/helloworldaction/test/SendJMSMessage.java 2007-04-29 19:16:21 UTC (rev 11474)
@@ -0,0 +1,76 @@
+/*
+ * 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.helloworldaction.test;
+
+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.InitialContext;
+import javax.naming.NamingException;
+
+public class SendJMSMessage {
+ QueueConnection conn;
+ QueueSession session;
+ Queue que;
+
+
+ public void setupConnection() throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ que = (Queue) iniCtx.lookup("queue/quickstart_helloworld_action_Request");
+ 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();
+
+ }
+
+}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_db_registration/src/org/jboss/soa/esb/samples/quickstart/helloworlddbregistration/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_db_registration/src/org/jboss/soa/esb/samples/quickstart/helloworlddbregistration/test/SendJMSMessage.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_db_registration/src/org/jboss/soa/esb/samples/quickstart/helloworlddbregistration/test/SendJMSMessage.java 2007-04-29 19:16:21 UTC (rev 11474)
@@ -0,0 +1,80 @@
+/*
+ * 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.helloworlddbregistration.test;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.jms.JMSException;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.QueueSender;
+import javax.jms.ObjectMessage;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class SendJMSMessage {
+ QueueConnection conn;
+ QueueSession session;
+ Queue que;
+
+
+ public void setupConnection() throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ que = (Queue) iniCtx.lookup("queue/quickstart_helloworld_db_registration");
+ 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();
+
+ }
+
+}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/org/jboss/soa/esb/samples/quickstart/helloworldfileaction/test/CreateTestFile.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/org/jboss/soa/esb/samples/quickstart/helloworldfileaction/test/CreateTestFile.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/org/jboss/soa/esb/samples/quickstart/helloworldfileaction/test/CreateTestFile.java 2007-04-29 19:16:21 UTC (rev 11474)
@@ -0,0 +1,46 @@
+/*
+ * 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.helloworldfileaction.test;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+
+public class CreateTestFile {
+
+
+ public static void main(String args[]) throws Exception
+ {
+ String inputDirectory = args[0];
+ String fileName = args[1];
+ String fileContents = args[2];
+ File x = new File(inputDirectory + "/" + fileName);
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter(x));
+ out.write(fileContents.toCharArray());
+ out.close();
+ } catch (Exception e) {
+ System.out.println("Error while writing the file: " + inputDirectory + "/" + fileName);
+ System.out.println(e.getMessage());
+ }
+ }
+
+}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_ftp_action/src/org/jboss/soa/esb/samples/quickstart/helloworldftpaction/test/CreateTestFile.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_ftp_action/src/org/jboss/soa/esb/samples/quickstart/helloworldftpaction/test/CreateTestFile.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_ftp_action/src/org/jboss/soa/esb/samples/quickstart/helloworldftpaction/test/CreateTestFile.java 2007-04-29 19:16:21 UTC (rev 11474)
@@ -0,0 +1,110 @@
+/*
+ * 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.helloworldftpaction.test;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class CreateTestFile {
+
+ public static void main(final String[] args) {
+ if (args.length != 5)
+ {
+ System.err.println("Usage: java " + CreateTestFile.class.getName() + " <hostname> <username> <password> <filename> <contents>") ;
+ System.exit(1) ;
+ }
+ else
+ {
+ final String hostname = args[0] ;
+ final String username = args[1] ;
+ final String password = args[2] ;
+ final String filename = args[3] ;
+ final String contents = args[4] ;
+
+ final URL url ;
+ final String filenameVal ;
+ if (filename.charAt(0) == '/')
+ {
+ filenameVal = (filename.length() > 1 ? "%2F" + filename.substring(1) : "%2F") ;
+ }
+ else
+ {
+ filenameVal = filename ;
+ }
+ try
+ {
+ url = new URL("ftp://" + username + ":" + password + "@" + hostname + "/" + filenameVal) ;
+ }
+ catch (final MalformedURLException murle)
+ {
+ exit("Invalid URL: " + filenameVal, murle, 2) ;
+ return ; // for compiler
+ }
+ final URLConnection connection ;
+ try
+ {
+ connection = url.openConnection() ;
+ }
+ catch (final IOException ioe)
+ {
+ exit("Error accessing location: " + filenameVal, ioe, 3) ;
+ return ; // for compiler
+ }
+ connection.setDoOutput(true) ;
+ final OutputStream os ;
+ try
+ {
+ os = connection.getOutputStream() ;
+ }
+ catch (final IOException ioe)
+ {
+ exit("Error obtaining output stream for location: " + filenameVal, ioe, 4) ;
+ return ; // for compiler
+ }
+
+ try
+ {
+ final PrintStream ps = new PrintStream(os) ;
+ ps.print(contents) ;
+ ps.close() ;
+ }
+ finally
+ {
+ try
+ {
+ os.close() ;
+ }
+ catch (final IOException ioe) {} //ignore
+ }
+ }
+ }
+
+ private static void exit(final String message, final Throwable th, final int exitValue)
+ {
+ System.err.println(message) ;
+ th.printStackTrace() ;
+ System.exit(exitValue) ;
+ }
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_sql_action/src/org/jboss/soa/esb/samples/quickstart/helloworldsqlaction/MyAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_sql_action/src/org/jboss/soa/esb/samples/quickstart/helloworldsqlaction/MyAction.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_sql_action/src/org/jboss/soa/esb/samples/quickstart/helloworldsqlaction/MyAction.java 2007-04-29 19:16:21 UTC (rev 11474)
@@ -0,0 +1,59 @@
+/*
+ * 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.helloworldsqlaction;
+
+import java.util.Map;
+
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.message.Message;
+
+public class MyAction extends AbstractActionLifecycle
+{
+
+ protected ConfigTree _config;
+
+ public MyAction(ConfigTree config) { _config = config; }
+
+ public Message noOperation(Message message) { return message; }
+
+ @SuppressWarnings("unchecked")
+ public Message displayMessage(Message message) throws Exception{
+ logHeader();
+ Map<String,Object> rowData =(Map)message.getProperties()
+ .getProperty(ListenerTagNames.SQL_ROW_DATA_TAG);
+ for (Map.Entry<String,Object> curr : rowData.entrySet())
+ System.out.println("column "+curr.getKey()+" = <" + curr.getValue()+">");
+ logFooter();
+ return message;
+ }
+
+ // This makes it easier to read on the console
+ private void logHeader() {
+ System.out.println("\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+ }
+ private void logFooter() {
+ System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
+ }
+
+
+}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/MyActionHandler.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/MyActionHandler.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/MyActionHandler.java 2007-04-29 19:16:21 UTC (rev 11474)
@@ -0,0 +1,30 @@
+package org.jboss.soa.esb.samples.quickstart.jbpmsimple1.test;
+
+import org.jbpm.context.exe.ContextInstance;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.Token;
+
+public class MyActionHandler implements ActionHandler
+{
+ private static final long serialVersionUID = 1L;
+
+ Long startFrom;
+
+ public void execute(ExecutionContext exCtx) throws Exception
+ {
+ Token token = exCtx.getToken();
+ ContextInstance context = token.getProcessInstance().getContextInstance();
+ Object obj = context.getVariable("counter",token);
+ if (null==obj)
+ {
+ if (null==startFrom)
+ startFrom = new Long(1);
+ context.createVariable("counter", new Long(startFrom), token);
+ return;
+ }
+ Long counter = 1+Long.parseLong(obj.toString());
+ context.setVariable("counter", counter , token);
+ }
+
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/TestBpmProcessor.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/TestBpmProcessor.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/org/jboss/soa/esb/samples/quickstart/jbpmsimple1/test/TestBpmProcessor.java 2007-04-29 19:16:21 UTC (rev 11474)
@@ -0,0 +1,177 @@
+/*
+ * 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.jbpmsimple1.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.listeners.message.Invoker;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.util.Helper;
+
+import com.arjuna.common.util.propertyservice.PropertyManager;
+
+public class TestBpmProcessor
+{
+
+ static Logger _logger = Logger.getLogger(TestBpmProcessor.class);
+
+ public static void main(String[] args) throws Exception
+ {
+ setupRegistry();
+ new TestBpmProcessor().run();
+ }
+
+ static File WORKDIR;
+ static
+ {
+ String os = System.getProperty("os.name","").toLowerCase();
+ String dflt = (os.indexOf("win")>=0) ? "/temp": "/tmp";
+ WORKDIR = new File(System.getProperty("java.io.tmpdir",dflt));
+ };
+
+ public void run() throws Exception
+ {
+ Message request, response;
+ String[] curr;
+ try
+ {
+ curr = new String[]{"jbpmQsCat1" ,"deployer"};
+ request = Helper.commandMessageTemplate();
+ // nothing extra required in message for 'deployer' service
+ response = Invoker.invokeAndAwaitResponse(request,curr[0], curr[1], 60000);
+ System.out.println(dumpResponse(response));
+
+ curr = new String[]{"jbpmQsCat2" ,"instantiator"};
+ request = Helper.commandMessageTemplate();
+ // nothing extra required in message for 'instantiator' service
+ response = Invoker.invokeAndAwaitResponse(request,curr[0], curr[1], 5000);
+ System.out.println(dumpResponse(response));
+ Long tokenId = Helper.getLongValue(response, Constants.TOKEN_ID);
+
+ showVars(tokenId);
+
+ curr = new String[]{"jbpmQsCat3" ,"signalCommand"};
+ request = Helper.commandMessageTemplate();
+ Helper.setLongValue(request, Constants.TOKEN_ID, tokenId);
+ response = Invoker.invokeAndAwaitResponse(request,curr[0], curr[1], 5000);
+ System.out.println(dumpResponse(response));
+
+ showVars(tokenId);
+
+ curr = new String[]{"jbpmQsCat3" ,"signalCommand"};
+ request = Helper.commandMessageTemplate();
+ Helper.setLongValue(request, Constants.TOKEN_ID, tokenId);
+ response = Invoker.invokeAndAwaitResponse(request,curr[0], curr[1], 5000);
+ System.out.println(dumpResponse(response));
+
+ showVars(tokenId);
+ }
+ catch (Exception _ex)
+ {
+ _ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * Invocation of this method should be unnecessary.
+ * Had to invoke it because I had trouble to have the properties loaded from jbossesb-properties.xml
+ * Once that is solved, you can get rid of the invocation to this method (up in the run() )
+ */
+ protected static void setupRegistry() {
+ PropertyManager mgr = null;
+
+ mgr = ModulePropertyManager.getPropertyManager("registry");
+ mgr.setProperty(Environment.REGISTRY_IMPEMENTATION_CLASS,"org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl");
+ mgr.setProperty(Environment.REGISTRY_QUERY_MANAGER_URI,"jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire");
+ mgr.setProperty(Environment.REGISTRY_LIFECYCLE_MANAGER_URI,"jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish");
+ mgr.setProperty(Environment.REGISTRY_FACTORY_CLASS,"org.apache.ws.scout.registry.ConnectionFactoryImpl");
+ mgr.setProperty(Environment.REGISTRY_SCOUT_TRANSPORT_CLASS,"org.apache.ws.scout.transport.RMITransport");
+ mgr.setProperty(Environment.REGISTRY_USER,"jbossesb");
+ mgr.setProperty(Environment.REGISTRY_PASSWORD,"password");
+ System.setProperty("javax.xml.registry.ConnectionFactoryClass", "org.apache.ws.scout.registry.ConnectionFactoryImpl");
+
+ mgr = ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE) ;
+ mgr.setProperty(Environment.REGISTRY_FILE_HELPER_DIR, WORKDIR.toString()) ;
+
+ }
+
+ private void showVars(long tokenId) throws Exception
+ {
+ String[] curr = new String[]{"jbpmQsCat4" ,"retriever"};
+ Message request = Helper.commandMessageTemplate();
+ Helper.setLongValue(request, Constants.TOKEN_ID, tokenId);
+
+ Message response = Invoker.invokeAndAwaitResponse(request,curr[0], curr[1], 5000);
+ System.out.println(dumpResponse(response));
+
+
+ }
+
+ public static String dumpResponse(Message response)
+ {
+ if (null==response)
+ return "No response received";
+ StringBuilder sb = new StringBuilder("\nResponse from service:\n");
+ sb.append(getObject(response,Constants.RETURN_CODE));
+ sb.append(getObject(response,Constants.ERROR_MESSAGE));
+ sb.append(getObject(response,Constants.EXCEPTION));
+ sb.append(getObject(response,Constants.ACTOR_ID));
+ sb.append(getObject(response,Constants.ACTOR_NAMES_ARRAY));
+ sb.append(getObject(response,Constants.CURRENT_NODE_NAME));
+ sb.append(getObject(response,Constants.JBPM_RETURN_OBJECT));
+ sb.append(getObject(response,Constants.PROCESS_DEFINITION_NAME));
+ sb.append(getObject(response,Constants.PROCESS_DEFINITION_VERSION));
+ sb.append(getObject(response,Constants.PROCESS_INSTANCE_ID));
+ sb.append(getObject(response,Constants.TASK_INSTANCE_ID));
+ sb.append(getObject(response,Constants.TOKEN_ID));
+ sb.append(getObject(response,Constants.HAS_ENDED));
+
+ sb.append(getObject(response,"counter"));
+
+ return sb.append("_______________________________________________________________________")
+ .toString();
+ }
+
+ public static String getObject(Message message, String key)
+ {
+ Object obj = message.getBody().get(key);
+ if (null==obj)
+ return "";
+ if (!(obj instanceof Exception))
+ return key+" = "+obj.toString()+"\n";
+ ByteArrayOutputStream ba = new ByteArrayOutputStream();
+ ((Exception)obj).printStackTrace(new PrintStream(ba));
+ return key+" = "+obj.toString()+"\n"+ba.toString();
+ }
+
+
+}
More information about the jboss-svn-commits
mailing list