Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-05-15 17:03:08 -0400
committerMichael Valenta2002-05-15 17:03:08 -0400
commit7f036f87efd92979679797069dfea83a6995d004 (patch)
tree851d755f0a0e995650e395a8f30213f3a4dc9d98 /tests/org.eclipse.team.tests.core
parent68ca7959a27db75eae2096fea121d3f715f91c46 (diff)
downloadeclipse.platform.team-7f036f87efd92979679797069dfea83a6995d004.tar.gz
eclipse.platform.team-7f036f87efd92979679797069dfea83a6995d004.tar.xz
eclipse.platform.team-7f036f87efd92979679797069dfea83a6995d004.zip
Initial release of ftp client tests
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/.classpath1
-rw-r--r--tests/org.eclipse.team.tests.core/.project1
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/ClientTest.java63
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/FTPTestSetup.java107
4 files changed, 172 insertions, 0 deletions
diff --git a/tests/org.eclipse.team.tests.core/.classpath b/tests/org.eclipse.team.tests.core/.classpath
index 6a4f509e0..1cdf36089 100644
--- a/tests/org.eclipse.team.tests.core/.classpath
+++ b/tests/org.eclipse.team.tests.core/.classpath
@@ -13,5 +13,6 @@
<classpathentry kind="src" path="/org.junit"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
+ <classpathentry kind="src" path="/org.eclipse.team.ftp"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/tests/org.eclipse.team.tests.core/.project b/tests/org.eclipse.team.tests.core/.project
index 3126885eb..228a6b1a8 100644
--- a/tests/org.eclipse.team.tests.core/.project
+++ b/tests/org.eclipse.team.tests.core/.project
@@ -11,6 +11,7 @@
<project>org.eclipse.team.core</project>
<project>org.eclipse.team.cvs.core</project>
<project>org.eclipse.team.cvs.ui</project>
+ <project>org.eclipse.team.ftp</project>
<project>org.eclipse.team.ui</project>
<project>org.eclipse.ui</project>
<project>org.junit</project>
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/ClientTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/ClientTest.java
new file mode 100644
index 000000000..ecfa571ef
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/ClientTest.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ******************************************************************************/
+package org.eclipse.team.tests.ftp;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.team.internal.ftp.FTPException;
+import org.eclipse.team.internal.ftp.FTPServerLocation;
+import org.eclipse.team.internal.ftp.client.FTPClient;
+import org.eclipse.team.tests.core.TeamTest;
+
+public class ClientTest extends TeamTest {
+
+ private static final IProgressMonitor DEFAULT_PROGRESS_MONITOR = new NullProgressMonitor();
+ /**
+ * Constructor for ClientTest.
+ * @param name
+ */
+ public ClientTest(String name) {
+ super(name);
+ }
+ public ClientTest() {
+ super();
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(ClientTest.class);
+ return new FTPTestSetup(suite);
+ //return new FTPTestSetup(new ClientTest("testName"));
+ }
+
+ public URL getURL() {
+ return FTPTestSetup.ftpURL;
+ }
+
+ public FTPClient openFTPConnection() throws FTPException {
+ FTPServerLocation location = FTPServerLocation.fromURL(getURL(), false);
+ FTPClient client = new FTPClient(location, null, null);
+ client.open(DEFAULT_PROGRESS_MONITOR);
+ return client;
+ }
+
+ public void testCreateDirectory() throws FTPException {
+ FTPClient client = openFTPConnection();
+ try {
+ client.createDirectory("test1", DEFAULT_PROGRESS_MONITOR);
+ } finally {
+ client.close(DEFAULT_PROGRESS_MONITOR);
+ }
+ }
+}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/FTPTestSetup.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/FTPTestSetup.java
new file mode 100644
index 000000000..0c2c7ab68
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/FTPTestSetup.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ******************************************************************************/
+package org.eclipse.team.tests.ftp;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import org.eclipse.team.internal.ftp.FTPException;
+import org.eclipse.team.internal.ftp.FTPServerLocation;
+import org.eclipse.team.internal.ftp.client.FTPClient;
+
+/**
+ * Provides the FTP tests with a host to ftp to.
+ */
+public class FTPTestSetup extends TestSetup {
+
+ public static final String FTP_URL;
+ public static final boolean SCRUB_URL;
+
+ public static URL ftpURL;
+
+ // Static initializer for constants
+ static {
+ loadProperties();
+ FTP_URL = System.getProperty("eclipse.ftp.url");
+ SCRUB_URL = Boolean.valueOf(System.getProperty("eclipse.ftp.init", "false")).booleanValue();
+ }
+
+ public static void loadProperties() {
+ String propertiesFile = System.getProperty("eclipse.ftp.properties");
+ if (propertiesFile == null) return;
+ File file = new File(propertiesFile);
+ if (file.isDirectory()) file = new File(file, "ftp.properties");
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ try {
+ for (String line; (line = reader.readLine()) != null; ) {
+ int sep = line.indexOf("=");
+ String property = line.substring(0, sep).trim();
+ String value = line.substring(sep + 1).trim();
+ System.setProperty("eclipse.ftp." + property, value);
+ }
+ } finally {
+ reader.close();
+ }
+ } catch (Exception e) {
+ System.err.println("Could not read ftp properties file: " + file.getAbsolutePath());
+ }
+ }
+
+ /**
+ * Constructor for FTPTestSetup.
+ * @param test
+ */
+ public FTPTestSetup(Test test) {
+ super(test);
+ }
+
+ public void setUp() throws MalformedURLException, FTPException {
+ if (ftpURL == null)
+ ftpURL = setupURL(FTP_URL);
+ }
+
+ protected void scrubURL(URL url) {
+ }
+
+ protected URL setupURL(String urlString) throws MalformedURLException, FTPException {
+
+ // Give some info about which repository the tests are running against
+ System.out.println("Connecting to: " + urlString);
+
+ // Validate that we can connect, also creates and caches the repository location. This
+ // is important for the UI tests.
+ URL url = new URL(urlString);
+ FTPServerLocation location = FTPServerLocation.fromURL(url, false);
+ FTPClient client = new FTPClient(location, null, null);
+ try {
+ client.open(null);
+ } finally {
+ client.close(null);
+ }
+
+ // Initialize the repo if requested (requires rsh access)
+ if( SCRUB_URL ) {
+ scrubURL(url);
+ }
+
+ return url;
+ }
+
+ public void tearDown() {
+ // Nothing to do here
+ }
+}

Back to the top