[jboss-svn-commits] JBL Code SVN: r5739 - in labs/jbossesb/trunk/qa: . junit junit/src/org/jboss/soa/esb/listeners junit/src/org/jboss/soa/esb/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Aug 11 05:53:16 EDT 2006
Author: tfennelly
Date: 2006-08-11 05:53:10 -0400 (Fri, 11 Aug 2006)
New Revision: 5739
Added:
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/MultiPollerConfig1.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerConfig1.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java
Modified:
labs/jbossesb/trunk/qa/build.xml
labs/jbossesb/trunk/qa/junit/build.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/DirectoryPollerTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/ListenerUtils.java
Log:
More tests and utilities
Modified: labs/jbossesb/trunk/qa/build.xml
===================================================================
--- labs/jbossesb/trunk/qa/build.xml 2006-08-11 08:43:08 UTC (rev 5738)
+++ labs/jbossesb/trunk/qa/build.xml 2006-08-11 09:53:10 UTC (rev 5739)
@@ -1,6 +1,7 @@
<project name="JBESB" default="test" basedir=".">
- <property id="test.properties" file="test.properties" />
+ <property file="test.properties" />
+ <property file="../product/config/deployment.properties" />
<target name="test" depends="test.junit" description="Run all QA tests." />
Modified: labs/jbossesb/trunk/qa/junit/build.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/build.xml 2006-08-11 08:43:08 UTC (rev 5738)
+++ labs/jbossesb/trunk/qa/junit/build.xml 2006-08-11 09:53:10 UTC (rev 5739)
@@ -15,6 +15,7 @@
<fileset dir="${coverage}/all/" includes="jbossesb-instr-all.jar" />
<fileset dir="${build.lib}/ext" includes="*.jar" />
<fileset dir="${build.lib}/ejb3" includes="*.jar" />
+ <fileset dir="${product}/config/lib" includes="*.jar" />
<!-- fileset dir="${build.lib}/ejb3_embedded" includes="*.jar" / -->
<pathelement location="../" />
</path>
@@ -52,6 +53,12 @@
<!-- Sys Props from the test.properties file... -->
<sysproperty key="org.jboss.soa.esb.jndi.server.type" value="${org.jboss.soa.esb.jndi.server.type}" />
<sysproperty key="org.jboss.soa.esb.jndi.server.url" value="${org.jboss.soa.esb.jndi.server.url}" />
+
+ <!-- Sys Props from the deployment.properties file... -->
+ <sysproperty key="org.jboss.esb.db.driver" value="${org.jboss.esb.db.driver}" />
+ <sysproperty key="org.jboss.esb.db.url" value="${org.jboss.esb.db.url}" />
+ <sysproperty key="org.jboss.esb.db.user" value="${org.jboss.esb.db.user}" />
+ <sysproperty key="org.jboss.esb.db.password" value="${org.jboss.esb.db.password}" />
</junit>
<!-- Remove all "fixed-up" listener configuration files -->
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/DirectoryPollerTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/DirectoryPollerTest.java 2006-08-11 08:43:08 UTC (rev 5738)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/DirectoryPollerTest.java 2006-08-11 09:53:10 UTC (rev 5739)
@@ -58,8 +58,11 @@
FileUtils.assertFileExists(new File(inputDoneDir, "infile1.inp.DONE"), 10000);
// Make sure the input gets removed from the "inputDoneDir"...
FileUtils.assertFileDoesntExists(new File(inputDir, "infile1.inp"), 10000);
+ // Make sure the proper files appear in the "copiedTo" directory.
+ FileUtils.asserFilesExist(copiedTo, "infile1.inp.*", 10000);
- //listenersMgr.assertShutdownOK(10000);
+ // There should have been no exceptions...
+ listenersMgr.assertNotInException();
// Send a Shutdown message to the command queue...
JMSClientUtil.sendMessageToQueue("shutdown", JMSClientUtil.QUEUE.A, new KeyValuePair[] {new KeyValuePair("gpMsgSelector", "test")});
@@ -68,8 +71,8 @@
protected void tearDown() throws Exception {
// Remove the directories required by the test...
- inputDir.delete();
- inputDoneDir.delete();
- copiedTo.delete();
+ //inputDir.delete();
+ //inputDoneDir.delete();
+ //copiedTo.delete();
}
}
Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/MultiPollerConfig1.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/MultiPollerConfig1.xml 2006-08-11 08:43:08 UTC (rev 5738)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/MultiPollerConfig1.xml 2006-08-11 09:53:10 UTC (rev 5739)
@@ -0,0 +1,100 @@
+<LoanBrokerExample
+ commandConnFactoryClass="ConnectionFactory"
+ commandJndiType="jboss"
+ commandJndiURL="localhost"
+ commandIsTopic="false"
+ messageSelector="gpMsgSelector='test'"
+ commandJndiName="queue/A"
+ parameterReloadSecs="20"
+>
+ <PollDirectoryExample
+ listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
+ actionClass="org.jboss.soa.esb.actions.DummyFileAction"
+ pollLatencySecs="5"
+ maxThreads="2"
+ inputDirURI="@qa.build@/inputDir"
+ inputSuffix=".inp"
+ workSuffix=".INPROC"
+ errorDirURI="@qa.build@/errorDir"
+ errorSuffix=".ERR"
+ postDirURI="@qa.build@/inputDoneDir"
+ postSuffix=".DONE"
+ postDelete="n"
+ >
+ <NotificationList type="OK">
+ <target class="NotifyFiles">
+ <file URI="@qa.build@/notifyDir/GpListenerExample.notifOK"
+ append="true"
+ />
+ </target>
+ </NotificationList>
+
+ <NotificationList type="err">
+ <target class="NotifyFiles">
+ <file URI="@qa.build@/notifyDir/GpListenerExample.notifErr"
+ append="true"
+ />
+ </target>
+ </NotificationList>
+ </PollDirectoryExample>
+
+ <PollSqlTableExample
+ listenerClass="org.jboss.soa.esb.listeners.SqlTablePoller"
+ actionClass="org.jboss.soa.esb.actions.DummySqlRowAction"
+ pollLatencySecs="2"
+ maxThreads="2"
+ connection-url="jdbc:postgresql://lavasca:5432/rosetta"
+ driver-class="org.postgresql.Driver"
+ user-name="postgres"
+ password=""
+ tableName="test_notif_table"
+ selectFields="oid,ref,msg"
+ keyFields="oid,ref"
+ inProcessField="status"
+ whereCondition="src='pepe'"
+ >
+ <NotificationList type="OK">
+ <target class="NotifyFiles">
+ <file URI="@qa.build@/notifyDir/GpListenerExample.notifOK"
+ append="true"
+ />
+ </target>
+ </NotificationList>
+
+ <NotificationList type="err">
+ <target class="NotifyFiles">
+ <file URI="@qa.build@/notifyDir/GpListenerExample.notifErr"
+ append="true"
+ />
+ </target>
+ </NotificationList>
+ </PollSqlTableExample>
+
+ <ListenJmsQueueExample
+ listenerClass="org.jboss.soa.esb.listeners.JmsQueueListener"
+ actionClass="org.jboss.soa.esb.actions.DummyAction"
+ maxThreads="1"
+ queueConnFactoryClass="ConnectionFactory"
+ listenJndiType="jboss"
+ listenJndiURL="localhost"
+ listenQueue="queue/A"
+ listenMsgSelector="listener='maradona'"
+ >
+ <NotificationList type="OK">
+ <target class="NotifyFiles">
+ <file URI="@qa.build@/notifyDir/GpListenerExample.notifOK"
+ append="true"
+ />
+ </target>
+ </NotificationList>
+
+ <NotificationList type="err">
+ <target class="NotifyFiles">
+ <file URI="@qa.build@/notifyDir/GpListenerExample.notifErr"
+ append="true"
+ />
+ </target>
+ </NotificationList>
+ </ListenJmsQueueExample>
+
+</LoanBrokerExample>
Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerConfig1.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerConfig1.xml 2006-08-11 08:43:08 UTC (rev 5738)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerConfig1.xml 2006-08-11 09:53:10 UTC (rev 5739)
@@ -0,0 +1,42 @@
+<LoanBrokerExample
+ commandConnFactoryClass="ConnectionFactory"
+ commandJndiType="jboss"
+ commandJndiURL="localhost"
+ commandIsTopic="false"
+ messageSelector="gpMsgSelector='test'"
+ commandJndiName="queue/A"
+>
+
+ <PollSqlTableExample
+ listenerClass="org.jboss.soa.esb.listeners.SqlTablePoller"
+ actionClass="org.jboss.soa.esb.actions.DummySqlRowAction"
+ pollLatencySecs="2"
+ maxThreads="2"
+ connection-url="@db.url@"
+ driver-class="@db.driver@"
+ user-name="@db.user@"
+ password="@db.password@"
+ tableName="test_notif_table"
+ selectFields="oid,ref,msg"
+ keyFields="oid,ref"
+ inProcessField="status"
+ whereCondition="src='pepe'"
+ >
+ <NotificationList type="OK">
+ <target class="NotifyFiles">
+ <file URI="@qa.build@/notifyDir/GpListenerExample.notifOK"
+ append="true"
+ />
+ </target>
+ </NotificationList>
+
+ <NotificationList type="err">
+ <target class="NotifyFiles">
+ <file URI="@qa.build@/notifyDir/GpListenerExample.notifErr"
+ append="true"
+ />
+ </target>
+ </NotificationList>
+ </PollSqlTableExample>
+
+</LoanBrokerExample>
Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java 2006-08-11 08:43:08 UTC (rev 5738)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java 2006-08-11 09:53:10 UTC (rev 5739)
@@ -0,0 +1,66 @@
+/*
+ * 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 org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.util.ClassUtils;
+import org.jboss.soa.esb.util.FileUtils;
+import org.jboss.soa.esb.util.JMSClientUtil;
+import org.jboss.soa.esb.util.ListenerUtils;
+import org.jboss.soa.esb.util.ListenerUtils.ListenersManagerExecThread;
+
+import junit.framework.TestCase;
+
+/**
+ * QA tests for the SQLTablePoller.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class SQLTablePollerTest extends TestCase {
+
+ private ListenersManagerExecThread listenersMgr;
+ File notifyDir;
+
+ protected void setUp() throws Exception {
+ // Create the directories required by the test...
+ notifyDir = FileUtils.createTestDir("notifyDir");
+
+ // Start the listener...
+ listenersMgr = ListenerUtils.startListeners(ClassUtils.toResourcePath(getClass().getPackage()) + "/SQLTablePollerConfig1.xml");
+ }
+
+ public void test() throws InterruptedException {
+
+ // There should have been no exceptions...
+ listenersMgr.assertNotInException();
+
+ // Send a Shutdown message to the command queue...
+ JMSClientUtil.sendMessageToQueue("shutdown", JMSClientUtil.QUEUE.A, new KeyValuePair[] {new KeyValuePair("gpMsgSelector", "test")});
+ listenersMgr.assertShutdownOK(10000);
+ }
+
+ protected void tearDown() throws Exception {
+ // Remove the directories required by the test...
+ //notifyDir.delete();
+ }
+}
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java 2006-08-11 08:43:08 UTC (rev 5738)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java 2006-08-11 09:53:10 UTC (rev 5739)
@@ -22,8 +22,10 @@
package org.jboss.soa.esb.util;
import java.io.File;
+import java.io.FileFilter;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.regex.Pattern;
import junit.framework.TestCase;
@@ -117,6 +119,42 @@
}
/**
+ * Assert that files matching the specified pattern appear in the specified directory.
+ * @param dir Directory to check.
+ * @param pattern Regexp pattern used to perform the matching.
+ * @param maxWait The maximum length of time (ms) to wait for for the files to appear.
+ */
+ public static void asserFilesExist(final File dir, final String pattern, int maxWait) {
+ if(!dir.isDirectory()) {
+ throw new IllegalArgumentException(dir.getAbsolutePath() + " is not a directory.");
+ }
+
+ long endTime = System.currentTimeMillis() + maxWait;
+ FileFilter fileFilter = new FileFilter() {
+ public boolean accept(File file) {
+ if(!file.getParentFile().equals(dir)) {
+ return false;
+ }
+ return Pattern.matches(pattern, file.getName());
+ }
+ };
+
+ while(System.currentTimeMillis() < endTime) {
+ if(dir.listFiles(fileFilter).length > 0) {
+ return;
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ logger.error("Thread interupt...", e);
+ }
+ }
+ String errorMsg = "Files matching the pattern [" + pattern + "] not found in directory [" + dir.getAbsolutePath() + "]. Waited for " + maxWait + "ms.";
+ logger.error(errorMsg);
+ TestCase.fail(errorMsg);
+ }
+
+ /**
* Assert that the specified file doesn't exists.
* @param file The file in question.
* @param maxWait The maximum length of time (ms) to wait for for the file to disappear.
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/ListenerUtils.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/ListenerUtils.java 2006-08-11 08:43:08 UTC (rev 5738)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/ListenerUtils.java 2006-08-11 09:53:10 UTC (rev 5739)
@@ -28,6 +28,7 @@
import junit.framework.TestCase;
import org.apache.log4j.Logger;
+import org.jboss.soa.esb.common.SystemProperties;
import org.jboss.soa.esb.listeners.GpListener;
import org.jboss.soa.esb.parameters.ParamFileRepository;
import org.jboss.soa.esb.parameters.ParamRepositoryException;
@@ -41,6 +42,16 @@
private static final String CONFIG_TMP_EXT = ".conftmp";
private static Logger logger = Logger.getLogger(ListenerUtils.class);
+
+ private static String DB_DRIVER = "org.jboss.esb.db.driver";
+ private static String DB_URL = "org.jboss.esb.db.url";
+ private static String DB_USER = "org.jboss.esb.db.user";
+ private static String DB_PASSWORD = "org.jboss.esb.db.password";
+
+ private static String dbDriver = System.getProperty(DB_DRIVER);
+ private static String dbUrl = System.getProperty(DB_URL);
+ private static String dbUser = System.getProperty(DB_USER);
+ private static String dbPassword = System.getProperty(DB_PASSWORD);
/**
* Start a list of Listeners based on the supplied configuration.
@@ -51,8 +62,8 @@
*/
public static ListenersManagerExecThread startListeners(String paramName) throws Exception {
ListenersManagerExecThread manager;
- File fixedConfig = fixUpConfig(paramName);
+ fixUpConfig(paramName);
manager = new ListenersManagerExecThread(new GpListener(paramName + CONFIG_TMP_EXT));
logger.info("Waiting on Listener Manager the start...");
@@ -86,6 +97,13 @@
try {
// Replace all the "@qa.build@" tokens with the qa "build" dirs file URI, and write to file...
configXml = configXml.replaceAll("@qa.build@", FileUtils.getEnvBuildDir().toURI().toString());
+ // Replace all the "@db.*@" tokens with the settings from the deployment.properties...
+ configXml = configXml.replaceAll("@db.driver@", dbDriver);
+ configXml = configXml.replaceAll("@db.url@", dbUrl);
+ configXml = configXml.replaceAll("@db.user@", dbUser);
+ configXml = configXml.replaceAll("@db.password@", dbPassword);
+
+ // Write the fixed up config ro a new file - this new file will be used as the listener config!
fixedUpFileStream.write(configXml.getBytes());
} finally {
fixedUpFileStream.flush();
More information about the jboss-svn-commits
mailing list