Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java (renamed from tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceException.java)6
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java7
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java106
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java98
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java3
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java425
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/NullOutputStream.java28
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java45
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java21
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java15
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java12
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceClient.java203
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java486
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java4
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFileTest.java221
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFolderTest.java447
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/SynchronizerTest.java254
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CommandsTest.java515
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java67
19 files changed, 632 insertions, 2331 deletions
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceException.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java
index 2f5678bdf..b8bd8746e 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceException.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java
@@ -1,13 +1,13 @@
-package org.eclipse.team.tests.ccvs.core.compatible;
+package org.eclipse.team.tests.ccvs.core;
/*
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
import org.eclipse.team.internal.ccvs.core.CVSException;
-public class ReferenceException extends CVSException {
+public class CVSClientException extends CVSException {
- public ReferenceException(String message) {
+ public CVSClientException(String message) {
super(message);
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
index cb6de755b..6db103257 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
@@ -19,11 +19,10 @@ import org.eclipse.team.internal.ccvs.core.CVSProvider;
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
public class CVSTestSetup extends TestSetup {
- public static String REPOSITORY_LOCATION;
- public static boolean INITIALIZE_REPO;
+ public static final String REPOSITORY_LOCATION;
+ public static final boolean INITIALIZE_REPO;
public static final boolean DEBUG;
public static final String RSH;
-
public static CVSRepositoryLocation repository;
@@ -88,8 +87,6 @@ public class CVSTestSetup extends TestSetup {
public void setUp() throws CVSException {
if (repository == null)
repository = setupRepository(REPOSITORY_LOCATION);
- if (!DEBUG)
- CVSProviderPlugin.getProvider().setPrintStream(new PrintStream(new NullOutputStream()));
}
protected CVSRepositoryLocation setupRepository(String location) throws CVSException {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java
new file mode 100644
index 000000000..db621ca41
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java
@@ -0,0 +1,106 @@
+package org.eclipse.team.tests.ccvs.core;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+
+import junit.framework.Assert;
+
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+public class CommandLineCVSClient {
+ private static final String cvsExecutable =
+ System.getProperty("eclipse.cvs.command");
+
+ public static void execute(
+ String repositoryLocation, File localRoot, String command,
+ String[] globalOptions, String[] localOptions,
+ String[] arguments) throws CVSException {
+ // test arguments
+ Assert.assertNotNull(repositoryLocation);
+ Assert.assertNotNull(localRoot);
+ Assert.assertNotNull(command);
+ Assert.assertNotNull(globalOptions);
+ Assert.assertNotNull(localOptions);
+ Assert.assertNotNull(arguments);
+ Assert.assertTrue(localRoot.exists());
+
+ // build command line
+ StringBuffer commandLineBuf = new StringBuffer(cvsExecutable);
+ commandLineBuf.append(" -d \"");
+ commandLineBuf.append(repositoryLocation);
+ commandLineBuf.append('"');
+ appendStrings(commandLineBuf, globalOptions);
+ commandLineBuf.append(' ');
+ commandLineBuf.append(command);
+ appendStrings(commandLineBuf, localOptions);
+ appendStrings(commandLineBuf, arguments);
+
+ // execute command
+ try {
+ PrintStream debugStream = CVSTestSetup.DEBUG ? System.out : null;
+ String commandLine = commandLineBuf.toString();
+
+ if (debugStream != null) {
+ // while debugging, dump CVS command line client results to stdout
+ // prefix distinguishes between message source stream
+ debugStream.println();
+ debugStream.println("CMD> " + commandLine);
+ debugStream.println("DIR> " + localRoot.toString());
+ }
+ Process cvsProcess = Runtime.getRuntime().exec(commandLine, null, localRoot);
+ // stream output must be dumped to avoid blocking the process or causing a deadlock
+ startBackgroundPipeThread(cvsProcess.getErrorStream(), debugStream, "ERR> ");
+ startBackgroundPipeThread(cvsProcess.getInputStream(), debugStream, "MSG> ");
+ int returnCode = cvsProcess.waitFor();
+
+ if (debugStream != null) {
+ debugStream.println("RESULT> " + returnCode);
+ }
+ if (returnCode != 0) {
+ throw new CVSClientException("Command line client returned non-zero code: " + returnCode);
+ }
+ } catch (IOException e) {
+ throw new CVSClientException("IOException while executing command line client: " + e);
+ } catch (InterruptedException e) {
+ throw new CVSClientException("InterruptedException while executing command line client: " + e);
+ }
+ }
+
+ private static void appendStrings(StringBuffer commandLine, String[] strings) {
+ for (int i = 0; i < strings.length; i++) {
+ String string = strings[i];
+ if (string != null && string.length() != 0) {
+ commandLine.append(" \"");
+ commandLine.append(string);
+ commandLine.append('"');
+ }
+ }
+ }
+
+ private static void startBackgroundPipeThread(final InputStream is, final PrintStream os,
+ final String prefix) {
+ new Thread() {
+ public void run() {
+ BufferedReader reader = null;
+ try {
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ for (;;) {
+ String line = reader.readLine();
+ if (line == null) break;
+ if (os != null) os.println(prefix + line);
+ }
+ } finally {
+ if (reader != null) reader.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }.start();
+ }
+}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java
new file mode 100644
index 000000000..9c6fd69ae
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java
@@ -0,0 +1,98 @@
+package org.eclipse.team.tests.ccvs.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.team.ccvs.core.CVSStatus;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.client.Session;
+import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
+import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+
+public class EclipseCVSClient {
+ private static final HashMap commandPool = new HashMap();
+ static {
+ commandPool.put("update", Command.UPDATE);
+ commandPool.put("co", Command.CHECKOUT);
+ commandPool.put("ci", Command.COMMIT);
+ commandPool.put("import", Command.IMPORT);
+ commandPool.put("add", Command.ADD);
+ commandPool.put("remove", Command.REMOVE);
+ commandPool.put("status", Command.STATUS);
+ commandPool.put("log", Command.LOG);
+ commandPool.put("tag", Command.TAG);
+ commandPool.put("rtag", Command.RTAG);
+ commandPool.put("admin", Command.ADMIN);
+ commandPool.put("diff", Command.DIFF);
+ }
+
+ public static void execute(
+ ICVSRepositoryLocation cvsRepositoryLocation, ICVSFolder cvsLocalRoot,
+ String command, String[] globalOptions, String[] localOptions,
+ String[] arguments) throws CVSException {
+ // test arguments
+ Assert.assertNotNull(cvsRepositoryLocation);
+ Assert.assertNotNull(cvsLocalRoot);
+ Assert.assertNotNull(command);
+ Assert.assertNotNull(globalOptions);
+ Assert.assertNotNull(localOptions);
+ Assert.assertNotNull(arguments);
+ Assert.assertTrue(cvsLocalRoot.exists());
+
+ // get command instance
+ Command cvsCommand = (Command) commandPool.get(command);
+
+ // get global options
+ List globals = new ArrayList();
+ for (int i = 0; i < globalOptions.length; i++) {
+ globals.add(new CustomGlobalOption(globalOptions[i]));
+ }
+ GlobalOption[] cvsGlobalOptions = (GlobalOption[]) globals.toArray(new GlobalOption[globals.size()]);
+
+ // get local options
+ List locals = new ArrayList();
+ for (int i = 0; i < localOptions.length; i++) {
+ String option = localOptions[i];
+ String argument = null;
+ if ((i < localOptions.length - 1) && (localOptions[i + 1].charAt(0) != '-')) {
+ argument = localOptions[++i];
+ }
+ locals.add(new CustomLocalOption(option, argument));
+ }
+ LocalOption[] cvsLocalOptions = (LocalOption[]) locals.toArray(new LocalOption[locals.size()]);
+
+ // execute command
+ IProgressMonitor monitor = new NullProgressMonitor();
+ Session session = new Session(cvsRepositoryLocation, cvsLocalRoot);
+ try {
+ session.open(monitor);
+ IStatus status = cvsCommand.execute(session,
+ cvsGlobalOptions, cvsLocalOptions, arguments, null, monitor);
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSClientException("Eclipse client returned non-ok status: " + status);
+ }
+ } finally {
+ session.close();
+ }
+ }
+
+ private static class CustomGlobalOption extends GlobalOption {
+ public CustomGlobalOption(String option) {
+ super(option);
+ }
+ }
+
+ private static class CustomLocalOption extends LocalOption {
+ public CustomLocalOption(String option, String arg) {
+ super(option, arg);
+ }
+ }
+}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
index f8b348057..e401c4b1c 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
@@ -260,9 +260,6 @@ public class EclipseTest extends EclipseWorkspaceTest {
protected void assertEquals(IProject project1, IProject project2) throws CoreException, TeamException, IOException {
assertEquals(project1, project2, false, false);
}
- protected void assertEquals(String message, IProject project1, IProject project2) throws CoreException, TeamException, IOException {
- assertEquals(project1, project2, false, false);
- }
protected void assertEquals(IProject project1, IProject project2, boolean includeTimestamps, boolean includeTags) throws CoreException, TeamException, IOException {
assertEquals(getProvider(project1), getProvider(project2), includeTimestamps, includeTags);
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
index 13c6b808e..f6c873314 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
@@ -4,38 +4,28 @@ package org.eclipse.team.tests.ccvs.core;
* All Rights Reserved.
*/
import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import junit.awtui.TestRunner;
import junit.framework.TestCase;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.CVSStatus;
-import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.util.FileUtil;
-import org.eclipse.team.internal.ccvs.core.util.Util;
/**
* Base-class to the low level-testcases for the Session.
@@ -43,198 +33,41 @@ import org.eclipse.team.internal.ccvs.core.util.Util;
* Especally data for a default-connection to the server is stored.
*/
public abstract class JUnitTestCase extends TestCase {
-
protected static final int RANDOM_CONTENT_SIZE = 10000;
protected static final boolean NEWLINE_TEST = false;
protected static final String PLATFORM_NEWLINE = System.getProperty("line.separator");
- protected static final File workspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
+ protected static final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
public static final String[] EMPTY_ARGS = new String[0];
-
- // Predefined parameters for calles of the client
- protected final String[] globalOptions;
- protected final IProgressMonitor monitor;
- protected final String[] arguments;
- protected static final String REPOSITORY_NAME = CVSTestSetup.REPOSITORY_LOCATION;
- static boolean propertiesSet = false;
-
- private static final HashMap commandPool = new HashMap();
- static {
- commandPool.put("update", Command.UPDATE);
- commandPool.put("co", Command.CHECKOUT);
- commandPool.put("ci", Command.COMMIT);
- commandPool.put("import", Command.IMPORT);
- commandPool.put("add", Command.ADD);
- commandPool.put("remove", Command.REMOVE);
- commandPool.put("status", Command.STATUS);
- commandPool.put("log", Command.LOG);
- commandPool.put("tag", Command.TAG);
- commandPool.put("rtag", Command.RTAG);
- commandPool.put("admin", Command.ADMIN);
- commandPool.put("diff", Command.DIFF);
- }
-
- /**
- * Convinience method for:<br>
- * Session.execute(request,globalOptions,localOptions,arguments,Session.getManagedFolder(root),monitor,messageOut)
- */
- public static void execute(String request,
- String[] globalOptions,
- String[] localOptions,
- String[] arguments,
- File root,
- IProgressMonitor monitor,
- PrintStream messageOut)
- throws CVSException {
- if (!CVSTestSetup.DEBUG)
- messageOut = new PrintStream(new NullOutputStream());
-
- List globals = new ArrayList();
- for (int i=0;i<globalOptions.length;i++) {
- if (globalOptions[i].equals("-d")) {
- i++;
- continue;
- }
- globals.add(new CustomGlobalOption(globalOptions[i]));
- }
- List locals = new ArrayList();
- for (int i=0;i<localOptions.length;i++) {
- if ((i < localOptions.length - 1) && (localOptions[i + 1].charAt(0) != '-')) {
- locals.add(new CustomLocalOption(localOptions[i], localOptions[i + 1]));
- i++;
- } else {
- locals.add(new CustomLocalOption(localOptions[i], null));
- }
- }
- Session s = new Session(getRepository(globalOptions, CVSWorkspaceRoot.getCVSFolderFor(root)), CVSWorkspaceRoot.getCVSFolderFor(root));
- s.open(monitor);
- try {
- IStatus status = ((Command)commandPool.get(request)).execute(s,
- (GlobalOption[]) globals.toArray(new GlobalOption[globals.size()]),
- (LocalOption[]) locals.toArray(new LocalOption[locals.size()]),
- arguments,
- null,
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- s.close();
- }
- }
-
- public static class CustomGlobalOption extends GlobalOption {
- public CustomGlobalOption(String option) {
- super(option);
- }
- }
- public static class CustomLocalOption extends LocalOption {
- public CustomLocalOption(String option, String arg) {
- super(option, arg);
- }
- }
- /**
- * This give you a new repo either from the global "-d" option
- * or form the root-property in the folder.
- *
- * This has to be rewritten in a nicer style.
- */
- private static CVSRepositoryLocation getRepository(String[] globalOptions,
- ICVSFolder mFolder)
- throws CVSException {
-
- String repoName = null;
-
- // look if the repo is specified in the global Options
- // this delets the option as well which is not so beatyful, but
- // we have got a copy and we do not want this option to appear
- // any more
- repoName = Util.getOption(globalOptions, "-d", true);
-
- // look if we have got an root-entrie in the root-folder
- if (repoName == null && mFolder.exists() && mFolder.isCVSFolder()) {
- repoName = mFolder.getFolderSyncInfo().getRoot();
- }
-
- if (repoName == null) {
- throw new CVSException("CVSROOT is not specified");
- }
-
- return CVSRepositoryLocation.fromString(repoName);
- }
-
- /**
- * Get a File relative to the working directory.
- */
- protected static File getFile(String relativePath) {
- // We need to get the cononical file in case relativePath contains a dot indicating the root directory
- try {
- return new File(workspaceRoot, relativePath).getCanonicalFile();
- } catch (IOException e) {
- fail(e.getMessage());
- return null;
- }
- }
-
- /**
- * Get the IO File for the given CVS resource
- */
- protected static File getFile(ICVSResource mResource) {
- return new File(((LocalResource)mResource).getPath());
- }
-
- /**
- * Get a CVSFolder relative to the working directory.
- */
- protected static ICVSFolder getManagedFolder(String relativePath) {
- try {
- return CVSWorkspaceRoot.getCVSFolderFor(getFile(relativePath));
- } catch (CVSException e) {
- fail(e.getMessage());
- return null;
- }
- }
-
/**
* Init the options and arguments to standard-values
*/
public JUnitTestCase(String name) {
super(name);
-
- monitor = new NullProgressMonitor();
- globalOptions = new String[]{"-d",REPOSITORY_NAME};
- arguments = new String[]{"proj1"};
}
/**
* Delete a project/resource form the standard cvs-server
*/
- protected void magicDeleteProject(String project) throws CVSException {
- CVSRepositoryLocation location = CVSRepositoryLocation.fromString(REPOSITORY_NAME);
- String host = location.getHost();
- String repoRoot = location.getRootDirectory();
- magicDeleteProject(location, project);
+ protected void magicDeleteRemote(String remoteName) throws CVSException {
+ magicDeleteRemote(CVSTestSetup.repository, remoteName);
}
/**
- * Delete a project/resource form the standard cvs-server
+ * Delete a project/resource form the specified cvs-server
*/
- protected static void magicDeleteProject(ICVSRepositoryLocation location, String project) throws CVSException {
-
- String commandLine;
- Process process;
-
- commandLine = new String(CVSTestSetup.RSH + " " + location.getHost() + " -l " + location.getUsername() + " rm -rf " + new Path(location.getRootDirectory()).append(project).toString());
-
+ protected static void magicDeleteRemote(ICVSRepositoryLocation location, String remoteName)
+ throws CVSException {
+ String commandLine = new String(CVSTestSetup.RSH + " " + location.getHost() +
+ " -l " + location.getUsername() + " rm -rf " +
+ new Path(location.getRootDirectory()).append(remoteName).toString());
try {
- process = Runtime.getRuntime().exec(commandLine);
+ Process process = Runtime.getRuntime().exec(commandLine);
process.waitFor();
-
if (process.exitValue() != 0) {
// throw new CVSException("Return Code of magicDeleteProject :" + process.exitValue());
}
-
} catch (IOException e) {
throw new CVSException("IOException in magicDeleteProject");
} catch (InterruptedException e) {
@@ -243,42 +76,38 @@ public abstract class JUnitTestCase extends TestCase {
}
/**
- * Set the project on the standard cvs-server up so that it contains the resources
- * in createResources. The files have random content.
+ * Sends the project to the standard cvs-server so that it contains the resources
+ * described in createResources. The files have random content.
+ *
+ * @param projectName the name of the project to import
+ * @param createResources e.g. new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"}
*/
- public void magicSetUpRepo(String project, String[] createResources) throws CVSException {
- CVSRepositoryLocation location = CVSRepositoryLocation.fromString(REPOSITORY_NAME);
- magicSetUpRepo(workspaceRoot, location ,project, createResources);
+ protected void magicSetUpRepo(String projectName, String[] createResources)
+ throws IOException, CoreException, CVSException {
+ magicSetUpRepo(CVSTestSetup.repository, projectName, createResources);
}
/**
- * Set the project on the standard cvs-server up so that it contains the resources
- * in createResources. The files have random content.
+ * Sends the project to the specified cvs-server so that it contains the resources
+ * described in createResources. The files have random content.
*
- * @param root a folder to place files temporaryly
- * @param host e.g. dev.eclipse.org:2401
- * @param repoRoot e.g. /home/cvs
- * @param repoName e.g. :pserver:anonymous@dev.eclipse.org:2401:/home/eclipse
- * @param project e.g. org.eclipse.swt
+ * @param location the CVS repository location
+ * @param projectName the name of the project to import
* @param createResources e.g. new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"}
*/
- private static void magicSetUpRepo(File root, ICVSRepositoryLocation location, String project, String[] createResources) throws CVSException {
-
- File workFolder;
-
- workFolder = new File(root, project + "tmpXXXtmp");
+ protected static void magicSetUpRepo(ICVSRepositoryLocation location, String projectName,
+ String[] createResources) throws IOException, CoreException, CVSException {
+ IProject projectRoot = workspaceRoot.getProject(projectName + "-setup-tmp");
+ mkdirs(projectRoot);
+ createRandomFile(projectRoot, createResources);
+ magicDeleteRemote(location, projectName);
- createRandomFile(workFolder, createResources);
-
- magicDeleteProject(location, project);
-
- String[] gOptions = new String[]{"-d", location.getLocation()};
String[] lOptions = new String[]{"-m","msg"};
- String[] args = new String[]{project,"a","b"};
-
- execute("import",gOptions,lOptions,args,workFolder,new NullProgressMonitor(),System.err);
-
- FileUtil.deepDelete(workFolder);
+ String[] args = new String[]{projectName,"a","b"};
+
+ EclipseCVSClient.execute(location, CVSWorkspaceRoot.getCVSFolderFor(projectRoot),
+ "import", EMPTY_ARGS, lOptions, args);
+ projectRoot.delete(false /*force*/, null);
}
/**
@@ -310,69 +139,64 @@ public abstract class JUnitTestCase extends TestCase {
}
- protected static void assertSynchronizerEmpty() {
- assertTrue(CVSProviderPlugin.getSynchronizer().isEmpty());
- }
-
/**
- * Write String[] to file as lines
+ * Write text lines to file from an array of strings.
*/
- protected static void writeToFile(File file, String[] content)
- throws IOException {
-
- BufferedWriter fileWriter;
-
- fileWriter = new BufferedWriter(new FileWriter(file));
- for (int i = 0; i<content.length; i++) {
- fileWriter.write(content[i]);
- fileWriter.newLine();
+ protected static void writeToFile(IFile file, String[] contents)
+ throws IOException, CoreException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintStream os = new PrintStream(bos);
+ try {
+ for (int i = 0; i < contents.length; i++) {
+ os.println(contents[i]);
+ }
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ if (file.exists()) {
+ file.setContents(bis, false /*force*/, true /*keepHistory*/, null);
+ } else {
+ mkdirs(file.getParent());
+ file.create(bis, false /*force*/, null);
+ }
+ } finally {
+ os.close();
}
- fileWriter.close();
}
/**
- * load file in lines to String[]
+ * Read text lines from file into an array of strings.
*/
- protected static String[] readFromFile(File file)
- throws IOException {
-
- BufferedReader fileReader;
+ protected static String[] readFromFile(IFile file)
+ throws IOException, CoreException {
+ if (! file.exists()) return null;
+ BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
List fileContentStore = new ArrayList();
- String line;
-
- if (!file.exists()) {
- return null;
- }
-
- fileReader = new BufferedReader(new FileReader(file));
- while ((line = fileReader.readLine()) != null) {
- fileContentStore.add(line);
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ fileContentStore.add(line);
+ }
+ } finally {
+ reader.close();
}
- fileReader.close();
-
return (String[]) fileContentStore.toArray(new String[fileContentStore.size()]);
}
/**
- * Append a String to an file (acctally to both of the files, that are going
- * to have the same content)
- * If the file is empty we create a new file with the content txt.
+ * Append text files to file from an array of strings, create new file if it
+ * does not exist yet.
*/
- protected void appendToFile(File file, String txt) throws IOException {
- String[] content;
- String[] newContent;
-
- content = readFromFile(file);
-
- if (content == null) {
- content = new String[0];
+ protected static void appendToFile(IFile file, String[] contents)
+ throws IOException, CoreException {
+ String[] oldContents = readFromFile(file);
+ String[] newContents;
+ if (contents != null) {
+ newContents = contents;
+ } else {
+ newContents = new String[oldContents.length + contents.length];
+ System.arraycopy(oldContents, 0, newContents, 0, oldContents.length);
+ System.arraycopy(contents, 0, newContents, oldContents.length, contents.length);
}
-
- newContent = new String[content.length + 1];
- System.arraycopy(content,0,newContent,0,content.length);
- newContent[content.length] = txt;
-
- writeToFile(file,newContent);
+ writeToFile(file, newContents);
}
/**
@@ -424,26 +248,43 @@ public abstract class JUnitTestCase extends TestCase {
}
/**
- * Creates the file with random contend, and all the folders on the
- * way to there
+ * Creates a folder (and its parents if needed).
*/
- private static void createRandomFile(File file) throws CVSException {
- try {
- file.getParentFile().mkdirs();
- writeToFile(file,new String[]{createRandomContent()});
- } catch (IOException e) {
- throw new CVSException(0,0,"IOException in test-setup",e);
- }
+ protected static void mkdirs(IContainer container) throws CoreException {
+ if (container.getType() == IResource.PROJECT) {
+ IProject project = (IProject) container;
+ if (! project.exists()) {
+ project.create(null);
+ }
+ project.open(null);
+ } else if (container.getType() == IResource.FOLDER) {
+ IFolder folder = (IFolder) container;
+ if (! folder.exists()) {
+ mkdirs(folder.getParent());
+ folder.create(false /*force*/, true /*local*/, null);
+ }
+ }
+ }
+
+ /**
+ * Creates the file with random content, and all the folders on the
+ * way to there.
+ */
+ private static void createRandomFile(IFile file)
+ throws IOException, CoreException {
+ mkdirs(file.getParent());
+ writeToFile(file, new String[] { createRandomContent() });
}
/**
* Build the given fileStructure, all files are going to have
- * sample content, all folders on the way are created
+ * sample content, all folders on the way are created.
*/
- protected static void createRandomFile(File root, String[] fileNameArray)
- throws CVSException {
- for (int i=0; i<fileNameArray.length; i++) {
- createRandomFile(new File(root, fileNameArray[i]));
+ protected static void createRandomFile(IContainer parent, String[] fileNameArray)
+ throws IOException, CoreException {
+ for (int i = 0; i < fileNameArray.length; i++) {
+ IFile file = parent.getFile(new Path(fileNameArray[i]));
+ createRandomFile(file);
}
}
@@ -463,37 +304,9 @@ public abstract class JUnitTestCase extends TestCase {
* It initialises some required parameter and runs the testcase.
*/
protected static void run(Class test) {
- System.setProperty("eclipse.cvs.standalone","true");
+ // XXX is this property used anywhere?
+ System.setProperty("eclipse.cvs.standalone", "true");
TestRunner.run(test);
}
-
- /**
- * This delte does a deepDelete for an ICVSResource and deletes all
- * the cached information for the resource and all its children as
- * well.
- * At some point this should be integrated into the LocalResource ...
- */
- public static void delete(ICVSResource resource) throws CVSException {
-
- // Deleting a file is an add-on that we need for the same-result
- // enviorment
- if (!resource.isFolder()) {
- resource.delete();
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)resource.getParent()).getLocalFile(), new NullProgressMonitor());
- return;
- }
-
- ICVSFolder folder = (ICVSFolder) resource;
-
- if (!folder.isCVSFolder()) {
- ICVSFolder[] folders = folder.getFolders();
- for (int i = 0; i < folders.length; i++) {
- delete(folders[i]);
- }
- }
-
- folder.delete();
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)folder).getLocalFile(), new NullProgressMonitor());
- }
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/NullOutputStream.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/NullOutputStream.java
deleted file mode 100644
index 6419fb047..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/NullOutputStream.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.team.tests.ccvs.core;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @version 1.0
- * @author ${user}
- */
-public class NullOutputStream extends OutputStream {
-
- /**
- * Constructor for NullOutputStream.
- */
- public NullOutputStream() {
- super();
- }
-
- /*
- * @see OutputStream#write(int)
- */
- public void write(int arg0) throws IOException {
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java
index 7e6a159d2..03205888a 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java
@@ -8,18 +8,16 @@ import java.util.GregorianCalendar;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
public class BasicTest extends JUnitTestCase {
-
SameResultEnv env1;
SameResultEnv env2;
public BasicTest(String arg) {
super(arg);
- env1 = new SameResultEnv(arg,getFile("checkout1"));
- env2 = new SameResultEnv(arg,getFile("checkout2"));
+ env1 = new SameResultEnv(arg + "-checkout1");
+ env2 = new SameResultEnv(arg + "-checkout2");
}
public BasicTest() {
@@ -33,7 +31,7 @@ public class BasicTest extends JUnitTestCase {
public static Test suite() {
TestSuite suite = new TestSuite(BasicTest.class);
return new CompatibleTestSetup(suite);
- //return new CompatibleTestSetup(new BasicTest("testRTag"));
+ //return new CompatibleTestSetup(new BasicTest("testDate"));
}
public void setUp() throws Exception {
env1.setUp();
@@ -44,10 +42,9 @@ public class BasicTest extends JUnitTestCase {
env2.deleteFile("proj2");
}
- public void tearDown() throws CVSException {
+ public void tearDown() throws Exception {
env1.tearDown();
env2.tearDown();
- assertSynchronizerEmpty();
}
public void testAdd() throws Exception {
@@ -130,7 +127,7 @@ public class BasicTest extends JUnitTestCase {
// change the file "proj1/folder1/c.txt" in env1 check it in
// on the server
- env1.appendToFile("proj2/f1/c.txt","AppendIt");
+ env1.appendToFile("proj2/f1/c.txt", new String[] { "AppendIt" });
env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
// assure that the file is different in env1 and env2
@@ -167,7 +164,7 @@ public class BasicTest extends JUnitTestCase {
env1.deleteFile("proj2/a.txt");
env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("status",EMPTY_ARGS,new String[]{"proj2"});
env1.execute("status",EMPTY_ARGS,new String[0],"proj2");
@@ -186,7 +183,7 @@ public class BasicTest extends JUnitTestCase {
env1.deleteFile("proj2/a.txt");
env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("log",EMPTY_ARGS,new String[]{"proj2"});
env1.execute("log",EMPTY_ARGS,new String[0],"proj2");
@@ -205,7 +202,7 @@ public class BasicTest extends JUnitTestCase {
env1.deleteFile("proj2/a.txt");
env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("tag",new String[]{"-b"},new String[]{"tag2","proj2"});
@@ -215,7 +212,7 @@ public class BasicTest extends JUnitTestCase {
// Try an commit and an add in the two different streams
env1.execute("co",new String[]{"-r","tag1"},new String[]{"proj2"});
- env1.appendToFile("proj2/f1/b.txt","AppendItTwo");
+ env1.appendToFile("proj2/f1/b.txt", new String[] { "AppendItTwo" });
env1.createRandomFile("proj2/d.txt");
env1.execute("add",new String[0],new String[]{"d.txt"},"proj2");
env1.execute("ci",new String[]{"-m","branch"},new String[]{"proj2"});
@@ -223,7 +220,7 @@ public class BasicTest extends JUnitTestCase {
env1.execute("co",new String[]{"-r","tag1"},new String[]{"proj2"});
env2.execute("co",new String[]{"-r","tag2"},new String[]{"proj2"});
- env2.appendToFile("proj2/f1/b.txt","AppendItThree");
+ env2.appendToFile("proj2/f1/b.txt", new String[] { "AppendItThree" });
env2.createRandomFile("proj2/d.txt");
env2.execute("add",new String[0],new String[]{"d.txt"},"proj2");
env2.execute("ci",new String[]{"-m","branch"},new String[]{"proj2"});
@@ -235,7 +232,7 @@ public class BasicTest extends JUnitTestCase {
// Try to branch of a workspace with local changes
env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
JUnitTestCase.waitMsec(1500);
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("tag",new String[]{"-b"},new String[]{"branch-with-changes","proj2"});
env1.execute("update",new String[]{"-r", "branch-with-changes"},new String[]{"proj2"});
}
@@ -247,7 +244,7 @@ public class BasicTest extends JUnitTestCase {
env1.deleteFile("proj2/a.txt");
env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("tag",EMPTY_ARGS,new String[]{"tag2","proj2"});
env1.execute("tag",EMPTY_ARGS,new String[]{"tag2"},"proj2");
@@ -347,8 +344,8 @@ public class BasicTest extends JUnitTestCase {
env1.setIgnoreExceptions(true);
- env1.appendToFile("proj2/f1/c.txt","AppendIt2");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/c.txt",new String[] {"AppendIt2" });
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("diff",EMPTY_ARGS,new String[]{"proj2"});
env1.execute("diff",EMPTY_ARGS,new String[0],"proj2");
@@ -365,7 +362,7 @@ public class BasicTest extends JUnitTestCase {
public void testReadOnly() throws Exception {
env1.execute("co",new String[]{"-r"},EMPTY_ARGS,new String[]{"proj2"},"");
env1.execute("update",new String[0],EMPTY_ARGS,new String[]{"proj2"},"");
- env1.deleteFile(".");
+ env1.deleteFile("");
env1.writeToFile("tmp.txt",new String[0]);
env1.deleteFile("tmp.txt");
env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
@@ -437,14 +434,14 @@ public class BasicTest extends JUnitTestCase {
waitMsec(1100);
- env1.appendToFile("proj2/a.txt","AppendIt");
+ env1.appendToFile("proj2/a.txt",new String[] { "AppendIt" });
env1.execute("ci",new String[]{"-m","msg"},new String[]{"proj2"});
firstChange = GregorianCalendar.getInstance().getTime();
waitMsec(1100);
- env1.appendToFile("proj2/a.txt","AppendIt2");
- env1.appendToFile("proj2/f1/b.txt","AppendIt2");
+ env1.appendToFile("proj2/a.txt",new String[] { "AppendIt2" });
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt2" });
env1.execute("ci",new String[]{"-m","msg"},new String[]{"proj2"});
secondChange = GregorianCalendar.getInstance().getTime();
@@ -475,12 +472,12 @@ public class BasicTest extends JUnitTestCase {
// We get try to merge changes from different dates
env1.execute("co",new String[0],new String[]{"proj2"});
- env1.appendToFile("proj2/a.txt","This is the world ...");
+ env1.appendToFile("proj2/a.txt", new String[] { "This is the world ..." });
env1.execute("update",new String[]{"-D",toGMTString(beforeChange)},new String[]{"proj2"});
- env1.appendToFile("proj2/a.txt","... witch constantly changes");
+ env1.appendToFile("proj2/a.txt", new String[] {"... which constantly changes" });
env1.execute("update",new String[]{"-A"},new String[]{"proj2"});
// Change something to be able to commit
- env1.appendToFile("proj2/a.txt","... and the changes are aproved");
+ env1.appendToFile("proj2/a.txt", new String[] { "... and the changes are approved" });
env1.execute("ci",new String[]{"-m","msg"},new String[]{"proj2"});
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java
index ffac0a0db..c5e991654 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java
@@ -14,13 +14,16 @@ import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
* @author ${user}
*/
public class CompatibleTestSetup extends CVSTestSetup {
-
- public static final String REFERENCE_CLIENT_REPOSITORY=System.getProperty("eclipse.cvs.repository1");
- public static final String ECLIPSE_CLIENT_REPOSITORY=System.getProperty("eclipse.cvs.repository2");
-
+ public static final String ECLIPSE_REPOSITORY_LOCATION;
+ public static final String REFERENCE_REPOSITORY_LOCATION;
public static CVSRepositoryLocation referenceClientRepository;
public static CVSRepositoryLocation eclipseClientRepository;
+ static {
+ REFERENCE_REPOSITORY_LOCATION = System.getProperty("eclipse.cvs.repository1");
+ ECLIPSE_REPOSITORY_LOCATION = System.getProperty("eclipse.cvs.repository2");
+ }
+
/**
* Constructor for CompatibleTestSetup.
*/
@@ -34,10 +37,12 @@ public class CompatibleTestSetup extends CVSTestSetup {
public void setUp() throws CVSException {
CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(false);
CVSProviderPlugin.getPlugin().setFetchAbsentDirectories(false);
- if ((referenceClientRepository != null) && (eclipseClientRepository != null))
- return;
- referenceClientRepository = setupRepository(REFERENCE_CLIENT_REPOSITORY);
- eclipseClientRepository = setupRepository(ECLIPSE_CLIENT_REPOSITORY);
+
+ // setup the repositories
+ if (referenceClientRepository == null)
+ referenceClientRepository = setupRepository(REFERENCE_REPOSITORY_LOCATION);
+ if (eclipseClientRepository == null)
+ eclipseClientRepository = setupRepository(ECLIPSE_REPOSITORY_LOCATION);
}
public void tearDown() throws CVSException {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
index e45529e3a..1957df21f 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
@@ -5,12 +5,9 @@ package org.eclipse.team.tests.ccvs.core.compatible;
*/
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
public class ConflictTest extends JUnitTestCase {
-
SameResultEnv env1;
SameResultEnv env2;
@@ -20,8 +17,8 @@ public class ConflictTest extends JUnitTestCase {
public ConflictTest(String arg) {
super(arg);
- env1 = new SameResultEnv(arg, getFile("checkout1"));
- env2 = new SameResultEnv(arg, getFile("checkout2"));
+ env1 = new SameResultEnv(arg + "checkout1");
+ env2 = new SameResultEnv(arg + "checkout2");
}
public void setUp() throws Exception {
@@ -33,7 +30,7 @@ public class ConflictTest extends JUnitTestCase {
env2.deleteFile("proj2");
}
- public void tearDown() throws CVSException {
+ public void tearDown() throws Exception {
env1.tearDown();
env2.tearDown();
}
@@ -50,8 +47,8 @@ public class ConflictTest extends JUnitTestCase {
env2.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
// change the file in both directories in a different way
- env1.appendToFile("proj2/f1/c.txt","AppendIt This");
- env2.appendToFile("proj2/f1/c.txt","AppendIt That");
+ env1.appendToFile("proj2/f1/c.txt", new String[] { "AppendIt This" });
+ env2.appendToFile("proj2/f1/c.txt", new String[] { "AppendIt That" });
// commit changes of the first
env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
@@ -68,7 +65,7 @@ public class ConflictTest extends JUnitTestCase {
// Make a change to the file in order to let the cvs-client know
// that we solved the confilict
- env2.appendToFile("proj2/f1/c.txt","That's allright");
+ env2.appendToFile("proj2/f1/c.txt", new String[] { "That's allright" });
env2.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
}
} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java
index feaa6b68c..fd9080cc8 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java
@@ -3,20 +3,18 @@ package org.eclipse.team.tests.ccvs.core.compatible;
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
-import junit.awtui.TestRunner;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
public class ModuleTest extends JUnitTestCase {
-
SameResultEnv env1;
SameResultEnv env2;
public ModuleTest(String arg) {
super(arg);
- env1 = new SameResultEnv(arg,getFile("checkout1"));
- env2 = new SameResultEnv(arg,getFile("checkout2"));
+ env1 = new SameResultEnv(arg + "checkout1");
+ env2 = new SameResultEnv(arg + "checkout2");
}
public static void main(String[] args) {
@@ -59,7 +57,7 @@ public class ModuleTest extends JUnitTestCase {
public void testSimpleModule() throws Exception {
setUpModuleFile(new String[]{"mod1 proj2"});
env1.execute("co",EMPTY_ARGS,new String[]{"mod1"});
- env1.appendToFile("mod1/a.txt","Append");
+ env1.appendToFile("mod1/a.txt", new String[] { "Append" });
env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1"});
env1.execute("update",EMPTY_ARGS,new String[]{"mod1"});
}
@@ -70,7 +68,7 @@ public class ModuleTest extends JUnitTestCase {
"mod1f &mod1-f1 &mod1-f2"});
env1.execute("co",EMPTY_ARGS,new String[]{"mod1f"});
- env1.appendToFile("mod1f/mod1-f1/b.txt","Append");
+ env1.appendToFile("mod1f/mod1-f1/b.txt", new String[] { "Append" });
env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1f"});
env1.execute("update",EMPTY_ARGS,new String[]{"mod1f"});
}
@@ -82,7 +80,7 @@ public class ModuleTest extends JUnitTestCase {
"mod1f -a mod1-f1 mod1-f2"});
env1.execute("co",EMPTY_ARGS,new String[]{"mod1f"});
- env1.appendToFile("mod1-f1/b.txt","Append");
+ env1.appendToFile("mod1-f1/b.txt", new String[] { "Append" });
env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1-f1","mod1-f2"});
env1.execute("update",EMPTY_ARGS,new String[]{"mod1-f1","mod1-f2"});
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceClient.java
deleted file mode 100644
index d3268bf4d..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceClient.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.compatible;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.ccvs.core.*;
-import org.eclipse.team.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileUtil;
-
-/**
- * This class is responsible for executing cvs commands using
- * a reference CVS command line client.
- */
-public class ReferenceClient {
-
- public static final String cvsLocation = System.getProperty("eclipse.cvs.command");
- /**
- * Puts opetions into one String seperated by
- * space.
- * starts and ends with a space.
- */
- private static String flatenOptions(String[] options) {
-
- StringBuffer result = new StringBuffer(" ");
- String quote;
-
- for (int i=0; i<options.length; i++) {
-
- if (options[i].indexOf(" ")==-1) {
- quote = "";
- } else {
- quote = "\"";
- }
- result.append(quote);
- result.append(options[i]);
- result.append(quote);
- result.append(' ');
- }
-
- return result.toString();
- }
-
- public static void execute(String request,
- String[] globalOptions,
- String[] localOptions,
- String[] arguments,
- File ioRoot,
- IProgressMonitor monitor,
- PrintStream messageOut)
- throws CVSException {
-
- Runtime runtime;
- Process process;
- BufferedReader stdIn;
- BufferedReader errIn;
- ICVSFolder mRoot;
-
- String global;
- String local;
- String arg;
- String commandLine;
-
- globalOptions = (String[]) globalOptions.clone();
- mRoot = CVSWorkspaceRoot.getCVSFolderFor(ioRoot);
-
- runtime = Runtime.getRuntime();
- global = flatenOptions(globalOptions);
- local = flatenOptions(localOptions);
- arg = flatenOptions(arguments);
-
- commandLine = cvsLocation + " ";
- commandLine = commandLine + global;
- commandLine = commandLine + request + " ";
- commandLine = commandLine + local;
- commandLine = commandLine + arg;
-
- // System.out.println(ioRoot.getPath() + "> " + commandLine);
-
- try {
- process = runtime.exec(commandLine, null, ioRoot);
- } catch (IOException e) {
- throw new CVSException("IOException while executing ReferenceClient",e);
- }
-
- stdIn = new BufferedReader(new InputStreamReader(process.getInputStream()));
- new ContiniousPipe(stdIn, messageOut, "M ");
-
- errIn = new BufferedReader(new InputStreamReader(process.getErrorStream()));
- new ContiniousPipe(errIn, messageOut, "E ");
-
- try {
- process.waitFor();
- } catch (InterruptedException e) {
- throw new CVSException("InterruptedException while executing ReferenceClient",e);
- }
-
- if (process.exitValue() != 0) {
- throw new ReferenceException("Return Code of CVS reference client: " +
- process.exitValue() + "\nwhile executing: " +
- commandLine);
- }
-
- SyncFileUtil.mergeEntriesLogFiles(ioRoot);
-
- }
-
- /**
- *
- * returns ":pserver:username@host:/cvs/root"
- * when you insert ":pserver:username:password@host:/cvs/root"
- */
- public static String removePassword(String repoName) {
-
- int atPlace = -1;
- int colonPlace = -1;
- int colonCount = 0;
- String currentChar;
-
- for (int i=0; i<repoName.length(); i++) {
-
- currentChar = repoName.substring(i,i+1);
-
- if (currentChar.equals(":")) {
- colonCount++;
-
- if (colonCount == 3) {
- colonPlace = i;
- }
- }
-
- if (currentChar.equals("@")) {
- if (colonPlace == -1) {
-
- // If the @ comes before the third colon, then
- // we do not have a password and return with the
- // same string
- return repoName;
- } else {
- atPlace = i;
- }
-
- }
- }
-
- if (atPlace == -1) {
- return repoName;
- }
-
- return repoName.substring(0,colonPlace) + repoName.substring(atPlace);
- }
-}
-
-/**
- * This class does continiously pipe from a bufferdReader
- * to a printStream. It does stop as soon, as the bufferdReader is
- * closed an therefore an IOException is thrown or the pipe returns null.
- *
- * It does close the BufferedReader on it's own (to be sure that it got
- * everything)
- */
-class ContiniousPipe implements Runnable {
-
- BufferedReader in;
- PrintStream out;
- String prefix;
-
- ContiniousPipe(BufferedReader in, PrintStream out, String prefix) {
- this.in = in;
- this.out = out;
- this.prefix = prefix;
- (new Thread(this)).start();
- }
-
- public void run() {
-
- String line;
-
- try {
- while ((line=in.readLine()) != null) {
- out.println(prefix + line);
- }
- } catch (IOException e) {
- // Should not happen, as the PrintStream does not throw IOExceptions
- // at all an in is a stream from a process
- } finally {
-
- try {
- in.close();
- } catch (IOException e) {}
-
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
index 975c9adfa..4b06d1c69 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
@@ -4,29 +4,33 @@ package org.eclipse.team.tests.ccvs.core.compatible;
* All Rights Reserved.
*/
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.PrintStream;
import java.text.ParseException;
+import java.util.StringTokenizer;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.*;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
+import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
import org.eclipse.team.internal.ccvs.core.util.Util;
+import org.eclipse.team.tests.ccvs.core.CVSClientException;
+import org.eclipse.team.tests.ccvs.core.CommandLineCVSClient;
+import org.eclipse.team.tests.ccvs.core.EclipseCVSClient;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-import org.eclipse.team.tests.ccvs.core.NullOutputStream;
/**
@@ -42,57 +46,125 @@ import org.eclipse.team.tests.ccvs.core.NullOutputStream;
* two (or more) different enviorments to test certain things.
*/
public final class SameResultEnv extends JUnitTestCase {
-
- public static final String REFERENCE_CLIENT_WORKSPACE="reference";
- public static final String ECLIPSE_CLIENT_WORKSPACE="eclipse";
-
- private File workspace;
- private File referenceClientRoot;
- private File eclipseClientRoot;
- private boolean ignoreExceptions=false;
- private boolean expectExceptions=false;
-
- private CVSRepositoryLocation referenceClientRepository;
- private CVSRepositoryLocation eclipseClientRepository;
-
- public SameResultEnv(String arg, File workspace) {
+ private IProject referenceProject;
+ private ICVSFolder referenceRoot;
+ private IProject eclipseProject;
+ private ICVSFolder eclipseRoot;
+
+ private boolean ignoreExceptions;
+
+ public SameResultEnv(String arg) {
super(arg);
- this.workspace = workspace;
- referenceClientRoot = new File(workspace, REFERENCE_CLIENT_WORKSPACE);
- eclipseClientRoot = new File(workspace, ECLIPSE_CLIENT_WORKSPACE);
-
- try {
- deleteFile(".");
- } catch (CVSException e) {
- fail();
- }
}
/**
* Always to be called in the setUp of the testCase that wants to
* use the same-result Enviorment.
*/
- public void setUp() throws CVSException {
+ public void setUp() throws Exception {
+ super.setUp();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ // setup reference client test project
+ referenceProject = root.getProject(getName() + "-reference");
+ referenceProject.delete(true /*deleteContent*/, true /*force*/, null);
+ mkdirs(referenceProject);
+ referenceRoot = CVSWorkspaceRoot.getCVSFolderFor(referenceProject);
+
+ // setup eclipse client test project
+ eclipseProject = root.getProject(getName() + "-eclipse");
+ eclipseProject.delete(true /*deleteContent*/, true /*force*/, null);
+ mkdirs(eclipseProject);
+ eclipseRoot = CVSWorkspaceRoot.getCVSFolderFor(eclipseProject);
+
// By default, exceptions are not ignored.
// Specific test cases can choose to ignore exceptions
ignoreExceptions = false;
- mkdirs(".");
}
/**
* Always to be called in the tearDown of the testCase that wants to
* use the same-result Enviorment.
*/
- public void tearDown() throws CVSException {
- deleteFile("");
+ public void tearDown() throws Exception {
+ // we deliberately don't clean up test projects to simplify debugging
+ super.tearDown();
}
/**
+ * Helper method.
+ * Calls execute(command, EMPTY_ARGS, localOptions, arguments, pathRelativeToRoot)
+ */
+ public void execute(String command, String[] localOptions, String[] arguments, String pathRelativeToRoot)
+ throws CVSException {
+ execute(command, EMPTY_ARGS, localOptions, arguments, pathRelativeToRoot);
+ }
+
+ /**
+ * Helper method.
+ * Calls execute(command, EMPTY_ARGS, localOptions, arguments, "")
+ */
+ public void execute(String command, String[] localOptions, String[] arguments)
+ throws CVSException {
+ execute(command, EMPTY_ARGS, localOptions, arguments, "");
+ }
+
+ /**
+ * Runs a command twice, once in the reference environments, once
+ * in the eclipse environment. Compares the resulting resources
+ * on disk, but not console output.
+ */
+ public void execute(String command,
+ String[] globalOptions, String[] localOptions, String[] arguments,
+ String pathRelativeToRoot) throws CVSException {
+
+ // run with reference client
+ boolean referenceClientException = false;
+ try {
+ File localRoot = referenceProject.getLocation().toFile();
+ if (pathRelativeToRoot.length() != 0) {
+ localRoot = new File(localRoot, pathRelativeToRoot);
+ }
+ CommandLineCVSClient.execute(
+ CompatibleTestSetup.referenceClientRepository.getLocation(),
+ localRoot, command, globalOptions, localOptions, arguments);
+ } catch (CVSClientException e) {
+ if (! ignoreExceptions) throw e;
+ referenceClientException = true;
+ } finally {
+ try {
+ referenceProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+ EclipseSynchronizer.getInstance().flushAll(referenceProject, false); // remove me once refresh local fixed
+ } catch (CoreException e) {
+ fail("CoreException during refreshLocal: " + e.getMessage());
+ }
+ }
+
+ // run with Eclipse client
+ boolean eclipseClientException = false;
+ try {
+ ICVSFolder localRoot = eclipseRoot;
+ IPath path = new Path(pathRelativeToRoot);
+ while (path.segmentCount() != 0) {
+ localRoot = localRoot.getFolder(path.segment(0));
+ path = path.removeFirstSegments(1);
+ }
+ EclipseCVSClient.execute(
+ CompatibleTestSetup.eclipseClientRepository, localRoot,
+ command, globalOptions, localOptions, arguments);
+ } catch (CVSClientException e) {
+ if (! ignoreExceptions) throw e;
+ eclipseClientException = true;
+ }
+ assertEquals(referenceClientException, eclipseClientException);
+ assertConsistent();
+ }
+
+ /**
* Deletes files on the both of the cvs-servers.
*/
- public void magicDeleteRemote(String project) throws CVSException {
- magicDeleteProject(CompatibleTestSetup.referenceClientRepository,project);
- magicDeleteProject(CompatibleTestSetup.eclipseClientRepository,project);
+ public void magicDeleteRemote(String remoteName) throws CVSException {
+ super.magicDeleteRemote(CompatibleTestSetup.referenceClientRepository, remoteName);
+ super.magicDeleteRemote(CompatibleTestSetup.eclipseClientRepository, remoteName);
}
/**
@@ -104,180 +176,48 @@ public final class SameResultEnv extends JUnitTestCase {
* b.txt
* c.txt
*/
- public void magicSetUpRepo(String project) throws CVSException {
- magicSetUpRepo(project,new String[]{"a.txt","f1/b.txt","f1/c.txt"});
+ public void magicSetUpRepo(String projectName)
+ throws IOException, CoreException, CVSException {
+ magicSetUpRepo(projectName, new String[]{"a.txt","f1/b.txt","f1/c.txt"});
}
/**
* Set up both of the repos on the cvs-server(s) with a filestructre
* resulting for your input in the parameter createResources.
*/
- public void magicSetUpRepo(String project,String[] createResources) throws CVSException {
-
- // This will trigger asynchronizer reload
- // deleteFile(project);
- magicDeleteRemote(project);
-
- createRandomFile(createResources, project);
- execute("import",new String[]{"-m","msg"},new String[]{project,"a","b"},project);
-
- deleteFile(".");
- mkdirs(".");
- }
-
- /**
- * Give null this gives an empty string-array back, otherwise
- * the parameter.
- */
- private static String[] notNull(String[] arg) {
- if (arg == null) {
- return new String[0];
- } else {
- return arg;
- }
- }
+ public void magicSetUpRepo(String projectName, String[] createResources)
+ throws IOException, CoreException, CVSException {
+ magicDeleteRemote(projectName);
- /**
- * Convienience Method, does the same like:<br>
- * execute(request,null,localOptions,arguments,rootExtention)
- */
- public void execute(String request,
- String[] localOptions,
- String[] arguments,
- String rootExtention)
- throws CVSException {
+ IProject projectRoot = workspaceRoot.getProject(projectName + "-setup-tmp");
+ mkdirs(projectRoot);
+ createRandomFile(projectRoot, createResources);
- execute(request,new String[0],localOptions,arguments,rootExtention);
- }
-
- /**
- * Convienience Method, does the same like:<br>
- * execute(request,null,localOptions,arguments,null)
- */
- public void execute(String request,
- String[] localOptions,
- String[] arguments)
- throws CVSException {
-
- execute(request,new String[0],localOptions,arguments,"");
- }
+ String[] lOptions = new String[]{"-m","msg"};
+ String[] args = new String[]{projectName,"a","b"};
- /**
- * Run a command in the two folders of this enviorment. In one folder the
- * reference-client runs in the the other the eclipse-client. After that
- * the results on disc are compared (the output of the clients is not
- * considert for the comparison)
- */
- public void execute(String request,
- String[] globalOptions,
- String[] localOptions,
- String[] arguments,
- String rootExtention)
- throws CVSException {
-
- globalOptions = notNull(globalOptions);
-
- String[] gOptions1 = new String[globalOptions.length + 2];
- String[] gOptions2 = new String[globalOptions.length + 2];
-
- System.arraycopy(globalOptions,0,gOptions1,0,globalOptions.length);
- System.arraycopy(globalOptions,0,gOptions2,0,globalOptions.length);
-
- gOptions1[globalOptions.length] = gOptions2[globalOptions.length] = "-d";
- gOptions1[globalOptions.length + 1] = CompatibleTestSetup.REFERENCE_CLIENT_REPOSITORY;
- gOptions2[globalOptions.length + 1] = CompatibleTestSetup.ECLIPSE_CLIENT_REPOSITORY;
+ magicDeleteRemote(CompatibleTestSetup.referenceClientRepository, projectName);
+ EclipseCVSClient.execute(CompatibleTestSetup.referenceClientRepository, CVSWorkspaceRoot.getCVSFolderFor(projectRoot),
+ "import", EMPTY_ARGS, lOptions, args);
+
+ magicDeleteRemote(CompatibleTestSetup.eclipseClientRepository, projectName);
+ EclipseCVSClient.execute(CompatibleTestSetup.eclipseClientRepository, CVSWorkspaceRoot.getCVSFolderFor(projectRoot),
+ "import", EMPTY_ARGS, lOptions, args);
- execute(request,gOptions1,gOptions2,localOptions,arguments,rootExtention);
- }
-
- /**
- * Acctally run the command in both folders. See doc above.
- */
- private void execute(String request,
- String[] globalOptions1,
- String[] globalOptions2,
- String[] localOptions,
- String[] arguments,
- String rootExtention)
- throws CVSException {
-
- assertNotNull(request);
- assertNotNull(globalOptions1);
- assertNotNull(globalOptions);
-
- boolean referenceClientException = false;
- boolean eclipseClientException = false;
-
- localOptions = notNull(localOptions);
- arguments = notNull(arguments);
- if (rootExtention == null || rootExtention.equals(".")) {
- rootExtention = "";
- }
-
- try {
- ReferenceClient.execute(request,
- globalOptions1,
- localOptions,
- arguments,
- new File(referenceClientRoot,rootExtention),
- new NullProgressMonitor(),
- new PrintStream(new NullOutputStream()));
- } catch (ReferenceException e) {
- referenceClientException = true;
- if (!ignoreExceptions) {
- throw e;
- }
- }
-
- try {
- execute(request,
- globalOptions2,
- localOptions,
- arguments,
- new File(eclipseClientRoot,rootExtention),
- new NullProgressMonitor(),
- new PrintStream(new NullOutputStream()));
- } catch (CVSServerException e) {
- eclipseClientException = true;
- if (!ignoreExceptions) {
- throw e;
- }
- }
- if(ignoreExceptions) {
- assertEquals(referenceClientException == true, eclipseClientException == true);
- }
- assertConsistent();
+ projectRoot.delete(false /*force*/, null);
}
/**
- * Checks whether the two directories inside the environment
- * are equal and therefore the state valid.
- */
- public void assertConsistent() throws CVSException {
- ICVSFolder referenceFolder = Session.getManagedFolder(referenceClientRoot);
- ICVSFolder eclipseFolder = Session.getManagedFolder(eclipseClientRoot);
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)referenceFolder).getLocalFile(), new NullProgressMonitor());
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)eclipseFolder).getLocalFile(), new NullProgressMonitor());
- assertEquals(referenceFolder,eclipseFolder);
- }
-
- /**
* Create a file with random-content in both, the reference client and
* the eclipse-client.
*
* @param relativeFileName is the relative path as allways in the
class used for access
*/
- public void createRandomFile(String relativeFileName) throws CVSException {
-
- String randomContent;
-
- randomContent = createRandomContent();
- try {
- writeToFile(relativeFileName,new String[]{randomContent});
- } catch (IOException e) {
- throw new CVSException("IOException while creating random content",e);
- }
+ public void createRandomFile(String relativeFileName)
+ throws IOException, CoreException {
+ String[] contents = new String[] { createRandomContent() };
+ writeToFile(relativeFileName, contents);
}
/**
@@ -285,18 +225,15 @@ public final class SameResultEnv extends JUnitTestCase {
*
* @see SameResultEnv#createRandomFile(String)
*/
- public void createRandomFile(String[] relativeFileNames, String rootExtention) throws CVSException {
-
- if (rootExtention == null || rootExtention.equals(".")) {
- rootExtention = "";
- }
-
- if (!rootExtention.equals("") && !rootExtention.startsWith("/")) {
- rootExtention = rootExtention + "/";
+ public void createRandomFile(String[] relativeFileNames,
+ String pathRelativeToRoot) throws CoreException, IOException {
+ if (pathRelativeToRoot == null) {
+ pathRelativeToRoot = "";
+ } else if (! pathRelativeToRoot.endsWith("/")) {
+ pathRelativeToRoot += "/";
}
-
- for (int i=0; i<relativeFileNames.length; i++) {
- createRandomFile(rootExtention + relativeFileNames[i]);
+ for (int i = 0; i < relativeFileNames.length; i++) {
+ createRandomFile(pathRelativeToRoot + relativeFileNames[i]);
}
}
@@ -304,91 +241,82 @@ public final class SameResultEnv extends JUnitTestCase {
* Read from the file (check that we have acctually got the same
* content in both versions
*/
- public String[] readFromFile(String relativeFileName) throws IOException {
-
- String[] content1;
- String[] content2;
-
- content1 = super.readFromFile(new File(referenceClientRoot,relativeFileName));
- content2 = super.readFromFile(new File(eclipseClientRoot,relativeFileName));
-
+ public String[] readFromFile(String relativeFileName)
+ throws IOException, CoreException {
+ IFile referenceFile = referenceProject.getFile(relativeFileName);
+ String[] content1 = super.readFromFile(referenceFile);
+ IFile eclipseFile = eclipseProject.getFile(relativeFileName);
+ String[] content2 = super.readFromFile(eclipseFile);
assertEqualsArrays(content1,content2);
-
return content1;
}
/**
- * Delete files from both of the directories
+ * Delete a file / folder from both directories.
*/
- public void deleteFile(String relativeFileName) throws CVSException {
-
- if (".".equals(relativeFileName)) {
- relativeFileName = "";
- }
-
- File file1 = new File(referenceClientRoot, relativeFileName);
- File file2 = new File(eclipseClientRoot, relativeFileName);
-
- assertEquals(file1.exists(),file2.exists());
-
- if (!file1.exists()) {
- return;
- }
-
- // Call the "clean-up-delete" that cares about deleting the
- // cache
- if (file1.isDirectory()) {
- delete(Session.getManagedFolder(file1));
- delete(Session.getManagedFolder(file2));
+ public void deleteFile(String relativeFileName) throws CoreException {
+ IResource referenceFile, eclipseFile;
+ if (relativeFileName.length() != 0) {
+ referenceFile = referenceProject.findMember(relativeFileName);
+ eclipseFile = eclipseProject.findMember(relativeFileName);
} else {
- delete(Session.getManagedFile(file1));
- delete(Session.getManagedFile(file2));
+ referenceFile = referenceProject;
+ eclipseFile = eclipseProject;
}
+ assertEquals(referenceFile != null, eclipseFile != null);
+ if (referenceFile == null) return;
+ assertEquals(referenceFile.exists(), eclipseFile.exists());
+ referenceFile.delete(true, null);
+ eclipseFile.delete(true, null);
}
/**
- * Create a folder and all the subfolders
- * in both of the directories
+ * Creates a folder (and its parents if needed) in both environments.
*/
- public void mkdirs(String folderName) {
- (new File(referenceClientRoot,folderName)).mkdirs();
- (new File(eclipseClientRoot,folderName)).mkdirs();
+ public void mkdirs(String relativeFolderName) throws CoreException {
+ IFolder referenceFolder = referenceProject.getFolder(relativeFolderName);
+ IFolder eclipseFolder = eclipseProject.getFolder(relativeFolderName);
+ assertEquals(referenceFolder.exists(), eclipseFolder.exists());
+ mkdirs(referenceFolder);
+ mkdirs(eclipseFolder);
}
/**
* Append a String to an file (acctally to both of the files, that are going
* to have the same content)
*/
- public void appendToFile(String relativeFileName, String txt) throws IOException {
- File file1 = new File(referenceClientRoot,relativeFileName);
- File file2 = new File(eclipseClientRoot,relativeFileName);
-
+ public void appendToFile(String relativeFileName, String[] contents)
+ throws IOException, CoreException {
// Wait a second so that the timestamp will change for sure
- waitMsec(2000);
-
- appendToFile(file1,txt);
- appendToFile(file2,txt);
+ waitMsec(1500);
+
+ IFile referenceFile = referenceProject.getFile(relativeFileName);
+ appendToFile(referenceFile, contents);
+ IFile eclipseFile = eclipseProject.getFile(relativeFileName);
+ appendToFile(eclipseFile, contents);
}
/**
* Write to the file (acctally to both of the files, that are going
* to have the same content)
- * Does create the underlying folder if they do not exist (the version
- * of JUnitTest does currently not)
*/
- public void writeToFile(String relativeFileName, String[] content) throws IOException {
-
- File file1 = new File(referenceClientRoot,relativeFileName);
- File file2 = new File(eclipseClientRoot,relativeFileName);
-
- file1.getParentFile().mkdirs();
- file2.getParentFile().mkdirs();
-
- writeToFile(file1,content);
- writeToFile(file2,content);
+ public void writeToFile(String relativeFileName, String[] contents)
+ throws IOException, CoreException {
+ IFile referenceFile = referenceProject.getFile(relativeFileName);
+ writeToFile(referenceFile, contents);
+ IFile eclipseFile = eclipseProject.getFile(relativeFileName);
+ writeToFile(eclipseFile, contents);
}
/**
+ * Checks whether the two directories inside the environment
+ * are equal and therefore the state valid.
+ */
+ public void assertConsistent() throws CVSException {
+ assertEquals(referenceRoot, eclipseRoot);
+ }
+
+ /**
* Deep compare of two ManagedResources (most likly folders).
* Passwords are ignored.
*
@@ -421,12 +349,12 @@ public final class SameResultEnv extends JUnitTestCase {
private static void assertEquals(ICVSFile mFile1, ICVSFile mFile2) throws CVSException {
// Check the permissions on disk
- assertEquals(getFile(mFile1).canWrite(), getFile(mFile2).canWrite());
+ assertEquals(mFile1.isReadOnly(), mFile2.isReadOnly());
// Compare the content of the files
try {
- InputStream in1 = new FileInputStream(getFile(mFile1));
- InputStream in2 = new FileInputStream(getFile(mFile2));
+ InputStream in1 = mFile1.getInputStream();
+ InputStream in2 = mFile2.getInputStream();
byte[] buffer1 = new byte[(int)mFile1.getSize()];
byte[] buffer2 = new byte[(int)mFile2.getSize()];
// This is not the right way to do it, because the Stream
@@ -502,8 +430,8 @@ public final class SameResultEnv extends JUnitTestCase {
assertEquals(mFolder1.isCVSFolder(),mFolder2.isCVSFolder());
if (mFolder1.isCVSFolder()) {
- String root1 = Util.removePassword(mFolder1.getFolderSyncInfo().getRoot());
- String root2 = Util.removePassword(mFolder2.getFolderSyncInfo().getRoot());
+ String root1 = removePassword(mFolder1.getFolderSyncInfo().getRoot());
+ String root2 = removePassword(mFolder2.getFolderSyncInfo().getRoot());
root1 = root1.substring(0,root1.lastIndexOf("@"));
root2 = root2.substring(0,root2.lastIndexOf("@"));
assertEquals(root1,root2);
@@ -556,4 +484,24 @@ public final class SameResultEnv extends JUnitTestCase {
public void setIgnoreExceptions(boolean ignoreExceptions) {
this.ignoreExceptions = ignoreExceptions;
}
+
+ /**
+ * returns ":pserver:nkrambro@fiji:/home/nkrambro/repo"
+ * when you insert ":pserver:nkrambro:password@fiji:/home/nkrambro/repo"
+ */
+ public static String removePassword(String root) {
+ StringTokenizer tok = new StringTokenizer(root, ":@", true);
+ StringBuffer filteredRoot = new StringBuffer();
+ int colonCounter = 3;
+ while (tok.hasMoreTokens()) {
+ String token = tok.nextToken();
+ if ("@".equals(token)) colonCounter = -1;
+ if (":".equals(token)) {
+ if (--colonCounter == 0) continue; // skip colon
+ }
+ if (colonCounter == 0) continue; // skip password
+ filteredRoot.append(token);
+ }
+ return filteredRoot.toString();
+ }
} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java
index 19c7acaa3..973a03dac 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java
@@ -18,11 +18,7 @@ public class AllTests extends TestSuite {
public static Test suite() {
TestSuite suite = new TestSuite();
-
- suite.addTest(LocalFileTest.suite());
- suite.addTest(LocalFolderTest.suite());
suite.addTest(ResourceSyncInfoTest.suite());
- suite.addTest(SynchronizerTest.suite());
return suite;
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFileTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFileTest.java
deleted file mode 100644
index a48ebbffa..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFileTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.*;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-
-
-public class LocalFileTest extends JUnitTestCase {
-
- ICVSFile file1;
- ICVSFile file1a;
- ICVSFile file2;
- ICVSFolder folder1;
-
- ResourceSyncInfo fileInfo1;
-
- File ioFile;
-
-
- public LocalFileTest(String arg) {
- super(arg);
- }
-
- public static void main(String[] args) {
- TestRunner.run(LocalFileTest.class);
- }
-
-
- public void setUp() throws CVSException {
-
- String tmpEntryLine1;
-
-
- String root = ":server:user:pwd@test:/home";
- String repo = "repository";
- folder1 = getManagedFolder("proj1");
- folder1.mkdir();
- folder1.setFolderSyncInfo(new FolderSyncInfo(repo,root,null,false));
-
- file1 = folder1.getFile("file1.txt");
- file1a = folder1.getFile("file1.txt");
- file2 = folder1.getFile("file2.txt");
-
- tmpEntryLine1 = "/.vcm_meta/1.1/Thu Sep 27 18:00:16 2001/-kb/TmyTag";
- fileInfo1 = new ResourceSyncInfo(tmpEntryLine1,null,null);
-
- ioFile = getFile("proj1/file1.txt");
-
- }
-
- public void tearDown() throws CVSException {
- folder1.delete();
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)folder1).getLocalFile(), new NullProgressMonitor());
- assertSynchronizerEmpty();
- assertTrue(!folder1.exists());
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(LocalFileTest.class);
- return suite;
- }
-
- public void testFileInfo() throws CVSException {
-
- String entryLine1;
- String entryLine2;
- String entryLine3;
- boolean fail=false;
-
- entryLine1 = "/.vcm_meta/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLine2 = "/file1.txt/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLine3 = "/file1.txt/1.2/27 Sep 2001 18:00:16/-kb/TmyTag";
-
- ResourceSyncInfo fileInfo1 = new ResourceSyncInfo(entryLine1,null,null);
- ResourceSyncInfo fileInfo2 = new ResourceSyncInfo(entryLine2,null,null);
- ResourceSyncInfo fileInfo3 = new ResourceSyncInfo(entryLine3,null,null);
-
- file1.setSyncInfo(fileInfo2);
-
- assertEquals(file1a.getSyncInfo(),fileInfo2);
-
- file1a.setSyncInfo(fileInfo3);
-
- assertEquals(file1.getSyncInfo(),fileInfo3);
- }
-
-// public void testSendReceive() throws Exception {
-//
-// String sendTxt;
-// String expectTxt;
-// InputStream in;
-//
-// sendTxt = "This is my text";
-// expectTxt = sendTxt.length() + "\n" + sendTxt;
-//
-// byte[] result = new byte[sendTxt.length()];
-//
-// PipedInputStream pIn;
-// PipedOutputStream pOut;
-//
-// pIn = new PipedInputStream();
-// pOut = new PipedOutputStream(pIn);
-//
-// in = new BufferedInputStream(pIn,sendTxt.length());
-//
-// pOut.write(sendTxt.getBytes());
-// file1.receiveFrom(in,sendTxt.length(),false,false, new NullProgressMonitor());
-// in.close();
-// pOut.close();
-//
-// result = new byte[expectTxt.length()];
-// pIn = new PipedInputStream();
-// pOut = new PipedOutputStream(pIn);
-//
-// in = new BufferedInputStream(pIn,sendTxt.length());
-// file1.sendTo(pOut,false, new NullProgressMonitor());
-// in.read(result);
-// in.close();
-// pOut.close();
-//
-// assertEquals(new String(result),expectTxt);
-// }
-
- public void testTimestamp() throws Exception {
-
- String timeStamp;
-
- ioFile.createNewFile();
- timeStamp = "Tue Oct 30 14:38:16 2001";
-
- file1.setTimeStamp(timeStamp);
- assertEquals(timeStamp, file1a.getTimeStamp());
-
- }
-
- public void testIsDirty() throws Exception {
-
- String timeStamp;
- String entryLine;
- ResourceSyncInfo fileInfo;
-
- ioFile.createNewFile();
- timeStamp = "Tue Oct 30 14:38:16 2001";
- entryLine = "/file1.txt/1.1/Tue Oct 30 14:38:16 2001/-kb/TmyTag";
-
- file1.setTimeStamp(timeStamp);
- timeStamp = file1.getTimeStamp();
-
- fileInfo = new ResourceSyncInfo(entryLine,null,timeStamp);
-
- file1.setSyncInfo(fileInfo);
-
- assertEquals(false, file1.isDirty());
-
- // touch the file
- writeToFile(ioFile,readFromFile(ioFile));
-
- assertEquals(true, file1.isDirty());
-
- file1.setTimeStamp(timeStamp);
-
- assertEquals(false, file1.isDirty());
- }
-
- // ---------------- Here the resource-tests start ---------------
-
- public void testExists() throws Exception {
-
- file1.delete();
- assertEquals(false, file1.exists());
- writeToFile(ioFile,new String[0]);
- assertEquals(true, file1.exists());
-
- }
-
- public void testGetName() {
- assertEquals("file1.txt", file1.getName());
- }
-
- public void testGetParent() {
- assertEquals(folder1,file1.getParent());
- }
-
- public void testGetRelativePath() throws CVSException {
- assertEquals("file1.txt", file1.getRelativePath(folder1));
- }
-
- public void testIsFolder() {
- assertEquals(false, file1.isFolder());
- }
-
- public void testIsManaged() throws CVSException {
-
- ResourceSyncInfo fileInfo2 = new ResourceSyncInfo("/file1.txt/1.1/27 Sep 2001 18:00:16/-kb/TmyTag",null,null);
-
- assertEquals(false, file1.isManaged());
- file1.setSyncInfo(fileInfo2);
- assertEquals(true, file1.isManaged());
-
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFolderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFolderTest.java
deleted file mode 100644
index 1c767ad90..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFolderTest.java
+++ /dev/null
@@ -1,447 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.File;
-import java.io.IOException;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.*;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.ICVSFolder;
-import org.eclipse.team.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-
-public class LocalFolderTest extends JUnitTestCase {
-
- ICVSFile file1;
- ICVSFile file1a;
- ICVSFile file2;
-
- ICVSFolder folder1;
- ICVSFolder folder1a;
- ICVSFolder folder2;
-
- String entryLine1;
- String entryLine2;
- String entryLineExtra1;
- String entryLineExtra2;
- String entryLineExtra3;
-
- String root;
- String repo;
- String root2;
- String repo2;
-
- ResourceSyncInfo fileInfo1;
-
- FolderSyncInfo folderInfo1;
- FolderSyncInfo folderInfo2;
-
- File ioFile1;
-
- public LocalFolderTest(String arg) {
- super(arg);
- }
-
- public static void main(String[] args) {
- TestRunner.run(LocalFolderTest.class);
- }
-
- /**
- * Leaves this file-structure:
- *
- * test (folder1, folder1a)
- * proj1 (folder2, ioFolder2) *** Does not exist ***
- * file1.txt (file1, file1a)
- * file2.txt (file2) *** Does not exist ***
- */
- public void setUp() throws CVSException, IOException {
-
- folder1 = getManagedFolder("test");
- folder1a = getManagedFolder("test");
- folder2 = folder1.getFolder("proj1");
- folder1.mkdir();
- assertTrue(folder1.exists());
-
- file1 = folder1.getFile("file1.txt");
- file1a = folder1.getFile("file1.txt");
- file2 = folder1.getFile("file2.txt");
-
- root = ":server:user:pwd@test:/home";
- repo = "repository";
- root2 = ":method:user:pwd@test2:/home/myFolder/repo";
- repo2 = "proj1/subdir";
-
- folderInfo1 = new FolderSyncInfo(repo,root,null,false);
- folderInfo2 = new FolderSyncInfo(repo2,root2,null,true);
-
- entryLine1 = "/.vcm_meta/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLine2 = "/file3.txt/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLineExtra1 = "/file1.txt/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLineExtra2 = "/file1.txt/1.2/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLineExtra3 = "/file2.txt/1.2/27 Sep 2001 18:00:16/-kb/TmyTag";
-
- folder1.setFolderSyncInfo(folderInfo1);
-
- fileInfo1 = new ResourceSyncInfo(entryLineExtra1,null,null);
- file1.setSyncInfo(fileInfo1);
-
- ioFile1 = getFile("test/file1.txt");
- ioFile1.createNewFile();
-
- }
-
- public void tearDown() throws CVSException {
- folder1.delete();
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)folder1).getLocalFile(), new NullProgressMonitor());
- assertSynchronizerEmpty();
- assertTrue(!folder1.exists());
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(LocalFolderTest.class);
- return suite;
- }
-
- public void testGetFolders() throws CVSException {
-
- // tests setFolderSyncInfo and getFolderSyncInfo as well
-
- boolean fail = false;
- ICVSFolder folder3;
- ICVSFolder tmpFolder;
- ICVSFolder[] resultFolders;
-
- folder3 = folder1.getFolder("folder3");
- folder3.mkdir();
-
- resultFolders = folder2.getFolders();
- assertEquals(0, resultFolders.length);
-
- // For the moment we assume, that seting a folderInfo
- // does not create the folder automatically but you
- // have to create it with mkdir.
- try {
- folder2.setFolderSyncInfo(folderInfo1);
- fail();
- } catch (Exception e) {
- }
-
- resultFolders = folder1.getFolders();
- assertEquals(1, resultFolders.length);
-
- folder2.mkdir();
-
- resultFolders = folder1.getFolders();
- assertEquals(2, resultFolders.length);
-
- folder2.delete();
-
- resultFolders = folder1.getFolders();
- assertEquals(1, resultFolders.length);
-
- folder2.mkdir();
- folder2.setFolderSyncInfo(folderInfo1);
-
- resultFolders = folder1.getFolders();
- assertEquals(2, resultFolders.length);
-
- folder2.delete();
-
- resultFolders = folder1.getFolders();
- assertEquals(2, resultFolders.length);
-
- tmpFolder = folder1.getFolder("proj1");
- assertEquals(false,tmpFolder.exists());
- assertEquals(true,tmpFolder.isManaged());
- }
-
- public void testGetFiles() throws Exception {
- // tests setFolderSyncInfo and getFolderSyncInfo as well
-
- boolean fail = false;
- ICVSFile[] resultFiles;
- ICVSFile file3;
- File ioFile3;
- ResourceSyncInfo fileInfo2;
-
- file3 = folder1.getFile("file3.txt");
- ioFile3 = getFile("test/file3.txt");
-
- // From here we check if the filelist does include files,
- // that are added locally but not as entries (and exclude them
- // again when we delete them)
- resultFiles = folder1.getFiles();
- assertEquals(1, resultFiles.length);
-
- ioFile3.createNewFile();
-
- resultFiles = folder1.getFiles();
- assertEquals(2, resultFiles.length);
-
- ioFile3.delete();
-
- resultFiles = folder1.getFiles();
- assertEquals(1, resultFiles.length);
-
- // Here is tested if we get files that do not exist locally but
- // in the entries
-
- // first we try a fileinfo with the wrong name
- try {
- file3.setSyncInfo(fileInfo1);
- } catch (Throwable e) {fail = true;}
- assertTrue(fail);
- fail = false;
-
- fileInfo2 = new ResourceSyncInfo(entryLine2,null,null);
-
- file3.setSyncInfo(fileInfo2);
-
- resultFiles = folder1.getFiles();
- assertEquals(2, resultFiles.length);
- assertEquals(false,file3.exists());
- assertEquals(true,file3.isManaged());
-
- file3.unmanage();
-
- resultFiles = folder1.getFiles();
- assertEquals(1, resultFiles.length);
- assertEquals(false,file3.exists());
- assertEquals(false,file3.isManaged());
- }
-
- public void testGetChild() throws CVSException {
-
- try {
- folder1.getChild("proj1");
- assertTrue(false);
- } catch (CVSException e) {}
-
- try {
- folder1.getChild("file2.txt");
- assertTrue(false);
- } catch (CVSException e) {}
-
- folder2.mkdir();
-
- assertEquals(true, folder1.getChild("proj1").isFolder());
- assertEquals("proj1", folder1.getChild("proj1").getName());
- assertEquals(false, folder1.getChild("file1.txt").isFolder());
-
- }
-
- // ---------------- Here the resource-tests start ---------------
-
- public void testExists() throws Exception {
- assertEquals(false, folder2.exists());
- folder2.mkdir();
- assertEquals(true, folder2.exists());
- folder2.delete();
- assertEquals(false, folder2.exists());
- }
-
- public void testGetName() throws CVSException {
- assertEquals("proj1", folder2.getName());
- folder2.mkdir();
- assertEquals("proj1", folder2.getName());
- }
-
- public void testGetParent() {
- assertEquals(folder1,folder2.getParent());
- }
-
- public void testGetRelativePath() throws CVSException {
- ICVSFolder subFolder1;
- ICVSFolder subFolder2;
- ICVSFolder subFolder3;
- String sep = "/";
-
- boolean fail = false;
-
- subFolder1 = folder1.getFolder("proj1");
- subFolder2 = subFolder1.getFolder("proj2");
- subFolder3 = subFolder2.getFolder("proj3");
-
- assertEquals("proj1", folder2.getRelativePath(folder1));
- assertEquals("testGetRelativeLocation.1","proj1", subFolder1.getRelativePath(folder1));
- assertEquals("testGetRelativeLocation.2","proj1" + sep + "proj2" + sep + "proj3", subFolder3.getRelativePath(folder1));
- assertEquals("testGetRelativeLocation.3","proj2", subFolder2.getRelativePath(subFolder1));
- assertEquals("testGetRelativeLocation.3a","", subFolder2.getRelativePath(subFolder2));
-
- try {
- subFolder1.getRelativePath(subFolder2);
- } catch (CVSException e) {fail = true;}
- assertTrue("testGetRelativeLocation.4",fail);
- fail = false;
-
- subFolder1.delete();
- }
-
- public void testIsFolder() {
- assertEquals(true, folder2.isFolder());
- }
-
- public void testFolderIsManaged() throws CVSException {
- ICVSFolder folder = getManagedFolder("testIsManaged");
- folder.mkdir();
- assertEquals(null, folder.getFolderSyncInfo());
-
- FolderSyncInfo info = new FolderSyncInfo("module", ":pserver:user@host:/home", null, false);
- folder.setFolderSyncInfo(info);
- assertTrue(folder.isCVSFolder() && !folder.isManaged());
- assertTrue(folder.getFolderSyncInfo().equals(info));
-
- folder.delete();
- reload(folder);
- }
-
- public void testFolderInfo() throws CVSException {
- FolderSyncInfo folderInfo2;
- FolderSyncInfo folderInfo3;
- String repo;
- String root;
-
- repo = "proj1/folder1";
- root = ":pserver:nkram:pwd@fiji:/home/nkrambro/repo";
-
- assertEquals(null, folder2.getFolderSyncInfo());
- assertEquals(false,folder2.isCVSFolder());
-
- folder1.setFolderSyncInfo(folderInfo1);
- folderInfo2 = folder1.getFolderSyncInfo();
-
- assertEquals(true,folder1.isCVSFolder());
- assertEquals(this.root,folderInfo2.getRoot());
- assertEquals(this.repo,folderInfo2.getRepository());
-
- folder1.unmanage();
-
- assertEquals(false,folder1.isCVSFolder());
- assertEquals(null,folder1.getFolderSyncInfo());
-
- folderInfo3 = new FolderSyncInfo(repo,root,folderInfo2.getTag(),false);
-
- folder1.setFolderSyncInfo(folderInfo3);
-
- assertEquals(root,folder1.getFolderSyncInfo().getRoot());
- assertEquals(repo,folder1.getFolderSyncInfo().getRepository());
- assertEquals("/home/repository",folderInfo2.getRemoteLocation());
- }
-
- public void testsetSyncInfo() throws CVSException {
- String entry1 = "/file1.txt/a/b/c/";
- String entry2 = "/file1.txt/b/b/c/";
- String entry3 = "/file2.txt/b/b/c/";
-
- ResourceSyncInfo info1 = new ResourceSyncInfo(entry1,null,null);
- ResourceSyncInfo info2 = new ResourceSyncInfo(entry2,null,null);
- ResourceSyncInfo info3 = new ResourceSyncInfo(entry3,null,null);
-
- ICVSFile file1 = this.file1;
- ICVSFile file2 = folder1.getFile("file2.txt");
-
- assertEquals(1,folder1.getFiles().length);
- file1.setSyncInfo(info1);
- assertEquals(1,folder1.getFiles().length);
- file1.setSyncInfo(info2);
- assertEquals(1,folder1.getFiles().length);
- file2.setSyncInfo(info3);
- assertEquals(2,folder1.getFiles().length);
-
- assertEquals(entry2,file1.getSyncInfo().getEntryLine(true));
- assertEquals(entry3,file2.getSyncInfo().getEntryLine(true));
-
- // The two files in the getFiles are acctually the files
- // we put in there
- assertTrue( ( folder1.getFiles()[0].equals(file1) ||
- folder1.getFiles()[0].equals(file2)) &&
- ( folder1.getFiles()[1].equals(file1) ||
- folder1.getFiles()[1].equals(file2)));
- }
-
- public void testSimpleGetFiles() throws CVSException {
- // When a file is added to the entries it should be in the list
- // of files afterwards ... this should be one of the current problems
- file2.setSyncInfo(new ResourceSyncInfo(entryLineExtra3,null,null));
- assertEquals(2,folder1.getFiles().length);
- file2.unmanage();
- assertEquals(1,folder1.getFiles().length);
- }
-
- public void testSimpleResourceSyncInfo() throws Exception {
-
- assertEquals(file1a.getSyncInfo(), fileInfo1);
-
- file1a.setSyncInfo(new ResourceSyncInfo(entryLineExtra2,null,null));
-
- assertEquals(file1.getSyncInfo().getEntryLine(true),entryLineExtra2);
-
- file1a.setSyncInfo(new ResourceSyncInfo(entryLineExtra1,null,null));
-
- assertEquals(file1.getSyncInfo().getEntryLine(true),entryLineExtra1);
-
- file1a.setSyncInfo(new ResourceSyncInfo(entryLineExtra2,null,null));
-
- assertEquals(file1.getSyncInfo().getEntryLine(true),entryLineExtra2);
- }
-
- public void testSimpleFolderSyncInfo() throws Exception {
- folder1.setFolderSyncInfo(folderInfo2);
- assertEquals(folder1.getFolderSyncInfo().getRepository(),repo2);
- assertEquals(folder1.getFolderSyncInfo().getRoot(),root2);
- assertEquals(folder1.getFolderSyncInfo().getIsStatic(),true);
-
- reload(folder1);
- assertEquals(folder1.getFolderSyncInfo().getRepository(),repo2);
- assertEquals(folder1.getFolderSyncInfo().getRoot(),root2);
- assertEquals(folder1.getFolderSyncInfo().getIsStatic(),true);
-
- folder1.setFolderSyncInfo(folderInfo1);
- assertEquals(folder1a.getFolderSyncInfo().getRepository(),repo);
- assertEquals(folder1a.getFolderSyncInfo().getRoot(),root);
- assertEquals(folder1a.getFolderSyncInfo().getIsStatic(),false);
- }
-
- public void testSyncIsCvsFolder() throws Exception {
-
- folder1.delete();
- reload(folder1);
- assertEquals(false,folder1.isCVSFolder());
-
- folder1.mkdir();
- assertEquals(false,folder1.isCVSFolder());
-
- folder1.setFolderSyncInfo(folderInfo1);
- assertEquals(true,folder1.isCVSFolder());
- assertEquals(false,folder1.isManaged());
-
- assertEquals(false,folder2.isCVSFolder());
-
- folder2.mkdir();
- assertEquals(false,folder2.isCVSFolder());
- assertEquals(false,folder2.isManaged());
-
- folder2.setFolderSyncInfo(folderInfo2);
- assertEquals(true,folder2.isCVSFolder());
- assertEquals(true,folder2.isManaged());
- }
-
- protected void reload(ICVSResource resource) throws CVSException {
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)resource).getLocalFile(), new NullProgressMonitor());
- }
-
- protected void save(ICVSResource resource) throws CVSException {
- CVSProviderPlugin.getSynchronizer().save(((LocalResource)resource).getLocalFile(), new NullProgressMonitor());
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/SynchronizerTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/SynchronizerTest.java
deleted file mode 100644
index d71bc8eca..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/SynchronizerTest.java
+++ /dev/null
@@ -1,254 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.ccvs.core.*;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.CVSTag;
-import org.eclipse.team.ccvs.core.ICVSFolder;
-import org.eclipse.team.ccvs.core.ICVSResource;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileUtil;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class SynchronizerTest extends EclipseTest {
-
- public SynchronizerTest() {
- super();
- }
-
- public SynchronizerTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(SynchronizerTest.class);
- return new CVSTestSetup(suite);
- }
-
- protected File getSyncFile(File parent, String syncFileName) {
- return new File(SyncFileUtil.getCVSSubdirectory(parent), syncFileName);
- }
-
- protected void appendLineToFile(File file, String line) throws IOException {
-
- BufferedReader fileReader;
- List fileContentStore = new ArrayList();
-
- if (!file.exists()) {
- return;
- }
-
- String l;
- fileReader = new BufferedReader(new FileReader(file));
- while ((l = fileReader.readLine()) != null) {
- fileContentStore.add(l);
- }
- fileReader.close();
-
- String[] content = (String[]) fileContentStore.toArray(new String[fileContentStore.size()]);
- String[] newContent;
-
- newContent = new String[content.length + 1];
- System.arraycopy(content,0,newContent,0,content.length);
- newContent[content.length] = line;
-
- file.delete();
-
- BufferedWriter fileWriter;
-
- fileWriter = new BufferedWriter(new FileWriter(file));
- for (int i = 0; i<newContent.length; i++) {
- fileWriter.write(newContent[i]);
- fileWriter.newLine();
- }
- fileWriter.close();
- }
-
- public void testFolderSync() throws CoreException, CVSException {
- IProject project = getUniqueTestProject("testFolderSync");
- IResource[] resources = buildResources(project, new String[] {"a.txt", "folder1/", "folder1/b.txt", "folder2/", "folder2/c.txt"}, true);
- ensureExistsInFileSystem(resources);
- IFolder folder1 = project.getFolder("folder1");
- IFolder folder2 = project.getFolder("folder2");
- File folder1File = folder1.getLocation().toFile();
- File folder2File = folder2.getLocation().toFile();
- File projectFile = project.getLocation().toFile();
- ICVSResource cvsProject = new LocalFolder(projectFile);
-
- // 1.
-
- try {
- CVSProviderPlugin.getSynchronizer().setFolderSync(new File("dummy"), new FolderSyncInfo("repo", "root", null, false));
- fail();
- } catch(Exception e) {
- }
-
- // 2.
-
- FolderSyncInfo info = new FolderSyncInfo("repo", "root", null, false);
- CVSProviderPlugin.getSynchronizer().setFolderSync(projectFile, info);
- assertTrue(CVSProviderPlugin.getSynchronizer().getFolderSync(projectFile).equals(info));
- assertTrue(CVSProviderPlugin.getSynchronizer().members(projectFile).length == 0);
-
- // 3.
-
- info = new FolderSyncInfo("repo", "root", new CVSTag("v1", CVSTag.BRANCH), true);
- CVSProviderPlugin.getSynchronizer().setFolderSync(folder1File, info);
- assertTrue(CVSProviderPlugin.getSynchronizer().getFolderSync(folder1File).equals(info));
- assertTrue(CVSProviderPlugin.getSynchronizer().members(projectFile).length == 1);
-
- // 4.
-
- CVSProviderPlugin.getSynchronizer().setFolderSync(folder2File, info);
- assertTrue(CVSProviderPlugin.getSynchronizer().getFolderSync(folder2File).equals(info));
- assertTrue(CVSProviderPlugin.getSynchronizer().members(projectFile).length == 2);
- }
-
- public void testDeleteListener() throws CoreException, CVSException, TeamException {
- IProject project = createProject("testDeleteListener", new String[] {"a.txt", "folder1/", "folder1/b.txt"});
- IFolder folder1 = project.getFolder("folder1");
- IFile file1 = folder1.getFile("b.txt");
- ICVSFolder cvsFolder = new LocalFolder(folder1.getLocation().toFile());
- ICVSFolder cvsProject = new LocalFolder(project.getLocation().toFile());
- ICVSFile cvsfile = new LocalFile(file1.getLocation().toFile());
-
- // 1. delete of a folder deletes sync info deep
-
- FolderSyncInfo info = cvsFolder.getFolderSyncInfo();
- assertTrue(info!=null);
-
- folder1.delete(true, new NullProgressMonitor());
-
- assertTrue(cvsFolder.getFolderSyncInfo()==null);
- assertTrue(cvsfile.getSyncInfo()==null);
-
- // 2. rename of a project deletes cached sync info of source project
-
- project.move(new Path("movedProject"), true, new NullProgressMonitor());
-
- assertTrue(cvsProject.getFolderSyncInfo()==null);
- }
-
- public void testResourceSync() throws CVSException, CoreException, TeamException {
- IProject project = createProject("testResourceSync", new String[] {"a.txt", "folder1/", "folder1/b.txt"});
- IFolder folder1 = project.getFolder("folder1");
- IFile file1 = project.getFile("a.txt");
- IFile newFile = folder1.getFile("c.txt");
- IFolder newFolder = project.getFolder("folder2");
- ICVSFolder cvsFolder = new LocalFolder(folder1.getLocation().toFile());
- ICVSFolder cvsNewFolder = new LocalFolder(newFolder.getLocation().toFile());
- ICVSFile cvsFile = new LocalFile(file1.getLocation().toFile());
- ICVSFile cvsNewFile = new LocalFile(newFile.getLocation().toFile());
- ICVSFolder cvsProject = new LocalFolder(project.getLocation().toFile());
-
- // 1.
-
- assertTrue(!cvsProject.isManaged());
- assertTrue(cvsProject.isCVSFolder());
- assertTrue(cvsFile.getSyncInfo()!=null);
- assertTrue(cvsFolder.getSyncInfo()!=null);
-
- assertTrue(cvsNewFile.getSyncInfo()==null);
- assertTrue(cvsNewFolder.getSyncInfo()==null);
-
- // 2.
-
- ResourceSyncInfo folderInfo = new ResourceSyncInfo(cvsNewFolder.getName());
- ResourceSyncInfo fileInfo = new ResourceSyncInfo(cvsNewFile.getName(), "1.1", "timestamp", "-kb", null, null);
-
- cvsNewFile.setSyncInfo(fileInfo);
- cvsNewFolder.setSyncInfo(folderInfo);
-
- assertTrue(cvsNewFile.getSyncInfo().equals(fileInfo));
- assertTrue(cvsNewFolder.getSyncInfo().equals(folderInfo));
-
- save(cvsProject);
-
- assertTrue(cvsNewFile.getSyncInfo().equals(fileInfo));
- assertTrue(cvsNewFolder.getSyncInfo().equals(folderInfo));
- }
-
- public void testReload() throws CVSException, CoreException, TeamException, IOException {
- IProject project = createProject("testReload", new String[] {"a.txt", "folder1/", "folder1/b.txt", "folder2/", "folder2/folder2a/", "folder2/folder2a/b.txt", "folder3/b.txt"});
-
- File projectFile = project.getLocation().toFile();
- IFile newFile = project.getFile("b.txt");
- newFile.create(getRandomContents(), true, null);
- IFolder folder1 = project.getFolder("folder1");
- IFolder newFolder = project.getFolder("newFolder");
- newFolder.create(true, true, null);
- ICVSFolder cvsProject = new LocalFolder(project.getLocation().toFile());
- ICVSFile cvsNewFile = new LocalFile(newFile.getLocation().toFile());
- ICVSFolder cvsNewFolder = new LocalFolder(newFolder.getLocation().toFile());
- ICVSFolder cvsFolder = new LocalFolder(folder1.getLocation().toFile());
-
- // 1. update entry from outside of synchronizer then reload
- assertTrue(cvsNewFile.getSyncInfo()==null);
- assertTrue(cvsNewFolder.getSyncInfo()==null);
- assertTrue(cvsFolder.getFolderSyncInfo()!=null);
-
- ResourceSyncInfo fileInfo = new ResourceSyncInfo("/b.txt/1.1/Thu Aug 30 15:31:40 2001/-kb/", null, null);
- ResourceSyncInfo folderInfo = new ResourceSyncInfo("newFolder");
-
- folder1.delete(true, true, null);
-
- appendLineToFile(getSyncFile(project.getLocation().toFile(), SyncFileUtil.ENTRIES), fileInfo.getEntryLine(true));
- appendLineToFile(getSyncFile(project.getLocation().toFile(), SyncFileUtil.ENTRIES), folderInfo.getEntryLine(true));
-
- reload(cvsProject);
-
- assertTrue(cvsNewFile.getSyncInfo().equals(fileInfo));
- assertTrue(cvsNewFolder.getSyncInfo().equals(folderInfo));
- assertTrue(cvsFolder.getFolderSyncInfo()==null);
- assertTrue(new LocalFile(new File(folder1.getLocation().toFile(), "b.txt")).getSyncInfo()==null);
-
- // 2. delete multiple directory hierarchy and reload should delete everything from cache
- IFolder folder2 = project.getFolder("folder2");
- IFolder folder2a = folder2.getFolder("folder2a");
- ICVSFolder folder2aFile = new LocalFolder(folder2a.getLocation().toFile());
- ICVSFolder folder2File = new LocalFolder(folder2.getLocation().toFile());
-
- folder2File.unmanage();
- assertTrue(folder2File.exists());
- assertTrue(folder2File.getSyncInfo()==null);
- assertTrue(folder2aFile.getSyncInfo()==null);
- assertTrue(folder2File.getFolderSyncInfo()==null);
- assertTrue(folder2File.getFolderSyncInfo()==null);
- }
-
- protected void reload(ICVSResource resource) throws CVSException {
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)resource).getLocalFile(), new NullProgressMonitor());
- }
-
- protected void save(ICVSResource resource) throws CVSException {
- CVSProviderPlugin.getSynchronizer().save(((LocalResource)resource).getLocalFile(), new NullProgressMonitor());
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CommandsTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CommandsTest.java
deleted file mode 100644
index 7dc6e1a5d..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CommandsTest.java
+++ /dev/null
@@ -1,515 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.provider;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.File;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.*;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.util.FileUtil;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-
-/**
- * This class tests the basic functionality of the Eclipse CVS client
- * and can be used to test basic sanity.
- *
- * It does not run against another cvs client.
- */
-public class CommandsTest extends JUnitTestCase {
-
-
- static final String PLATFORM_NEWLINE = System.getProperty("line.separator");
-
- private File ioFolder1;
- private File ioFolder2;
- private File ioFolder3;
- private File ioFolder4;
-
- private String[] arguments;
-
- private boolean isSetUp = false;
-
- public static void main(String[] args) {
- run(CommandsTest.class);
- }
-
- public void setUp() throws Exception {
- if (!isSetUp) {
- try {
- magicSetUpRepo("proj1", new String[] { "folder1/c.txt", "folder1/d.txt", "folder2/test.flag"});
- } catch (Exception e) {
- System.err.println("Could not setup repository");
- }
- isSetUp = true;
- }
- ioFolder1 = getFile("test1");
- ioFolder2 = getFile("test2");
- ioFolder3 = getFile("test2/proj1");
- ioFolder4 = getFile("test2/proj1/folder1");
-
- FileUtil.deepDelete(ioFolder1);
- FileUtil.deepDelete(ioFolder2);
- ioFolder1.mkdir();
- ioFolder2.mkdir();
-
- }
-
- public void tearDown() throws CVSException {
- FileUtil.deepDelete(ioFolder1);
- FileUtil.deepDelete(ioFolder2);
- }
-
- public CommandsTest() {
- super("CommandsTest");
- arguments = new String[]{"proj1"};
- }
-
- public CommandsTest(String name) {
- super(name);
- arguments = new String[]{"proj1"};
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(CommandsTest.class);
- return new CVSTestSetup(suite);
- }
-
- /**
- * This should somehow create the following file-structure:
- *
- * temp
- * test1
- * proj1
- * CVS
- * folder1
- * CVS
- * c.txt
- * d.txt
- * folder2
- * CVS
- * test.flag
- * test2
- * proj1
- * CVS
- * folder1
- * CVS
- * c.txt
- * d.txt
- * folder2
- * CVS
- * test.flag
- *
- * where the cvs-folder contains the appropiate files including
- * the appropiated Entries-files
- */
- public void subTestCeckout() throws CVSException {
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder1,
- monitor,
- System.err);
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder2,
- monitor,
- System.err);
- }
-
- public void testCommitFiles() throws Exception {
- subTestCeckout();
- subTestCommitUpdate();
- }
-
- /**
- * Made for checking the ability of the client to cope with
- * multible folders and files as arguments
- */
- public void testDoubleRound() throws Exception {
-
- File folder1;
- File folder2;
-
- File file1a;
- File file2a;
- File file3a;
- File file4a;
-
- File file1b;
- File file2b;
- File file3b;
- File file4b;
-
- folder1 = ioFolder1;
- folder2 = ioFolder2;
-
- file1a = new File(folder1,"coProject1/a.txt");
- file2a = new File(folder1,"coProject2/a.txt");
- file3a = new File(folder2,"coProject1/a.txt");
- file4a = new File(folder2,"coProject2/a.txt");
-
- file1b = new File(folder1,"coProject1/f1/b.txt");
- file2b = new File(folder1,"coProject2/f1/b.txt");
- file3b = new File(folder2,"coProject1/f1/b.txt");
- file4b = new File(folder2,"coProject2/f1/b.txt");
-
-
- // Do the setup ...
- magicSetUpRepo("coProject1",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"});
- magicSetUpRepo("coProject2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"});
-
- execute("co",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1","coProject2"},
- folder1,
- monitor,
- System.err);
-
- execute("co",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1","coProject2"},
- folder2,
- monitor,
- System.err);
-
- // Change the two projects
- appendToFile(file1a,"AppendIt The first");
- appendToFile(file2a,"AppendIt The second");
-
- appendToFile(file1b,"AppendIt The first");
- appendToFile(file2b,"AppendIt The second");
-
- // Send the two projects to the server
- execute("ci",
- globalOptions,
- new String[]{"-m","msg" + PLATFORM_NEWLINE + "second Line"},
- new String[]{"coProject1","coProject2"},
- folder1,
- monitor,
- System.err);
-
- execute("update",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1","coProject2"},
- folder2,
- monitor,
- System.err);
-
- // Look if all the changes have been done allright
- assertEqualsArrays(readFromFile(file1a),readFromFile(file3a));
- assertEqualsArrays(readFromFile(file2a),readFromFile(file4a));
-
- assertEqualsArrays(readFromFile(file1b),readFromFile(file3b));
- assertEqualsArrays(readFromFile(file2b),readFromFile(file4b));
-
-
- // Now check if the programm works with single files
- appendToFile(file1a,"AppendIt The EXTRA");
- appendToFile(file1b,"AppendIt The EXTRA");
- execute("ci",
- globalOptions,
- new String[]{"-m","msg"},
- new String[]{"coProject1/a.txt"},
- folder1,
- monitor,
- System.err);
-
- execute("update",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1/a.txt"},
- folder2,
- monitor,
- System.err);
-
- // It should have the 1a file updated but not the 1b file
- // because we did not upload and commit it
- assertEqualsArrays(readFromFile(file1a),readFromFile(file3a));
- try {
- assertEqualsArrays(readFromFile(file1b),readFromFile(file3b));
- throw new IllegalArgumentException("Fail-Statment");
- } catch (AssertionFailedError e) {}
- }
-
- /**
- * This TestCase should maybe become simpler.
- *
- * Anyway, it is about Up and downloading changes
- * without conflicts
- */
- public void subTestCommitUpdate() throws Exception {
-
- File file1;
- File file2;
- String[] fileContent1;
- // String[] fileContent2;
- boolean fail = false;
- GregorianCalendar calender;
-
- calender = new GregorianCalendar();
-
- fileContent1 = new String[]{"This is a ", "two-liner", calender.get(Calendar.MILLISECOND) + ""};
- // fileContent2 = new String[]{"This is a one-liner", calender.get(Calendar.MILLISECOND) + 10 + ""};
-
- file1 = getFile("test1/proj1/folder1/c.txt");
- file2 = getFile("test2/proj1/folder1/c.txt");
-
- // change something and commit the canges
- // in client1
- // writeToFile("test1/...", contents)
- writeToFile(file1,fileContent1);
-
- execute("ci",globalOptions,
- new String[]{"-m","TestMessage"},
- arguments,
- ioFolder1,
- monitor,
- System.err);
-
- // test that files in client1 and client2 are unequal before
- try {
- assertEqualsArrays(readFromFile(file1),readFromFile(file2));
- } catch (Throwable e) {
- fail = true;
- }
-
- assertTrue("subTestCommitUpdate.0a (This could happen by coincedence, try again) ",fail);
- fail = false;
-
- execute("update",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder2,
- monitor,
- System.err);
-
- assertEqualsArrays(fileContent1,readFromFile(file2));
-
- }
-
- public void testDifferentFolders() throws Exception {
-
- File file1;
- File file2;
- String[] fileContent1;
- String[] fileContent2;
- boolean fail = false;
- GregorianCalendar calender;
-
- calender = new GregorianCalendar();
-
- // Init the field
- subTestCeckout();
-
- file1 = getFile("test1/proj1/folder1/c.txt");
- file2 = getFile("test2/proj1/folder1/c.txt");
- fileContent1 = new String[]{"This is a ", "two-liner", calender.get(Calendar.MILLISECOND) + ""};
- fileContent2 = new String[]{"This is a one-liner", calender.get(Calendar.MILLISECOND) + 10 + ""};
-
- // First run
- writeToFile(file1,fileContent1);
-
-
- execute("ci",globalOptions,
- new String[]{"-m","TestMessage"},
- arguments,
- ioFolder1,
- monitor,
- System.err);
-
- try {
- assertEqualsArrays(readFromFile(file1),readFromFile(file2));
- } catch (Throwable e) {
- fail = true;
- }
-
- assertTrue("testDifferentFolders.1 (This could happen by coincedence, try again) ",fail);
- fail = false;
-
- // Should be able to set globalOptions to new String[0]
- execute("update",new String[0],
- EMPTY_ARGS,
- new String[0],
- ioFolder4,
- monitor,
- System.err);
-
- assertEqualsArrays(fileContent1,readFromFile(file2));
-
- // Seconde run
- //
- // wait a second to get a new timestamp and
- // check that the resource has acctually a new timestamp
- waitMsec(4000);
- writeToFile(file2,fileContent2);
- assertEquals(true, CVSWorkspaceRoot.getCVSFolderFor(ioFolder4).getFile("c.txt").isModified());
-
- // Should be able to set globalOptions to new String[0]
- execute("ci",new String[0],
- new String[]{"-m","TestMessage"},
- new String[0],
- ioFolder4,
- monitor,
- System.err);
-
- try {
- assertEqualsArrays(readFromFile(file1),readFromFile(file2));
- } catch (Throwable e) {
- fail = true;
- }
-
- assertTrue("testDifferentFolders.3 (This could happen by coincedence, try again) ",fail);
- fail = false;
-
- execute("update",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder1,
- monitor,
- System.err);
-
- assertEqualsArrays(fileContent2,readFromFile(file1));
-
- }
-
- public void testCommit() throws Exception {
-
- File ioFolder = ioFolder1;
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder,
- monitor,
- System.err);
-
- GregorianCalendar calender;
-
-
- calender = new GregorianCalendar();
-
- writeToFile(getFile("test1\\proj1\\folder1\\c.txt"), new String[]{"This is my","Test",calender.get(Calendar.MILLISECOND) +""});
-
- execute("ci",globalOptions,
- new String[]{"-m","TestMessage"},
- arguments,
- ioFolder,
- monitor,
- System.err);
- }
-
- public void testConnection() throws CVSException {
-
- File ioFolder = ioFolder1;
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- new String[]{"proj1"},
- ioFolder,
- monitor,
- System.err);
- try {
- execute("co",globalOptions,
- EMPTY_ARGS,
- new String[]{"proj1XXX"},
- ioFolder,
- monitor,
- System.err);
- fail();
- } catch (CVSException e) {}
- }
-
- public void testDoubleCheckout() throws Exception {
-
- magicSetUpRepo("coProject1",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"});
- magicSetUpRepo("coProject2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"});
- execute("co",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1","coProject2"},
- workspaceRoot,
- monitor,
- System.err);
-
- assertTrue(getFile("coProject1/a.txt").exists());
- assertTrue(getFile("coProject1/f1/b.txt").exists());
- assertTrue(getFile("coProject2/a.txt").exists());
- assertTrue(getFile("coProject2/f1/b.txt").exists());
-
- FileUtil.deepDelete(getFile("coProject1"));
- FileUtil.deepDelete(getFile("coProject2"));
-
- }
-
- public void testImport() throws Exception {
- File ioFolder = ioFolder1;
- ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor(ioFolder);
-
- String[] fileStructure = new String[]{"im/a.txt","im/f1/a.txt","im/f1/b.txt"};
- createRandomFile(ioFolder,fileStructure);
-
- magicDeleteProject("im");
-
- execute("import",globalOptions,
- new String[]{"-m","Initial Release"},
- new String[]{"im","r1","r2"},
- getFile(mFolder.getFolder("im")),
- new NullProgressMonitor(),
- System.err);
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- new String[]{"im"},
- getFile(mFolder),
- new NullProgressMonitor(),
- System.err);
- }
-
- public void testUpdate() throws CVSException {
-
- File ioFolder = ioFolder1;
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder,
- monitor,
- System.err);
-
- try {
- execute("update",globalOptions,
- EMPTY_ARGS,
- new String[0],
- ioFolder,
- monitor,
- System.err);
- fail();
- } catch (CVSException e) {}
-
- execute("update",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder,
- monitor,
- System.err);
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
index 7148efcea..f08e8638b 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
@@ -3,20 +3,26 @@ package org.eclipse.team.tests.ccvs.core.provider;
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.internal.plugins.PluginDescriptor;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.IPluginRegistry;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSResource;
@@ -87,19 +93,27 @@ public class ModuleTest extends EclipseTest {
isSetUp = true;
}
- protected void uploadProject(String projectName) throws TeamException, IOException {
- // upload the modules definitions file
- PluginDescriptor testPlugin = (PluginDescriptor)Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.team.tests.cvs.core");
- String filePath = testPlugin.getLocation().concat(RESOURCE_PATH + projectName);
- URL url = null;
- try {
- url = new URL (filePath);
- } catch (java.net.MalformedURLException e) {
- assertTrue("Bad URL for " + filePath, true);
- }
+ protected void uploadProject(String projectName) throws TeamException, IOException, CoreException {
+ // locate the test case contents in the plugin resources
+ IPluginRegistry registry = Platform.getPluginRegistry();
+ IPluginDescriptor descriptor = registry.getPluginDescriptor("org.eclipse.team.tests.cvs.core");
+ URL baseURL = descriptor.getInstallURL();
+ URL url = new URL(baseURL, RESOURCE_PATH + projectName);
+ url = Platform.resolve(url);
+ Assert.assertTrue(url.getProtocol().equals("file"));
+ IPath path = new Path(url.getPath());
- // Import the project into CVS
- Session s = new Session(getRepository(), CVSWorkspaceRoot.getCVSFolderFor(new File(url.getPath())));
+ // create a project rooted there
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot workspaceRoot = workspace.getRoot();
+ IProject project = workspaceRoot.getProject(projectName);
+ IProjectDescription projectDescription = workspace.newProjectDescription(projectName);
+ projectDescription.setLocation(path);
+ project.create(projectDescription, null);
+ project.open(null);
+
+ // import the project into CVS
+ Session s = new Session(getRepository(), CVSWorkspaceRoot.getCVSFolderFor(project));
s.open(DEFAULT_MONITOR);
try {
Command.IMPORT.execute(s, Command.NO_GLOBAL_OPTIONS,
@@ -110,6 +124,9 @@ public class ModuleTest extends EclipseTest {
} finally {
s.close();
}
+
+ // delete the project locally
+ project.delete(false /*deleteContent*/, false /*force*/, null);
}
// XXX Temporary method of checkout (i.e. with vcm_meta
@@ -145,7 +162,7 @@ public class ModuleTest extends EclipseTest {
public void testSelfReferencingModule() throws TeamException, CoreException, IOException {
uploadProject("project1");
IProject project1 = checkoutProject("project1", null);
- IRemoteSyncElement tree = getProvider(project1).getRemoteSyncTree(project1, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project1, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project1), (ICVSResource)tree.getRemote(), false, false);
RemoteModule module = getRemoteModule("project1");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
@@ -161,13 +178,13 @@ public class ModuleTest extends EclipseTest {
public void testFlattenedStructure() throws TeamException, CoreException, IOException {
IProject docs = checkoutProject("docs", null);
- IRemoteSyncElement tree = getProvider(docs).getRemoteSyncTree(docs, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(docs, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(docs), (ICVSResource)tree.getRemote(), false, false);
RemoteModule module = getRemoteModule("docs");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
IProject macros = checkoutProject("macros", null);
- tree = getProvider(macros).getRemoteSyncTree(macros, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(macros, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(macros), (ICVSResource)tree.getRemote(), false, false);
module = getRemoteModule("macros");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
@@ -185,14 +202,14 @@ public class ModuleTest extends EclipseTest {
public void testIncludeAndExcludeDocs() throws TeamException, CoreException, IOException {
uploadProject("project2");
IProject project2 = checkoutProject("project2", null);
- IRemoteSyncElement tree = getProvider(project2).getRemoteSyncTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project2), (ICVSResource)tree.getRemote(), false, false);
RemoteModule module = getRemoteModule("project2");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
project2 = checkoutProject("project2-only", null);
- tree = getProvider(project2).getRemoteSyncTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project2), (ICVSResource)tree.getRemote(), false, false);
module = getRemoteModule("project2-only");
@@ -211,15 +228,15 @@ public class ModuleTest extends EclipseTest {
public void testAliasForFiles() throws TeamException, CoreException, IOException {
uploadProject("project3");
IProject project3 = checkoutProject("project3-sub", null);
- IRemoteSyncElement tree = getProvider(project3).getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project3), (ICVSResource)tree.getRemote(), false, false);
project3 = checkoutProject("project3-src", null);
- tree = getProvider(project3).getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project3), (ICVSResource)tree.getRemote(), false, false);
project3 = checkoutProject("project3-src_file", null);
- tree = getProvider(project3).getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project3), (ICVSResource)tree.getRemote(), false, false);
}
@@ -234,15 +251,15 @@ public class ModuleTest extends EclipseTest {
public void testAliases() throws TeamException, CoreException, IOException {
uploadProject("project7");
IProject project7 = checkoutProject("project7-common", null);
- IRemoteSyncElement tree = getProvider(project7).getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project7), (ICVSResource)tree.getRemote(), false, false);
project7 = checkoutProject("project7-pc", null);
- tree = getProvider(project7).getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project7), (ICVSResource)tree.getRemote(), false, false);
project7 = checkoutProject("project7-linux", null);
- tree = getProvider(project7).getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project7), (ICVSResource)tree.getRemote(), false, false);
}

Back to the top