[jboss-svn-commits] JBL Code SVN: r8440 - in labs/jbossesb/trunk/product/core: listeners/src/org/jboss/soa/esb/actions listeners/src/org/jboss/soa/esb/listeners listeners/tests/src/org/jboss/soa/esb/listeners rosetta/src/org/jboss/internal/soa/esb/couriers rosetta/src/org/jboss/internal/soa/esb/couriers/helpers rosetta/src/org/jboss/internal/soa/esb/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Dec 20 10:38:18 EST 2006
Author: mark.little at jboss.com
Date: 2006-12-20 10:38:08 -0500 (Wed, 20 Dec 2006)
New Revision: 8440
Added:
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerBaseTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerFTPIntegrationTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerFileUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerFtp.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerJdbc.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerJms.xml
Removed:
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerBrokenXntegrationTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerUnitTest.java
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FtpUploader.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerFile.xml
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/FtpFileHandler.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
Log:
More listener unit and integration tests from Esteban.
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FtpUploader.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FtpUploader.java 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FtpUploader.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -67,7 +67,6 @@
try
{
- System.out.println("FTP uploading "+obj);
_ftpClient = new FtpClientUtil(_parms,true);
_remoteDir = _parms.getAttribute(FtpClientUtil.PARMS_REMOTE_DIR);
_ftpClient.uploadFile(_workFile,_workFile.getInputFile().getName());
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -174,6 +174,8 @@
}
catch (Exception e)
{
+ e.printStackTrace();
+
_logger.error("Problem", e);
throw new ConfigurationException("xx", e);
}
@@ -241,6 +243,7 @@
+ protocol);
String inputSuffix = tree.getAttribute(FileEpr.INPUT_SUFFIX_TAG);
+
if (!Util.isNullString(inputSuffix))
epr.setInputSuffix(inputSuffix);
@@ -248,6 +251,7 @@
FileEpr.ERROR_DEL_TAG, "true"));
String errorDir = tree.getAttribute(FileEpr.ERROR_DIR_TAG);
String errorSuffix = tree.getAttribute(FileEpr.ERROR_SUFFIX_TAG);
+
if (bErrorDel)
{
if (null != errorDir || null != errorSuffix)
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerBaseTest.java (from rev 8408, labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerUnitTest.java 2006-12-19 15:54:17 UTC (rev 8408)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerBaseTest.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -0,0 +1,173 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerManager;
+import org.jboss.soa.esb.listeners.message.EsbListenerController;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.testutils.FileUtil;
+import org.jboss.soa.esb.testutils.HsqldbUtil;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+
+public class ListenerManagerBaseTest extends BaseTest
+{
+
+ static void bytesToFile(File file, byte[] text) throws Exception
+ {
+ OutputStream out = new FileOutputStream(file);
+ out.write(text);
+ out.close();
+ }
+
+ static String stringFromFile(File file) throws Exception
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ FileInputStream inp = new FileInputStream(file);
+ byte[] ba = new byte[1000];
+ int iQ;
+ while (-1 != (iQ = inp.read(ba)))
+ if (iQ > 0)
+ out.write(ba, 0, iQ);
+ inp.close();
+
+ out.close();
+ return out.toString();
+ }
+
+ protected void runBeforeAllTests()
+ {
+ try {
+ DOMConfigurator.configure(TestEnvironmentUtil.getUserDir("product","../product") + "/etc/test/resources/log4j.xml");
+ TestEnvironmentUtil.setESBPropertiesFileToUse("product","../product");
+ // Set the juddi properties file in System so juddi will pick it up
+ // later and use the test values.
+ String juddiPropertiesFile = "/org/jboss/soa/esb/listeners/juddi-unittest.properties";
+ System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
+ // Read this properties file to get the db connection string
+ Properties props = new Properties();
+ InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
+
+ props.load(inStream);
+ mDbDriver = props.getProperty("juddi.jdbcDriver");
+ mDbUrl = props.getProperty("juddi.jdbcUrl");
+ mDbUsername = props.getProperty("juddi.jdbcUsername");
+ mDbPassword = props.getProperty("juddi.jdbcPassword");
+
+ String database="not tested yet";
+ if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
+ database = "hsqldb";
+ // Bring up hsql on default port 9001
+ HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir("product","../product") + "/build/hsqltestdb", "juddi");
+ } else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
+ database = "mysql";
+ } // add and test your own database..
+
+ // Get the registry-schema create scripts
+ String sqlDir = TestEnvironmentUtil.getUserDir("product","../product") + "/install/jUDDI-registry/sql/" + database + "/";
+ // Drop what is there now, if exists. We want to start fresh.
+ String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
+ String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
+ String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
+
+ try
+ {
+ Class.forName(mDbDriver);
+ }
+ catch (Exception e)
+ {
+ System.out.println("ERROR: failed to load " + database + " JDBC driver.");
+ e.printStackTrace();
+ return;
+ }
+ java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
+ Statement stmnt = con.createStatement();
+ stmnt.execute(sqlDropCmd);
+ stmnt.execute(sqlCreateCmd);
+ stmnt.execute(sqlInsertPubCmd);
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.out.println("We should stop testing, since we don't have a db.");
+ assertTrue(false);
+ }
+ }
+
+ protected static final String TMP_DIR = System.getProperty("java.io.tmpdir");
+
+ protected static Logger _logger = Logger
+ .getLogger(ListenerManagerBaseTest.class);
+
+ static File _returnFile = new File(TMP_DIR, "ListenerManagerOutput.txt");
+
+ EsbListenerController _esbListController;
+
+ ListenerManager _manager;
+
+ private static String mDbDriver;
+ private static String mDbUrl;
+ private static String mDbUsername;
+ private static String mDbPassword;
+
+ public static class MockMessageAwareAction
+ {
+ Random _rand = new Random(System.currentTimeMillis());
+
+ ConfigTree _config;
+
+ public MockMessageAwareAction(ConfigTree config)
+ {
+ _config = config;
+ }
+
+ public Message writeToDisk(Message message) throws Exception
+ {
+ String id = message.getHeader().getCall().getMessageID()
+ .toASCIIString();
+ long lSleep = Math.abs(_rand.nextInt()) % 300;
+
+ _logger.info("Random sleep on " + Thread.currentThread() + "="
+ + lSleep + "-Message id=" + id);
+ Thread.sleep(lSleep);
+ bytesToFile(_returnFile, message.getBody().getContents());
+
+ return message;
+ }
+ }
+
+}
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerBrokenXntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerBrokenXntegrationTest.java 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerBrokenXntegrationTest.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -1,232 +0,0 @@
-/*
- * 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;
-
-
-public class ListenerManagerBrokenXntegrationTest
-{
-/*
- @BeforeClass
- public static void setUp() throws Exception
- {
- _logger.info("Writing temp files to "+TMP_DIR);
-
- // delete this one just to make sure asserts take the new ones
- _returnFile.delete();
-
- // initialize registry
- runBeforeAllTests();
-
- }
-
- @AfterClass
- public static void tearDown() throws Exception
- {
- _returnFile.delete();
-
- Thread.sleep(2000);
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
- HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
- }
-
- @Test
- public void allTests() throws Exception
- {
- String winOrUnix = (isWindows()) ? "Win" : "Unix";
- for (String file : new String[]
- {
- "/esbListenerFtp.xml"
- ,"/esbListenerFile"+winOrUnix+".xml"
- ,"/esbListenerJms.xml"
- })
- {
- _logger.info("___Test for FILENAME: "+file+" starting ____________________");
- oneTest(file);
- _logger.info("___Test for FILENAME: "+file+" FINISHED ____________________");
- }
- } //________________________________
-
- private void oneTest(String fileName) throws Exception
- {
- // Write wome messages to EPR obtained from configuration file
- String configFile = getClass().getResource(fileName).getFile();
- ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(configFile));
- ConfigTree eprElement = tree.getAllChildren()[0].getFirstChild("EPR");
- EPR toEPR = ListenerUtil.assembleEpr(eprElement);
- if (toEPR instanceof FileEpr)
- {
- // take inputSuffix as outputSuffix for initial message sending
- eprElement.setAttribute(FileEpr.POST_SUFFIX_TAG,eprElement.getAttribute(FileEpr.INPUT_SUFFIX_TAG));
- eprElement.setAttribute(FileEpr.INPUT_SUFFIX_TAG,null);
- toEPR = ListenerUtil.assembleEpr(eprElement);
- }
-
- String THE_TEXT = "___Config="+fileName+"___ Message Content ___";
-
- int howMany = 10; // how many messages do you want to send before the listener comes up
- DeliverOnlyCourier sender = CourierFactory.getCourier(toEPR);
- Message message = MessageFactory.getInstance().getMessage();
- message.getHeader().setCall(new Call(toEPR));
- message.getBody().setContents(THE_TEXT.getBytes());
- for (int i1=0; i1<howMany; i1++)
- {
- URI uri = new URI(UUID.randomUUID().toString());
- message.getHeader().getCall().setMessageID(uri);
- sender.deliver(message);
- }
-
- _returnFile.delete();
- // launch listener manager in a child thread
- _manager = ListenerUtil.launchManager(configFile, true);
- _logger.debug(" Waiting for all child listeners to start");
- _manager.waitUntilReady();
- _logger.debug(" All child listeners ready");
-
- // JUST FOR THIS TEST:
- // Give your listener some time to process queued messages (see howMany above)
- // Time allowed, and maxThreads in config file will impact how many messages
- // will be processed, and how many will remain unprocessed
- Thread.sleep(150*howMany);
-
- _logger.debug("going to EndRequested");
- _manager.requestEnd();
- _logger.debug("back from EndRequested");
-
- Assert.assertEquals(THE_TEXT, stringFromFile(_returnFile));
- _returnFile.delete();
- }
-
- static void bytesToFile(File file, byte[] text) throws Exception
- {
- OutputStream out = new FileOutputStream(file);
- out.write(text);
- out.close();
- } //________________________________
-
- static String stringFromFile(File file) throws Exception
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- FileInputStream inp = new FileInputStream(file);
- byte[] ba = new byte[1000];
- int iQ;
- while (-1 != (iQ=inp.read(ba)))
- if (iQ > 0)
- out.write(ba,0,iQ);
- inp.close();
-
- out.close();
- return out.toString();
- } //________________________________
-
- public static void runBeforeAllTests()
- {
- try {
- DOMConfigurator.configure(TestEnvironmentUtil.getUserDir("product","../product") + "etc/test/resources/log4j.xml");
- TestEnvironmentUtil.setESBPropertiesFileToUse("product","../product");
- //Set the juddi properties file in System so juddi will pick it up later and use the test values.
- String juddiPropertiesFile = "/org/jboss/soa/esb/services/registry/juddi-qatest.properties";
- System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
- //Read this properties file to get the db connection string
- Properties props = new Properties();
- InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
- props.load(inStream);
- mDbDriver = props.getProperty("juddi.jdbcDriver");
- mDbUrl = props.getProperty("juddi.jdbcUrl");
- mDbUsername = props.getProperty("juddi.jdbcUsername");
- mDbPassword = props.getProperty("juddi.jdbcPassword");
-
- String database="not tested yet";
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
- database = "hsqldb";
- //Bring up hsql on default port 9001
- HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir("product","../product") + "build/hsqltestdb", "juddi");
- } else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
- database = "mysql";
- } //add and test your own database..
-
- //Get the registry-schema create scripts
- String sqlDir = TestEnvironmentUtil.getUserDir("product","../product") + "install/jUDDI-registry/sql/" + database + "/";
- //Drop what is there now, if exists. We want to start fresh.
- String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
- String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
- String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
-
- try {
- Class.forName(mDbDriver);
- } catch (Exception e) {
- System.out.println("ERROR: failed to load " + database + " JDBC driver.");
- e.printStackTrace();
- return;
- }
- java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
- Statement stmnt = con.createStatement();
- stmnt.execute(sqlDropCmd);
- stmnt.execute(sqlCreateCmd);
- stmnt.execute(sqlInsertPubCmd);
-
- } catch (Throwable e) {
- e.printStackTrace();
- System.out.println("We should stop testing, since we don't have a db.");
- assertTrue(false);
- }
- }
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(ListenerManagerIntegrationTest.class);
- }
-
- private static boolean isWindows()
- { return System.getProperty("os.name").toLowerCase().contains("window"); }
- private static final String TMP_DIR = isWindows() ? "/temp" : "/tmp";
-
- private static Logger _logger = Logger.getLogger(ListenerManagerIntegrationTest.class);
-
- static File _returnFile = new File(TMP_DIR,"ListenerManagerOutput.txt");
-
-
- EsbListenerController _esbListController;
- ListenerManager _manager;
-
- private static String mDbDriver;
- private static String mDbUrl;
- private static String mDbUsername;
- private static String mDbPassword;
-
- public static class MockMessageAwareAction
- {
- Random _rand = new Random(System.currentTimeMillis());
- ConfigTree _config;
- public MockMessageAwareAction(ConfigTree config) { _config = config; }
- public Message writeToDisk (Message message) throws Exception
- {
- String id = message.getHeader().getCall().getMessageID().toASCIIString();
- long lSleep = Math.abs(_rand.nextInt())%300;
- _logger.info("Random sleep on "+Thread.currentThread()+"="+lSleep+"-Message id="+id);
- Thread.sleep(lSleep);
- bytesToFile(_returnFile, message.getBody().getContents());
- return message;
- } // ________________________________
-
- } // ___________________________________________________
-*/
-}
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerFTPIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerFTPIntegrationTest.java 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerFTPIntegrationTest.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -0,0 +1,127 @@
+/*
+ * 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.FileInputStream;
+import java.net.URI;
+import java.util.UUID;
+
+import junit.framework.Assert;
+
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+public class ListenerManagerFTPIntegrationTest extends ListenerManagerFileUnitTest
+{
+
+ public ListenerManagerFTPIntegrationTest ()
+ {
+ setConfig("listenerFTP.xml");
+ }
+
+ protected void oneTest (String fileName) throws Exception
+ {
+ // Write wome messages to EPR obtained from configuration file
+ String configFile = getClass().getResource(fileName).getFile();
+ ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(
+ configFile));
+ String url = null;
+
+ if (getFtpPwd() == null)
+ url = "ftp://"+getFtpUser()+"@"+getFtpHostname()+":"+getFtpDir();
+ else
+ url = "ftp://"+getFtpUser()+":"+getFtpPwd()+"@"+getFtpHostname()+":"+getFtpDir();
+
+ ConfigTree eprElement = tree.getAllChildren()[0].getFirstChild("EPR");
+ eprElement.setAttribute(ListenerTagNames.URL_TAG, url);
+
+ EPR toEPR = ListenerUtil.assembleEpr(eprElement);
+
+ if (toEPR instanceof FTPEpr)
+ {
+ // take inputSuffix as outputSuffix for initial message sending
+ eprElement.setAttribute(FileEpr.POST_SUFFIX_TAG, eprElement
+ .getAttribute(FileEpr.INPUT_SUFFIX_TAG));
+ eprElement.setAttribute(FileEpr.INPUT_SUFFIX_TAG, null);
+ toEPR = ListenerUtil.assembleEpr(eprElement);
+ }
+ else
+ Assert.fail();
+
+ String THE_TEXT = "___Config=" + fileName + "___ Message Content ___";
+
+ int howMany = 10; // how many messages do you want to send before the
+ // listener comes up
+
+ DeliverOnlyCourier sender = CourierFactory.getCourier(toEPR);
+
+ Message message = MessageFactory.getInstance().getMessage();
+ message.getHeader().setCall(new Call(toEPR));
+ message.getBody().setContents(THE_TEXT.getBytes());
+
+ for (int i1 = 0; i1 < howMany; i1++)
+ {
+ URI uri = new URI(UUID.randomUUID().toString());
+ message.getHeader().getCall().setMessageID(uri);
+ sender.deliver(message);
+ }
+
+ _returnFile.delete();
+
+ // launch listener manager in a child thread
+ final ConfigTree newTree = ConfigTree.fromInputStream(new FileInputStream(
+ configFile));
+ final ConfigTree newTreeEPRElement = newTree.getAllChildren()[0].getFirstChild("EPR");
+ newTreeEPRElement.setAttribute(ListenerTagNames.URL_TAG, url) ;
+
+ _manager = ListenerUtil.launchManager(newTree, true);
+ _logger.debug("Waiting for all child listeners to start");
+ _manager.waitUntilReady();
+ _logger.debug(" All child listeners ready");
+
+ // JUST FOR THIS TEST:
+ // Give your listener some time to process queued messages (see howMany
+ // above)
+ // Time allowed, and maxThreads in config file will impact how many
+ // messages
+ // will be processed, and how many will remain unprocessed
+
+ Thread.sleep(150 * howMany);
+
+ _logger.debug("going to EndRequested");
+ _manager.requestEnd();
+ _logger.debug("back from EndRequested");
+
+ Assert.assertEquals(THE_TEXT, stringFromFile(_returnFile));
+
+ _returnFile.delete();
+ }
+
+}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerFileUnitTest.java (from rev 8397, labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerUnitTest.java 2006-12-19 12:13:15 UTC (rev 8397)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerFileUnitTest.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -0,0 +1,163 @@
+/*
+ * 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.File;
+import java.io.FileInputStream;
+import java.net.URI;
+import java.util.UUID;
+
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerUtil;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+public class ListenerManagerFileUnitTest extends ListenerManagerBaseTest
+{
+ public ListenerManagerFileUnitTest ()
+ {
+ setConfig("listenerFile.xml");
+ }
+
+ public void testListener ()
+ {
+ _logger.info("___Test for FILENAME: " + _file
+ + " starting ____________________");
+
+ try
+ {
+ oneTest(_file);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+
+ fail();
+ }
+
+ _logger.info("___Test for FILENAME: " + _file
+ + " FINISHED ____________________");
+ }
+
+ public void setUp()
+ {
+ _logger.info("Writing temp files to " + TMP_DIR);
+
+ // delete this one just to make sure asserts take the new ones
+ _returnFile.delete();
+
+ // initialize registry
+ runBeforeAllTests();
+ }
+
+ public void tearDown()
+ {
+ _returnFile.delete();
+ }
+
+ protected final void setConfig (String config)
+ {
+ _file = config;
+ }
+
+ protected void oneTest (String fileName) throws Exception
+ {
+ // Write wome messages to EPR obtained from configuration file
+ String configFile = getClass().getResource(fileName).getFile();
+ ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(
+ configFile));
+ final File tmpDir = new File(System.getProperty("java.io.tmpdir")) ;
+ final String tmpDirForm = tmpDir.toURL().toExternalForm() ;
+
+ ConfigTree eprElement = tree.getAllChildren()[0].getFirstChild("EPR");
+ eprElement.setAttribute(ListenerTagNames.URL_TAG, tmpDirForm) ;
+
+ EPR toEPR = ListenerUtil.assembleEpr(eprElement);
+
+ if (toEPR instanceof FileEpr)
+ {
+ // take inputSuffix as outputSuffix for initial message sending
+ eprElement.setAttribute(FileEpr.POST_SUFFIX_TAG, eprElement
+ .getAttribute(FileEpr.INPUT_SUFFIX_TAG));
+ eprElement.setAttribute(FileEpr.INPUT_SUFFIX_TAG, null);
+ toEPR = ListenerUtil.assembleEpr(eprElement);
+ }
+ else
+ fail();
+
+ String THE_TEXT = "___Config=" + fileName + "___ Message Content ___";
+
+ int howMany = 10; // how many messages do you want to send before the
+ // listener comes up
+
+ DeliverOnlyCourier sender = CourierFactory.getCourier(toEPR);
+
+ Message message = MessageFactory.getInstance().getMessage();
+ message.getHeader().setCall(new Call(toEPR));
+ message.getBody().setContents(THE_TEXT.getBytes());
+
+ for (int i1 = 0; i1 < howMany; i1++)
+ {
+ URI uri = new URI(UUID.randomUUID().toString());
+ message.getHeader().getCall().setMessageID(uri);
+ sender.deliver(message);
+ }
+
+ _returnFile.delete();
+
+ // launch listener manager in a child thread
+ final ConfigTree newTree = ConfigTree.fromInputStream(new FileInputStream(
+ configFile));
+ final ConfigTree newTreeEPRElement = newTree.getAllChildren()[0].getFirstChild("EPR");
+ newTreeEPRElement.setAttribute(ListenerTagNames.URL_TAG, tmpDirForm) ;
+ _manager = ListenerUtil.launchManager(newTree, true);
+ _logger.debug("Waiting for all child listeners to start");
+ _manager.waitUntilReady();
+ _logger.debug(" All child listeners ready");
+
+ // JUST FOR THIS TEST:
+ // Give your listener some time to process queued messages (see howMany
+ // above)
+ // Time allowed, and maxThreads in config file will impact how many
+ // messages
+ // will be processed, and how many will remain unprocessed
+
+ Thread.sleep(150 * howMany);
+
+ _logger.debug("going to EndRequested");
+ _manager.requestEnd();
+ _logger.debug("back from EndRequested");
+
+ assertEquals(THE_TEXT, stringFromFile(_returnFile));
+
+ _returnFile.delete();
+ }
+
+ protected String _file;
+
+}
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerUnitTest.java 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/ListenerManagerUnitTest.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -1,296 +0,0 @@
-/*
- * 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 static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.Properties;
-import java.util.Random;
-import java.util.UUID;
-
-import junit.framework.Assert;
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.xml.DOMConfigurator;
-import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
-import org.jboss.soa.esb.addressing.Call;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.eprs.FileEpr;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.message.EsbListenerController;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.testutils.FileUtil;
-import org.jboss.soa.esb.testutils.HsqldbUtil;
-import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class ListenerManagerUnitTest
-{
- @BeforeClass
- public static void setUp() throws Exception
- {
- _logger.info("Writing temp files to " + TMP_DIR);
-
- // delete this one just to make sure asserts take the new ones
- _returnFile.delete();
-
- // initialize registry
- runBeforeAllTests();
- }
-
- @AfterClass
- public static void tearDown() throws Exception
- {
- _returnFile.delete();
- }
-
- @Test
- public void allTests() throws Exception
- {
- String file = "listenerFile.xml";
-
- _logger.info("___Test for FILENAME: " + file
- + " starting ____________________");
-
- oneTest(file);
-
- _logger.info("___Test for FILENAME: " + file
- + " FINISHED ____________________");
- }
-
- private void oneTest(String fileName) throws Exception
- {
- // Write wome messages to EPR obtained from configuration file
- String configFile = getClass().getResource(fileName).getFile();
- ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(
- configFile));
- final File tmpDir = new File(System.getProperty("java.io.tmpdir")) ;
- final String tmpDirForm = tmpDir.toURL().toExternalForm() ;
-
- ConfigTree eprElement = tree.getAllChildren()[0].getFirstChild("EPR");
- eprElement.setAttribute(ListenerTagNames.URL_TAG, tmpDirForm) ;
-
- EPR toEPR = ListenerUtil.assembleEpr(eprElement);
-
- if (toEPR instanceof FileEpr)
- {
- // take inputSuffix as outputSuffix for initial message sending
- eprElement.setAttribute(FileEpr.POST_SUFFIX_TAG, eprElement
- .getAttribute(FileEpr.INPUT_SUFFIX_TAG));
- eprElement.setAttribute(FileEpr.INPUT_SUFFIX_TAG, null);
- toEPR = ListenerUtil.assembleEpr(eprElement);
- }
- else
- Assert.fail();
-
- String THE_TEXT = "___Config=" + fileName + "___ Message Content ___";
-
- int howMany = 10; // how many messages do you want to send before the
- // listener comes up
-
- DeliverOnlyCourier sender = CourierFactory.getCourier(toEPR);
-
- Message message = MessageFactory.getInstance().getMessage();
- message.getHeader().setCall(new Call(toEPR));
- message.getBody().setContents(THE_TEXT.getBytes());
-
- for (int i1 = 0; i1 < howMany; i1++)
- {
- URI uri = new URI(UUID.randomUUID().toString());
- message.getHeader().getCall().setMessageID(uri);
- sender.deliver(message);
- }
-
- _returnFile.delete();
-
- // launch listener manager in a child thread
- final ConfigTree newTree = ConfigTree.fromInputStream(new FileInputStream(
- configFile));
- final ConfigTree newTreeEPRElement = newTree.getAllChildren()[0].getFirstChild("EPR");
- newTreeEPRElement.setAttribute(ListenerTagNames.URL_TAG, tmpDirForm) ;
- _manager = ListenerUtil.launchManager(newTree, true);
- _logger.debug("Waiting for all child listeners to start");
- _manager.waitUntilReady();
- _logger.debug(" All child listeners ready");
-
- // JUST FOR THIS TEST:
- // Give your listener some time to process queued messages (see howMany
- // above)
- // Time allowed, and maxThreads in config file will impact how many
- // messages
- // will be processed, and how many will remain unprocessed
-
- Thread.sleep(150 * howMany);
-
- _logger.debug("going to EndRequested");
- _manager.requestEnd();
- _logger.debug("back from EndRequested");
-
- Assert.assertEquals(THE_TEXT, stringFromFile(_returnFile));
-
- _returnFile.delete();
- }
-
- static void bytesToFile(File file, byte[] text) throws Exception
- {
- OutputStream out = new FileOutputStream(file);
- out.write(text);
- out.close();
- }
-
- static String stringFromFile(File file) throws Exception
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- FileInputStream inp = new FileInputStream(file);
- byte[] ba = new byte[1000];
- int iQ;
- while (-1 != (iQ = inp.read(ba)))
- if (iQ > 0)
- out.write(ba, 0, iQ);
- inp.close();
-
- out.close();
- return out.toString();
- }
-
- public static void runBeforeAllTests()
- {
- try {
- DOMConfigurator.configure(TestEnvironmentUtil.getUserDir("product","../product") + "/etc/test/resources/log4j.xml");
- TestEnvironmentUtil.setESBPropertiesFileToUse("product","../product");
- // Set the juddi properties file in System so juddi will pick it up
- // later and use the test values.
- String juddiPropertiesFile = "/org/jboss/soa/esb/listeners/juddi-unittest.properties";
- System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
- // Read this properties file to get the db connection string
- Properties props = new Properties();
- InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
-
- props.load(inStream);
- mDbDriver = props.getProperty("juddi.jdbcDriver");
- mDbUrl = props.getProperty("juddi.jdbcUrl");
- mDbUsername = props.getProperty("juddi.jdbcUsername");
- mDbPassword = props.getProperty("juddi.jdbcPassword");
-
- String database="not tested yet";
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
- database = "hsqldb";
- // Bring up hsql on default port 9001
- HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir("product","../product") + "/build/hsqltestdb", "juddi");
- } else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
- database = "mysql";
- } // add and test your own database..
-
- // Get the registry-schema create scripts
- String sqlDir = TestEnvironmentUtil.getUserDir("product","../product") + "/install/jUDDI-registry/sql/" + database + "/";
- // Drop what is there now, if exists. We want to start fresh.
- String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
- String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
- String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
-
- try
- {
- Class.forName(mDbDriver);
- }
- catch (Exception e)
- {
- System.out.println("ERROR: failed to load " + database + " JDBC driver.");
- e.printStackTrace();
- return;
- }
- java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
- Statement stmnt = con.createStatement();
- stmnt.execute(sqlDropCmd);
- stmnt.execute(sqlCreateCmd);
- stmnt.execute(sqlInsertPubCmd);
-
- } catch (Throwable e) {
- e.printStackTrace();
- System.out.println("We should stop testing, since we don't have a db.");
- assertTrue(false);
- }
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(ListenerManagerUnitTest.class);
- }
-
- private static final String TMP_DIR = System.getProperty("java.io.tmpdir");
-
- private static Logger _logger = Logger
- .getLogger(ListenerManagerUnitTest.class);
-
- static File _returnFile = new File(TMP_DIR, "ListenerManagerOutput.txt");
-
- EsbListenerController _esbListController;
-
- ListenerManager _manager;
-
- private static String mDbDriver;
- private static String mDbUrl;
- private static String mDbUsername;
- private static String mDbPassword;
-
- public static class MockMessageAwareAction
- {
- Random _rand = new Random(System.currentTimeMillis());
-
- ConfigTree _config;
-
- public MockMessageAwareAction(ConfigTree config)
- {
- _config = config;
- }
-
- public Message writeToDisk(Message message) throws Exception
- {
- String id = message.getHeader().getCall().getMessageID()
- .toASCIIString();
- long lSleep = Math.abs(_rand.nextInt()) % 300;
-
- _logger.info("Random sleep on " + Thread.currentThread() + "="
- + lSleep + "-Message id=" + id);
- Thread.sleep(lSleep);
- bytesToFile(_returnFile, message.getBody().getContents());
-
- return message;
- }
- }
-
-}
Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerFile.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerFile.xml 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerFile.xml 2006-12-20 15:38:08 UTC (rev 8440)
@@ -13,7 +13,7 @@
postSuffix=".processedOK"
/>
- <action class="org.jboss.soa.esb.listeners.ListenerManagerUnitTest$MockMessageAwareAction" process="writeToDisk" />
+ <action class="org.jboss.soa.esb.listeners.ListenerManagerBaseTest$MockMessageAwareAction" process="writeToDisk" />
<action class="org.jboss.soa.esb.actions.Notifier" okMethod="notifyOK">
<NotificationList type="OK">
<target class="NotifyConsole" />
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerFtp.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerFtp.xml 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerFtp.xml 2006-12-20 15:38:08 UTC (rev 8440)
@@ -0,0 +1,22 @@
+<DummyTester parameterReloadSecs="180">
+ <DummyActionConfig
+ service-category="CatgFileEsbListener"
+ service-name="testFileListener"
+ service-description="My Dummy Service Name FILE"
+ listenerClass="org.jboss.soa.esb.listeners.message.MessageAwareListener"
+ maxThreads="10"
+ >
+ <EPR
+ URL="ftp://ftpuser:ftppassword@localhost:/"
+ inputSuffix=".testFile"
+ postDelete="true"
+ />
+
+ <action class="org.jboss.soa.esb.listeners.ListenerManagerBaseTest$MockMessageAwareAction" process="writeToDisk" />
+ <action class="org.jboss.soa.esb.actions.Notifier" okMethod="notifyOK">
+ <NotificationList type="OK">
+ <target class="NotifyConsole" />
+ </NotificationList>
+ </action>
+ </DummyActionConfig>
+</DummyTester>
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerJdbc.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerJdbc.xml 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerJdbc.xml 2006-12-20 15:38:08 UTC (rev 8440)
@@ -0,0 +1,25 @@
+<DummyTester parameterReloadSecs="180">
+ <DummyActionConfig
+ service-category="CatgSqlEsbListener"
+ service-name="testSqlTableListener"
+ service-description="My Dummy Service Name SQL table"
+ listenerClass="org.jboss.soa.esb.listeners.message.MessageAwareListener"
+ maxThreads="10"
+ >
+ <EPR
+ URL="jdbc:postgresql://localhost:5432/testDB"
+ driver="org.postgresql.Driver"
+ username="postgres"
+ password=""
+ tablename="esb_messages"
+ />
+
+ <action class="org.jboss.soa.esb.listeners.ListenerManagerUnitTest$MockMessageAwareAction" process="writeToDisk" />
+ <action class="org.jboss.soa.esb.actions.Notifier " okMethod="notifyOK">
+ <NotificationList type="OK">
+ <target class="NotifyConsole" />
+ </NotificationList>
+ </action>
+ </DummyActionConfig>
+</DummyTester>
+
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerJms.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerJms.xml 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/listenerJms.xml 2006-12-20 15:38:08 UTC (rev 8440)
@@ -0,0 +1,26 @@
+<DummyTester parameterReloadSecs="180">
+ <DummyActionConfig
+ service-category="CatgFileEsbListener"
+ service-name="testFileListener"
+ service-description="My Dummy Service Name FILE"
+ listenerClass="org.jboss.soa.esb.listeners.message.MessageAwareListener"
+ maxThreads="10"
+ >
+ <EPR
+ protocol="jms"
+ connection-factory="ConnectionFactory"
+ destination-type="queue"
+ destination-name="queue/A"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost"
+ message-selector="messSelector='testJmsGateway'"
+ />
+
+ <action class="org.jboss.soa.esb.listeners.ListenerManagerUnitTest$MockMessageAwareAction" process="writeToDisk" />
+ <action class="org.jboss.soa.esb.actions.Notifier" okMethod="notifyOK">
+ <NotificationList type="OK">
+ <target class="NotifyConsole" />
+ </NotificationList>
+ </action>
+ </DummyActionConfig>
+</DummyTester>
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -180,6 +180,7 @@
File tmpFile = null;
if (handler instanceof LocalFileHandler)
+ {
try
{
File dir = new File(_url.getFile());
@@ -204,6 +205,7 @@
{
throw new CourierException(e);
}
+ }
try
{
@@ -243,15 +245,18 @@
} // ________________________________
public Message pickup(long millis) throws CourierException
- {
+ {
Message result = null;
long limit = System.currentTimeMillis()
+ ((millis < 100) ? 100 : millis);
+
do
{
FileHandler handler = (null != _localFhandler) ? _localFhandler
: FileHandlerFactory.getInstance().getFileHandler(_epr);
+
File[] files = handler.getFileList();
+
if (null != files && files.length > 0)
{
File input = files[0];
@@ -278,6 +283,8 @@
}
try
{
+ // TODO magic number!!
+
Thread.sleep(200);
}
catch (InterruptedException e)
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/FtpFileHandler.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/FtpFileHandler.java 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/FtpFileHandler.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -76,7 +76,7 @@
_passwd = (sa.length < 2) ? "" : sa[1];
_remoteDir = url.getFile();
-
+
final String tmpdir = System.getProperty("java.io.tmpdir") ;
if ((_remoteDir == null) || (_remoteDir.equals("")))
_remoteDir = ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE).getProperty(Environment.FTP_REMOTEDIR, tmpdir);
@@ -151,6 +151,8 @@
}
catch (Exception e)
{
+ e.printStackTrace();
+
throw new CourierException(e);
}
}
@@ -182,6 +184,8 @@
}
catch (Exception e)
{
+ e.printStackTrace();
+
throw new CourierException(e);
}
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java 2006-12-20 15:12:27 UTC (rev 8439)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java 2006-12-20 15:38:08 UTC (rev 8440)
@@ -416,6 +416,7 @@
{
String sRemoteOK = getRemoteDir() + "/" + p_sRemoteName;
String sRemoteTmp = sRemoteOK + TMP_SUFFIX;
+
m_oConn.put(FtpUtils.fileToFtpString(p_oFile), sRemoteTmp);
m_oConn.rename(sRemoteTmp, sRemoteOK);
}
More information about the jboss-svn-commits
mailing list