diff --git a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF
index dc407674047..05cec28a36c 100644
--- a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF
+++ b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF
@@ -16,7 +16,11 @@ Require-Bundle: org.junit,
org.eclipse.rse.subsystems.shells.core,
org.eclipse.rse.tests.framework,
org.eclipse.ui.views,
- org.eclipse.rse.services
+ org.eclipse.rse.services,
+ org.eclipse.rse.services.files.ftp,
+ org.eclipse.rse.subsystems.files.ftp,
+ org.apache.commons.net,
+ com.ibm.icu
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Export-Package: org.eclipse.rse.tests,
diff --git a/rse/tests/org.eclipse.rse.tests/plugin.xml b/rse/tests/org.eclipse.rse.tests/plugin.xml
index f49f1e527bc..030c28bf30f 100644
--- a/rse/tests/org.eclipse.rse.tests/plugin.xml
+++ b/rse/tests/org.eclipse.rse.tests/plugin.xml
@@ -11,8 +11,8 @@
-
-
+
+
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java
index e867108f7a4..ff20d134345 100644
--- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java
@@ -14,9 +14,9 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite;
-import org.eclipse.rse.tests.files.RSEFileTestSuite;
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
import org.eclipse.rse.tests.internal.RSEInternalFrameworkTestSuite;
+import org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite;
/**
* Main class bundling all single specialized test suites into a
@@ -51,7 +51,7 @@ public class RSECombinedTestSuite extends DelegatingTestSuiteHolder {
// add the single test suites to the overall one here.
suite.addTest(RSEInternalFrameworkTestSuite.suite());
suite.addTest(RSEConnectionTestSuite.suite());
- suite.addTest(RSEFileTestSuite.suite());
+ suite.addTest(RSEFileSubsystemTestSuite.suite());
return suite;
}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties
index af007a38d68..2fce42a011f 100644
--- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties
@@ -27,6 +27,11 @@ RSEConnectionTestCase.testConnectionRemoval=true
RSEConnectionTestCase.testConnect=true
RSEConnectionTestCase.testResolveFilterString=true
+FileServiceTest.testCaseSensitive=true
+FileServiceTest.testCreateFile=true
+FileServiceTest.testCreateCaseSensitive=true
+FTPFileSubsystemTestCase.testFTPAccessToHost_ftp_suse_com=true
+
#
# The following section contains externalized string for the single classes
#
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FTPFileSubsystemTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FTPFileSubsystemTestCase.java
new file mode 100644
index 00000000000..87317152e22
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FTPFileSubsystemTestCase.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Uwe Stieber (Wind River) - initial API and implementation.
+ *******************************************************************************/
+package org.eclipse.rse.tests.subsystems.files;
+
+import java.io.IOException;
+
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
+import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.files.IHostFile;
+import org.eclipse.rse.services.files.ftp.FTPService;
+import org.eclipse.rse.subsystems.files.ftp.FTPFileSubSystemConfiguration;
+import org.eclipse.rse.tests.RSETestsPlugin;
+import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties;
+import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
+import org.eclipse.rse.ui.RSEUIPlugin;
+
+/**
+ * Test cases for FTP based remote host access.
+ */
+public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase {
+ private ISubSystem subSystem;
+ private IHost connection;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ if (subSystem != null && subSystem.isConnected()) {
+ subSystem.disconnect(true);
+ }
+ if (connection != null) {
+ getConnectionManager().removeConnection(connection.getSystemProfileName(), connection.getName());
+ }
+
+ subSystem = null;
+ connection = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Test the FTP read access via ftp://ftp.suse.com
+ */
+ public void testFTPAccessToHost_ftp_suse_com() {
+ if (!RSETestsPlugin.isTestCaseEnabled("FTPFileSubsystemTestCase.testFTPAccessToHost_ftp_suse_com")) return; //$NON-NLS-1$
+
+ ISystemRegistry systemRegistry = RSEUIPlugin.getTheSystemRegistry();
+ assertNotNull("Failed to get RSE system registry instance!", systemRegistry); //$NON-NLS-1$
+
+ // Calculate the location of the test connection properties
+ IPath location = getTestDataLocation("testFTPAccessToHost_ftp_suse_com", false); //$NON-NLS-1$
+ assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$
+ location = location.append("connection.properties"); //$NON-NLS-1$
+ assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$
+ assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$
+ assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$
+
+ // Load the properties from the calculated location without backing up defaults
+ IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false);
+ assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$
+
+ // Lookup and create the connection now if necessary
+ connection = getConnectionManager().findOrCreateConnection(properties);
+ assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$
+ // expand the connection in the UI
+ systemRegistry.expandHost(connection);
+
+ Exception exception = null;
+ String cause = null;
+
+ subSystem = null;
+ try {
+ subSystem = getConnectionManager().getFileSubSystem(connection, "ftp.files"); //$NON-NLS-1$
+ } catch(Exception e) {
+ exception = e;
+ cause = e.getLocalizedMessage();
+ }
+ assertNull("Failed to get ftp.files subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$
+ assertNotNull("No ftp.files subystem", subSystem); //$NON-NLS-1$
+
+ // we expect that the subsystem is not connected yet
+ assertFalse("ftp.files subsystem is unexpectedly connected!", subSystem.isConnected()); //$NON-NLS-1$
+ try {
+ subSystem.connect();
+ } catch(Exception e) {
+ exception = e;
+ cause = e.getLocalizedMessage();
+ }
+ assertNull("Failed to connect ftp.files subsystem to host " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME) + "! Possible cause: " + cause, exception); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Failed to connect ftp.files subsystem to host " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME) + "! Unknown cause!", subSystem.isConnected()); //$NON-NLS-1$ //$NON-NLS-2$
+ // expand the subsystem
+ systemRegistry.expandSubSystem(subSystem);
+
+ ISubSystemConfiguration configuration = systemRegistry.getSubSystemConfiguration(subSystem);
+ assertNotNull("Failed to get ftp.files subsystem configuration instance!", configuration); //$NON-NLS-1$
+
+ // The ftp.files subsystem supports filtering, therefor ISubSystem.getChildren() is expected
+ // to return a non null value.
+ assertTrue("Unexpected return value false for ftp.files subsystem configuration supportFilters()!", configuration.supportsFilters()); //$NON-NLS-1$
+ assertNotNull("Unexpected return value null for ftp.files subsystem getChildren()!", subSystem.getChildren()); //$NON-NLS-1$
+
+ // get access to the services
+ assertTrue("ftp.files subsystem configuration instance is not of expected type FileServiceSubSystemConfiguration!", configuration instanceof FTPFileSubSystemConfiguration); //$NON-NLS-1$
+ FTPFileSubSystemConfiguration ftpConfiguration = (FTPFileSubSystemConfiguration)configuration;
+ IFileService service = ftpConfiguration.getFileService(connection);
+ assertNotNull("Failed to get IFileService instance from ftp.files subsystem configuration!", service); //$NON-NLS-1$
+ assertTrue("IFileService instance is not of expected type FTPService!", service instanceof FTPService); //$NON-NLS-1$
+ FTPService ftpService = (FTPService)service;
+
+ // now we have the service reference and can start reading things from the server
+ IHostFile[] roots = ftpService.getRoots(new NullProgressMonitor());
+ assertNotNull("Failed to get root nodes from ftp.files service!", roots); //$NON-NLS-1$
+
+ FTPClient ftpClient = ftpService.getFTPClient();
+ assertNotNull("Failed to get FTPClient instance!", ftpClient); //$NON-NLS-1$
+
+ exception = null;
+ cause = null;
+
+ FTPFile[] files = null;
+ try {
+ files = ftpClient.listFiles();
+ } catch (IOException e) {
+ exception = e;
+ cause = e.getLocalizedMessage();
+ }
+ assertNull("Failed to list the files from ftp server " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME) + "! Possible cause: " + cause, exception); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull("Unexpected return value null for FTPClient.listFiles()!", files); //$NON-NLS-1$
+ }
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/FileServiceTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceTest.java
similarity index 92%
rename from rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/FileServiceTest.java
rename to rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceTest.java
index 7bf9ea94be6..7edae3e4b58 100644
--- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/FileServiceTest.java
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceTest.java
@@ -8,7 +8,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - initial API and implementation
*******************************************************************************/
-package org.eclipse.rse.tests.files;
+package org.eclipse.rse.tests.subsystems.files;
import java.io.File;
import java.io.IOException;
@@ -23,6 +23,7 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.services.files.IHostFile;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import org.eclipse.rse.tests.RSETestsPlugin;
import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
public class FileServiceTest extends RSEBaseConnectionTestCase {
@@ -80,6 +81,8 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
}
public void testCaseSensitive() {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCaseSensitive")) return; //$NON-NLS-1$
+
if (isWindows()) {
assertFalse(fss.getSubSystemConfiguration().isCaseSensitive());
assertFalse(fss.isCaseSensitive());
@@ -92,6 +95,8 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
}
public void testCreateFile() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
+
String testName = getTestFileName();
IHostFile hf = fs.createFile(mon, tempDirPath, testName);
assertTrue(hf.exists());
@@ -109,6 +114,8 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
}
public void testCreateCaseSensitive() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateCaseSensitive")) return; //$NON-NLS-1$
+
String testName = getTestFileName();
String testName2 = testName.toUpperCase();
IHostFile hf = fs.createFile(mon, tempDirPath, testName);
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/RSEFileTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/RSEFileSubsystemTestSuite.java
similarity index 85%
rename from rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/RSEFileTestSuite.java
rename to rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/RSEFileSubsystemTestSuite.java
index ffcdbb10db4..2d9154c9007 100644
--- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/RSEFileTestSuite.java
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/RSEFileSubsystemTestSuite.java
@@ -8,14 +8,14 @@
* Contributors:
* Martin Oberhuber (Wind River) - initial API and implementation
*******************************************************************************/
-package org.eclipse.rse.tests.files;
+package org.eclipse.rse.tests.subsystems.files;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
-public class RSEFileTestSuite extends DelegatingTestSuiteHolder {
+public class RSEFileSubsystemTestSuite extends DelegatingTestSuiteHolder {
/**
* Standard Java application main method. Allows to launch the test
* suite from outside as part of nightly runs, headless runs or other.
@@ -38,9 +38,10 @@ public class RSEFileTestSuite extends DelegatingTestSuiteHolder {
* @return The test suite instance.
*/
public static Test suite() {
- TestSuite suite = new TestSuite("RSE File Test Suite"); //$NON-NLS-1$
+ TestSuite suite = new TestSuite("RSE File Subsystem Test Suite"); //$NON-NLS-1$
// add the single test suites to the overall one here.
suite.addTestSuite(FileServiceTest.class);
+ suite.addTestSuite(FTPFileSubsystemTestCase.class);
return suite;
}
@@ -49,7 +50,7 @@ public class RSEFileTestSuite extends DelegatingTestSuiteHolder {
* @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite()
*/
public TestSuite getTestSuite() {
- return (TestSuite)RSEFileTestSuite.suite();
+ return (TestSuite)RSEFileSubsystemTestSuite.suite();
}
}
diff --git a/rse/tests/org.eclipse.rse.tests/test.data/testFTPAccessToHost_ftp_suse_com/connection.properties b/rse/tests/org.eclipse.rse.tests/test.data/testFTPAccessToHost_ftp_suse_com/connection.properties
new file mode 100644
index 00000000000..0397085fb4e
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/test.data/testFTPAccessToHost_ftp_suse_com/connection.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# Copyright (c) 2006 Wind River Systems, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Uwe Stieber (Wind River) - initial contribution.
+###############################################################################
+
+# Do not change the properties within this file without changing
+# the consuming unittest too!
+name = test_ftp.suse.com
+profile_name = junit_test_profile
+system_type = FTP Only
+address = ftp.suse.com
+userid = anonymous
+password = rseunittest@eclipse.org