[jboss-svn-commits] JBL Code SVN: r10088 - labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Mar 9 08:08:37 EST 2007
Author: mark.little at jboss.com
Date: 2007-03-09 08:08:37 -0500 (Fri, 09 Mar 2007)
New Revision: 10088
Added:
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerIntegrationTest.java
Modified:
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListenerUnitTest.java
Log:
http://jira.jboss.com/jira/browse/JBESB-345
Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java 2007-03-09 13:06:54 UTC (rev 10087)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java 2007-03-09 13:08:37 UTC (rev 10088)
@@ -25,10 +25,14 @@
import java.io.File;
import java.io.FileOutputStream;
+import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.common.tests.BaseTest;
import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.soa.esb.listeners.gateway.FileGatewayListener;
import org.jboss.soa.esb.listeners.gateway.GatewayException;
+import org.jboss.soa.esb.listeners.gateway.FileGatewayListener.PackageFileContents;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
public class FileGatewayListenerUnitTest extends BaseTest
{
@@ -49,6 +53,7 @@
tree.setAttribute("inputSuffix", "dummy");
tree.setAttribute("workSuffix", "work");
tree.setAttribute("postDelete", "true");
+ tree.setAttribute(ListenerTagNames.POLL_LATENCY_SECS_TAG, "abcd");
FileGatewayListener gateway = new FileGatewayListener(tree);
boolean exception = false;
@@ -65,6 +70,67 @@
if (!exception)
fail();
+ try
+ {
+ gateway.doInitialise();
+ }
+ catch (ManagedLifecycleException ex)
+ {
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+
+ fail();
+ }
+
+ exception = false;
+
+ try
+ {
+ gateway.stop();
+ }
+ catch (ManagedLifecycleException ex)
+ {
+ exception = true;
+ }
+ catch (Exception ex)
+ {
+ fail();
+ }
+
+ gateway.run();
+
+ PackageFileContents f = gateway.new PackageFileContents();
+
+ exception = false;
+
+ try
+ {
+ f.process(new File("hello"));
+ }
+ catch (GatewayException ex)
+ {
+ exception = true;
+ }
+
+ if (!exception)
+ fail();
+
+ exception = false;
+
+ try
+ {
+ f.process("hello");
+ }
+ catch (ConfigurationException ex)
+ {
+ exception = true;
+ }
+
+ if (!exception)
+ fail();
+
File testFile = null;
File anTestFile = null;
@@ -78,6 +144,10 @@
stream.write(testString.getBytes());
stream.close();
+ f = gateway.new PackageFileContents();
+
+ f.process(testFile);
+
try
{
byte[] content = gateway.getFileContents(testFile);
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerIntegrationTest.java (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerIntegrationTest.java 2007-03-09 13:08:37 UTC (rev 10088)
@@ -0,0 +1,129 @@
+/*
+ * 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.gateway;
+
+import java.io.File;
+
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerUtil;
+import org.jboss.soa.esb.listeners.gateway.GatewayException;
+
+public class RemoteGatewayListenerIntegrationTest extends BaseTest
+{
+ public RemoteGatewayListenerIntegrationTest ()
+ {
+ }
+
+ public void testGateway () throws Exception
+ {
+ ConfigTree tree = new ConfigTree("test");
+ final File tmpDir = new File(System.getProperty("user.dir")) ;
+ final String tmpDirForm = tmpDir.toURL().toExternalForm() ;
+
+ tree.setAttribute("inputDir", tmpDirForm);
+ tree.setAttribute("target-service-category", "Example");
+ tree.setAttribute("target-service-name", "Test");
+ tree.setAttribute("gatewayClass", "org.jboss.soa.esb.listeners.gateway.RemoteGatewayListener");
+ tree.setAttribute("inputSuffix", ".dummy");
+ tree.setAttribute("workSuffix", "work");
+ tree.setAttribute("postDelete", "true");
+ tree.setAttribute("protocol", "ftp");
+
+ String url = null;
+
+ if (getFtpUser() != null)
+ url = getFtpUser()+":";
+
+ if (getFtpPwd() != null)
+ url = url + getFtpPwd()+"@";
+
+ tree.setAttribute(FTPEpr.URL_TAG, "ftp://"+url+getFtpHostname()+"/"+getFtpDir());
+
+ RemoteGatewayListener gateway = new RemoteGatewayListener(tree);
+ boolean exception = false;
+
+ try
+ {
+ gateway.deleteFile(new File("foo"));
+ }
+ catch (GatewayException ex)
+ {
+ exception = true;
+ }
+
+ if (!exception)
+ fail();
+
+ gateway.run();
+
+ try
+ {
+ byte[] contents = gateway.getFileContents(new File("bar"));
+
+ fail();
+ }
+ catch (GatewayException ex)
+ {
+ }
+
+ // TODO this ignores the parameter too!
+
+ try
+ {
+ gateway.getFileList("foobar");
+ }
+ catch (GatewayException ex)
+ {
+ fail();
+ }
+
+ exception = false;
+
+ try
+ {
+ gateway.deleteFile(new File("foo"));
+ }
+ catch (GatewayException ex)
+ {
+ exception = true;
+ }
+
+ if (!exception)
+ fail();
+
+ try
+ {
+ gateway.renameFile(new File("foo"), new File("bar"));
+
+ fail();
+ }
+ catch (GatewayException ex)
+ {
+ }
+ }
+
+}
Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListenerUnitTest.java 2007-03-09 13:06:54 UTC (rev 10087)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListenerUnitTest.java 2007-03-09 13:08:37 UTC (rev 10088)
@@ -123,7 +123,24 @@
tree.setAttribute("target-service-category", "Example");
tree.setAttribute("target-service-name", "Test");
tree.setAttribute("gatewayClass", "org.jboss.soa.esb.listeners.gateway.JdbcTableGatewayListener");
+ tree.setAttribute(ListenerTagNames.SQL_SELECT_FIELDS_TAG, "esb_messages");
+ exception = false;
+
+ try
+ {
+ gateway = new SqlTableGatewayListener(tree);
+ }
+ catch (ConfigurationException ex)
+ {
+ exception = true;
+ }
+
+ if (!exception)
+ fail();
+
+ tree.setAttribute(ListenerTagNames.SQL_SELECT_FIELDS_TAG, "*");
+
gateway = new SqlTableGatewayListener(tree);
try
@@ -137,6 +154,8 @@
fail();
}
+ gateway.resolveComposerClass();
+
exception = false;
try
@@ -150,12 +169,21 @@
if (!exception)
fail();
-
+
gateway.pollForCandidates();
+ gateway.doDestroy();
+
gateway.changeStatusToDone();
- gateway.deleteCurrentRow();
+ try
+ {
+ gateway.deleteCurrentRow();
+ }
+ catch (IllegalStateException ex)
+ {
+ fail();
+ }
}
}
More information about the jboss-svn-commits
mailing list