
|
[mule-transport-sftp-dev] [98] branches/mule-2.2.x/src/test/java/org/mule/transport/sftp: Ensure that the connection is disconnected after getSftpClient(..) is used.

Some parts of this message have been removed.
Learn more about Nabble's security policy.
[98] branches/mule-2.2.x/src/test/java/org/mule/transport/sftp: Ensure that the connection is disconnected after getSftpClient(..) is used.
- Revision
- 98
- Author
- elhoo
- Date
- 2009-11-01 09:26:51 -0600 (Sun, 01 Nov 2009)
Log Message
Ensure that the connection is disconnected after getSftpClient(..) is used.
Also, try to reuse the sftpClient object as often as possible.
Modified Paths
Diff
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/AbstractSftpTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/AbstractSftpTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/AbstractSftpTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -16,6 +16,7 @@
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.SftpException;
+import org.apache.log4j.Logger;
import org.mule.api.MuleEventContext;
import org.mule.api.MuleException;
import org.mule.api.endpoint.EndpointBuilder;
@@ -38,23 +39,27 @@
*/
public abstract class AbstractSftpTestCase extends FunctionalTestCase
{
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(AbstractSftpTestCase.class);
/** Deletes all files in the directory, useful when testing to ensure that no files are in the way... */
- protected void cleanupRemoteFtpDirectory(MuleClient muleClient, String endpointName) throws IOException
- {
- SftpClient sftpClient = getSftpClient(muleClient, endpointName);
+// protected void cleanupRemoteFtpDirectory(MuleClient muleClient, String endpointName) throws IOException
+// {
+// SftpClient sftpClient = getSftpClient(muleClient, endpointName);
+//
+// EndpointURI endpointURI = getUriByEndpointName(muleClient, endpointName);
+// sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(endpointURI.getPath()));
+//
+// String[] files = sftpClient.listFiles();
+// for (String file : files)
+// {
+// sftpClient.deleteFile(file);
+// }
+// }
- EndpointURI endpointURI = getUriByEndpointName(muleClient, endpointName);
- sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(endpointURI.getPath()));
- String[] files = sftpClient.listFiles();
- for (String file : files)
- {
- sftpClient.deleteFile(file);
- }
- }
-
-
/**
* Deletes a directory with all its files and sub-directories. The reason it do a "chmod 700" before the delete is that some tests
* changes the permission, and thus we have to restore the right to delete it...
@@ -64,10 +69,8 @@
* @param relativePath
* @throws IOException
*/
- protected void recursiveDelete(MuleClient muleClient, String endpointName, String relativePath) throws IOException
+ protected void recursiveDelete(MuleClient muleClient, SftpClient sftpClient, String endpointName, String relativePath) throws IOException
{
- SftpClient sftpClient = getSftpClient(muleClient, endpointName);
-
EndpointURI endpointURI = getUriByEndpointName(muleClient, endpointName);
String path = endpointURI.getPath() + relativePath;
@@ -82,9 +85,12 @@
String[] directories = sftpClient.listDirectories();
for (String directory : directories)
{
- recursiveDelete(muleClient, endpointName, relativePath + "/" + directory);
+ recursiveDelete(muleClient, sftpClient, endpointName, relativePath + "/" + directory);
}
+ // Needs to change the directory back after the recursiveDelete
+ sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(path));
+
// Delete all files
String[] files = sftpClient.listFiles();
for (String file : files)
@@ -107,73 +113,35 @@
}
}
- /** Deletes the <i>directoryName</i> under the endpoint path */
- protected void deleteRemoteDirectory(MuleClient muleClient, String endpointName, String directoryName) throws IOException
- {
- SftpClient sftpClient = getSftpClient(muleClient, endpointName);
-
- EndpointURI endpointURI = getUriByEndpointName(muleClient, endpointName);
-
- // The deleteDirectory operation will fail if there are files in the directory
- try
- {
- sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(endpointURI.getPath() + "/" + directoryName));
- String[] files = sftpClient.listFiles();
- for (String file : files)
- {
- sftpClient.deleteFile(file);
- }
- } catch (Exception e)
- {
- // Ignore, this will occur if the directory didnt exist!
- }
-
- try
- {
- // Ensure that we can delete it (if write is not permitted then delete is either)
- remoteChmod(muleClient, endpointName, 00700);
- sftpClient.deleteDirectory(endpointURI.getPath() + "/" + directoryName);
- } catch (Exception e)
- {
- e.printStackTrace();
- }
-
- try
- {
- String dir = endpointURI.getPath() + "/" + directoryName;
- sftpClient.changeWorkingDirectory(dir);
- fail("The directory '" + dir + "' should have been deleted");
- } catch (IOException e)
- {
- // Expected
- }
- }
-
/** Creates the <i>directoryName</i> under the endpoint path */
protected void createRemoteDirectory(MuleClient muleClient, String endpointName, String directoryName) throws IOException
{
SftpClient sftpClient = getSftpClient(muleClient, endpointName);
- EndpointURI endpointURI = getUriByEndpointName(muleClient, endpointName);
- sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(endpointURI.getPath()));
+ try {
+ EndpointURI endpointURI = getUriByEndpointName(muleClient, endpointName);
+ sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(endpointURI.getPath()));
- try
- {
- sftpClient.mkdir(directoryName);
- } catch (IOException e)
- {
- e.printStackTrace();
- // Expected if the directory didnt exist
- }
+ try
+ {
+ sftpClient.mkdir(directoryName);
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ // Expected if the directory didnt exist
+ }
- try
- {
- sftpClient.changeWorkingDirectory(endpointURI.getPath() + "/" + directoryName);
- } catch (IOException e)
- {
- fail("The directory should have been created");
- }
- }
+ try
+ {
+ sftpClient.changeWorkingDirectory(endpointURI.getPath() + "/" + directoryName);
+ } catch (IOException e)
+ {
+ fail("The directory should have been created");
+ }
+ } finally {
+ sftpClient.disconnect();
+ }
+ }
protected EndpointURI getUriByEndpointName(MuleClient muleClient, String endpointName) throws IOException
{
@@ -194,9 +162,8 @@
return "sftp://" + endpointURI.getUser() + ":" + endpointURI.getPassword() + "@" + endpointURI.getHost() + endpointURI.getPath();
}
- protected String getPathByEndpoint(MuleClient muleClient, String endpointName) throws IOException
+ protected String getPathByEndpoint(MuleClient muleClient, SftpClient sftpClient, String endpointName) throws IOException
{
- SftpClient sftpClient = getSftpClient(muleClient, endpointName);
ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(endpointName);
EndpointURI endpointURI = endpoint.getEndpointURI();
@@ -220,14 +187,17 @@
EndpointURI endpointURI = endpoint.getEndpointURI();
SftpConnector sftpConnector = (SftpConnector) endpoint.getConnector();
- sftpClient.connect(endpointURI.getHost());
- if (sftpConnector.getIdentityFile() != null)
- {
- assertTrue("Login failed", sftpClient.login(endpointURI.getUser(), sftpConnector.getIdentityFile(), sftpConnector.getPassphrase()));
- } else
- {
- assertTrue("Login failed", sftpClient.login(endpointURI.getUser(), endpointURI.getPassword()));
- }
+// if(!sftpClient.isConnected()) {
+ sftpClient.connect(endpointURI.getHost());
+
+ if (sftpConnector.getIdentityFile() != null)
+ {
+ assertTrue("Login failed", sftpClient.login(endpointURI.getUser(), sftpConnector.getIdentityFile(), sftpConnector.getPassphrase()));
+ } else
+ {
+ assertTrue("Login failed", sftpClient.login(endpointURI.getUser(), endpointURI.getPassword()));
+ }
+// }
return sftpClient;
}
@@ -385,10 +355,9 @@
return endpoint;
}
- protected void remoteChmod(MuleClient muleClient, String endpointName, int permissions) throws IOException, SftpException
+ protected void remoteChmod(MuleClient muleClient, SftpClient sftpClient, String endpointName, int permissions) throws IOException, SftpException
{
- SftpClient sftpClient = getSftpClient(muleClient, endpointName);
- ChannelSftp channelSftp = sftpClient.getChannelSftp();
+ ChannelSftp channelSftp = sftpClient.getChannelSftp();
ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(endpointName);
EndpointURI endpointURI = endpoint.getEndpointURI();
@@ -409,17 +378,20 @@
{
MuleClient muleClient = new MuleClient();
SftpClient sftpClient = getSftpClient(muleClient, endpointName);
- ChannelSftp channelSftp = sftpClient.getChannelSftp();
+ try {
+ ChannelSftp channelSftp = sftpClient.getChannelSftp();
+ try
+ {
+ recursiveDelete(muleClient, sftpClient, endpointName, "");
+ } catch (IOException e)
+ {
+ logger.error("", e);
+ }
- try
- {
- recursiveDelete(muleClient, endpointName, "");
- } catch (IOException e)
- {
- logger.error("", e);
+ String path = getPathByEndpoint(muleClient, sftpClient, endpointName);
+ channelSftp.mkdir(path);
+ } finally {
+ sftpClient.disconnect();
}
-
- String path = getPathByEndpoint(muleClient, endpointName);
- channelSftp.mkdir(path);
}
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpIdentityFileFunctionalTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpIdentityFileFunctionalTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpIdentityFileFunctionalTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -39,7 +39,6 @@
private static final int DEFAULT_TIMEOUT = 10000;
//Increase this to be a little larger than expected download time
- protected static final long TIMEOUT = 500000;
private static final String INBOUND_ENDPOINT_NAME = "inboundEndpoint";
protected String getConfigResources()
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpTempDirFunctionalTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpTempDirFunctionalTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpTempDirFunctionalTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -70,21 +70,27 @@
// for example since we dont have the TestComp
Thread.sleep(10000);
- try
+ SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
+ try
{
- SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
EndpointURI endpointURI = getUriByEndpointName(muleClient, OUTBOUND_ENDPOINT_NAME);
sftpClient.changeWorkingDirectory(endpointURI.getPath() + "/" + TEMP_DIR);
} catch (IOException f)
{
fail("The temp directory should have been created");
- }
+ } finally {
+ sftpClient.disconnect();
+ }
- SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
- ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(OUTBOUND_ENDPOINT_NAME);
- assertTrue("The file should exist in the final destination", super.verifyFileExists(sftpClient, endpoint.getEndpointURI(), fileName));
- assertFalse("No file should exist in the temp directory", super.verifyFileExists(sftpClient, endpoint.getEndpointURI().getPath() + "/uploading", fileName));
- }
+ try {
+ sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
+ ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(OUTBOUND_ENDPOINT_NAME);
+ assertTrue("The file should exist in the final destination", super.verifyFileExists(sftpClient, endpoint.getEndpointURI(), fileName));
+ assertFalse("No file should exist in the temp directory", super.verifyFileExists(sftpClient, endpoint.getEndpointURI().getPath() + "/uploading", fileName));
+ } finally {
+ sftpClient.disconnect();
+ }
+ }
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/AbstractSftpDataIntegrityTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/AbstractSftpDataIntegrityTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/AbstractSftpDataIntegrityTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -32,21 +32,27 @@
protected void verifyInAndOutFiles(MuleClient muleClient, String inboundEndpointName, String outboundEndpointName,
boolean shouldInboundFileStillExist, boolean shouldOutboundFileExist) throws IOException {
SftpClient sftpClientInbound = getSftpClient(muleClient, inboundEndpointName);
- ImmutableEndpoint inboundEndpoint = (ImmutableEndpoint) muleClient.getProperty(inboundEndpointName);
-
SftpClient sftpClientOutbound = getSftpClient(muleClient, outboundEndpointName);
- ImmutableEndpoint outboundEndpoint = (ImmutableEndpoint) muleClient.getProperty(outboundEndpointName);
- if (shouldInboundFileStillExist) {
- assertTrue("The inbound file should still exist", super.verifyFileExists(sftpClientInbound, inboundEndpoint.getEndpointURI(), FILE_NAME));
- } else {
- assertFalse("The inbound file should have been deleted", super.verifyFileExists(sftpClientInbound, inboundEndpoint.getEndpointURI(), FILE_NAME));
- }
+ try {
+ ImmutableEndpoint inboundEndpoint = (ImmutableEndpoint) muleClient.getProperty(inboundEndpointName);
- if (shouldOutboundFileExist) {
- assertTrue("The outbound file should exist", super.verifyFileExists(sftpClientOutbound, outboundEndpoint.getEndpointURI(), FILE_NAME));
- } else {
- assertFalse("The outbound file should have been deleted", super.verifyFileExists(sftpClientOutbound, outboundEndpoint.getEndpointURI(), FILE_NAME));
+ ImmutableEndpoint outboundEndpoint = (ImmutableEndpoint) muleClient.getProperty(outboundEndpointName);
+
+ if (shouldInboundFileStillExist) {
+ assertTrue("The inbound file should still exist", super.verifyFileExists(sftpClientInbound, inboundEndpoint.getEndpointURI(), FILE_NAME));
+ } else {
+ assertFalse("The inbound file should have been deleted", super.verifyFileExists(sftpClientInbound, inboundEndpoint.getEndpointURI(), FILE_NAME));
+ }
+
+ if (shouldOutboundFileExist) {
+ assertTrue("The outbound file should exist", super.verifyFileExists(sftpClientOutbound, outboundEndpoint.getEndpointURI(), FILE_NAME));
+ } else {
+ assertFalse("The outbound file should have been deleted", super.verifyFileExists(sftpClientOutbound, outboundEndpoint.getEndpointURI(), FILE_NAME));
+ }
+ } finally {
+ sftpClientInbound.disconnect();
+ sftpClientOutbound.disconnect();
}
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpCantCreateTempDirectoryTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpCantCreateTempDirectoryTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpCantCreateTempDirectoryTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -1,6 +1,7 @@
package org.mule.transport.sftp.dataintegrity;
import org.mule.module.client.MuleClient;
+import org.mule.transport.sftp.SftpClient;
/**
* Tests that files are not deleted if the temp directory can't be created
@@ -35,20 +36,26 @@
{
MuleClient muleClient = new MuleClient();
- // change the chmod to "dr-x------" on the outbound-directory
- // --> the temp directory should not be able to be created
- remoteChmod(muleClient, OUTBOUND_ENDPOINT_NAME, 00500);
+ SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
- // Send an file to the SFTP server, which the inbound-outboundEndpoint then can pick up
- muleClient.dispatch(getAddressByEndpoint(muleClient, INBOUND_ENDPOINT_NAME), TEST_MESSAGE, fileNameProperties);
+ try {
+// change the chmod to "dr-x------" on the outbound-directory
+ // --> the temp directory should not be able to be created
+ remoteChmod(muleClient, sftpClient, OUTBOUND_ENDPOINT_NAME, 00500);
- // TODO dont know any better way to wait for the above to finish? We cant use the same as SftpFileAgeFunctionalTestCase
- // for example since we don't have the TestComponent because we want to have to Sftp-endpoints?
- Thread.sleep(5000);
+ // Send an file to the SFTP server, which the inbound-outboundEndpoint then can pick up
+ muleClient.dispatch(getAddressByEndpoint(muleClient, INBOUND_ENDPOINT_NAME), TEST_MESSAGE, fileNameProperties);
- verifyInAndOutFiles(muleClient, INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME, true, false);
- }
+ // TODO dont know any better way to wait for the above to finish? We cant use the same as SftpFileAgeFunctionalTestCase
+ // for example since we don't have the TestComponent because we want to have to Sftp-endpoints?
+ Thread.sleep(5000);
+ verifyInAndOutFiles(muleClient, INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME, true, false);
+ } finally {
+ sftpClient.disconnect();
+ }
+ }
+
/**
* The same test as above, but with the difference that this time it should be okay to create the directory,
* and the file should be gone from the inbound directory.
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpCantWriteToFinalDestAfterTempDirectoryTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpCantWriteToFinalDestAfterTempDirectoryTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpCantWriteToFinalDestAfterTempDirectoryTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -40,8 +40,11 @@
// Must create the temp directory before we change the access rights
createRemoteDirectory(muleClient, OUTBOUND_ENDPOINT_NAME, "uploading");
+ SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
+
+ try {
// change the chmod to "dr-x------" on the outbound-directory
- remoteChmod(muleClient, OUTBOUND_ENDPOINT_NAME, 00500);
+ remoteChmod(muleClient, sftpClient, OUTBOUND_ENDPOINT_NAME, 00500);
// Send an file to the SFTP server, which the inbound-outboundEndpoint then can pick up
muleClient.dispatch(getAddressByEndpoint(muleClient, INBOUND_ENDPOINT_NAME), TEST_MESSAGE, fileNameProperties);
@@ -52,9 +55,11 @@
verifyInAndOutFiles(muleClient, INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME, true, false);
- SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
- ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(OUTBOUND_ENDPOINT_NAME);
- assertFalse("The inbound file should not be left in the TEMP-dir", super.verifyFileExists(sftpClient, endpoint.getEndpointURI().getPath() + "/" + TEMP_DIR, FILE_NAME));
- }
+ ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(OUTBOUND_ENDPOINT_NAME);
+ assertFalse("The inbound file should not be left in the TEMP-dir", super.verifyFileExists(sftpClient, endpoint.getEndpointURI().getPath() + "/" + TEMP_DIR, FILE_NAME));
+ } finally {
+ sftpClient.disconnect();
+ }
+ }
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpNoOutboundDirectoryTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpNoOutboundDirectoryTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpNoOutboundDirectoryTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -39,8 +39,12 @@
Thread.sleep(2000);
SftpClient sftpClient = getSftpClient(muleClient, ENDPOINT_NAME);
- ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(ENDPOINT_NAME);
- assertTrue("The inbound file should still exist", super.verifyFileExists(sftpClient, endpoint.getEndpointURI(), FILE_NAME));
+ try {
+ ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(ENDPOINT_NAME);
+ assertTrue("The inbound file should still exist", super.verifyFileExists(sftpClient, endpoint.getEndpointURI(), FILE_NAME));
+ } finally {
+ sftpClient.disconnect();
+ }
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpNoWriteAccessToOutboundDirectoryTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpNoWriteAccessToOutboundDirectoryTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpNoWriteAccessToOutboundDirectoryTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -1,6 +1,7 @@
package org.mule.transport.sftp.dataintegrity;
import org.mule.module.client.MuleClient;
+import org.mule.transport.sftp.SftpClient;
/**
* Verify that the original file is not lost if the outbound directory doesn't exist
@@ -30,18 +31,24 @@
{
MuleClient muleClient = new MuleClient();
- // change the chmod to "dr-x------" on the outbound-directory
- remoteChmod(muleClient, OUTBOUND_ENDPOINT_NAME, 00500);
+ SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
- // Send an file to the SFTP server, which the inbound-outboundEndpoint then can pick up
- muleClient.dispatch(getAddressByEndpoint(muleClient, INBOUND_ENDPOINT_NAME), TEST_MESSAGE, fileNameProperties);
+ try {
+// change the chmod to "dr-x------" on the outbound-directory
+ remoteChmod(muleClient, sftpClient, OUTBOUND_ENDPOINT_NAME, 00500);
- // TODO dont know any better way to wait for the above to finish? We cant use the same as SftpFileAgeFunctionalTestCase
- // for example since we dont have the TestComponent
- Thread.sleep(4000);
+ // Send an file to the SFTP server, which the inbound-outboundEndpoint then can pick up
+ muleClient.dispatch(getAddressByEndpoint(muleClient, INBOUND_ENDPOINT_NAME), TEST_MESSAGE, fileNameProperties);
- verifyInAndOutFiles(muleClient, INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME, true, false);
- }
+ // TODO dont know any better way to wait for the above to finish? We cant use the same as SftpFileAgeFunctionalTestCase
+ // for example since we dont have the TestComponent
+ Thread.sleep(4000);
+ verifyInAndOutFiles(muleClient, INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME, true, false);
+ } finally {
+ sftpClient.disconnect();
+ }
+ }
+
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpWrongPassPhraseOnOutboundDirectoryTestCase.java (97 => 98)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpWrongPassPhraseOnOutboundDirectoryTestCase.java 2009-11-01 14:30:42 UTC (rev 97)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/SftpWrongPassPhraseOnOutboundDirectoryTestCase.java 2009-11-01 15:26:51 UTC (rev 98)
@@ -42,8 +42,12 @@
Thread.sleep(5000);
SftpClient sftpClient = getSftpClient(muleClient, INBOUND_ENDPOINT_NAME);
- ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(INBOUND_ENDPOINT_NAME);
- assertTrue("The inbound file should still exist", super.verifyFileExists(sftpClient, endpoint.getEndpointURI(), FILE_NAME));
- }
+ try {
+ ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(INBOUND_ENDPOINT_NAME);
+ assertTrue("The inbound file should still exist", super.verifyFileExists(sftpClient, endpoint.getEndpointURI(), FILE_NAME));
+ } finally {
+ sftpClient.disconnect();
+ }
+ }
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MuleForge Dev" group. To post to this group, send email to muleforgedev@... To unsubscribe from this group, send email to muleforgedev+unsubscribe@... For more options, visit this group at http://groups.google.com/group/muleforgedev?hl=en
-~----------~----~----~----~------~----~------~--~---
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://admin.muleforge.org/manage_email
|