Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-05-16 14:45:21 +0000
committerMichael Valenta2002-05-16 14:45:21 +0000
commit57a65f22e5847638c9090c0abe34345ec919602b (patch)
treeebe759309e1417da0691139cb63f3235ff0cf3ef /tests/org.eclipse.team.tests.core
parente591d2af465003068bcc058d74377b537b296b4f (diff)
downloadeclipse.platform.team-57a65f22e5847638c9090c0abe34345ec919602b.tar.gz
eclipse.platform.team-57a65f22e5847638c9090c0abe34345ec919602b.tar.xz
eclipse.platform.team-57a65f22e5847638c9090c0abe34345ec919602b.zip
*** empty log message ***
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/.project1
-rw-r--r--tests/org.eclipse.team.tests.core/plugin.xml1
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/ClientTest.java70
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/FTPTestSetup.java152
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/TestApplication.java190
5 files changed, 0 insertions, 414 deletions
diff --git a/tests/org.eclipse.team.tests.core/.project b/tests/org.eclipse.team.tests.core/.project
index 984829fd3..5d3bdfef7 100644
--- a/tests/org.eclipse.team.tests.core/.project
+++ b/tests/org.eclipse.team.tests.core/.project
@@ -12,7 +12,6 @@
<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/plugin.xml b/tests/org.eclipse.team.tests.core/plugin.xml
index b3c274ca5..376835ebe 100644
--- a/tests/org.eclipse.team.tests.core/plugin.xml
+++ b/tests/org.eclipse.team.tests.core/plugin.xml
@@ -20,7 +20,6 @@
<import plugin="org.eclipse.team.cvs.core"/>
<import plugin="org.eclipse.team.ui"/>
<import plugin="org.eclipse.team.cvs.ui"/>
- <import plugin="org.eclipse.team.ftp"/>
<import plugin="org.eclipse.compare"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.junit"/>
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
deleted file mode 100644
index 2eea918ce..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/ClientTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * 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.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 {
- return FTPTestSetup.openFTPConnection(getURL());
- }
-
- public void testCreateDirectory() throws FTPException {
- FTPClient client = openFTPConnection();
- try {
- client.createDirectory("testCreateDirectory", DEFAULT_PROGRESS_MONITOR);
- client.deleteDirectory("testCreateDirectory", DEFAULT_PROGRESS_MONITOR);
- } finally {
- client.close(DEFAULT_PROGRESS_MONITOR);
- }
- }
-
- public void testSimpleTransfer() throws FTPException {
- FTPClient client = openFTPConnection();
- try {
- client.createDirectory("testCreateDirectory", DEFAULT_PROGRESS_MONITOR);
- client.deleteDirectory("testCreateDirectory", 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
deleted file mode 100644
index 3790be9d4..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/FTPTestSetup.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * 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.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-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.internal.ftp.client.FTPDirectoryEntry;
-import org.eclipse.team.internal.ftp.client.IFTPClientListener;
-
-/**
- * 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;
-
- private static final IProgressMonitor DEFAULT_PROGRESS_MONITOR = new NullProgressMonitor();
-
- 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 scrubCurrentDirectory(FTPClient client) throws FTPException {
- FTPDirectoryEntry[] entries = client.listFiles(null, DEFAULT_PROGRESS_MONITOR);
- for (int i = 0; i < entries.length; i++) {
- FTPDirectoryEntry entry = entries[i];
- if (entry.hasFileSemantics()) {
- client.deleteFile(entry.getName(), DEFAULT_PROGRESS_MONITOR);
- }
- if (entry.hasDirectorySemantics()) {
- client.deleteDirectory(entry.getName(), DEFAULT_PROGRESS_MONITOR);
- }
- }
- }
-
- 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 = openFTPConnection(url);
- try {
- // Initialize the repo if requested
- // For safety, do not scrub if no path is provided
- if( SCRUB_URL && ! new Path(url.getPath()).isEmpty()) {
- scrubCurrentDirectory(client);
- }
- } finally {
- client.close(DEFAULT_PROGRESS_MONITOR);
- }
-
- return url;
- }
-
- public void tearDown() {
- // Nothing to do here
- }
-
- public static FTPClient openFTPConnection(URL url) throws FTPException {
- FTPServerLocation location = FTPServerLocation.fromURL(url, false);
- FTPClient client = new FTPClient(location, null, getListener());
- client.open(DEFAULT_PROGRESS_MONITOR);
- try {
- client.createDirectory(url.getPath(), DEFAULT_PROGRESS_MONITOR);
- } catch (FTPException e) {
- // Ignore the exception
- }
- client.changeDirectory(url.getPath(), DEFAULT_PROGRESS_MONITOR);
- return client;
- }
-
- public static IFTPClientListener getListener() {
- return new IFTPClientListener() {
- public void responseReceived(int responseCode, String responseText) {
- System.out.println(responseText);
- }
- public void requestSent(String command, String argument) {
- if (argument != null) {
- System.out.println(command + " " + argument);
- } else {
- System.out.println(command);
- }
- }
- };
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/TestApplication.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/TestApplication.java
deleted file mode 100644
index e65f1ff67..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ftp/TestApplication.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * 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.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.boot.IPlatformRunnable;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ftp.*;
-import org.eclipse.team.internal.ftp.FTPException;
-import org.eclipse.team.internal.ftp.FTPProxyLocation;
-import org.eclipse.team.internal.ftp.FTPServerLocation;
-import org.eclipse.team.internal.ftp.client.*;
-import org.eclipse.team.internal.ftp.client.FTPClient;
-import org.eclipse.team.internal.ftp.client.FTPCommunicationException;
-import org.eclipse.team.internal.ftp.client.FTPDirectoryEntry;
-import org.eclipse.team.internal.ftp.client.IFTPClientListener;
-
-public class TestApplication implements IPlatformRunnable {
- protected PrintWriter out;
- protected BufferedReader in;
- protected FTPServerLocation location;
- protected FTPProxyLocation proxy;
- protected FTPClient client;
- protected IFTPClientListener listener;
- protected IProject project;
-
- public Object run(Object args) {
- /*** initialize ***/
- out = new PrintWriter(new OutputStreamWriter(System.out), true);
- in = new BufferedReader(new InputStreamReader(System.in));
- listener = new IFTPClientListener() {
- public void responseReceived(int responseCode, String responseText) {
- out.println(responseText);
- }
- public void requestSent(String command, String argument) {
- if (argument != null) {
- out.println(command + " " + argument);
- } else {
- out.println(command);
- }
- }
- };
-
- // we'll dump downloaded files into
- project = ResourcesPlugin.getWorkspace().getRoot().getProject("FTP-test");
- try {
- if (! project.exists()) {
- project.create(null);
- }
- if (! project.isOpen()) {
- project.open(null);
- }
- } catch (CoreException e) {
- e.printStackTrace();
- }
-
- /*** run ***/
- printHelp();
- for (;;) {
- String line;
- try {
- line = in.readLine();
- } catch (IOException e) {
- break;
- }
- StringTokenizer tok = new StringTokenizer(line);
- if (! tok.hasMoreTokens()) continue;
- String command = tok.nextToken().toLowerCase();
- try {
- if (command.equals("proxy") && tok.countTokens() >= 2 && tok.countTokens() <= 4) {
- proxy = new FTPProxyLocation(
- tok.nextToken(),
- Integer.parseInt(tok.nextToken(), 10),
- tok.hasMoreTokens() ? tok.nextToken() : null,
- tok.hasMoreTokens() ? tok.nextToken() : null);
- } else if (command.equals("open") && tok.countTokens() == 5) {
- location = new FTPServerLocation(
- tok.nextToken(),
- Integer.parseInt(tok.nextToken(), 10),
- tok.nextToken(),
- tok.nextToken(),
- tok.nextToken().equals("true"));
- client = new FTPClient(location, proxy, listener);
- client.open(getProgressMonitor());
- } else if (command.equals("close")) {
- client.close(getProgressMonitor());
- } else if (command.equals("quit")) {
- break;
- } else if (command.equals("cd") && tok.countTokens() == 1) {
- client.changeDirectory(tok.nextToken(), getProgressMonitor());
- } else if (command.equals("ls") && tok.countTokens() == 0) {
- FTPDirectoryEntry[] infos = client.listFiles(null, getProgressMonitor());
- printFileList(infos);
- } else if (command.equals("ls") && tok.countTokens() == 1) {
- FTPDirectoryEntry[] infos = client.listFiles(tok.nextToken(), getProgressMonitor());
- printFileList(infos);
- } else if (command.equals("mkdir") && tok.countTokens() == 1) {
- client.createDirectory(tok.nextToken(), getProgressMonitor());
- } else if (command.equals("rmdir") && tok.countTokens() == 1) {
- client.deleteDirectory(tok.nextToken(), getProgressMonitor());
- } else if (command.equals("get") && tok.countTokens() == 3) {
- String remoteFilePath = tok.nextToken();
- boolean binary = tok.nextToken().equals("true");
- boolean resume = tok.nextToken().equals("true");
- IFile file = project.getFile(new Path(remoteFilePath).lastSegment());
- client.getFile(remoteFilePath, file, binary, resume, getProgressMonitor());
- } else if (command.equals("put") && tok.countTokens() == 2) {
- String remoteFilePath = tok.nextToken();
- boolean binary = tok.nextToken().equals("true");
- IFile file = project.getFile(new Path(remoteFilePath).lastSegment());
- client.putFile(remoteFilePath, file, binary, getProgressMonitor());
- } else if (command.equals("rm") && tok.countTokens() == 1) {
- client.deleteFile(tok.nextToken(), getProgressMonitor());
- } else {
- printHelp();
- }
- } catch (FTPException e) {
- out.println("error: " + e.toString());
- }
- }
- out.println("Terminated.");
- return null;
- }
-
- private IProgressMonitor getProgressMonitor() {
- return new NullProgressMonitor();
- }
-
- private void printHelp() {
- out.println("--- Interactive Test FTP Client ---");
- out.println("Commands:");
- out.println(" proxy <hostname> <port> <username> <password>");
- out.println(" open <hostname> <port> <username> <password> <passive true/false>");
- out.println(" close");
- out.println(" help");
- out.println(" quit");
- out.println(" cd <dir>");
- out.println(" ls <dir>");
- out.println(" mkdir <dir>");
- out.println(" rmdir <dir>");
- out.println(" get <file> <binary true/false> <resume true/false>");
- out.println(" put <file> <binary true/false>");
- out.println(" rm <file>");
- out.println();
- }
-
- private void printFileList(FTPDirectoryEntry[] infos) {
- for (int i = 0; i < infos.length; i++) {
- FTPDirectoryEntry info = infos[i];
- out.print(info.hasDirectorySemantics() ? "d" : "-");
- out.print(info.hasFileSemantics() ? "f" : "-");
- out.print(' ');
- out.print(pad("\"" + info.getName() + "\"", 40));
- out.print(' ');
- out.print(pad(info.getSize() != info.UNKNOWN_SIZE ? Long.toString(info.getSize()) : "?", 12));
- out.print(' ');
- if (info.getModTime() != null) out.print(info.getModTime().toGMTString());
- else out.println("?");
- out.println();
- }
- }
-
- private String pad(String string, int len) {
- int count = len - string.length();
- if (count <= 0) return string;
- StringBuffer buf = new StringBuffer(string);
- while (count-- > 0) buf.append(' ');
- return buf.toString();
- }
-}

Back to the top