
|
[mule-transport-sftp-dev] [96] branches/mule-2.2.x/src/test/resources: Added the initEndpointDirectory to every test to that all tests now ensurers that the directory exists (and is writable).

Some parts of this message have been removed.
Learn more about Nabble's security policy.
[96] branches/mule-2.2.x/src/test/resources: Added the initEndpointDirectory to every test to that all tests now ensurers that the directory exists (and is writable).
- Revision
- 96
- Author
- elhoo
- Date
- 2009-10-31 15:55:41 -0500 (Sat, 31 Oct 2009)
Log Message
Added the initEndpointDirectory to every test to that all tests now ensurers that the directory exists (and is writable).
This makes the setup very easy for new developers - no directories are needs to be created!
Modified Paths
Diff
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/AbstractSftpTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/AbstractSftpTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/AbstractSftpTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -17,6 +17,7 @@
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.SftpException;
import org.mule.api.MuleEventContext;
+import org.mule.api.MuleException;
import org.mule.api.endpoint.EndpointBuilder;
import org.mule.api.endpoint.EndpointURI;
import org.mule.api.endpoint.ImmutableEndpoint;
@@ -257,7 +258,8 @@
MuleClient client = new MuleClient();
// Do some cleaning so that the endpoint doesn't have any other files
- cleanupRemoteFtpDirectory(client, inputEndpointName);
+ // We don't need to do this anymore since we are deleting and then creating the directory for each test
+ // cleanupRemoteFtpDirectory(client, inputEndpointName);
final CountDownLatch latch = new CountDownLatch(1);
final AtomicInteger loopCount = new AtomicInteger(0);
@@ -394,4 +396,30 @@
// RW - so that we can do initial cleanup
channelSftp.chmod(permissions, sftpClient.getAbsolutePath(endpointURI.getPath()));
}
+
+ /**
+ * Ensures that the directory exists and is writable by deleting the directory and then recreate it.
+ *
+ * @param endpointName
+ * @throws org.mule.api.MuleException
+ * @throws java.io.IOException
+ * @throws com.jcraft.jsch.SftpException
+ */
+ protected void initEndpointDirectory(String endpointName) throws MuleException, IOException, SftpException
+ {
+ MuleClient muleClient = new MuleClient();
+ SftpClient sftpClient = getSftpClient(muleClient, endpointName);
+ ChannelSftp channelSftp = sftpClient.getChannelSftp();
+
+ try
+ {
+ recursiveDelete(muleClient, endpointName, "");
+ } catch (IOException e)
+ {
+ logger.error("", e);
+ }
+
+ String path = getPathByEndpoint(muleClient, endpointName);
+ channelSftp.mkdir(path);
+ }
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpArchiveFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpArchiveFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpArchiveFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -27,24 +27,34 @@
// TODO. Runs much faster but makes test3 to fail.
// setDisposeManagerPerSuite(true);
}
-
+
protected String getConfigResources()
{
return "mule-sftp-archive-test-config.xml";
}
+ @Override
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+
+ initEndpointDirectory("inboundEndpoint1");
+ initEndpointDirectory("inboundEndpoint2");
+ initEndpointDirectory("inboundEndpoint3");
+ initEndpointDirectory("inboundEndpoint4");
+ }
+
/**
- * Test plain archive functionality with no extra features enabled
+ * Test plain archive functionality with no extra features enabled
*/
public void testArchive1() throws Exception
{
// TODO. Add some tests specific to this test, i.e. not only rely on the tests performed by executeTest().
-
+
executeBaseTest("inboundEndpoint1", "vm://test.upload1", "file1.txt", SEND_SIZE, "receiving1", TIMEOUT);
}
/**
- * Test archive functionality with full usage of temp-dir and creation of unique names of temp-files
+ * Test archive functionality with full usage of temp-dir and creation of unique names of temp-files
*/
public void testArchive2() throws Exception
{
@@ -64,7 +74,7 @@
}
/**
- * Test archive functionality with usage of temp-dir for archive but not for inbound and outbound endpoints
+ * Test archive functionality with usage of temp-dir for archive but not for inbound and outbound endpoints
*/
public void testArchive4() throws Exception
{
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpDuplicateHandlingFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpDuplicateHandlingFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpDuplicateHandlingFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -24,7 +24,7 @@
// TODO. Not very elegant solution, but the best I could figure out right now. Needs tp be improved over time...
private boolean expectException = false;
-
+
// Size of the generated stream - 2 Mb
final static int SEND_SIZE = 1024 * 1024 * 2;
@@ -43,38 +43,43 @@
{
return "mule-sftp-duplicateHandling-test-config.xml";
}
-
+
@Override
protected void doSetUp() throws Exception {
super.doSetUp();
+
+ initEndpointDirectory("inboundEndpoint1");
+ initEndpointDirectory("inboundEndpoint2");
+ initEndpointDirectory("inboundEndpoint3");
+
ExceptionListener.reset();
expectException = false;
}
-
+
/**
- * Test 1 - test duplicate handling by throwing an exception
+ * Test 1 - test duplicate handling by throwing an exception
*/
public void testDuplicateHandlingThrowException() throws Exception
{
// TODO. Add some tests specific to this test, i.e. not only rely on the tests performed by executeTest().
-
+
executeBaseTest("inboundEndpoint1", "vm://test.upload1", "file1.txt", SEND_SIZE, "receiving1", TIMEOUT);
}
/**
- * Test 2 - test duplicate handling by overwriting the existing file
+ * Test 2 - test duplicate handling by overwriting the existing file
* Not yet implemented, so currently we check for a valid exception...
*/
public void testDuplicateHandlingOverwrite() throws Exception
{
// TODO. Add some tests specific to this test, i.e. not only rely on the tests performed by executeTest().
-
+
expectException = true;
assertNull(ExceptionListener.getStandardException());
executeBaseTest("inboundEndpoint2", "vm://test.upload2", "file2.txt", SEND_SIZE, "receiving2", TIMEOUT);
-
+
// Verify that a NotImplementedException exception was throwed...
Throwable ex = ExceptionListener.getStandardException();
assertNotNull(ex);
@@ -82,7 +87,7 @@
}
/**
- * Test 3 - test duplicate handling by adding a sequence number to the new file
+ * Test 3 - test duplicate handling by adding a sequence number to the new file
*/
public void testDuplicateHandlingAddSeqNo() throws Exception
{
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpFileAgeFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpFileAgeFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpFileAgeFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -45,6 +45,13 @@
return "mule-sftp-file-age-config.xml";
}
+ @Override
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+
+ initEndpointDirectory("inboundEndpoint");
+ }
+
public void testFileAge() throws Exception
{
final CountDownLatch latch = new CountDownLatch(1);
@@ -77,7 +84,7 @@
MuleClient client = new MuleClient();
// Ensure that no other files exists
- cleanupRemoteFtpDirectory(client, INBOUND_ENDPOINT_NAME);
+// cleanupRemoteFtpDirectory(client, INBOUND_ENDPOINT_NAME);
Object component = getComponent("testComponent");
assertTrue("FunctionalTestComponent expected", component instanceof FunctionalTestComponent);
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpIdentityFileFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpIdentityFileFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpIdentityFileFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -47,7 +47,14 @@
return "mule-sftp-identity-file-config.xml";
}
+ @Override
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+ initEndpointDirectory(INBOUND_ENDPOINT_NAME);
+ }
+
+
//Downloads large file in the remote directory specified in config
public void testIdentityFile() throws Exception
{
@@ -81,7 +88,7 @@
MuleClient client = new MuleClient();
// Ensure that no other files exists
- cleanupRemoteFtpDirectory(client, INBOUND_ENDPOINT_NAME);
+// cleanupRemoteFtpDirectory(client, INBOUND_ENDPOINT_NAME);
Map properties = new HashMap();
// properties.put("filename", "foo.bar");
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpNotificationFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpNotificationFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpNotificationFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -26,6 +26,9 @@
@Override
protected void doSetUp() throws Exception {
super.doSetUp();
+
+ initEndpointDirectory("inboundEndpoint");
+
SftpTransportNotificationTestListener.reset();
}
@@ -47,22 +50,22 @@
*/
@Override
protected void executeBaseAssertionsBeforeCall() {
-
+
super.executeBaseAssertionsBeforeCall();
-
+
// Assert that none of the sftp-notifications already are set
assertFalse(SftpTransportNotificationTestListener.gotSftpPutNotification());
assertFalse(SftpTransportNotificationTestListener.gotSftpRenameNotification());
assertFalse(SftpTransportNotificationTestListener.gotSftpGetNotification());
- assertFalse(SftpTransportNotificationTestListener.gotSftpDeleteNotification());
- }
+ assertFalse(SftpTransportNotificationTestListener.gotSftpDeleteNotification());
+ }
/**
* To be overridden by the test-classes if required
*/
@Override
protected void executeBaseAssertionsAfterCall(int sendSize, int receivedSize) {
-
+
super.executeBaseAssertionsAfterCall(sendSize, receivedSize);
// Now also verify that we got the expected sftp-notifications
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpQuartzRequesterFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpQuartzRequesterFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpQuartzRequesterFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -27,13 +27,21 @@
return "mule-sftp-quartzRequester-test-config.xml";
}
+ @Override
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+
+ // In this test we need to get the outboundEndpoint instead of the inbound
+ initEndpointDirectory("outboundEndpoint");
+ }
+
/**
- * Test a quarts based requester
+ * Test a quarts based requester
*/
public void testQuartzRequester() throws Exception
{
// TODO. Add some tests specific to sizeCheck, i.e. create a very large file and ensure that the sizeChec prevents the inbound enpoint to read the file during creation of it
-
+
executeBaseTest("inboundEndpoint", "vm://test.upload", "file.txt", SEND_SIZE, "receiving", TIMEOUT);
}
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSendReceiveFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSendReceiveFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSendReceiveFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -11,8 +11,6 @@
package org.mule.transport.sftp;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -47,7 +45,14 @@
return "mule-send-receive-test-config.xml";
}
+ @Override
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+ initEndpointDirectory("inboundEndpoint");
+ }
+
+
public void testSendAndReceiveSingleFile() throws Exception
{
sendFiles = new ArrayList<String>();
@@ -85,8 +90,8 @@
sendAndReceiveFiles();
}
-
-
+
+
protected void sendAndReceiveFiles() throws Exception
{
final CountDownLatch latch = new CountDownLatch(sendFiles.size());
@@ -94,9 +99,6 @@
MuleClient client = new MuleClient();
- // Do some cleaning so that the endpoint doesnt have any other files
- super.cleanupRemoteFtpDirectory(client, "inboundEndpoint");
-
receiveFiles = new ArrayList<String>();
EventCallback callback = new EventCallback()
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSendReceiveLargeFileFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSendReceiveLargeFileFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSendReceiveLargeFileFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -41,6 +41,13 @@
return "mule-send-receive-large-file-test-config.xml";
}
+ @Override
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+
+ initEndpointDirectory("inboundEndpoint");
+ }
+
/**
* Test sending and receiving a large file.
*
@@ -48,5 +55,5 @@
public void testSendAndReceiveLargeFile() throws Exception
{
executeBaseTest("inboundEndpoint", "vm://test.upload", "bigfile.txt", SEND_SIZE, "receiving", TIMEOUT * 10);
- }
+ }
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSizeCheckFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSizeCheckFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpSizeCheckFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -27,13 +27,20 @@
return "mule-sftp-sizeCheck-test-config.xml";
}
+ @Override
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+
+ initEndpointDirectory("inboundEndpoint");
+ }
+
/**
- * Test the sizeCheck feature
+ * Test the sizeCheck feature
*/
public void testSizeCheck() throws Exception
{
// TODO. Add some tests specific to sizeCheck, i.e. create a very large file and ensure that the sizeChec prevents the inbound enpoint to read the file during creation of it
-
+
executeBaseTest("inboundEndpoint", "vm://test.upload", "file.txt", SEND_SIZE, "receiving", TIMEOUT);
}
}
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpTempDirFunctionalTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpTempDirFunctionalTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/SftpTempDirFunctionalTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -44,16 +44,24 @@
return "mule-sftp-temp-dir-config.xml";
}
+ @Override
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+
+ initEndpointDirectory(INBOUND_ENDPOINT_NAME);
+ initEndpointDirectory(OUTBOUND_ENDPOINT_NAME);
+ }
+
public void testTempDir() throws Exception
{
MuleClient muleClient = new MuleClient();
// Ensure that no other files exists
- cleanupRemoteFtpDirectory(muleClient, OUTBOUND_ENDPOINT_NAME);
- cleanupRemoteFtpDirectory(muleClient, INBOUND_ENDPOINT_NAME);
+// cleanupRemoteFtpDirectory(muleClient, OUTBOUND_ENDPOINT_NAME);
+// cleanupRemoteFtpDirectory(muleClient, INBOUND_ENDPOINT_NAME);
// Delete the temp directory so that we can ensure that it is created
- deleteRemoteDirectory(muleClient, OUTBOUND_ENDPOINT_NAME, TEMP_DIR);
+// deleteRemoteDirectory(muleClient, OUTBOUND_ENDPOINT_NAME, TEMP_DIR);
// Send an file to the SFTP server, which the inbound-endpoint then can pick up
muleClient.dispatch(getAddressByEndpoint(muleClient, INBOUND_ENDPOINT_NAME) + "?connector=sftpCustomConnector", TEST_MESSAGE, fileNameProperties);
Modified: branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/AbstractSftpDataIntegrityTestCase.java (95 => 96)
--- branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/AbstractSftpDataIntegrityTestCase.java 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/java/org/mule/transport/sftp/dataintegrity/AbstractSftpDataIntegrityTestCase.java 2009-10-31 20:55:41 UTC (rev 96)
@@ -50,31 +50,4 @@
}
}
- /**
- * Deletes the directory and then recreate it.
- * TODO: this assumes that no other directories than the tempDir exist (sftp doesn't support recursive delete)
- *
- * @param endpointName
- * @throws org.mule.api.MuleException
- * @throws java.io.IOException
- * @throws com.jcraft.jsch.SftpException
- */
- protected void initEndpointDirectory(String endpointName) throws MuleException, IOException, SftpException
- {
- MuleClient muleClient = new MuleClient();
- SftpClient sftpClient = getSftpClient(muleClient, endpointName);
- ChannelSftp channelSftp = sftpClient.getChannelSftp();
-
- try
- {
- recursiveDelete(muleClient, endpointName, "");
- } catch (IOException e)
- {
- logger.error("", e);
- }
-
- String path = getPathByEndpoint(muleClient, endpointName);
- channelSftp.mkdir(path);
- }
-
}
Modified: branches/mule-2.2.x/src/test/resources/mule-sftp-quartzRequester-test-config.xml (95 => 96)
--- branches/mule-2.2.x/src/test/resources/mule-sftp-quartzRequester-test-config.xml 2009-10-16 13:42:25 UTC (rev 95)
+++ branches/mule-2.2.x/src/test/resources/mule-sftp-quartzRequester-test-config.xml 2009-10-31 20:55:41 UTC (rev 96)
@@ -16,10 +16,10 @@
http://www.mulesource.org/schema/mule/quartz/2.2 http://www.mulesource.org/schema/mule/quartz/2.2/mule-quartz.xsd">
<sftp:connector name="sftp"/>
-
+
<!-- synchronous="true" - otherwise the inbound endpoint will trigger several times -->
- <sftp:endpoint
- name="inboundEndpoint"
+ <sftp:endpoint
+ name="inboundEndpoint"
synchronous="true"
address="sftp://${USER1_NAME}:${USER1_PASSWORD}@${SFTP_HOST}/data"/>
@@ -31,7 +31,8 @@
<outbound>
<pass-through-router>
<sftp:outbound-endpoint
- address="sftp://${USER1_NAME}:${USER1_PASSWORD}@${SFTP_HOST}/data"
+ name="outboundEndpoint"
+ address="sftp://${USER1_NAME}:${USER1_PASSWORD}@${SFTP_HOST}/data"
outputPattern="${DATE}.dat"/>
</pass-through-router>
</outbound>
@@ -41,9 +42,9 @@
<model name="receive">
<service name="receiving">
<inbound>
- <quartz:inbound-endpoint
+ <quartz:inbound-endpoint
name="quartzInboundEndpoint"
- cronExpression="0/3 * * * * ?"
+ cronExpression="0/3 * * * * ?"
jobName="cronJob">
<quartz:endpoint-polling-job>
<quartz:job-endpoint ref="inboundEndpoint" />
--~--~---------~--~----~------------~-------~--~----~
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
|