Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests')
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java36
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllTests.java37
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java21
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestLogListener.java59
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java210
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSUITestSetup.java22
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java81
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java119
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java949
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/ICVSClient.java22
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java329
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java119
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java46
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java39
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java33
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java496
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java58
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java95
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java94
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java490
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java35
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/BatchedTestSetup.java36
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseFolderTest.java95
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java750
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncBytesTest.java127
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java183
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java39
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java551
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ConcurrencyTests.java89
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java185
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/IsModifiedTests.java544
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/LinkResourcesTest.java87
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java280
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java360
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java272
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/WatchEditTest.java146
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/AllTestsTeamSubscriber.java38
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java105
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java623
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java247
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java1316
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java91
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncSetTests.java106
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestCommitOperation.java66
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestMergeUpdateOperation.java46
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestOverrideAndUpdateOperation.java33
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java45
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/AllUITests.java36
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSOperationTest.java30
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CheckoutOperationTests.java126
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CompareOperationTests.java184
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MenuEnablementTest.java497
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MiscOperationsTests.java63
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java249
54 files changed, 0 insertions, 11035 deletions
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java
deleted file mode 100644
index d2c43208e..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.team.tests.ccvs.core.cvsresources.AllTestsCVSResources;
-
-/**
- * Tests that don't require the Team UI plugin to be loaded.
- */
-public class AllCoreTests extends EclipseTest {
-
- public AllCoreTests() {
- super();
- }
-
- public AllCoreTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(AllTestsCVSResources.suite());
- return new CVSTestSetup(suite);
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllTests.java
deleted file mode 100644
index 0df86a5ed..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.team.tests.ccvs.core.provider.AllTestsProvider;
-import org.eclipse.team.tests.ccvs.core.subscriber.AllTestsTeamSubscriber;
-import org.eclipse.team.tests.ccvs.ui.AllUITests;
-
-public class AllTests extends EclipseTest {
-
- public AllTests() {
- super();
- }
-
- public AllTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(AllTestsProvider.suite());
- suite.addTest(AllTestsTeamSubscriber.suite());
- suite.addTest(AllUITests.suite());
- return new CVSUITestSetup(suite);
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java
deleted file mode 100644
index 7ea4fba13..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-public class CVSClientException extends CVSException {
-
- public CVSClientException(String message) {
- super(message);
- }
-
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestLogListener.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestLogListener.java
deleted file mode 100644
index ad874ffd7..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestLogListener.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-/**
- * Listener that accumulates test errors
- */
-public class CVSTestLogListener implements ILogListener {
-
- Map errors = new HashMap();
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.ILogListener#logging(org.eclipse.core.runtime.IStatus, java.lang.String)
- */
- public void logging(IStatus status, String plugin) {
- List pluginErrors = (List)errors.get(plugin);
- if (pluginErrors == null) {
- pluginErrors = new ArrayList();
- errors.put(plugin, pluginErrors);
- }
- pluginErrors.add(status);
- }
-
- public void checkErrors() throws CoreException {
- if (errors.isEmpty()) return;
- List allErrors = new ArrayList();
- for (Iterator iter = errors.values().iterator(); iter.hasNext();) {
- allErrors.addAll((List)iter.next());
- }
- errors.clear();
- if (allErrors.isEmpty()) return;
- IStatus status = null;
- if (allErrors.size() == 1) {
- status = (IStatus)allErrors.get(0);
- if (!status.isMultiStatus()) {
- throw new CVSException(status);
- }
- }
- if (status == null) {
- status = new MultiStatus("org.eclipse.team.tests.cvs.core", 0,
- (IStatus[]) allErrors.toArray(new IStatus[allErrors.size()]),
- "Errors were logged during this test. Check the log file for details", null);
- }
- throw new CoreException(status);
- }
-}
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
deleted file mode 100644
index cf6279aeb..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-import java.io.*;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSCommunicationException;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
-
-public class CVSTestSetup extends TestSetup {
- public static final String REPOSITORY_LOCATION;
- public static final boolean INITIALIZE_REPO;
- public static final boolean DEBUG;
- public static final boolean LOCAL_REPO;
- public static final String RSH;
- public static final int WAIT_FACTOR;
- public static final int COMPRESSION_LEVEL;
- public static final boolean FAIL_IF_EXCEPTION_LOGGED;
-
- public static CVSRepositoryLocation repository;
- public static CVSTestLogListener logListener;
-
- // Static initializer for constants
- static {
- loadProperties();
- REPOSITORY_LOCATION = System.getProperty("eclipse.cvs.repository");
- INITIALIZE_REPO = Boolean.valueOf(System.getProperty("eclipse.cvs.initrepo", "false")).booleanValue();
- DEBUG = Boolean.valueOf(System.getProperty("eclipse.cvs.debug", "false")).booleanValue();
- RSH = System.getProperty("eclipse.cvs.rsh", "rsh");
- LOCAL_REPO = Boolean.valueOf(System.getProperty("eclipse.cvs.localRepo", "false")).booleanValue();
- WAIT_FACTOR = Integer.parseInt(System.getProperty("eclipse.cvs.waitFactor", "1"));
- COMPRESSION_LEVEL = Integer.parseInt(System.getProperty("eclipse.cvs.compressionLevel", "0"));
- FAIL_IF_EXCEPTION_LOGGED = Boolean.valueOf(System.getProperty("eclipse.cvs.failLog", "true")).booleanValue();
- }
-
- public static void loadProperties() {
- String propertiesFile = System.getProperty("eclipse.cvs.properties");
- if (propertiesFile == null) return;
- File file = new File(propertiesFile);
- if (file.isDirectory()) file = new File(file, "repository.properties");
- try {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- try {
- for (String line; (line = reader.readLine()) != null; ) {
- if (line.startsWith("#")) continue;
- int sep = line.indexOf("=");
- String property = line.substring(0, sep).trim();
- String value = line.substring(sep + 1).trim();
- System.setProperty("eclipse.cvs." + property, value);
- }
- } finally {
- reader.close();
- }
- } catch (Exception e) {
- System.err.println("Could not read repository properties file: " + file.getAbsolutePath());
- }
- }
-
- /**
- * Constructor for CVSTestSetup.
- */
- public CVSTestSetup(Test test) {
- super(test);
- }
-
- public static void executeRemoteCommand(ICVSRepositoryLocation repository, String commandLine) {
- if (! LOCAL_REPO) {
- commandLine = RSH + " " + repository.getHost() + " -l " + repository.getUsername() + " " + commandLine;
- }
- int returnCode = executeCommand(commandLine, null, null);
- if (returnCode != -1 && returnCode != 0) {
- System.err.println("Remote command returned " + returnCode + ": " + commandLine);
- }
- }
-
- /**
- * Executes a command.
- * Returns the command's return code, or -1 on failure.
- *
- * @param commandLine the local command line to run
- * @param environment the new environment variables, or null to inherit from parent process
- * @param workingDirectory the new workingDirectory, or null to inherit from parent process
- */
- public static int executeCommand(String commandLine, String[] environment, File workingDirectory) {
- PrintStream debugStream = CVSTestSetup.DEBUG ? System.out : null;
- try {
- if (debugStream != null) {
- // while debugging, dump CVS command line client results to stdout
- // prefix distinguishes between message source stream
- debugStream.println();
- printPrefixedLine(debugStream, "CMD> ", commandLine);
- if (workingDirectory != null) printPrefixedLine(debugStream, "DIR> ", workingDirectory.toString());
- }
- Process cvsProcess = Runtime.getRuntime().exec(commandLine, environment, workingDirectory);
- // 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);
- return returnCode;
- } catch (IOException e) {
- printPrefixedLine(System.err, "Unable to execute command: ", commandLine);
- e.printStackTrace(System.err);
- } catch (InterruptedException e) {
- printPrefixedLine(System.err, "Unable to execute command: ", commandLine);
- e.printStackTrace(System.err);
- }
- return -1;
- }
-
- 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) printPrefixedLine(os, prefix, line);
- }
- } finally {
- if (reader != null) reader.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }.start();
- }
-
- private static void printPrefixedLine(PrintStream os, String prefix, String line) {
- os.print(prefix);
- os.println(line.substring(0, Math.min(line.length(), 256))); // trim long lines
- }
-
- /*
- * Use rsh to delete any contents of the repository and initialize it again
- */
- private static void initializeRepository(CVSRepositoryLocation repository) {
- String repoRoot = repository.getRootDirectory();
- executeRemoteCommand(repository, "rm -rf " + repoRoot);
- executeRemoteCommand(repository, "cvs -d " + repoRoot + " init");
- }
-
- public void setUp() throws CoreException {
- if (repository == null) {
- repository = setupRepository(REPOSITORY_LOCATION);
- }
- CVSProviderPlugin.getPlugin().setCompressionLevel(COMPRESSION_LEVEL);
- // Add a log listener so we can ensure that nothing is logged during a test
- if (logListener == null) {
- logListener = new CVSTestLogListener();
- Platform.addLogListener(logListener);
- }
- }
-
- protected CVSRepositoryLocation setupRepository(String location) throws CVSException {
-
- // Validate that we can connect, also creates and caches the repository location. This
- // is important for the UI tests.
- CVSRepositoryLocation repository = (CVSRepositoryLocation)KnownRepositories.getInstance().getRepository(location);
- KnownRepositories.getInstance().addRepository(repository, false);
- repository.setUserAuthenticator(new TestsUserAuthenticator());
-
- // Give some info about which repository the tests are running with
- System.out.println("Connecting to: " + repository.getHost() + ":" + repository.getMethod().getName());
-
- try {
- try {
- repository.validateConnection(new NullProgressMonitor());
- } catch (CVSCommunicationException e) {
- // Try once more, just in case it is a transient server problem
- repository.validateConnection(new NullProgressMonitor());
- }
- } catch (CVSException e) {
- System.out.println("Unable to connect to remote repository: " + repository.toString());
- throw e;
- }
-
- // Initialize the repo if requested (requires rsh access)
- if( INITIALIZE_REPO ) {
- initializeRepository(repository);
- }
-
- return repository;
- }
-
- public void tearDown() throws CVSException {
- // Nothing to do here
- }
-
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSUITestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSUITestSetup.java
deleted file mode 100644
index 8222b0c98..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSUITestSetup.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.eclipse.team.tests.ccvs.core;
-
-import junit.framework.Test;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.ui.PlatformUI;
-
-public class CVSUITestSetup extends CVSTestSetup implements Test {
-
- public CVSUITestSetup(Test test) {
- super(test);
- }
-
- /* (non-Javadoc)
- * @see junit.extensions.TestSetup#setUp()
- */
- public void setUp() throws CoreException {
- super.setUp();
- PlatformUI.getWorkbench().getDecoratorManager().setEnabled(CVSUIPlugin.DECORATOR_ID, true);
- }
-}
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
deleted file mode 100644
index ec6ff38d3..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-
-import java.io.File;
-
-import junit.framework.Assert;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-
-public class CommandLineCVSClient implements ICVSClient {
- public static final ICVSClient INSTANCE = new CommandLineCVSClient();
- private static final String cvsExecutable =
- System.getProperty("eclipse.cvs.command");
-
- public void executeCommand(ICVSRepositoryLocation repositoryLocation,
- IContainer localRoot, String command, String[] globalOptions,
- String[] localOptions, String[] arguments) throws CVSException {
- execute(repositoryLocation.getLocation(), localRoot.getLocation().toFile(), command,
- globalOptions, localOptions, arguments);
- try {
- localRoot.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- throw new CVSClientException("CoreException during refreshLocal: " + e.getMessage());
- }
- }
-
- 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
- JUnitTestCase.waitMsec(1500);
- int returnCode = CVSTestSetup.executeCommand(commandLineBuf.toString(), null, localRoot);
- if (returnCode != 0) {
- throw new CVSClientException("Command line client returned non-zero code: " + returnCode);
- }
- }
-
- 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('"');
- }
- }
- }
-}
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
deleted file mode 100644
index 3931795fa..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-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.resources.IContainer;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-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.resources.CVSWorkspaceRoot;
-
-public class EclipseCVSClient implements ICVSClient {
- public static final ICVSClient INSTANCE = new 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 void executeCommand(ICVSRepositoryLocation repositoryLocation,
- IContainer localRoot, String command, String[] globalOptions,
- String[] localOptions, String[] arguments) throws CVSException {
- execute(repositoryLocation, CVSWorkspaceRoot.getCVSFolderFor(localRoot), command,
- globalOptions, localOptions, arguments);
- }
-
- 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, true /* open for modification */);
- 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();
- monitor.done();
- }
- }
-
- 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
deleted file mode 100644
index c052f739c..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
+++ /dev/null
@@ -1,949 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-import java.io.*;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import junit.framework.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.connection.*;
-import org.eclipse.team.internal.ccvs.core.resources.*;
-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.SyncFileChangeListener;
-import org.eclipse.team.internal.ccvs.ui.operations.*;
-import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class EclipseTest extends EclipseWorkspaceTest {
-
- protected static IProgressMonitor DEFAULT_MONITOR = new NullProgressMonitor();
- protected static final int RANDOM_CONTENT_SIZE = 3876;
- protected static String eol = System.getProperty("line.separator");
-
- public static Test suite(Class c) {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(c);
- return new CVSTestSetup(suite);
- } else {
- try {
- return new CVSTestSetup((Test)c.getConstructor(new Class[] { String.class }).newInstance(new Object[] {testName}));
- } catch (Exception e) {
- fail(e.getMessage());
- // Above will throw so below is never actually reached
- return null;
- }
- }
- }
-
- public EclipseTest() {
- super();
- if (eol == null) eol = "\n";
- }
-
- public EclipseTest(String name) {
- super(name);
- if (eol == null) eol = "\n";
- }
-
- /*
- * Get the resources for the given resource names
- */
- public IResource[] getResources(IContainer container, String[] hierarchy) throws CoreException {
- IResource[] resources = new IResource[hierarchy.length];
- for (int i=0;i<resources.length;i++) {
- resources[i] = container.findMember(hierarchy[i]);
- if (resources[i] == null) {
- resources[i] = buildResources(container, new String[] {hierarchy[i]})[0];
- }
- }
- return resources;
- }
-
- /**
- * Add the resources to an existing container and upload them to CVS
- */
- public IResource[] addResources(IContainer container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- IResource[] newResources = buildResources(container, hierarchy, false);
- addResources(newResources);
- if (checkin) commitResources(newResources, IResource.DEPTH_ZERO);
- return newResources;
- }
-
- protected void addResources(IResource[] newResources) throws CoreException {
- if (newResources.length == 0) return;
- executeHeadless(new AddOperation(null, newResources));
- }
-
- /**
- * Perform a CVS edit of the given resources
- */
- public IResource[] editResources(IContainer container, String[] hierarchy) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- getProvider(container).edit(resources, true /* recurse */, true /* notifyServer */, ICVSFile.NO_NOTIFICATION, DEFAULT_MONITOR);
- assertReadOnly(resources, false /* isReadOnly */, true /* recurse */);
- return resources;
- }
-
- /**
- * Perform a CVS unedit of the given resources
- */
- public IResource[] uneditResources(IContainer container, String[] hierarchy) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- getProvider(container).unedit(resources, true /* recurse */, true/* notifyServer */, DEFAULT_MONITOR);
- assertReadOnly(resources, true /* isReadOnly */, true /* recurse */);
- return resources;
- }
-
- public void appendText(IResource resource, String text, boolean prepend) throws CoreException, IOException, CVSException {
- IFile file = (IFile)resource;
- String contents = getFileContents(file);
- StringBuffer buffer = new StringBuffer();
- if (prepend) {
- buffer.append(text);
- }
- buffer.append(contents);
- if (!prepend) {
- buffer.append(eol + text);
- }
- setContentsAndEnsureModified(file, buffer.toString());
- }
-
- public void assertEndsWith(IFile file, String text) throws IOException, CoreException {
- assertTrue(getFileContents(file).endsWith(text));
- }
-
- public void assertStartsWith(IFile file, String text) throws IOException, CoreException {
- assertTrue(getFileContents(file).startsWith(text));
- }
-
- public static String getFileContents(IFile file) throws IOException, CoreException {
- StringBuffer buf = new StringBuffer();
- Reader reader = new InputStreamReader(new BufferedInputStream(file.getContents()));
- try {
- int c;
- while ((c = reader.read()) != -1) buf.append((char)c);
- } finally {
- reader.close();
- }
- return buf.toString();
- }
-
- /**
- * Delete the resources from an existing container and the changes to CVS
- */
- public IResource[] changeResources(IContainer container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- List changedResources = new ArrayList(hierarchy.length);
- for (int i=0;i<hierarchy.length;i++) {
- IResource resource = container.findMember(hierarchy[i]);
- if (resource.getType() == IResource.FILE) {
- changedResources.add(resource);
- setContentsAndEnsureModified((IFile)resource);
- }
- }
- IResource[] resources = (IResource[])changedResources.toArray(new IResource[changedResources.size()]);
- if (checkin) commitResources(resources, IResource.DEPTH_ZERO);
- return resources;
- }
-
- /**
- * Delete the resources from an existing container and the changes to CVS
- */
- public IResource[] deleteResources(IContainer container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- deleteResources(resources);
- if (checkin)
- commitResources(resources, IResource.DEPTH_ZERO);
- return resources;
- }
-
- /**
- * Delete the resources and mark them as outgoing deletions.
- * Deleting the resources is enough since the move/delete hook will
- * tak care of making them outgoing deletions.
- */
- protected void deleteResources(IResource[] resources) throws TeamException, CoreException {
- if (resources.length == 0) return;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- resource.delete(false, DEFAULT_MONITOR);
- }
- }
- /**
- * Unmanage the resources
- */
- public void unmanageResources(IContainer container, String[] hierarchy) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- unmanageResources(resources);
- }
-
- protected void unmanageResources(IResource[] resources) throws TeamException, CoreException {
- for (int i=0;i<resources.length;i++) {
- CVSWorkspaceRoot.getCVSResourceFor(resources[i]).unmanage(null);
- }
- }
- /**
- * Update the resources from an existing container with the changes from the CVS repository
- */
- public IResource[] updateResources(IContainer container, String[] hierarchy, boolean ignoreLocalChanges) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- LocalOption[] options = Command.NO_LOCAL_OPTIONS;
- if(ignoreLocalChanges) {
- options = new LocalOption[] {Update.IGNORE_LOCAL_CHANGES};
- }
- executeHeadless(new UpdateOperation(null, resources, options, null));
- return resources;
- }
-
-
- protected void replace(IContainer container, String[] hierarchy, CVSTag tag, boolean recurse) throws CoreException {
- IResource[] resources = getResources(container, hierarchy);
- replace(resources, tag, recurse);
- }
-
- protected void replace(IResource[] resources, CVSTag tag, boolean recurse) throws CoreException {
- ReplaceOperation op = new ReplaceOperation(null, resources, tag, recurse);
- executeHeadless(op);
- }
-
- public void updateProject(IProject project, CVSTag tag, boolean ignoreLocalChanges) throws TeamException {
- LocalOption[] options = Command.NO_LOCAL_OPTIONS;
- if(ignoreLocalChanges) {
- options = new LocalOption[] {Update.IGNORE_LOCAL_CHANGES};
- }
- executeHeadless(new UpdateOperation(null, new IResource[] {project}, options, tag));
- }
-
- public void commitProject(IProject project) throws TeamException, CoreException {
- commitResources(project, true);
- }
-
- public void commitResources(IContainer container, boolean deep) throws TeamException, CoreException {
- commitResources(new IResource[] {container }, deep?IResource.DEPTH_INFINITE:IResource.DEPTH_ZERO);
- }
-
- /**
- * Commit the resources from an existing container to the CVS repository
- */
- public IResource[] commitResources(IContainer container, String[] hierarchy) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- commitResources(resources, IResource.DEPTH_ZERO);
- return resources;
- }
-
- /*
- * Commit the provided resources which must all be in the same project
- */
- protected void commitResources(IResource[] resources, int depth) throws TeamException, CoreException {
- if (resources.length == 0) return;
- executeHeadless(new CommitOperation(null, resources, new Command.LocalOption[] { Commit.makeArgumentOption(Command.MESSAGE_OPTION, "") }));
- }
- /**
- * Commit the resources from an existing container to the CVS repository
- */
- public void tagProject(IProject project, CVSTag tag, boolean force) throws TeamException {
- ITagOperation op = new TagOperation((IWorkbenchPart)null, new IResource[] {project});
- runTag(op, tag, force);
- }
-
- public void tagRemoteResource(ICVSRemoteResource resource, CVSTag tag, boolean force) throws TeamException {
- ITagOperation op = new TagInRepositoryOperation(null, new ICVSRemoteResource[] {resource});
- runTag(op, tag, force);
-
- }
- private void runTag(ITagOperation op, CVSTag tag, boolean force) throws TeamException {
- if (force) op.moveTag();
- op.setTag(tag);
- try {
- ((CVSOperation)op).run(DEFAULT_MONITOR);
- } catch (InterruptedException e) {
- fail("Tag interrupted.");
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof TeamException) {
- throw (TeamException) e.getTargetException();
- } else {
- e.printStackTrace();
- fail("Unexpected error while tagging");
- }
- }
- }
- public void makeBranch(IResource[] resources, CVSTag version, CVSTag branch, boolean update) throws CVSException {
- BranchOperation op = new BranchOperation(null, resources);
- op.setTags(version, branch, update);
- executeHeadless(op);
- }
- /**
- * Return a collection of resources defined by hierarchy. The resources
- * are added to the workspace and to the file system. If the manage flag is true, the
- * resources are auto-managed, if false, they are left un-managed.
- */
- public IResource[] buildResources(IContainer container, String[] hierarchy, boolean includeContainer) throws CoreException {
- List resources = new ArrayList(hierarchy.length + 1);
- resources.addAll(Arrays.asList(buildResources(container, hierarchy)));
- if (includeContainer)
- resources.add(container);
- IResource[] result = (IResource[]) resources.toArray(new IResource[resources.size()]);
- ensureExistsInWorkspace(result, true);
- for (int i = 0; i < result.length; i++) {
- if (result[i].getType() == IResource.FILE)
- // 3786 bytes is the average size of Eclipse Java files!
- ((IFile) result[i]).setContents(getRandomContents(RANDOM_CONTENT_SIZE), true, false, null);
- }
- return result;
- }
-
- /*
- * Checkout a copy of the project into a project with the given postfix
- */
- protected IProject checkoutCopy(IProject project, String postfix) throws TeamException {
- // Check the project out under a different name and validate that the results are the same
- IProject copy = getWorkspace().getRoot().getProject(project.getName() + postfix);
- checkout(getRepository(), copy, CVSWorkspaceRoot.getCVSFolderFor(project).getFolderSyncInfo().getRepository(), null, DEFAULT_MONITOR);
- return copy;
- }
-
- protected IProject checkoutCopy(IProject project, CVSTag tag) throws TeamException {
- // Check the project out under a different name and validate that the results are the same
- IProject copy = getWorkspace().getRoot().getProject(project.getName() + tag.getName());
- checkout(getRepository(), copy,
- CVSWorkspaceRoot.getCVSFolderFor(project).getFolderSyncInfo().getRepository(),
- tag, DEFAULT_MONITOR);
- return copy;
- }
-
- public static void checkout(
- final ICVSRepositoryLocation repository,
- final IProject project,
- final String sourceModule,
- final CVSTag tag,
- IProgressMonitor monitor)
- throws TeamException {
-
- RemoteFolder remote = new RemoteFolder(null, repository, sourceModule == null ? project.getName() : sourceModule, tag);
- executeHeadless(new CheckoutSingleProjectOperation(null, remote, project, null, false /* the project is not preconfigured */) {
- public boolean promptToOverwrite(String title, String msg) {
- return true;
- }
- });
-
- }
-
- protected IProject checkoutProject(IProject project, String moduleName, CVSTag tag) throws TeamException {
- if (project == null)
- project = getWorkspace().getRoot().getProject(new Path(moduleName).lastSegment());
- checkout(getRepository(), project, moduleName, tag, DEFAULT_MONITOR);
- return project;
- }
- /*
- * This method creates a project with the given resources, imports
- * it to CVS and checks it out
- */
- protected IProject createProject(String prefix, String[] resources) throws CoreException, TeamException {
- IProject project = getUniqueTestProject(prefix);
- buildResources(project, resources, true);
- shareProject(project);
- assertValidCheckout(project);
- return project;
- }
-
- /*
- * Create a test project using the currently running test case as the project name prefix
- */
- protected IProject createProject(String[] strings) throws TeamException, CoreException {
- return createProject(getName(), strings);
- }
-
- /*
- * Compare two projects by comparing thier providers
- */
- protected void assertEquals(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);
- }
-
- /*
- * Compare CVS team providers by comparing the cvs resource corresponding to the provider's project
- */
- protected void assertEquals(CVSTeamProvider provider1, CVSTeamProvider provider2, boolean includeTimestamps, boolean includeTags) throws CoreException, TeamException, IOException {
- assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSFolderFor(provider1.getProject()),
- CVSWorkspaceRoot.getCVSFolderFor(provider2.getProject()),
- includeTimestamps, includeTags);
- }
-
- protected void assertContentsEqual(IContainer c1, IContainer c2) throws CoreException {
- assertTrue("The number of resource in " + c1.getProjectRelativePath().toString() + " differs",
- c1.members().length == c2.members().length);
- IResource[] resources = c1.members();
- for (int i= 0;i <resources.length;i++) {
- assertContentsEqual(resources[i], c2.findMember(resources[i].getName()));
- }
- }
-
- protected void assertContentsEqual(IResource resource, IResource resource2) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- assertContentsEqual((IFile)resource, (IFile)resource2);
- } else {
- assertContentsEqual((IContainer)resource, (IContainer)resource2);
- }
- }
-
- protected void assertContentsEqual(IFile resource, IFile resource2) throws CoreException {
- assertTrue("Contents of " + resource.getProjectRelativePath() + " do not match", compareContent(resource.getContents(), resource2.getContents()));
- }
- /*
- * Compare resources by casting them to their prpoer type
- */
- protected void assertEquals(IPath parent, ICVSResource resource1, ICVSResource resource2, boolean includeTimestamps, boolean includeTags) throws CoreException, CVSException, IOException {
- assertEquals("Resource types do not match for " + parent.append(resource1.getName()), resource1.isFolder(), resource2.isFolder());
- if (!resource1.isFolder())
- assertEquals(parent, (ICVSFile)resource1, (ICVSFile)resource2, includeTimestamps, includeTags);
- else
- assertEquals(parent, (ICVSFolder)resource1, (ICVSFolder)resource2, includeTimestamps, includeTags);
- }
-
- /*
- * Compare folders by comparing their folder sync info and there children
- *
- * XXX What about unmanaged children?
- */
- protected void assertEquals(IPath parent, ICVSFolder container1, ICVSFolder container2, boolean includeTimestamps, boolean includeTags) throws CoreException, CVSException, IOException {
- IPath path = parent.append(container1.getName());
- assertEquals(path, container1.getFolderSyncInfo(), container2.getFolderSyncInfo(), includeTags);
- assertTrue("The number of resource in " + path.toString() + " differs",
- container1.members(ICVSFolder.ALL_EXISTING_MEMBERS).length
- == container2.members(ICVSFolder.ALL_EXISTING_MEMBERS).length);
- ICVSResource[] resources = container1.members(ICVSFolder.ALL_EXISTING_MEMBERS);
- for (int i= 0;i <resources.length;i++) {
- assertEquals(path, resources[i], container2.getChild(resources[i].getName()), includeTimestamps, includeTags);
- }
-
- }
-
- /*
- * Compare the files contents and sync information
- */
- protected void assertEquals(IPath parent, ICVSFile file1, ICVSFile file2, boolean includeTimestamps, boolean includeTags) throws CoreException, CVSException, IOException {
- if (file1.getName().equals(".project")) return;
- // Getting the contents first is important as it will fetch the proper sync info if one of the files is a remote handle
- assertTrue("Contents of " + parent.append(file1.getName()) + " do not match", compareContent(getContents(file1), getContents(file2)));
- assertEquals(parent.append(file1.getName()), file1.getSyncInfo(), file2.getSyncInfo(), includeTimestamps, includeTags);
- }
-
- /*
- * Compare sync info by comparing the entry line generated by the sync info
- */
- protected void assertEquals(IPath path, ResourceSyncInfo info1, ResourceSyncInfo info2, boolean includeTimestamp, boolean includeTag) throws CoreException, CVSException, IOException {
- if (info1 == null || info2 == null) {
- if (info1 == info2) return;
- if (info1 == null) {
- fail("Expected no resource sync info for " + path.toString() + " but it was " + info2 + " instead");
- }
- if (info2 == null) {
- fail("Expected resource sync info of " + info1 + " for " + path.toString() + " but there was no sync info.");
- }
- fail("Shouldn't be able to get here");
- return;
- }
- String line1;
- String line2;
- if(includeTimestamp) {
- line1 = info1.getEntryLine();
- line2 = info2.getEntryLine();
- } else {
- line1 = info1.getServerEntryLine(null);
- line2 = info2.getServerEntryLine(null);
- }
- if (!includeTag) {
- // Strip everything past the last slash
- line1 = line1.substring(0, line1.lastIndexOf('/'));
- line2 = line2.substring(0, line2.lastIndexOf('/'));
- }
- assertEquals("Resource Sync info differs for " + path.toString(), line1, line2);
- }
-
- /*
- * Use the equals of folder sync info unless the tag is not included in which case we just
- * compare the root and repository
- */
- protected void assertEquals(IPath path, FolderSyncInfo info1, FolderSyncInfo info2, boolean includeTag) throws CoreException, CVSException, IOException {
- if (info1 == null && info2 == null) {
- return;
- } else if (info1 == null) {
- fail("Expected " + path.toString() + " not to be a CVS folder but it is.");
- } else if (info2 == null) {
- fail("Expected " + path.toString() + " to be a CVS folder but it isn't.");
- }
-
- if (includeTag) {
- assertTrue("Folder sync info differs for " + path.toString(), info1.equals(info2));
- } else {
- assertTrue("Repository Root differs for " + path.toString(), info1.getRoot().equals(info2.getRoot()));
- assertTrue("Repository relative path differs for " + path.toString(), info1.getRepository().equals(info2.getRepository()));
- }
- }
-
-
- /*
- * Compare folders by comparing their folder sync info and there children
- *
- * XXX What about unmanaged children?
- */
- protected void assertEquals(IPath parent, RemoteFolder container1, RemoteFolder container2, boolean includeTags) throws CoreException, TeamException, IOException {
- IPath path = parent.append(container1.getName());
- assertEquals(path, container1.getFolderSyncInfo(), container2.getFolderSyncInfo(), includeTags);
- ICVSRemoteResource[] members1 = container1.getMembers(DEFAULT_MONITOR);
- ICVSRemoteResource[] members2 = container2.getMembers(DEFAULT_MONITOR);
- assertTrue("Number of members differ for " + path, members1.length == members2.length);
- Map memberMap2 = new HashMap();
- for (int i= 0;i <members2.length;i++) {
- memberMap2.put(members2[i].getName(), members2[i]);
- }
- for (int i= 0;i <members1.length;i++) {
- ICVSRemoteResource member2 = (ICVSRemoteResource)memberMap2.get(members1[i].getName());
- assertNotNull("Resource does not exist: " + path.append(members1[i].getName()) + member2);
- assertEquals(path, members1[i], member2, includeTags);
- }
- }
- protected void assertEquals(IPath parent, ICVSRemoteResource resource1, ICVSRemoteResource resource2, boolean includeTags) throws CoreException, TeamException, IOException {
- assertEquals("Resource types do not match for " + parent.append(resource1.getName()), resource1.isContainer(), resource2.isContainer());
- if (resource1.isContainer())
- assertEquals(parent, (RemoteFolder)resource1, (RemoteFolder)resource2, includeTags);
- else
- assertEquals(parent, (ICVSFile)resource1, (ICVSFile)resource2, false, includeTags);
- }
-
-
- /*
- * Compare the local project with the remote state by checking out a copy of the project.
- */
- protected void assertLocalStateEqualsRemote(IProject project) throws TeamException, CoreException, IOException {
- assertEquals(getProvider(project), getProvider(checkoutCopy(project, "-remote")), false, true);
- }
-
- /*
- * Compare the local project with the remote state indicated by the given tag by checking out a copy of the project.
- */
- protected void assertLocalStateEqualsRemote(String message, IProject project, CVSTag tag) throws TeamException, CoreException, IOException {
- assertEquals(getProvider(project), getProvider(checkoutCopy(project, tag)), true, false);
- }
-
- protected void assertHasNoRemote(String prefix, IResource[] resources) throws TeamException {
- for (int i=0;i<resources.length;i++)
- assertHasNoRemote(prefix, resources[i]);
- }
-
- protected void assertHasNoRemote(String prefix, IResource resource) throws TeamException {
- assertTrue(prefix + " resource should not have a remote", !CVSWorkspaceRoot.hasRemote(resource));
- }
-
- protected void assertHasRemote(String prefix, IResource[] resources) throws TeamException {
- for (int i=0;i<resources.length;i++)
- assertHasRemote(prefix, resources[i]);
- }
-
- protected void assertHasRemote(String prefix, IResource resource) throws TeamException {
- assertTrue(prefix + " resource should have a remote", CVSWorkspaceRoot.hasRemote(resource));
- }
-
- protected void assertIsModified(String prefix, IResource[] resources) throws TeamException {
- for (int i=0;i<resources.length;i++)
- assertIsModified(prefix, resources[i]);
- }
-
- protected void assertIsModified(String prefix, IResource resource) throws TeamException {
- // Only check for files as CVS doesn't dirty folders
- if (resource.getType() == IResource.FILE)
- assertTrue(prefix + " resource " + resource.getFullPath() + " should be dirty.", ((ICVSFile)getCVSResource(resource)).isModified(null));
- }
-
- protected void assertNotModified(String prefix, IResource[] resources) throws TeamException {
- for (int i=0;i<resources.length;i++)
- assertNotModified(prefix, resources[i]);
- }
-
- protected void assertNotModified(String prefix, IResource resource) throws TeamException {
- assertTrue(prefix + " resource should be dirty", !((ICVSFile)getCVSResource(resource)).isModified(null));
- }
-
- protected void assertIsIgnored(IResource resource, boolean ignoredState) throws TeamException {
- assertEquals("Resource " + resource.getFullPath() + " should be ignored but isn't.",
- ignoredState, getCVSResource(resource).isIgnored());
- }
-
- protected void assertValidCheckout(IProject project) {
- // NOTE: Add code to ensure that the project was checkout out properly
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project);
- assertNotNull(provider);
- }
-
- protected void assertReadOnly(IResource[] resources, final boolean isReadOnly, final boolean recurse) throws CoreException {
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- assertEquals(isReadOnly, resource.isReadOnly());
- }
- return recurse;
- }
- });
- }
- }
-
- protected InputStream getContents(ICVSFile file) throws CVSException, IOException {
- if (file instanceof ICVSRemoteFile)
- return ((RemoteFile)file).getContents(DEFAULT_MONITOR);
- else
- return new BufferedInputStream(file.getContents());
- }
-
- /*
- * Get the CVS Resource for the given resource
- */
- protected ICVSResource getCVSResource(IResource resource) throws CVSException {
- return CVSWorkspaceRoot.getCVSResourceFor(resource);
- }
-
- protected IProject getNamedTestProject(String name) throws CoreException {
- IProject target = getWorkspace().getRoot().getProject(name);
- if (!target.exists()) {
- target.create(null);
- target.open(null);
- }
- assertExistsInFileSystem(target);
- return target;
- }
- protected CVSTeamProvider getProvider(IResource resource) throws TeamException {
- return (CVSTeamProvider)RepositoryProvider.getProvider(resource.getProject());
- }
- protected static InputStream getRandomContents(int sizeAtLeast) {
- StringBuffer randomStuff = new StringBuffer(sizeAtLeast + 100);
- while (randomStuff.length() < sizeAtLeast) {
- randomStuff.append(getRandomSnippet() + eol);
- }
- return new ByteArrayInputStream(randomStuff.toString().getBytes());
- }
- /**
- * Return String with some random text to use
- * as contents for a file resource.
- */
- public static String getRandomSnippet() {
- switch ((int) Math.round(Math.random() * 10)) {
- case 0 :
- return "este e' o meu conteudo (portuguese)";
- case 1 :
- return "Dann brauchen wir aber auch einen deutschen Satz!";
- case 2 :
- return "I'll be back";
- case 3 :
- return "don't worry, be happy";
- case 4 :
- return "there is no imagination for more sentences";
- case 5 :
- return "customize yours";
- case 6 :
- return "foo";
- case 7 :
- return "bar";
- case 8 :
- return "foobar";
- case 9 :
- return "case 9";
- default :
- return "these are my contents";
- }
- }
- protected IProject getUniqueTestProject(String prefix) throws CoreException {
- // manage and share with the default stream create by this class
- return getNamedTestProject(prefix + "-" + Long.toString(System.currentTimeMillis()));
- }
-
- protected CVSRepositoryLocation getRepository() {
- return CVSTestSetup.repository;
- }
- protected void importProject(IProject project) throws TeamException {
-
- // Create the root folder for the import operation
- ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(project);
-
- // Perform the import
- IStatus status;
- Session s = new Session(getRepository(), root);
- s.open(DEFAULT_MONITOR, true /* open for modification */);
- try {
- status = Command.IMPORT.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {Import.makeArgumentOption(Command.MESSAGE_OPTION, "Initial Import")},
- new String[] { project.getName(), getRepository().getUsername(), "start" },
- null,
- DEFAULT_MONITOR);
- } finally {
- s.close();
- }
-
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
-
- protected void shareProject(IProject project) throws TeamException, CoreException {
- mapNewProject(project);
- commitNewProject(project);
- }
-
- protected void mapNewProject(IProject project) throws TeamException {
- shareProject(getRepository(), project, null, DEFAULT_MONITOR);
- }
-
- /**
- * Map the given local project to remote folder, creating the remote folder or any of
- * its ancestors as necessary.
- * @param location
- * @param project
- * @param moduleName
- * @param default_monitor
- */
- protected void shareProject(CVSRepositoryLocation location, IProject project, String moduleName, IProgressMonitor default_monitor) throws CVSException {
- ShareProjectOperation op = new ShareProjectOperation(null, location, project, moduleName);
- executeHeadless(op);
- }
-
- protected void commitNewProject(IProject project) throws CoreException, CVSException, TeamException {
- List resourcesToAdd = new ArrayList();
- IResource[] members = project.members();
- for (int i = 0; i < members.length; i++) {
- if ( ! CVSWorkspaceRoot.getCVSResourceFor(members[i]).isIgnored()) {
- resourcesToAdd.add(members[i]);
- }
- }
- addResources((IResource[]) resourcesToAdd.toArray(new IResource[resourcesToAdd.size()]));
- commitResources(new IResource[] {project}, IResource.DEPTH_INFINITE);
- // Pause to ensure that future operations happen later than timestamp of committed resources
- waitMsec(1500);
- }
-
- /**
- * Return an input stream with some random text to use
- * as contents for a file resource.
- */
- public InputStream getRandomContents() {
- return getRandomContents(RANDOM_CONTENT_SIZE);
- }
-
- protected void setContentsAndEnsureModified(IFile file) throws CoreException, TeamException {
- setContentsAndEnsureModified(file, getRandomContents().toString());
- }
-
- protected void setContentsAndEnsureModified(IFile file, String contents) throws CoreException, CVSException {
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
- int count = 0;
- if (contents == null) contents ="";
- do {
- file.setContents(new ByteArrayInputStream(contents.getBytes()), false, false, null);
- assertTrue("Timestamp granularity is too small. Increase test wait factor", count <= CVSTestSetup.WAIT_FACTOR);
- if (!cvsFile.isModified(null)) {
- waitMsec(1500);
- count++;
- }
- } while (!cvsFile.isModified(null));
- }
-
- public void waitMsec(int msec) {
- try {
- Thread.sleep(msec);
- } catch(InterruptedException e) {
- fail("wait-problem");
- }
- }
-
- public static void waitForJobCompletion(Job job) {
- // process UI events first, give the main thread a chance
- // to handle any syncExecs or asyncExecs posted as a result
- // of the event processing thread.
- while (Display.getCurrent().readAndDispatch()) {};
-
- // wait for the event handler to process changes.
- while(job.getState() != Job.NONE) {
- while (Display.getCurrent().readAndDispatch()) {};
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- }
- }
- while (Display.getCurrent().readAndDispatch()) {};
- }
-
- public static void waitForIgnoreFileHandling() {
- waitForJobCompletion(SyncFileChangeListener.getDeferredHandler().getEventHandlerJob());
- }
-
- public static void waitForSubscriberInputHandling(SubscriberSyncInfoCollector input) {
- input.waitForCollector(new IProgressMonitor() {
- public void beginTask(String name, int totalWork) {
- }
- public void done() {
- }
- public void internalWorked(double work) {
- }
- public boolean isCanceled() {
- return false;
- }
- public void setCanceled(boolean value) {
- }
- public void setTaskName(String name) {
- }
- public void subTask(String name) {
- }
- public void worked(int work) {
- while (Display.getCurrent().readAndDispatch()) {}
- }
- });
- }
-
- protected static void executeHeadless(CVSOperation op) throws CVSException {
- try {
- try {
- // Bypass contxt by executing run(IProgressMonitor) directly
- op.run(DEFAULT_MONITOR);
- } catch (InvocationTargetException e1) {
- throw CVSException.wrapException(e1);
- }
- } catch (InterruptedException e) {
- throw new OperationCanceledException();
- }
- }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- if (CVSTestSetup.logListener != null) {
- try {
- CVSTestSetup.logListener.checkErrors();
- } catch (CoreException e) {
- if (CVSTestSetup.FAIL_IF_EXCEPTION_LOGGED) {
- fail("Exception written to log: ", e);
- } else {
- // Write the log to standard out so it can be more easily seen
- write(e.getStatus(), 0);
- }
- }
- }
- }
-
- protected void write(IStatus status, int indent) {
- PrintStream output = System.out;
- indent(output, indent);
- output.println("Severity: " + status.getSeverity());
-
- indent(output, indent);
- output.println("Plugin ID: " + status.getPlugin());
-
- indent(output, indent);
- output.println("Code: " + status.getCode());
-
- indent(output, indent);
- output.println("Message: " + status.getMessage());
-
- Throwable t = status.getException();
- if (t != null) {
- t.printStackTrace(output);
- if (t instanceof CoreException) {
- write(((CoreException)t).getStatus(), indent + 1);
- }
- }
-
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++)
- write(children[i], indent + 1);
- }
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#runBare()
- */
- public void runBare() throws Throwable {
- try {
- super.runBare();
- } catch (CVSException e) {
- // If a communication exception occurred
- // perhaps it is a server problem
- // Try again, just in case it is
- if (containsCommunicationException(e)) {
- super.runBare();
- } else {
- throw e;
- }
- }
- }
-
- private boolean containsCommunicationException(CVSException e) {
- if (e instanceof CVSCommunicationException) return true;
- IStatus status = e.getStatus();
- if (status.getException() instanceof CVSCommunicationException) return true;
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus child = children[i];
- if (child.getException() instanceof CVSCommunicationException) return true;
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.tests.harness.EclipseWorkspaceTest#ensureDoesNotExistInWorkspace(org.eclipse.core.resources.IResource)
- */
- public void ensureDoesNotExistInWorkspace(IResource resource) {
- // Overridden to change how the workspace is deleted on teardown
- if (resource.getType() == IResource.ROOT) {
- // Delete each project individually
- Job[] allJobs = Platform.getJobManager().find(null /* all families */);
- IProject[] projects = ((IWorkspaceRoot)resource).getProjects();
- try {
- ensureDoesNotExistInWorkspace(projects);
- } catch (AssertionFailedError e) {
- // The delete failed. Write the active jobs to stdout
- System.out.println("Jobs active at time of deletion failure: "); //$NON-NLS-1$
- if (allJobs.length == 0) {
- System.out.println("None"); //$NON-NLS-1$
- }
- for (int i = 0; i < allJobs.length; i++) {
- Job job = allJobs[i];
- System.out.println(job.getName());
- }
- if (CVSTestSetup.FAIL_IF_EXCEPTION_LOGGED) {
- throw e;
- }
- }
- } else {
- super.ensureDoesNotExistInWorkspace(resource);
- }
- }
-
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/ICVSClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/ICVSClient.java
deleted file mode 100644
index a89cec5e1..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/ICVSClient.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-
-public interface ICVSClient {
- public void executeCommand(
- ICVSRepositoryLocation repositoryLocation, IContainer localRoot, String command,
- String[] globalOptions, String[] localOptions, String[] arguments)
- throws CVSException;
-}
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
deleted file mode 100644
index c8f4ad4af..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-import java.io.BufferedReader;
-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.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.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-
-/**
- * Base-class to the low level-testcases for the Session.
- * Supplies convinience-methods and default attributes for the testcases.
- * 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 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-
- public static final String[] EMPTY_ARGS = new String[0];
-
- /**
- * Init the options and arguments to standard-values
- */
- public JUnitTestCase(String name) {
- super(name);
- }
-
- /**
- * Delete a project/resource form the standard cvs-server
- */
- protected void magicDeleteRemote(String remoteName) throws CVSException {
- magicDeleteRemote(CVSTestSetup.repository, remoteName);
- }
-
- /**
- * Delete a project/resource form the specified cvs-server
- */
- protected static void magicDeleteRemote(ICVSRepositoryLocation location, String remoteName)
- throws CVSException {
- CVSTestSetup.executeRemoteCommand(location, "rm -rf " +
- new Path(location.getRootDirectory()).append(remoteName).toString());
- }
-
- /**
- * 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"}
- */
- protected void magicSetUpRepo(String projectName, String[] createResources)
- throws IOException, CoreException, CVSException {
- magicSetUpRepo(CVSTestSetup.repository, projectName, createResources);
- }
-
- /**
- * Sends the project to the specified cvs-server so that it contains the resources
- * described in createResources. The files have random content.
- *
- * @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"}
- */
- 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);
-
- String[] lOptions = new String[]{"-m","msg"};
- String[] args = new String[]{projectName,"a","b"};
-
- EclipseCVSClient.execute(location, CVSWorkspaceRoot.getCVSFolderFor(projectRoot),
- "import", EMPTY_ARGS, lOptions, args);
- projectRoot.delete(false /*force*/, null);
- }
-
- /**
- * Compare Arrays and find the first different element
- */
- protected static void assertEqualsArrays(Object[] obArr1, Object[] obArr2) {
-
- assertEquals("Called assertEqualsArrays with null on one side", obArr1 == null,obArr2 == null);
- if (obArr1 == null) {
- return;
- }
-
- for (int i=0; i<Math.min(obArr1.length,obArr2.length); i++) {
- assertEquals("At Element " + i + " of the array",obArr1[i],obArr2[i]);
- }
-
- // If the Arrays are different in length, look for the first
- // not existing element and compare it to the existing in the
- // other array
- if (obArr1.length > obArr2.length) {
- assertEquals("Arrays of different length",obArr1[obArr2.length],null);
- return;
- }
-
- if (obArr1.length < obArr2.length) {
- assertEquals("Arrays of different length",obArr2[obArr1.length],null);
- return;
- }
-
- }
-
- /**
- * Write text lines to file from an array of strings.
- */
- 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();
- }
- }
-
- /**
- * Read text lines from file into an array of strings.
- */
- 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();
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- fileContentStore.add(line);
- }
- } finally {
- reader.close();
- }
- return (String[]) fileContentStore.toArray(new String[fileContentStore.size()]);
- }
-
- /**
- * Append text files to file from an array of strings, create new file if it
- * does not exist yet.
- */
- protected static void appendToFile(IFile file, String[] contents)
- throws IOException, CoreException {
- String[] oldContents = readFromFile(file);
- String[] newContents;
- if (oldContents == 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);
- }
- writeToFile(file, newContents);
- }
-
- /**
- * Pre-Append text files to file from an array of strings, create new file if it
- * does not exist yet.
- */
- protected static void prefixToFile(IFile file, String[] contents)
- throws IOException, CoreException {
- String[] oldContents = readFromFile(file);
- String[] newContents;
- if (oldContents == null) {
- newContents = contents;
- } else {
- newContents = new String[oldContents.length + contents.length];
- System.arraycopy(contents, 0, newContents, 0, contents.length);
- System.arraycopy(oldContents, 0, newContents, contents.length, oldContents.length);
- }
- writeToFile(file, newContents);
- }
-
- /**
- * genertates Random content meand to be written in a File
- */
- protected static String createRandomContent() {
-
- StringBuffer content = new StringBuffer();
- int contentSize;
-
- content.append("Random file generated for test" + PLATFORM_NEWLINE);
-
- contentSize = (int) Math.round(RANDOM_CONTENT_SIZE * 2 * Math.random());
- for (int i=0; i<contentSize; i++) {
-
- if (Math.random()>0.99) {
- content.append(PLATFORM_NEWLINE);
- }
-
- if (Math.random()>0.99) {
- content.append("\n");
- }
-
- if (NEWLINE_TEST) {
- if (Math.random()>0.99) {
- content.append("\n\r");
- }
- if (Math.random()>0.99) {
- content.append('\r');
- }
- if (Math.random()>0.99) {
- content.append("\r\n");
- }
- if (Math.random()>0.99) {
- content.append("\n");
- }
- if (Math.random()>0.99) {
- content.append("\n\n");
- }
- if (Math.random()>0.99) {
- content.append("\r\r");
- }
- }
-
- content.append((char)('\u0021' + Math.round(60 * Math.random())));
- }
-
- return content.toString();
- }
-
- /**
- * Creates a folder (and its parents if needed).
- */
- 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.
- */
- 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);
- }
- }
-
- /**
- * wait milliseconds to continou the execution
- */
- public static void waitMsec(int msec) {
- try {
- int wait = CVSTestSetup.WAIT_FACTOR * msec;
- long start = System.currentTimeMillis();
- Thread.sleep(wait);
- long end = System.currentTimeMillis();
- // Allow a 100 ms error in waiting
- assertTrue("Error in thread class. Did not wait long enough", (end - start) > (wait - 100));
- } catch(InterruptedException e) {
- fail("wait-problem");
- }
- }
-
- /**
- * Call this method from the main-method of your test-case.
- * It initialises some required parameter and runs the testcase.
- */
- protected static void run(Class test) {
- // XXX is this property used anywhere?
- System.setProperty("eclipse.cvs.standalone", "true");
- TestRunner.run(test);
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java
deleted file mode 100644
index 682c9b6ec..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException;
-
-/**
- * @author Administrator
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class TestConnection implements IServerConnection {
-
- public static TestConnection currentConnection;
-
- public static List previousLines;
- public static StringBuffer currentLine;
-
-
- private ByteArrayInputStream serverResponse;
-
- private static final String VALID_SERVER_REQUESTS = "Valid-requests Root Valid-responses valid-requests Repository Directory Max-dotdot Static-directory Sticky Checkin-prog Update-prog Entry Kopt Checkin-time Modified Is-modified UseUnchanged Unchanged Notify Questionable Case Argument Argumentx Global_option Gzip-stream wrapper-sendme-rcsOptions Set Kerberos-encrypt Gssapi-encrypt Gssapi-authenticate expand-modules ci co update diff log rlog add remove update-patches gzip-file-contents status rdiff tag rtag import admin export history release watch-on watch-off watch-add watch-remove watchers editors init annotate rannotate noop version";
-
- public static IServerConnection createConnection(ICVSRepositoryLocation location, String password) {
- currentConnection = new TestConnection();
- return currentConnection;
- }
-
- public static String getLastLine() {
- if (previousLines.isEmpty()) return null;
- return (String)previousLines.get(previousLines.size() - 1);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IServerConnection#open(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException {
- resetStreams();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IServerConnection#close()
- */
- public void close() throws IOException {
- resetStreams();
- }
-
- /**
- *
- */
- private void resetStreams() {
- currentLine = new StringBuffer();
- previousLines = new ArrayList();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IServerConnection#getInputStream()
- */
- public InputStream getInputStream() {
- // TODO Auto-generated method stub
- return new InputStream() {
- public int read() throws IOException {
- if (serverResponse == null) {
- throw new IOException("Not prepared to make a response");
- } else {
- return serverResponse.read();
- }
- }
- };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IServerConnection#getOutputStream()
- */
- public OutputStream getOutputStream() {
- return new OutputStream() {
- public void write(int output) throws IOException {
- byte b = (byte)output;
- if (b == '\n') {
- String sentLine = currentLine.toString();
- previousLines.add(sentLine);
- currentLine = new StringBuffer();
- respondToSentLine(sentLine);
- } else {
- currentLine.append((char)b);
- }
- }
- };
- }
-
- /**
- * @param sentLine
- */
- protected void respondToSentLine(String sentLine) {
- if (sentLine.equals("valid-requests")) {
- serverResponse = new ByteArrayInputStream((VALID_SERVER_REQUESTS + "\nok\n").getBytes());
- }
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java
deleted file mode 100644
index d64a946ff..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IConnectionMethod;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-
-/**
- * @author Administrator
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class TestConnectionMethod implements IConnectionMethod {
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IConnectionMethod#getName()
- */
- public String getName() {
- return "test";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IConnectionMethod#createConnection(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, java.lang.String)
- */
- public IServerConnection createConnection(ICVSRepositoryLocation location, String password) {
- return TestConnection.createConnection(location, password);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IConnectionMethod#disconnect(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation)
- */
- public void disconnect(ICVSRepositoryLocation location) {
- // Nothing need to be done
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java
deleted file mode 100644
index 576e44629..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core;
-
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * A test authenticator that provide defaults for all methods.
- */
-public class TestsUserAuthenticator implements IUserAuthenticator {
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#promptForUserInfo(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.IUserInfo, java.lang.String)
- */
- public void promptForUserInfo(ICVSRepositoryLocation location, IUserInfo userInfo, String message) throws CVSException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#prompt(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, int, java.lang.String, java.lang.String, int[], int)
- */
- public int prompt(ICVSRepositoryLocation location, int promptType, String title, String message, int[] promptResponses, int defaultResponseIndex) {
- return defaultResponseIndex;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#promptForKeyboradInteractive(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, java.lang.String, java.lang.String, java.lang.String, java.lang.String[], boolean[])
- */
- public String[] promptForKeyboradInteractive(ICVSRepositoryLocation location, String destination, String name, String instruction, String[] prompt, boolean[] echo) throws CVSException {
- return prompt;
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java
deleted file mode 100644
index 12d4bc836..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.compatible;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTestsCompatibility extends TestSuite {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(BasicTest.suite());
- suite.addTest(ConflictTest.suite());
- suite.addTest(ModuleTest.suite());
- return new CompatibleTestSetup(suite);
- }
-
- public AllTestsCompatibility(String name) {
- super(name);
- }
-
- public AllTestsCompatibility() {
- super();
- }
-}
-
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
deleted file mode 100644
index 207241341..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.compatible;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-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 + "-checkout1");
- env2 = new SameResultEnv(arg + "-checkout2");
- }
-
- public BasicTest() {
- this("BasicTest");
- }
-
- public static void main(String[] args) {
- run(BasicTest.class);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(BasicTest.class);
- return new CompatibleTestSetup(suite);
- //return new CompatibleTestSetup(new BasicTest("testReadOnly"));
- }
- public void setUp() throws Exception {
- env1.setUp();
- env2.setUp();
-
- // Set the project to the content we need ...
- env1.magicSetUpRepo("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt"});
- env2.deleteFile("proj2");
- }
-
- public void tearDown() throws Exception {
- env1.tearDown();
- env2.tearDown();
- }
-
- public void testAdd() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env1.writeToFile("proj2/d.txt",new String[]{"The file to be added","next"});
- env1.mkdirs("proj2/f2/f3");
- env1.mkdirs("proj2/f4/f5");
- env1.writeToFile("proj2/f4/f5/e.txt", new String[]{"Another file to be added","next"});
-
- env1.execute("add",EMPTY_ARGS,new String[]{"d.txt"},"proj2");
- env1.execute("add",EMPTY_ARGS,new String[]{"f2","f2/f3"},"proj2");
- env1.execute("add",EMPTY_ARGS,new String[]{"f4"},"proj2");
- env1.execute("add",EMPTY_ARGS,new String[]{"f4/f5"},"proj2");
- env1.execute("add",EMPTY_ARGS,new String[]{"f4/f5/e.txt"},"proj2");
- env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"});
-
- // Check the stuff out somewhere else to acctually check, that
- // the file has been accepted
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- }
-
- public void testAddUpdate() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"});
-
- env1.writeToFile("proj2/d.txt",new String[]{"The file to be added","next"});
- env1.mkdirs("proj2/f2/f3");
- env1.mkdirs("proj2/f4/f5");
- env1.writeToFile("proj2/f4/f5/e.txt", new String[]{"Another file to be added","next"});
-
- env1.execute("add",EMPTY_ARGS,new String[]{"d.txt"},"proj2");
- env1.execute("add",EMPTY_ARGS,new String[]{"f2","f2/f3"},"proj2");
- env1.execute("add",EMPTY_ARGS,new String[]{"f4"},"proj2");
- env1.execute("add",EMPTY_ARGS,new String[]{"f4/f5"},"proj2");
- env1.execute("add",EMPTY_ARGS,new String[]{"f4/f5/e.txt"},"proj2");
- env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"});
-
- env2.execute("update",EMPTY_ARGS,new String[]{"proj2"});
-
- }
-
- public void testRemove() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env1.deleteFile("proj2/a.txt");
- env1.deleteFile("proj2/f1/c.txt");
-
- env1.execute("remove",EMPTY_ARGS,new String[]{"a.txt"},"proj2");
- env1.execute("remove",EMPTY_ARGS,new String[]{"f1/c.txt"},"proj2");
- env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"});
-
- // Check the stuff out somewhere else to acctually check, that
- // the file has been accepted
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- }
-
- public void testRemoveRecusive() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"});
-
- env1.deleteFile("proj2/a.txt");
- env1.deleteFile("proj2/f1/c.txt");
-
- env1.execute("remove",EMPTY_ARGS,new String[0],"proj2");
- env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"});
-
- // Check the stuff out somewhere else to acctually check, that
- // the file has been accepted
- env2.execute("update",EMPTY_ARGS,new String[]{"proj2"});
- }
-
- public void testRoundRewrite() throws Exception {
-
- // Download content in two locations
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
-
- // change the file "proj1/folder1/c.txt" in env1 check it in
- // on the server
- 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
- // try {
- // assertEqualsArrays(env1.readFromFile("proj2/f1/c.txt"),
- // env2.readFromFile("proj2/f1/c.txt"));
- // throw new IllegalArgumentException("This is a failed Assertion");
- // } catch (AssertionFailedError e) {}
-
- // update env2 and make sure the changes are there
- env2.execute("update",EMPTY_ARGS,new String[]{"proj2"},"");
- // assertEqualsArrays(env1.readFromFile("proj2/f1/c.txt"),
- // env2.readFromFile("proj2/f1/c.txt"));
- }
-
- public void testUpdateMinusN() throws Exception {
- String[] fileContent1;
-
- fileContent1 = new String[]{"RandomNumber", Math.random() + ""};
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"});
-
- env1.writeToFile("proj1/folder1/c.txt",fileContent1);
-
- env1.execute("ci",new String[]{"-n"},new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
- env2.execute("update",EMPTY_ARGS,new String[]{"proj2"});
- }
-
- public void testStatus() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env1.execute("status",EMPTY_ARGS,new String[]{"proj2"});
-
- env1.deleteFile("proj2/a.txt");
- env1.deleteFile("proj2/f1/c.txt");
- 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");
-
- env1.createRandomFile("proj2/d.txt");
-
- env1.execute("status",EMPTY_ARGS,new String[0],"proj2");
- env1.execute("status",EMPTY_ARGS,new String[]{"f1/b.txt"},"proj2");
- // env1.execute("status",localOptions,new String[]{"d.txt"},"proj2");
- }
-
- public void testLog() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env1.execute("log",EMPTY_ARGS,new String[]{"proj2"});
-
- env1.deleteFile("proj2/a.txt");
- env1.deleteFile("proj2/f1/c.txt");
- 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");
-
- env1.createRandomFile("proj2/d.txt");
-
- env1.execute("log",EMPTY_ARGS,new String[0],"proj2");
- env1.execute("log",EMPTY_ARGS,new String[]{"f1/b.txt"},"proj2");
-
- }
-
- public void testBranchTag() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env1.execute("tag",new String[]{"-b"},new String[]{"tag1","proj2"});
-
- env1.deleteFile("proj2/a.txt");
- env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
-
- env1.execute("tag",new String[]{"-b"},new String[]{"tag2","proj2"});
-
- env1.createRandomFile("proj2/d.txt");
-
- env1.deleteFile("proj2");
-
- // 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", 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"});
- env1.deleteFile("proj2");
- 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", 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"});
- env2.deleteFile("proj2");
- env2.execute("co",new String[]{"-r","tag2"},new String[]{"proj2"});
- }
-
- public void testBranchingWithLocalChanges() throws Exception {
- // 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",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"});
- }
-
- public void testTag() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env1.execute("tag",EMPTY_ARGS,new String[]{"tag1","proj2"});
-
- env1.deleteFile("proj2/a.txt");
- env1.deleteFile("proj2/f1/c.txt");
- 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");
-
- env1.createRandomFile("proj2/d.txt");
-
- env1.execute("tag",EMPTY_ARGS,new String[]{"tag3"},"proj2");
- env1.execute("tag",EMPTY_ARGS,new String[]{"tag3","f1/b.txt"},"proj2");
-
- env1.deleteFile("proj2");
- env1.execute("co",new String[]{"-r","tag1"},new String[]{"proj2"});
- env1.deleteFile("proj2");
- env1.execute("co",new String[]{"-r","tag2"},new String[]{"proj2"});
- env1.deleteFile("proj2");
- env1.execute("co",new String[]{"-r","tag3"},new String[]{"proj2"});
-
- // env1.execute("tag",localOptions,new String[]{"d.txt"},"proj2");
-
- env1.execute("update", new String[]{"-r","tag1"}, new String[]{"proj2"});
- env1.execute("update", new String[]{"-r","tag2"}, new String[]{"proj2"});
- env1.execute("update", new String[]{"-r","tag3"}, new String[]{"proj2"});
- env1.execute("update", new String[]{"-A"}, new String[]{"proj2"});
- }
-
- public void testRTag() throws Exception {
-
- // Checkout and tag the project
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env1.execute("tag",EMPTY_ARGS,new String[]{"tag1","proj2"});
- env1.deleteFile("proj2");
-
- // Use rtag to tag the above tag as both a version and a branch
- env1.execute("rtag",new String[]{"-r", "tag1"},new String[]{"rtag1","proj2"});
- env1.execute("rtag",new String[]{"-b", "-r", "tag1"},new String[]{"btag1","proj2"});
-
- // Checkout the version and branch
- env1.deleteFile("proj2");
- env1.execute("co",new String[]{"-r","rtag1"},new String[]{"proj2"});
- env1.deleteFile("proj2");
- env1.execute("co",new String[]{"-r","btag1"},new String[]{"proj2"});
- }
-
- public void testPrune() throws Exception {
-
- // Download content in two locations
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
-
- // change the file "proj1/folder1/c.txt" in env1 check it in
- // on the server
- env1.deleteFile("proj2/f1/b.txt");
- env1.deleteFile("proj2/f1/c.txt");
- env1.execute("remove",EMPTY_ARGS,new String[0],"proj2");
-
- env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
- env1.execute("update",new String[]{"-P"},new String[]{"proj2"},"");
-
- // update env2 and make sure the changes are there
- env2.execute("update",new String[]{"-P"},new String[]{"proj2"},"");
-
- }
-
- public void testPrune2() throws Exception {
-
- // Download content in two locations
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
-
- // change the file "proj1/folder1/c.txt" in env1 check it in
- // on the server
- env1.deleteFile("proj2/f1/b.txt");
- env1.deleteFile("proj2/f1/c.txt");
- env1.execute("remove",EMPTY_ARGS,new String[0],"proj2");
-
- env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
- env1.execute("update",new String[]{"-P"},new String[]{},"proj2");
-
- // update env2 and make sure the changes are there
- env2.execute("update",new String[]{"-P"},new String[]{},"proj2");
-
- }
-
- public void testAdmin() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
-
- env1.execute("admin",new String[]{"-kb"},new String[]{"proj2/f1/b.txt"},"");
- env1.execute("update",EMPTY_ARGS,new String[]{"proj2"},"");
-
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
- }
-
- public void testDiff() throws Exception {
-
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
- env1.execute("diff",EMPTY_ARGS,new String[]{"proj2"});
-
- env1.setIgnoreExceptions(true);
-
- 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");
-
- env1.createRandomFile("proj2/d.txt");
-
- env1.execute("diff",EMPTY_ARGS,new String[0],"proj2");
- env1.execute("diff",EMPTY_ARGS,new String[]{"f1/b.txt"},"proj2");
- // env1.execute("diff",localOptions,new String[]{"d.txt"},"proj2");
-
- env1.setIgnoreExceptions(false);
- }
-
- public void testReadOnly() throws Exception {
-
- // Checkout a read-only copy
- env1.execute("co",new String[]{"-r"},EMPTY_ARGS,new String[]{"proj2"},"");
- // Checkout and modify a writable copy
- env2.execute("co",new String[]{},EMPTY_ARGS,new String[]{"proj2"},"");
- env2.appendToFile("proj2/f1/c.txt",new String[] {"AppendIt2" });
- // Update the read only copy
- env1.execute("update",new String[] {"-r"},EMPTY_ARGS,new String[]{"proj2"},"");
-
- // Update the read-only copy to writable
- env1.execute("update",new String[] {},EMPTY_ARGS,new String[]{"proj2"},"");
- }
-
- public void testQuestionables() throws Exception {
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
- env1.writeToFile("proj2/f2/d.txt", new String[]{"content"});
- env1.writeToFile("proj2/f3/f4/d.txt", new String[]{"content"});
- env1.writeToFile("proj2/f5/f6/f7/d.txt", new String[]{"content"});
- env1.execute("add",new String[0],new String[]{"f3"},"proj2");
- env1.execute("add",new String[0],new String[]{"f3/f4"},"proj2");
- env1.execute("update",new String[0],new String[]{"."},"proj2");
- }
-
- public void testImportWrappers() throws Exception {
- // Make the project empty
- env1.magicSetUpRepo("proj3",new String[]{"NoImportant.txt"});
- env2.deleteFile("proj3");
-
- // Create resouces and import them with the
- // special wrapper
- env1.createRandomFile(new String[]{"a.txt","a.class","a.xxx"},"proj3");
- env1.execute("import",
- new String[]{"-W","*.txt -k 'kv'","-W","*.class -k 'b'","-I","*.xxx","-m","msg"},
- new String[]{"proj3","aTag","bTag"},
- "proj3");
-
- // download the server-version
- env2.execute("co",EMPTY_ARGS,new String[]{"proj3"},"");
- }
-
- public void testImportIgnores() throws Exception {
- // Make the project empty
- env1.magicSetUpRepo("proj3",new String[]{"NoImportant.txt"});
- env2.deleteFile("proj3");
-
- // Create resouces and import them with the
- // special wrapper
- env1.createRandomFile(new String[]{"a.txt","a.class","a.xxx"},"proj3");
- env1.execute("import",
- new String[]{"-I","*.xxx","-m","msg"},
- new String[]{"proj3","aTag","bTag"},
- "proj3");
-
- // download the server-version
- env2.execute("co",EMPTY_ARGS,new String[]{"proj3"},"");
- }
-
- private String toGMTString(Date d) {
- return d.toGMTString();
- }
-
- public void testDate() throws Exception {
-
- // IMPOTANT:
- // Do not make tests with relative dates, because the times coming back form the server will
- // sometimes differ from the reference-client to the eclipse-client due to the time-delay in calling
-
- Date beforeChange;
- Date firstChange;
- Date secondChange;
-
- env1.execute("co",new String[0],new String[]{"proj2"});
-
- // Change the file "a.txt" and record the times you are doing that at
- waitMsec(1100); // here we wait for the import to finish
- beforeChange = GregorianCalendar.getInstance().getTime();
-
- waitMsec(1100);
-
- 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",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();
-
- waitMsec(1100);
-
- env1.deleteFile("proj2");
-
- // Now check the project at different times out
- env1.execute("co",new String[]{"-D",toGMTString(beforeChange)},new String[]{"proj2"});
- env1.deleteFile("proj2");
-
- env1.execute("co",new String[]{"-D",toGMTString(firstChange)},new String[]{"proj2"});
- env1.deleteFile("proj2");
-
- env1.execute("co",new String[]{"-D",toGMTString(secondChange)},new String[]{"proj2"});
- env1.deleteFile("proj2");
-
- // Now do some updates to look if update -D works
- env1.execute("co",new String[0],new String[]{"proj2"});
- env1.execute("update",new String[]{"-D",toGMTString(beforeChange)},new String[]{"proj2"});
- env1.execute("update",new String[]{"-D",toGMTString(firstChange)},new String[]{"proj2"});
- env1.execute("update",new String[]{"-D",toGMTString(secondChange)},new String[]{"proj2"});
-
- // We look if the parameter -a is working
- env1.execute("update",new String[]{"-D",toGMTString(beforeChange),"-A"},new String[]{"proj2"});
- env1.execute("update",new String[]{"-D",toGMTString(secondChange)},new String[]{"proj2"});
- env1.deleteFile("proj2");
-
- // We get try to merge changes from different dates
- env1.execute("co",new String[0],new String[]{"proj2"});
- 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", 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", 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
deleted file mode 100644
index 98f1dfbf0..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.compatible;
-import junit.framework.Test;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-
-/**
- * @version 1.0
- * @author ${user}
- */
-public class CompatibleTestSetup extends CVSTestSetup {
- 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.
- */
- public CompatibleTestSetup(Test test) {
- super(test);
- }
-
- /**
- * For compatibility testing, we need to set up two repositories
- */
- public void setUp() throws CVSException {
- CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(false);
- CVSProviderPlugin.getPlugin().setFetchAbsentDirectories(false);
-
- // setup the repositories
- if (referenceClientRepository == null)
- referenceClientRepository = setupRepository(REFERENCE_REPOSITORY_LOCATION);
- if (eclipseClientRepository == null)
- eclipseClientRepository = setupRepository(ECLIPSE_REPOSITORY_LOCATION);
- }
-
- public void tearDown() throws CVSException {
- CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(true);
- CVSProviderPlugin.getPlugin().setFetchAbsentDirectories(true);
- }
-}
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
deleted file mode 100644
index 3dc2c59d0..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.compatible;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-
-public class ConflictTest extends JUnitTestCase {
- SameResultEnv env1;
- SameResultEnv env2;
-
- public ConflictTest() {
- this(null);
- }
-
- public ConflictTest(String arg) {
- super(arg);
- env1 = new SameResultEnv(arg + "checkout1");
- env2 = new SameResultEnv(arg + "checkout2");
- }
-
- public void setUp() throws Exception {
- env1.setUp();
- env2.setUp();
-
- // Set the project to the content we need ...
- env1.magicSetUpRepo("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt"});
- env2.deleteFile("proj2");
- }
-
- public void tearDown() throws Exception {
- env1.tearDown();
- env2.tearDown();
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ConflictTest.class);
- //return new CompatibleTestSetup(new ConflictTest("testSimpleConflict"));
- return new CompatibleTestSetup(suite);
- }
-
- public void testSimpleConflict() throws Exception {
- // Download content in two locations
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
-
- // change the file in both directories in a different way
- 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"},"");
-
- // load the changes into the changed file
- // and submit the merge
- env2.execute("update",EMPTY_ARGS,new String[]{"proj2"},"");
-
- // commit must fail because we have a merged conflict which has not been
- // edited.
- env2.setIgnoreExceptions(true);
- env2.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
- env2.setIgnoreExceptions(false);
-
- // 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", new String[] { "That's allright" });
- env2.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
- }
-
- public void testMergedUpdate() throws Exception {
- // Download content in two locations
- env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
- env2.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
-
- // change the file in both directories in a different way so that
- // can be merged without conflicts
- env1.prefixToFile("proj2/f1/c.txt", new String[] { "AppendIt at top" });
- env2.appendToFile("proj2/f1/c.txt", new String[] { "AppendIt at bottom" });
-
- // commit changes of the first
- env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
-
- // changes should be merged
- env2.execute("update",EMPTY_ARGS,new String[]{"proj2"},"");
- env2.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
- }
-}
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
deleted file mode 100644
index 8c1f0b18b..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.compatible;
-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 + "checkout1");
- env2 = new SameResultEnv(arg + "checkout2");
- }
-
- public static void main(String[] args) {
- run(ModuleTest.class);
- }
-
- public void setUp() throws Exception {
- env1.setUp();
- env2.setUp();
-
- // Set the project to the content we need ...
- env1.magicDeleteRemote("CVSROOT/modules");
- env1.magicDeleteRemote("CVSROOT/modules,v");
- env1.magicSetUpRepo("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt","f2/f3/e.txt"});
- env2.deleteFile("proj2");
- }
-
- public void tearDown() throws Exception {
- env1.tearDown();
- env2.tearDown();
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ModuleTest.class);
- return new CompatibleTestSetup(suite);
- }
-
- private void setUpModuleFile(String[] change) throws Exception {
-
- // Write the modules-file
- env1.execute("co",EMPTY_ARGS,new String[]{"CVSROOT"});
- env1.writeToFile("CVSROOT/modules",change);
-
- // Send it up to the server
- env1.execute("add",new String[]{"-m","m"},new String[]{"modules"},"CVSROOT");
- env1.execute("ci",new String[]{"-m","m"},new String[]{"CVSROOT"});
- env1.deleteFile("CVSROOT");
- }
-
- public void testSimpleModule() throws Exception {
- setUpModuleFile(new String[]{"mod1 proj2"});
- env1.execute("co",EMPTY_ARGS,new String[]{"mod1"});
- 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"});
- }
-
- public void testCompositeModule() throws Exception {
- setUpModuleFile(new String[]{ "mod1-f1 proj2/f1",
- "mod1-f2 proj2/f2",
- "mod1f &mod1-f1 &mod1-f2"});
-
- env1.execute("co",EMPTY_ARGS,new String[]{"mod1f"});
- 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"});
- }
-
- public void testCompositeAliasModule() throws Exception {
- setUpModuleFile(new String[]{"mod1-f1 proj2/f1",
- "mod1t proj2/f1 b.txt",
- "mod1-f2 &proj2/f2 &mod1t",
- "mod1f -a mod1-f1 mod1-f2"});
-
- env1.execute("co",EMPTY_ARGS,new String[]{"mod1f"});
- 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/SameResultEnv.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
deleted file mode 100644
index 948cad490..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
+++ /dev/null
@@ -1,490 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.compatible;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.StringTokenizer;
-
-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.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.tests.ccvs.core.CommandLineCVSClient;
-import org.eclipse.team.tests.ccvs.core.EclipseCVSClient;
-import org.eclipse.team.tests.ccvs.core.ICVSClient;
-import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-
-
-/**
- * This is a TestCase that does provide the possibility
- * to run tests on both the reference reference-client and the
- * client provided by us, and to check on equal results
- * in files and messages to the consol.
- *
- * No own tests should be placed here, instead you should
- * instanciate this testcase in order to make your test from
- * another suite.
- * The class is final, because you need to be able to open
- * two (or more) different enviorments to test certain things.
- */
-public final class SameResultEnv extends JUnitTestCase {
- private IProject referenceProject;
- private ICVSFolder referenceRoot;
- private IProject eclipseProject;
- private ICVSFolder eclipseRoot;
-
- private boolean ignoreExceptions;
-
- public SameResultEnv(String arg) {
- super(arg);
- }
-
- /**
- * Always to be called in the setUp of the testCase that wants to
- * use the same-result Enviorment.
- */
- 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;
- }
-
- /**
- * Always to be called in the tearDown of the testCase that wants to
- * use the same-result Enviorment.
- */
- 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 = execute(CommandLineCVSClient.INSTANCE,
- CompatibleTestSetup.referenceClientRepository, referenceProject,
- command, globalOptions, localOptions, arguments, pathRelativeToRoot);
- // run with Eclipse client
- boolean eclipseClientException = execute(EclipseCVSClient.INSTANCE,
- CompatibleTestSetup.eclipseClientRepository, eclipseProject,
- command, globalOptions, localOptions, arguments, pathRelativeToRoot);
-
- // assert same results
- assertEquals(referenceClientException, eclipseClientException);
- assertConsistent();
- }
-
- private boolean execute(ICVSClient client, ICVSRepositoryLocation repositoryLocation,
- IContainer localRoot, String command,
- String[] globalOptions, String[] localOptions, String[] arguments,
- String pathRelativeToRoot) throws CVSException {
- try {
- IPath path = new Path(pathRelativeToRoot);
- if (path.segmentCount() != 0) {
- localRoot = localRoot.getFolder(path);
- }
- client.executeCommand(repositoryLocation, localRoot, command, globalOptions,
- localOptions, arguments);
- } catch (CVSException e) {
- if (ignoreExceptions) return true;
- throw e;
- }
- return false;
- }
-
- /**
- * Deletes files on the both of the cvs-servers.
- */
- public void magicDeleteRemote(String remoteName) throws CVSException {
- super.magicDeleteRemote(CompatibleTestSetup.referenceClientRepository, remoteName);
- super.magicDeleteRemote(CompatibleTestSetup.eclipseClientRepository, remoteName);
- }
-
- /**
- * Set up both of the repos on the cvs-server(s) with the standard
- * file-structure:
- * project
- * a.txt
- * f1
- * b.txt
- * 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 projectName, String[] createResources)
- throws IOException, CoreException, CVSException {
- magicDeleteRemote(projectName);
-
- IProject projectRoot = workspaceRoot.getProject(projectName + "-setup-tmp");
- mkdirs(projectRoot);
- createRandomFile(projectRoot, createResources);
-
- String[] lOptions = new String[]{"-m","msg"};
- String[] args = new String[]{projectName,"a","b"};
-
- 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);
-
- projectRoot.delete(false /*force*/, null);
- }
-
- /**
- * 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 IOException, CoreException {
- String[] contents = new String[] { createRandomContent() };
- writeToFile(relativeFileName, contents);
- }
-
- /**
- * Call createRandomFile for every element of the array
- *
- * @see SameResultEnv#createRandomFile(String)
- */
- 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(pathRelativeToRoot + relativeFileNames[i]);
- }
- }
-
- /**
- * Read from the file (check that we have acctually got the same
- * content in both versions
- */
- 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 a file / folder from both directories.
- */
- public void deleteFile(String relativeFileName) throws CoreException {
- IResource referenceFile, eclipseFile;
- if (relativeFileName.length() != 0) {
- referenceFile = referenceProject.findMember(relativeFileName);
- eclipseFile = eclipseProject.findMember(relativeFileName);
- } else {
- 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);
- }
-
- /**
- * Creates a folder (and its parents if needed) in both environments.
- */
- 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[] contents)
- throws IOException, CoreException {
- // Wait a second so that the timestamp will change for sure
- waitMsec(1500);
-
- IFile referenceFile = referenceProject.getFile(relativeFileName);
- appendToFile(referenceFile, contents);
- IFile eclipseFile = eclipseProject.getFile(relativeFileName);
- appendToFile(eclipseFile, contents);
- }
-
- /**
- * Append a String to an file (acctally to both of the files, that are going
- * to have the same content)
- */
- public void prefixToFile(String relativeFileName, String[] contents)
- throws IOException, CoreException {
- // Wait a second so that the timestamp will change for sure
- waitMsec(1500);
-
- IFile referenceFile = referenceProject.getFile(relativeFileName);
- prefixToFile(referenceFile, contents);
- IFile eclipseFile = eclipseProject.getFile(relativeFileName);
- prefixToFile(eclipseFile, contents);
- }
-
- /**
- * Write to the file (acctally to both of the files, that are going
- * to have the same 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.
- *
- * @param ignoreTimestamp if true timestamps of
- files are ignored for the comparison
- */
- public static void assertEquals(ICVSResource mResource1,
- ICVSResource mResource2)
- throws CVSException {
-
- assertEquals(mResource1.isFolder(), mResource2.isFolder());
- assertEquals(mResource1.isManaged() , mResource2.isManaged());
- assertEquals(mResource1.exists(), mResource2.exists());
-
- if (!mResource1.exists()) {
- return;
- }
-
- if (mResource1.isFolder()) {
- assertEquals((ICVSFolder)mResource1,(ICVSFolder)mResource2);
- } else {
- assertEquals((ICVSFile)mResource1,(ICVSFile)mResource2);
- }
- }
-
- /**
- * Assert that two CVSFile's are equal by comparing the content
- * and the metainformation out of the ResourceSync.
- */
- private static void assertEquals(ICVSFile mFile1, ICVSFile mFile2) throws CVSException {
-
- if (mFile1.getName().equals(".project")) return;
-
- // Check the permissions on disk
- assertEquals(mFile1.isReadOnly(), mFile2.isReadOnly());
-
- // Compare the content of the files
- try {
- InputStream in1 = mFile1.getContents();
- InputStream in2 = mFile2.getContents();
- 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
- // may read less than the whoole file
- in1.read(buffer1);
- in2.read(buffer2);
- in1.close();
- in2.close();
- assertEquals("Length differs for file " + mFile1.getName(), buffer1.length, buffer2.length);
- assertEquals("Contents differs for file " + mFile1.getName(), new String(buffer1),new String(buffer2));
- } catch (IOException e) {
- throw new CVSException("Error in TestCase");
- }
-
- // We can not do the ceck, because the reference client does
- // check out dirty files ?!?
- // assertEquals(mFile1.isDirty(),mFile2.isDirty());
-
- assertEquals(mFile1.getSyncInfo() == null,mFile2.getSyncInfo() == null);
- if (mFile1.getSyncInfo() == null) {
- return;
- }
-
- ResourceSyncInfo info1 = mFile1.getSyncInfo();
- ResourceSyncInfo info2 = mFile2.getSyncInfo();
-
- assertEquals(info1.getKeywordMode(), info2.getKeywordMode());
- assertEquals(info1.getTag(), info2.getTag());
- assertEquals(info1.getName(), info2.getName());
- assertEquals(info1.getRevision(), info2.getRevision());
-
- assertEquals(info1.isDeleted(), info2.isDeleted());
- assertEquals(info1.isAdded(), info2.isAdded());
- assertEquals(info1.isMerged(), info2.isMerged());
- assertEquals(info1.isMergedWithConflicts(), info2.isMergedWithConflicts());
-
- // Ensure that timestamps are written using same timezone.
- // assertTimestampEquals(info1.getTimeStamp(), info2.getTimeStamp());
-
- // We are not able to check for the permissions, as the reference-client doesn't save them
- }
-
- private static void assertTimestampEquals(Date timestamp1, Date timestamp2) {
- assertEquals(timestamp1!=null, timestamp2!=null);
- if(timestamp1!=null) {
- long time1 = timestamp1.getTime();
- long time2 = timestamp2.getTime();
- long difference = Math.abs(time1 - time2);
- assertTrue("timestamps should be in same timezone:" + timestamp1 + ":" + timestamp2, difference < (10*60*1000)); // 10 minutes
- }
- }
-
- /**
- * Assert that two CVSFile's are equal. First the
- * metainformation out of the FolderSync for this
- * folder is compared, then the amount of children is
- * checked and finally the recussion is started to
- * compare the children of this folder.
- */
- private static void assertEquals(ICVSFolder mFolder1,
- ICVSFolder mFolder2)
- throws CVSException {
-
- assertEquals(mFolder1.isCVSFolder(),mFolder2.isCVSFolder());
-
- if (mFolder1.isCVSFolder()) {
- 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);
-
- assertEquals(mFolder1.getFolderSyncInfo().getRepository(),mFolder2.getFolderSyncInfo().getRepository());
- assertEquals(mFolder1.getFolderSyncInfo().getIsStatic(),mFolder2.getFolderSyncInfo().getIsStatic());
- assertEquals(mFolder1.getFolderSyncInfo().getTag(),mFolder2.getFolderSyncInfo().getTag());
- }
-
- ICVSResource[] resourceList1 = mFolder1.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.FOLDER_MEMBERS);
- ICVSResource[] resourceList2 = mFolder2.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.FOLDER_MEMBERS);
- assertEquals(resourceList1.length, resourceList2.length);
- for (int i=0; i<resourceList1.length; i++) {
- boolean resourceFound = false;
- for (int j=0; j<resourceList2.length; j++) {
- if (resourceList1[i].getName().equals(resourceList2[j].getName())) {
- assertEquals(resourceList1[i], resourceList2[j]);
- resourceFound = true;
- break;
- }
- }
- assertTrue("Resource " + resourceList1[i].getName() + " not found in the list",resourceFound);
- }
- }
-
- /**
- * Sets whether Exceptions that are thrown in the execution of both of the clients are
- * catched or thrown to the upper level. If the exceptions are catched the result of the
- * reference-client and this client are compared as if the execution succseded.
- */
- 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();
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java
deleted file mode 100644
index f769c0b28..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class AllTestsCVSResources extends EclipseTest {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(ResourceSyncInfoTest.suite());
- suite.addTest(EclipseSynchronizerTest.suite());
- suite.addTest(EclipseFolderTest.suite());
- suite.addTest(ResourceSyncBytesTest.suite());
- return suite;
- }
-
- public AllTestsCVSResources(String name) {
- super(name);
- }
-
- public AllTestsCVSResources() {
- super();
- }
-}
-
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/BatchedTestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/BatchedTestSetup.java
deleted file mode 100644
index 011c09238..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/BatchedTestSetup.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-
-public class BatchedTestSetup extends TestSetup {
- private ISchedulingRule rule;
-
- public BatchedTestSetup(Test test) {
- super(test);
- }
-
- public void setUp() throws CVSException {
- rule = EclipseSynchronizer.getInstance().beginBatching(ResourcesPlugin.getWorkspace().getRoot(), null);
- }
-
- public void tearDown() throws CVSException {
- EclipseSynchronizer.getInstance().endBatching(rule, null);
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseFolderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseFolderTest.java
deleted file mode 100644
index c60abc3ac..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseFolderTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-/**
- * What does this class do?
- */
-public class EclipseFolderTest extends EclipseTest {
- public EclipseFolderTest() {
- super();
- }
-
- public EclipseFolderTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(EclipseFolderTest.class);
- return new CVSTestSetup(suite);
- }
-
- protected void assertChildrenHaveSync(IContainer root, final boolean hasSync) throws CoreException, CVSException {
- root.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- try {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if(!cvsResource.isIgnored()) {
- if(resource.getType()==IResource.FILE) {
- assertTrue((cvsResource.getSyncInfo()!=null) == hasSync);
- } else {
- assertTrue((((ICVSFolder)cvsResource).getFolderSyncInfo()!=null) == hasSync);
- }
- }
- } catch(CVSException e) {
- throw new CoreException(e.getStatus());
- }
- return true;
- }
- });
- }
-
- public void testUnmanageFolder() throws CoreException, TeamException {
- IProject project = createProject("testUnmanageFolder_A", new String[] {"a.txt", "folder1/", "folder1/b.txt", "folder1/folder2/", "folder1/folder2/c.txt"});
- ICVSFolder cvsProject = CVSWorkspaceRoot.getCVSFolderFor(project);
- assertChildrenHaveSync(project, true);
-
- // test that unmanaging the project flushes sync info
- cvsProject.unmanage(null);
- assertChildrenHaveSync(project, false);
-
- final IProject projectB = createProject("testUnmanageFolder_B", new String[] {"a.txt", "folder1/", "folder1/b.txt", "folder1/folder2/", "folder1/folder2/c.txt"});
- final ICVSFolder cvsProjectB = CVSWorkspaceRoot.getCVSFolderFor(projectB);
- assertChildrenHaveSync(projectB, true);
-
- // test that unmanaging in a CVS runnable flushes too
- cvsProjectB.run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- assertChildrenHaveSync(projectB, true);
- cvsProjectB.unmanage(null);
- assertChildrenHaveSync(projectB, false);
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- }, null);
- assertChildrenHaveSync(projectB, false);
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java
deleted file mode 100644
index f938909ea..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java
+++ /dev/null
@@ -1,750 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-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.IResourceVisitor;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-/**
- * Tests the EclipseSynchronizer.
- * Does not test state change broadcasts.
- */
-public class EclipseSynchronizerTest extends EclipseTest {
- private IProject project;
- private static EclipseSynchronizer sync = EclipseSynchronizer.getInstance();
-
- public EclipseSynchronizerTest() {
- super();
- }
-
- public EclipseSynchronizerTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
-
- // Run all tests twice to ensure consistency between batched and non-batched behaviour.
- // 1. First run -- no batching
- suite.addTestSuite(EclipseSynchronizerTest.class);
- // 2. Second run -- with batching
- suite.addTest(new BatchedTestSetup(new TestSuite(EclipseSynchronizerTest.class)));
- return new CVSTestSetup(suite);
- }
-
- public void testFolderSync() throws CoreException, CVSException {
- // Workspace root
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- // Setting should not be an error but sync info should always be null
- FolderSyncInfo info = sync.getFolderSync(root);
- assertNull(info);
- sync.deleteFolderSync(root);
- sync.setFolderSync(root, dummyFolderSync(root));
- info = sync.getFolderSync(root);
- assertNull(info);
-
- // Non-existant project
- IProject project = root.getProject(getName() + "-" + System.currentTimeMillis());
- assertDoesNotExistInFileSystem(project);
- _testFolderSyncInvalid(project);
-
- // Project
- project.create(null);
- project.open(null);
- _testFolderSyncValid(project);
-
- // Non-existant folder
- IFolder folder = project.getFolder("folder1");
- assertDoesNotExistInFileSystem(folder);
- _testFolderSyncInvalid(folder);
-
- // Non-existant folder with non-existant parent
- IFolder childFolder = folder.getFolder("folder2");
- assertDoesNotExistInFileSystem(childFolder);
- _testFolderSyncInvalid(childFolder);
-
- // Folder
- folder.create(false /*force*/, true /*local*/, null);
- _testFolderSyncValid(folder);
-
- // Child folder
- childFolder.create(false /*force*/, true /*local*/, null);
- _testFolderSyncValid(childFolder);
-
- // Deleted folder -- sync info should no longer exist
- sync.setFolderSync(folder, dummyFolderSync(folder));
- folder.delete(false /*force*/, null);
- _testFolderSyncInvalid(folder); // verifies sync info was deleted
-
- // Recreated folder -- sync info should not be preserved across deletions
- folder.create(false /*force*/, true /*local*/, null);
- sync.setFolderSync(folder, dummyFolderSync(folder));
- folder.delete(false /*force*/, null);
- folder.create(false /*force*/, true /*local*/, null);
- _testFolderSyncValid(folder); // verifies sync info has not reappeared
-
- // Deleted project
- sync.setFolderSync(project, dummyFolderSync(project));
- project.delete(false /*force*/, null);
- _testFolderSyncInvalid(project);
- }
-
- /*
- * Test get/set/delete folder sync for things that support it.
- * Assumes container does not already have sync info.
- */
- private void _testFolderSyncValid(IContainer container) throws CoreException, CVSException {
- FolderSyncInfo info = sync.getFolderSync(container);
- assertNull(info);
- sync.deleteFolderSync(container);
- FolderSyncInfo newInfo = dummyFolderSync(container);
- sync.setFolderSync(container, newInfo);
- info = sync.getFolderSync(container);
- assertEquals(newInfo, info);
- // verify that deleteFolderSync() does the right thing
- buildResources(container, new String[] { "hassync/", "nosync", "hassync.txt", "nosync.txt" }, true);
- IResource resource = container.getFile(new Path("hassync.txt"));
- sync.setResourceSync(resource, dummyResourceSync(resource));
- resource = container.getFolder(new Path("hassync"));
- sync.setResourceSync(resource, dummyResourceSync(resource));
- assertNotNull(sync.getResourceSync(container.getFile(new Path("hassync.txt"))));
- assertNull(sync.getResourceSync(container.getFile(new Path("nosync.txt"))));
- assertNotNull(sync.getResourceSync(container.getFolder(new Path("hassync"))));
- assertNull(sync.getResourceSync(container.getFolder(new Path("nosync"))));
- if (container.getType() == IResource.FOLDER) {
- sync.setResourceSync(container, dummyResourceSync(container));
- assertNotNull(sync.getResourceSync(container));
- }
- // should delete folder sync for self, and resource sync for children
- sync.deleteFolderSync(container);
- info = sync.getFolderSync(container);
- assertNull(info);
- assertNull(sync.getResourceSync(container.getFile(new Path("hassync.txt"))));
- assertNull(sync.getResourceSync(container.getFile(new Path("nosync.txt"))));
- assertNull(sync.getResourceSync(container.getFolder(new Path("hassync"))));
- assertNull(sync.getResourceSync(container.getFolder(new Path("nosync"))));
- if (container.getType() == IResource.FOLDER) {
- assertNotNull(sync.getResourceSync(container));
- }
- }
-
- /*
- * Test get/set/delete folder sync for things that should not support it.
- * Assumes container does not already have sync info.
- */
- private void _testFolderSyncInvalid(IContainer container) throws CVSException {
- FolderSyncInfo info = sync.getFolderSync(container);
- assertNull(info);
- sync.deleteFolderSync(container);
- try {
- sync.setFolderSync(container, dummyFolderSync(container));
- fail("Expected CVSException");
- } catch (CVSException e) {
- }
- info = sync.getFolderSync(container);
- assertNull(info);
- }
-
- public void testResourceSync() throws CoreException, CVSException {
- // Workspace root
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- _testResourceSyncInvalid(root);
-
- // Project
- IProject project = getUniqueTestProject(getName());
- assertExistsInFileSystem(project);
- _testResourceSyncInvalid(project);
-
- // Folder
- IFolder folder = project.getFolder("folder1");
- folder.create(false /*force*/, true /*local*/, null);
- _testResourceSyncValid(folder);
-
- // File
- IFile file = folder.getFile("file1");
- file.create(getRandomContents(), false /*force*/, null);
- _testResourceSyncValid(file);
-
- // Deleted/recreated file -- if parent exists, sync info should be preserved across deletions
- ResourceSyncInfo info = dummyResourceSync(file);
- sync.setResourceSync(file, info);
- // Note: deleting a resource will delete it's sync info unless the project has a CVS provider
- file.delete(false /*force*/, null);
- ResourceSyncInfo newInfo = sync.getResourceSync(file);
- //assertEquals(newInfo, info);
- assertEquals(newInfo, null); /* changed for reason noted above */
- file.create(getRandomContents(), false /*force*/, null);
- sync.setResourceSync(file, info); /* added for reason noted above */
- newInfo = sync.getResourceSync(file);
- assertEquals(newInfo, info);
- sync.deleteResourceSync(file);
- file.delete(false /*force*/, null);
- _testResourceSyncValid(file);
-
- // Deleted parent -- sync info of children should also be deleted
- sync.setResourceSync(file, info);
- folder.delete(false /*force*/, null);
- info = sync.getResourceSync(file);
- assertNull(info);
-
- // File in non-existant folder
- IFolder dummyFolder = project.getFolder("folder2");
- assertDoesNotExistInFileSystem(dummyFolder);
- IFile dummyFile = dummyFolder.getFile("file2");
- assertDoesNotExistInFileSystem(dummyFile);
- _testResourceSyncInvalid(dummyFile);
- }
-
- /*
- * Test get/set/delete resource sync for things that support it.
- * Assumes resource does not already have sync info.
- */
- private void _testResourceSyncValid(IResource resource) throws CVSException {
- ResourceSyncInfo info = sync.getResourceSync(resource);
- assertNull(info);
- sync.deleteResourceSync(resource);
- ResourceSyncInfo newInfo = dummyResourceSync(resource);
- sync.setResourceSync(resource, newInfo);
- info = sync.getResourceSync(resource);
- assertEquals(newInfo, info);
- sync.deleteResourceSync(resource);
- info = sync.getResourceSync(resource);
- assertNull(info);
- }
-
- /*
- * Test get/set/delete resource sync for things that should not support it.
- * Assumes resource does not already have sync info.
- */
- private void _testResourceSyncInvalid(IResource resource) throws CVSException {
- ResourceSyncInfo info = sync.getResourceSync(resource);
- assertNull(info);
- sync.deleteResourceSync(resource);
- try {
- sync.setResourceSync(resource, dummyResourceSync(resource));
- fail("Expected CVSException");
- } catch (CVSException e) {
- }
- info = sync.getResourceSync(resource);
- assertNull(info);
- }
-
- public void testIsIgnored() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("isIgnoredTests");
- IResource[] resources = buildResources(project, new String[] {"a.txt", "c.java", "folder1/", "folder1/b.txt", "folder2/"}, true /* include project */);
-
- sync.addIgnored(project, "*.txt");
-
- assertIsIgnored(project.getFile("a.txt"), true);
- assertIsIgnored(project.getFile("c.java"), false);
- assertIsIgnored(project.getFolder("folder1"), false);
- assertIsIgnored(project.getFolder("folder2"), false);
- assertIsIgnored(project.getFile("folder1/b.txt"), false);
- assertIsIgnored(project.getFile("folder1/not-existing.txt"), false);
- assertIsIgnored(project.getParent(), false);
- assertIsIgnored(project, false);
-
- sync.addIgnored(project, "folder1");
-
- assertIsIgnored(project.getFile("a.txt"), true);
- assertIsIgnored(project.getFile("c.java"), false);
- assertIsIgnored(project.getFolder("folder1"), true);
- assertIsIgnored(project.getFolder("folder2"), false);
- assertIsIgnored(project.getFile("folder1/b.txt"), true);
- assertIsIgnored(project.getFile("folder1/not-existing.txt"), true);
- assertIsIgnored(project.getParent(), false);
- assertIsIgnored(project, false);
-
- // delete the ignores, the resource delta should clear the cached
- // ignore list
- IResource cvsIgnore = project.getFile(".cvsignore");
- cvsIgnore.delete(true, null);
- waitForIgnoreFileHandling();
-
- assertIsIgnored(project.getFile("a.txt"), false);
- assertIsIgnored(project.getFile("c.java"), false);
- assertIsIgnored(project.getFolder("folder1"), false);
- assertIsIgnored(project.getFolder("folder2"), false);
- assertIsIgnored(project.getFile("folder1/b.txt"), false);
- assertIsIgnored(project.getFile("folder1/not-existing.txt"), false);
- assertIsIgnored(project.getParent(), false);
- assertIsIgnored(project, false);
- project.delete(true, true, null);
- }
-
- public void testIgnores() throws CoreException, CVSException {
- // Workspace root
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- _testIgnoresInvalid(root);
-
- // Non-existant project
- IProject project = root.getProject(getName() + "-" + System.currentTimeMillis());
- assertDoesNotExistInFileSystem(project);
- _testIgnoresInvalid(project);
-
- // Project
- project.create(null);
- project.open(null);
- _testIgnoresValid(project);
-
- // Non-existant folder
- IFolder folder = project.getFolder("folder1");
- assertDoesNotExistInFileSystem(folder);
- _testIgnoresInvalid(folder);
-
- // Non-existant folder with non-existant parent
- IFolder childFolder = folder.getFolder("folder2");
- assertDoesNotExistInFileSystem(childFolder);
- _testIgnoresInvalid(childFolder);
-
- // Folder
- folder.create(false /*force*/, true /*local*/, null);
- _testIgnoresValid(folder);
-
- // Child folder
- childFolder.create(false /*force*/, true /*local*/, null);
- _testIgnoresValid(childFolder);
-
- // Deleted folder -- ignores should no longer exist
- sync.addIgnored(folder, "*.foo");
- folder.delete(false /*force*/, null);
- _testIgnoresInvalid(folder); // verifies sync info was deleted
-
- // Recreated folder -- sync info should not be preserved across deletions
- folder.create(false /*force*/, true /*local*/, null);
- sync.addIgnored(folder, "*.foo");
- folder.delete(false /*force*/, null);
- folder.create(false /*force*/, true /*local*/, null);
- _testIgnoresValid(folder); // verifies sync info has not reappeared
-
- // Deleted project
- sync.addIgnored(project, "*.foo");
- project.delete(false /*force*/, null);
- _testIgnoresInvalid(project);
- }
-
-
-
- /*
- * Test get/set ignores for things that should not support it.
- * Assumes resource does not already have ignores.
- */
- private void _testIgnoresValid(IContainer container) throws CVSException {
- String[] ignored = getIgnored(container);
- assertTrue(ignored.length == 0);
- sync.addIgnored(container, "*.xyz");
- ignored = getIgnored(container);
- assertBijection(ignored, new String[] { "*.xyz" }, null);
- sync.addIgnored(container, "*.abc");
- sync.addIgnored(container, "*.def");
- ignored = getIgnored(container);
- assertBijection(ignored, new String[] { "*.abc", "*.def", "*.xyz" }, null);
- }
-
- /**
- * TODO: should use chached ignores somehow
- * @param container
- * @return String[]
- * @throws CVSException
- */
- private String[] getIgnored(IContainer container) throws CVSException {
- if (container.getType() == IResource.ROOT) return new String[0];
- String[] ignored = SyncFileWriter.readCVSIgnoreEntries(container);
- if (ignored == null) return new String[0];
- return ignored;
- }
-
- /*
- * Test get/set ignores for things that should not support it.
- * Assumes resource does not already have ignores.
- */
- private void _testIgnoresInvalid(IContainer container) throws CVSException {
- try {
- sync.addIgnored(container, "*.xyz");
- fail("Expected CVSException");
- } catch (CVSException e) {
- }
- }
-
- public void testMembers() throws CoreException, CVSException {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IProject project1 = getUniqueTestProject(getName() + "1");
- IProject project2 = root.getProject(getName() + "2" + System.currentTimeMillis());
-
- // Workspace root
- IResource[] members = sync.members(ResourcesPlugin.getWorkspace().getRoot());
- assertBijection(members, ResourcesPlugin.getWorkspace().getRoot().getProjects(), null);
-
- // Non-existant project
- members = sync.members(project2);
- assertEquals("Non-existant project should have no members", 0, members.length);
-
- // Non-existant folder
- IFolder folder = project1.getFolder("folder1");
- assertDoesNotExistInFileSystem(folder);
- members = sync.members(folder);
- assertEquals("Non-existant folder should have no members", 0, members.length);
-
- // Non-existant folder with non-existant parent
- IFolder childFolder = folder.getFolder("folder2");
- assertDoesNotExistInFileSystem(childFolder);
- members = sync.members(childFolder);
- assertEquals("Non-existant folder should have no members", 0, members.length);
-
- // Project
- buildResources(project1, new String[] {
- "hassync.txt", "deleted_nosync.txt", "deleted.txt", "hassync/", "deleted/", "deleted_nosync/" }, true);
-
- // initially none of the resources have sync info and they all exist
- Object[] ignores = new Object[] { project1.getFolder("CVS") };
- Set expectedMembers = new HashSet(Arrays.asList(project1.members()));
- members = sync.members(project1);
- assertBijection(expectedMembers.toArray(), members, ignores);
-
- // add sync info, resources should still appear exactly once
- IResource resource = project1.getFile("hassync.txt");
- sync.setResourceSync(resource, dummyResourceSync(resource));
- resource = project1.getFolder("hassync");
- sync.setResourceSync(resource, dummyResourceSync(resource));
-
- resource = project1.getFile("deleted.txt");
- sync.setResourceSync(resource, dummyResourceSync(resource));
- resource = project1.getFolder("deleted");
- sync.setResourceSync(resource, dummyResourceSync(resource));
-
- members = sync.members(project1);
- assertBijection(expectedMembers.toArray(), members, ignores);
-
- // delete resources, those with sync info should still appear, those without should not
- // (Note: This is only true for projects that have a CVS provider)
- resource = project1.getFile("deleted.txt");
- resource.delete(false /*force*/, null);
- expectedMembers.remove(resource); /* added for reason noted above */
- resource = project1.getFolder("deleted");
- resource.delete(false /*force*/, null);
- expectedMembers.remove(resource); /* added for reason noted above */
-
- resource = project1.getFile("deleted_nosync.txt");
- resource.delete(false /*force*/, null);
- expectedMembers.remove(resource);
- resource = project1.getFolder("deleted_nosync");
- resource.delete(false /*force*/, null);
- expectedMembers.remove(resource);
-
- members = sync.members(project1);
- assertBijection(expectedMembers.toArray(), members, ignores);
-
- // delete sync info, only those that exist should appear
- resource = project1.getFile("hassync.txt");
- sync.deleteResourceSync(resource);
- resource = project1.getFolder("hassync");
- sync.deleteResourceSync(resource);
-
- resource = project1.getFile("deleted.txt");
- sync.deleteResourceSync(resource);
- expectedMembers.remove(resource);
- resource = project1.getFolder("deleted");
- sync.deleteResourceSync(resource);
- expectedMembers.remove(resource);
-
- members = sync.members(project1);
- assertBijection(expectedMembers.toArray(), members, ignores);
- }
-
- private FolderSyncInfo dummyFolderSync(IContainer container) {
- return new FolderSyncInfo("repo", ":pserver:user@host:/root", CVSTag.DEFAULT, false);
- }
-
- private ResourceSyncInfo dummyResourceSync(IResource resource) {
- if (resource.getType() == IResource.FILE) {
- MutableResourceSyncInfo info = new MutableResourceSyncInfo(resource.getName(), "1.1");
- info.setTag(CVSTag.DEFAULT);
- return info;
- } else {
- return new ResourceSyncInfo(resource.getName());
- }
- }
-
- /**
- * Assert that there exists a bijection between the elements of the arrays.
- */
- private void assertBijection(Object[] a, Object[] b, Object[] ignores) {
- List listA = new LinkedList(Arrays.asList(a));
- List listB = new LinkedList(Arrays.asList(b));
- if (ignores != null) {
- for (int i = 0; i < ignores.length; ++i ) {
- listA.remove(ignores[i]);
- listB.remove(ignores[i]);
- }
- }
- assertEquals("Should have same number of elements", listA.size(), listB.size());
- for (Iterator it = listB.iterator(); it.hasNext();) {
- Object obj = it.next();
- assertTrue("Should contain the same elements", listA.contains(obj));
- listA.remove(obj);
- }
- }
-
- /**
- * Create a test project whose name is derived from the currently running test case.
- * The resources are built using the names supplied in the given String array.
- * Paths ending in / will be folders while others will be files. Intermediate folders
- * are created as needed. Dummy sync info is applied to all created resources and
- * the project is mapped to the CVS repository provider.
- * @param resourcePaths paths of resources to be generated
- * @return the create project
- */
- protected IProject createProject(String[] resourcePaths) throws CoreException {
- // Create the project and build the resources
- IProject project = getUniqueTestProject(getName());
- buildResources(project, resourcePaths, true);
-
- // Associate dummy sync info with al create resources
- project.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() != IResource.PROJECT) {
- sync.setResourceSync(resource, dummyResourceSync(resource));
- }
- if (resource.getType() != IResource.FILE) {
- sync.setFolderSync((IContainer)resource, dummyFolderSync((IContainer)resource));
- }
- return true;
- }
- });
-
- // Map the project to CVS so the Move/Delete hook works
- RepositoryProvider.map(project, CVSProviderPlugin.getTypeId());
- return project;
- }
-
- /**
- * Assert that the resources at the given resource paths have sync info.
- * Also assert that the ancestors of the resources also have sync info
- * @param project the project containing the resources
- * @param resourcePaths the project relative resource paths
- * @throws CVSException
- */
- protected void assertHasSyncInfo(IProject project, String[] resourcePaths) throws CVSException {
- for (int i = 0; i < resourcePaths.length; i++) {
- String path = resourcePaths[i];
- IResource resource = findResource(project, path);
- assertHasSyncInfo(resource);
- }
- }
-
- private IResource findResource(IProject project, String path) {
- IResource resource = project.findMember(path);
- if (resource == null) {
- if (path.charAt(path.length()-1) == Path.SEPARATOR)
- resource = (IResource) project.getFolder(path);
- else
- resource = (IResource) project.getFile(path);
- }
- return resource;
- }
-
- /**
- * Assert that the resource and its ancestors have sync info
- * @param resource the resource being queried
- * @throws CVSException
- */
- protected void assertHasSyncInfo(IResource resource) throws CVSException {
- if (resource.getType() == IResource.ROOT) return;
- if (resource.getType() != IResource.FILE) {
- assertNotNull("Folder should have folder sync info but does not: " + resource.getProjectRelativePath(), sync.getFolderSync((IContainer)resource));
- }
- if (resource.getType() != IResource.PROJECT) {
- assertNotNull("Resource should have sync bytes but does not: " + resource.getProjectRelativePath(), sync.getSyncBytes(resource));
- assertHasSyncInfo(resource.getParent());
- }
- }
-
- /**
- * Assert that the resources at the given resource paths do not have sync info.
- * Also assert that the descendants of the resources also do not have sync info
- * @param project
- * @param resourcePaths
- * @throws CVSException
- */
- private void assertHasNoSyncInfo(IProject project, String[] resourcePaths) throws CoreException {
- for (int i = 0; i < resourcePaths.length; i++) {
- String path = resourcePaths[i];
- IResource resource = findResource(project, path);
- assertHasNoSyncInfo(resource);
- }
- }
-
- protected void assertHasNoSyncInfo(IResource resource) throws CoreException {
- if (resource.getType() == IResource.ROOT) return;
- if (resource.getType() != IResource.FILE) {
- assertNull("Folder should not have folder sync but does: " + resource.getProjectRelativePath(), sync.getFolderSync((IContainer)resource));
- IResource[] members = ((IContainer)resource).members();
- for (int i = 0; i < members.length; i++) {
- IResource child = members[i];
- assertHasNoSyncInfo(child);
- }
- }
- if (resource.getType() != IResource.PROJECT) {
- assertNull("Resource should not have sync bytes but does: " + resource.getProjectRelativePath(), sync.getSyncBytes(resource));
- }
- }
-
- public void testDeleteFile() throws CoreException {
- // Create a project with dummy sync info
- IProject project = createProject(new String[] {"folder1/folder2/file1", "folder1/folder2/file2"});
-
- // Delete the file and assert old sync info is still in place and new has no sync info
- IFile file = project.getFile("folder1/folder2/file1");
- file.delete(false, false, null);
- assertHasSyncInfo(project, new String[] {"folder1/folder2/file1"});
- }
-
- public void testDeleteFolder() throws CoreException {
- // Create a project with dummy sync info
- IProject project = createProject(new String[] {"folder1/folder2/file1", "folder1/folder2/file2"});
-
- // Delete the folder and assert old sync info is still in place and new has no sync info
- IFolder folder = project.getFolder("folder1/folder2/");
- folder.delete(false, false, null);
- assertHasSyncInfo(project, new String[] {"folder1/folder2/file1", "folder1/folder2/file2"});
- }
-
- public void testMoveFile() throws CoreException {
- // Create a project with dummy sync info
- IProject project = createProject(new String[] {"folder1/folder2/file1", "folder1/folder2/file2"});
-
- // Move the file and assert old sync info is still in place and new has no sync info
- IFile file = project.getFile("folder1/folder2/file1");
- project.getFolder("folder1/folder3/").create(false, true, null);
- file.move(project.getFolder("folder1/folder3/file1").getFullPath(), false, null);
- assertHasSyncInfo(project, new String[] {"folder1/folder2/file1"});
- assertHasNoSyncInfo(project, new String[] {"folder1/folder3"});
- }
-
- public void testMoveFolder() throws CoreException {
- // Create a project with dummy sync info
- IProject project = createProject(new String[] {"folder1/folder2/file1"});
-
- // Move the folder and assert old sync info is still in place and new has no sync info
- IFolder folder = project.getFolder("folder1/folder2/");
- folder.move(project.getFolder("folder1/folder3").getFullPath(), false, null);
- assertHasSyncInfo(project, new String[] {"folder1/folder2/file1"});
- assertHasNoSyncInfo(project, new String[] {"folder1/folder3/"});
- }
-
- /*
- * See bug 44446
- */
- public void testFileRecreation() throws CoreException {
- // Create a project with dummy sync info
- IProject project = createProject(new String[] {"folder1/file1"});
-
- // Remove the file and assert that it still has sync info
- IFile file = project.getFile("folder1/file1");
- file.delete(false, false, null);
- assertHasSyncInfo(file);
-
- // Recreate the file and assert that it still has sync info
- file.create(getRandomContents(), false /*force*/, null);
- assertHasSyncInfo(file);
-
- // unmanage the file and assert that sync info is gone
- sync.deleteResourceSync(file);
- assertHasNoSyncInfo(file);
- }
-
- /*
- * This testcase simulates an update that has an incoming deletion and a merge
- * (which may do a move).
- */
- public void testFileMoveAndDelete() throws CoreException {
- // Create a project with dummy sync info
- final IProject project = createProject(new String[] {"folder1/file1", "folder1/file2"});
-
- sync.run(project, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- IFile file1 = project.getFile("folder1/file1");
- IFile file2 = project.getFile("folder1/file2");
- // Delete file 1
- file1.delete(false, false, null);
- assertHasSyncInfo(file1);
- assertHasSyncInfo(file2);
- sync.deleteResourceSync(file1);
- assertHasNoSyncInfo(file1);
- assertHasSyncInfo(file2);
- // Move file 2
- file2.move(new Path("file3"), false, false, null);
- assertHasNoSyncInfo(file1);
- assertHasSyncInfo(file2);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- }, null);
- }
-
- public void testMoveFolderOverFolder() throws CoreException {
- // Create a project with dummy sync info
- final IProject project = createProject(new String[] {"folder1/file1", "folder2/file1"});
-
- // Change the sync info of folder1/file1 to be revision 1.9
- String revision = "1.9";
- IFile file11 = project.getFile("folder1/file1");
- ResourceSyncInfo info = sync.getResourceSync(file11);
- MutableResourceSyncInfo muttable = info.cloneMutable();
- muttable.setRevision(revision);
- sync.setResourceSync(file11, muttable);
-
- // Move the folder and verify that the sync info stays
- project.getFolder("folder2").delete(false, false, null);
- project.getFolder("folder1").move(new Path("folder2"), false, false, null);
- assertHasSyncInfo(file11);
- IFile file21 = project.getFile("folder2/file1");
- assertHasSyncInfo(file21);
- assertTrue(sync.getResourceSync(file11).getRevision().equals(revision));
- assertTrue(!sync.getResourceSync(file21).getRevision().equals(revision));
-
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncBytesTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncBytesTest.java
deleted file mode 100644
index 1956138d0..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncBytesTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-
-import java.text.ParseException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-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.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.*;
-import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-import org.eclipse.team.tests.ccvs.core.TestConnection;
-
-public class ResourceSyncBytesTest extends EclipseTest {
-
- public ResourceSyncBytesTest() {
- super();
- }
-
- public ResourceSyncBytesTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ResourceSyncBytesTest.class);
- return new CVSTestSetup(suite);
- }
-
- /**
- * Convert the input to bytes and get the bytes in the given slot delimited by slash (/).
- * Only retieve the bytes in the given slot and not the rest.
- * @param input
- * @param slot
- * @return
- */
- private byte[] getBytesForSlot(String input, int slot) {
- return getBytesForSlot(input, slot, false /* include rest */);
- }
-
- /**
- * Convert the input to bytes and get the bytes in the given slot delimited by slash (/).
- * @param input
- * @param slot
- * @return
- */
- private byte[] getBytesForSlot(String input, int slot, boolean includeRest) {
- byte[] result = Util.getBytesForSlot(input.getBytes(), (byte) '/', slot, includeRest);
- return result;
- }
-
- private void assertEqualBytes(String expected, byte[] actual) {
- assertEquals(expected, new String(actual));
- }
-
- public void testUtilGetBytesForSlot() {
- // test success cases
- String input = "zero/one/two";
- assertEqualBytes("zero", getBytesForSlot(input, 0));
- assertEqualBytes("one", getBytesForSlot(input, 1));
- assertEqualBytes("two", getBytesForSlot(input, 2));
- assertEqualBytes("one/two", getBytesForSlot(input, 1, true /* include rest */));
- assertEqualBytes("", getBytesForSlot("///", 0));
- assertEqualBytes("", getBytesForSlot("///", 1));
- assertEqualBytes("", getBytesForSlot("///", 2));
- assertEqualBytes("/", getBytesForSlot("///", 2, true /* include rest */));
-
- // test failure cases
- input = "zero/one/two";
- assertNull(getBytesForSlot(input, 3));
- assertNull(getBytesForSlot(input, 4));
- assertNull(getBytesForSlot(input, -1));
- }
-
- public void testSendEntry() throws CVSException, ParseException {
- ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(":test:user:password@host:/path");
- // disable version detemrination to reduce traffic
- CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(false);
- // create and open a session
- Session session = new Session(location, CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()));
- session.open(DEFAULT_MONITOR, false /* read-only */);
-
- // test a normal entry line
- byte[] entryLine = "/plugin.xml/1.27/Tue Mar 4 19:47:36 2003/-ko/".getBytes();
- session.sendEntry(entryLine, ResourceSyncInfo.getTimestampToServer(entryLine, CVSDateFormatter.entryLineToDate("Tue Mar 4 19:47:36 2003")));
- assertEquals("Entry /plugin.xml/1.27//-ko/", TestConnection.getLastLine());
-
- // test a server merged with conflict entry line
- entryLine = "/newfile.txt/1.10/Result of merge+Thu Mar 20 16:36:56 2003//".getBytes();
- session.sendEntry(entryLine, ResourceSyncInfo.getTimestampToServer(entryLine, CVSDateFormatter.entryLineToDate("Thu Mar 20 16:36:56 2003")));
- assertEquals("Entry /newfile.txt/1.10/+=//", TestConnection.getLastLine());
-
- // test a server merged entry line
- entryLine = "/newfile.txt/1.10/Result of merge+Thu Mar 20 16:36:56 2003//".getBytes();
- session.sendEntry(entryLine, ResourceSyncInfo.getTimestampToServer(entryLine, CVSDateFormatter.entryLineToDate("Thu Mar 20 16:37:56 2003")));
- assertEquals("Entry /newfile.txt/1.10/+modified//", TestConnection.getLastLine());
-
- // test added entry line
- entryLine = "/plugin.xml/0/dummy timestamp/-ko/".getBytes();
- session.sendEntry(entryLine, ResourceSyncInfo.getTimestampToServer(entryLine, CVSDateFormatter.entryLineToDate("Tue Mar 4 19:47:36 2003")));
- assertEquals("Entry /plugin.xml/0//-ko/", TestConnection.getLastLine());
-
- // test empty timestamp entry line
- entryLine = "/plugin.xml/1.1//-ko/".getBytes();
- session.sendEntry(entryLine, ResourceSyncInfo.getTimestampToServer(entryLine, CVSDateFormatter.entryLineToDate("Tue Mar 4 19:47:36 2003")));
- assertEquals("Entry /plugin.xml/1.1//-ko/", TestConnection.getLastLine());
-
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java
deleted file mode 100644
index 1e7d9ad4b..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-import java.util.Date;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class ResourceSyncInfoTest extends EclipseTest {
-
- public ResourceSyncInfoTest() {
- super();
- }
-
- public ResourceSyncInfoTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ResourceSyncInfoTest.class);
- return new CVSTestSetup(suite);
- }
-
- public void testEntryLineParsing() {
-
- // testing malformed entry lines first
- try {
- new ResourceSyncInfo("//////", null, null);
- fail();
- } catch(CVSException e) {
- // Error expected
- }
- try {
- new ResourceSyncInfo("//1.1///", null, null);
- fail();
- } catch(CVSException e) {
- // Error expected
- }
- try {
- new ResourceSyncInfo("/file.txt////", null, null);
- fail();
- } catch(CVSException e) {
- // Error expected
- }
- try {
- new ResourceSyncInfo("/file.txt//////////", null, null);
- fail();
- } catch(CVSException e) {
- // Error expected
- }
- }
-
- public void testEntryLineConstructor() throws CVSException {
- ResourceSyncInfo info;
- info = new ResourceSyncInfo("/file.java/-1.1/Mon Feb 25 21:44:02 2002/-k/", null, null);
- assertTrue(info.isDeleted());
-
- info = new ResourceSyncInfo("/file.java/0/something/-k/", null, null);
- assertTrue(info.isAdded());
-
- info = new ResourceSyncInfo("/file.java/1.0/Mon Feb 25 21:44:02 2002/-k/Tv1", null, null);
- assertTrue(info.getTag() != null);
-
- Date timestamp = new Date(123000);
- info = new ResourceSyncInfo("/file.java/1.0/Mon Feb 25 21:44:02 2002/-k/Tv1", null, timestamp);
- assertTrue(info.getTimeStamp().equals(timestamp));
-
- info = new ResourceSyncInfo("/file.java/0/Mon Feb 25 21:44:02 2002/-k/", null, timestamp);
- assertTrue(info.getTimeStamp().equals(timestamp));
-
- String permissions = "u=rwx,g=rwx,o=rwx";
- info = new ResourceSyncInfo("/file.java/2.0/Mon Feb 25 21:44:02 2002/-k/Tv1", permissions, null);
- assertTrue(info.getPermissions().equals(permissions));
-
- info = new ResourceSyncInfo("D/file.java////", null, null);
- assertTrue(info.isDirectory());
- }
-
- public void testConstructor() throws CVSException {
- ResourceSyncInfo info;
-
- info = new ResourceSyncInfo("folder");
- assertTrue(info.isDirectory());
-
- info = new ResourceSyncInfo("/file.java/-2.34/Mon Feb 25 21:44:02 2002/-k/Tv1", null, null);
- assertTrue(info.isDeleted());
- assertTrue(info.getRevision().equals("2.34"));
-
- info = new ResourceSyncInfo("/file.java/0/Mon Feb 25 21:44:02 2002/-k/Tv1", null, null);
- assertTrue(info.isAdded());
- }
-
- public void testMergeTimestamps() throws CVSException {
- ResourceSyncInfo info, info2;
- Date timestamp = new Date(123000);
- Date timestamp2 = new Date(654000);
-
- info = new ResourceSyncInfo("/file.java/1.1//-kb/", null, timestamp);
- assertTrue(!info.isMerged());
- assertTrue(!info.isNeedsMerge(timestamp));
-
- // test merged entry lines the server and ensure that their entry line format is compatible
- info = new ResourceSyncInfo("/file.java/1.1/+=/-kb/", null, timestamp);
- String entryLine = info.getEntryLine();
- info2 = new ResourceSyncInfo(entryLine, null, null);
- assertTrue(info.isMerged() && info2.isMerged());
- assertTrue(info.isNeedsMerge(timestamp) && info2.isNeedsMerge(timestamp));
- assertTrue(!info.isNeedsMerge(timestamp2) && !info2.isNeedsMerge(timestamp2));
- assertTrue(info.getTimeStamp().equals(timestamp) && info2.getTimeStamp().equals(timestamp));
-
- info = new ResourceSyncInfo("/file.java/1.1/+modified/-kb/", null, null);
- entryLine = info.getEntryLine();
- info2 = new ResourceSyncInfo(entryLine, null, null);
- assertTrue(info.isMerged() && info2.isMerged());
- assertTrue(!info.isNeedsMerge(timestamp) && !info2.isNeedsMerge(timestamp));
- assertTrue(!info.isNeedsMerge(timestamp2) && !info2.isNeedsMerge(timestamp2));
- assertTrue(info.getTimeStamp()==null && info2.getTimeStamp()==null);
- }
-
- public void testTimestampCompatibility() throws CVSException, CoreException {
- String entryLine1 = "/a.bin/1.1/Mon Feb 9 21:44:02 2002/-kb/";
- String entryLine2 = "/a.bin/1.1/Mon Feb 9 21:44:02 2002/-kb/";
- String entryLine3 = "/a.bin/1.1/Mon Feb 09 21:44:02 2002/-kb/";
- ResourceSyncInfo info1 = new ResourceSyncInfo(entryLine1, null, null);
- ResourceSyncInfo info2 = new ResourceSyncInfo(entryLine2, null, null);
- ResourceSyncInfo info3 = new ResourceSyncInfo(entryLine3, null, null);
- Date date1 = info1.getTimeStamp();
- Date date2 = info2.getTimeStamp();
- Date date3 = info3.getTimeStamp();
- assertTrue(date1.equals(date2));
- assertTrue(date1.equals(date3));
- assertTrue(date2.equals(date3));
- }
-
- public void testRevisionComparison() {
- assertTrue(ResourceSyncInfo.isLaterRevision("1.9", "1.8"));
- assertTrue( ! ResourceSyncInfo.isLaterRevision("1.8", "1.8"));
- assertTrue( ! ResourceSyncInfo.isLaterRevision("1.8", "1.9"));
-
- assertTrue(ResourceSyncInfo.isLaterRevision("1.8.1.2", "1.8"));
- assertTrue( ! ResourceSyncInfo.isLaterRevision("1.8", "1.8.1.2"));
- assertTrue( ! ResourceSyncInfo.isLaterRevision("1.8.1.2", "1.7"));
-
- assertTrue( ! ResourceSyncInfo.isLaterRevision("0", "1.1"));
- assertTrue(ResourceSyncInfo.isLaterRevision("1.1", "0"));
- }
-
- public void testRevisionOnBranchComparison() throws CVSException {
- ResourceSyncInfo syncInfo1 = new ResourceSyncInfo("/name/1.5/dummy timestamp//", null, null);
- ResourceSyncInfo syncInfo2 = new ResourceSyncInfo("/name/1.4/dummy timestamp//", null, null);
-
- ResourceSyncInfo syncInfo3 = new ResourceSyncInfo("/name/1.4.1.2/dummy timestamp//Nb1", null, null);
- ResourceSyncInfo syncInfo4 = new ResourceSyncInfo("/name/1.4/dummy timestamp//Nb1", null, null);
-
- ResourceSyncInfo syncInfo5 = new ResourceSyncInfo("/name/1.4.1.2/dummy timestamp//Tv1", null, null);
-
- assertTrue(ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo1.getBytes(), syncInfo2.getBytes()));
- assertTrue( ! ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo2.getBytes(), syncInfo1.getBytes()));
- assertTrue( ! ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo1.getBytes(), syncInfo1.getBytes()));
-
- assertTrue(ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo3.getBytes(), syncInfo4.getBytes()));
- assertTrue( ! ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo4.getBytes(), syncInfo3.getBytes()));
- assertTrue( ! ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo4.getBytes(), syncInfo4.getBytes()));
-
- assertTrue( ! ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo5.getBytes(), syncInfo4.getBytes()));
- assertTrue( ! ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo4.getBytes(), syncInfo5.getBytes()));
- assertTrue( ! ResourceSyncInfo.isLaterRevisionOnSameBranch(syncInfo5.getBytes(), syncInfo5.getBytes()));
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java
deleted file mode 100644
index 594b6c78b..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class AllTestsProvider extends EclipseTest {
-
- public AllTestsProvider() {
- super();
- }
-
- public AllTestsProvider(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- //suite.addTestSuite(ModuleTest.class);
- suite.addTest(ImportTest.suite());
- suite.addTest(RemoteResourceTest.suite());
- suite.addTest(CVSProviderTest.suite());
- suite.addTest(ResourceDeltaTest.suite());
- suite.addTest(WatchEditTest.suite());
- suite.addTest(LinkResourcesTest.suite());
- suite.addTest(IsModifiedTests.suite());
- return new CVSTestSetup(suite);
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
deleted file mode 100644
index 3ac8b4925..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
+++ /dev/null
@@ -1,551 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-import java.io.*;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.Test;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.*;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-/*
- * This class tests both the CVSProvider and the CVSTeamProvider
- */
-public class CVSProviderTest extends EclipseTest {
-
- /**
- * Constructor for CVSProviderTest
- */
- public CVSProviderTest() {
- super();
- }
-
- /**
- * Constructor for CVSProviderTest
- */
- public CVSProviderTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return suite(CVSProviderTest.class);
- }
-
- public void testAdd() throws TeamException, CoreException {
-
- // Test add with cvsignores
- /*
- IProject project = createProject("testAdd", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- IFile file = project.getFile(".cvsignore");
- file.create(new ByteArrayInputStream("ignored.txt".getBytes()), false, null);
- file = project.getFile("ignored.txt");
- file.create(new ByteArrayInputStream("some text".getBytes()), false, null);
- file = project.getFile("notignored.txt");
- file.create(new ByteArrayInputStream("some more text".getBytes()), false, null);
- file = project.getFile("folder1/.cvsignore");
- file.create(new ByteArrayInputStream("ignored.txt".getBytes()), false, null);
- file = project.getFile("folder1/ignored.txt");
- file.create(new ByteArrayInputStream("some text".getBytes()), false, null);
- file = project.getFile("folder1/notignored.txt");
- file.create(new ByteArrayInputStream("some more text".getBytes()), false, null);
-
- getProvider(project).add(new IResource[] {project}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
-
- assertTrue( ! CVSWorkspaceRoot.getCVSResourceFor(project.getFile("ignored.txt")).isManaged());
- assertTrue( ! CVSWorkspaceRoot.getCVSResourceFor(project.getFile("folder1/ignored.txt")).isManaged());
-
- assertTrue(CVSWorkspaceRoot.getCVSResourceFor(project.getFile("notignored.txt")).isManaged());
- assertTrue(CVSWorkspaceRoot.getCVSResourceFor(project.getFile("folder1/notignored.txt")).isManaged());
- assertTrue(CVSWorkspaceRoot.getCVSResourceFor(project.getFile(".cvsignore")).isManaged());
- assertTrue(CVSWorkspaceRoot.getCVSResourceFor(project.getFile("folder1/.cvsignore")).isManaged());
- */
- }
-
- public void testDeleteHandling() throws TeamException, CoreException {
-
- IProject project = createProject("testDeleteHandling", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // Delete a file and ensure that it is an outgoing deletion
- project.getFile("deleted.txt").delete(false, false, null);
- ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(project.getFile("deleted.txt"));
- assertTrue("File is not outgoing deletion", file.getSyncInfo().isDeleted());
-
- // Delete a folder and ensure that the file is managed but doesn't exist
- // (Special behavior is provider by the CVS move/delete hook but this is not part of CVS core)
- project.getFolder("folder1").delete(false, false, null);
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project.getFolder("folder1"));
- assertTrue("Deleted folder not in proper state", ! folder.exists() && folder.isManaged());
- }
-
- public void testCheckin() throws TeamException, CoreException, IOException {
- IProject project = createProject("testCheckin", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // Perform some operations on the project
- IResource[] newResources = buildResources(project, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
- setContentsAndEnsureModified(project.getFile("changed.txt"));
- addResources(newResources);
- deleteResources(new IResource[] {project.getFile("deleted.txt")});
- assertIsModified("testDeepCheckin: ", newResources);
- assertIsModified("testDeepCheckin: ", new IResource[] {project.getFile("deleted.txt"), project.getFile("changed.txt")});
- commitResources(new IResource[] {project}, IResource.DEPTH_INFINITE);
- assertLocalStateEqualsRemote(project);
- }
-
- public void testMoveHandling() throws TeamException, CoreException {
- IProject project = createProject("testMoveHandling", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // Move a file and ensure that it is an outgoing deletion at the source and unmanaged at the destination
- project.getFile("deleted.txt").move(new Path("moved.txt"), false, false, null);
- ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(project.getFile("deleted.txt"));
- assertTrue("Source is not outgoing deletion", file.getSyncInfo().isDeleted());
- file = CVSWorkspaceRoot.getCVSFileFor(project.getFile("moved.txt"));
- assertTrue("Destination not in proper state", ! file.isManaged());
-
- // Move a folder and ensure the source is deleted
- project.getFolder("folder1").move(new Path("moved"), false, false, null);
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project.getFolder("folder1"));
- assertTrue("Deleted folder not in proper state", ! folder.exists() && folder.isManaged());
- folder = CVSWorkspaceRoot.getCVSFolderFor(project.getFolder("moved"));
- assertTrue("Moved folder should not be managed", ! folder.isManaged());
- assertTrue("Moved folder should not be a CVS folder", ! folder.isCVSFolder());
- }
-
- public void testUpdate() throws TeamException, CoreException, IOException {
- // Create a test project, import it into cvs and check it out
- IProject project = createProject("testUpdate", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // Check the project out under a different name
- IProject copy = checkoutCopy(project, "-copy");
-
- // Perform some operations on the copy
- addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
- setContentsAndEnsureModified(copy.getFile("changed.txt"));
- deleteResources(new IResource[] {copy.getFile("deleted.txt")});
-
- // Commit the copy and update the project
- commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE);
- updateProject(project, null, false);
- assertEquals(project, copy);
- }
-
- public void testVersionTag() throws TeamException, CoreException, IOException {
-
- // Create a test project, import it into cvs and check it out
- IProject project = createProject("testVersionTag", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // Perform some operations on the copy and commit
- IProject copy = checkoutCopy(project, "-copy");
- addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
- changeResources(copy, new String[] {"changed.txt"}, false);
- deleteResources(copy, new String[] {"deleted.txt"}, false);
- commitResources(copy, true);
-
- // Tag the original, checkout the tag and compare with original
- CVSTag v1Tag = new CVSTag("v1", CVSTag.VERSION);
- tagProject(project, v1Tag, false);
- IProject v1 = checkoutCopy(project, v1Tag);
- assertEquals(project, v1);
-
- // Update original to HEAD and compare with copy including tags
- updateProject(project, null, false);
- assertEquals(project, copy, false, true);
-
- // Update copy to v1 and compare with the copy (including tag)
- updateProject(copy, v1Tag, false);
- assertEquals(copy, v1, false, true);
-
- // Update copy back to HEAD and compare with project (including tag)
- updateProject(copy, CVSTag.DEFAULT, false);
- assertEquals(project, copy, false, true);
- }
-
- public void testMakeBranch() throws TeamException, CoreException, IOException {
- // Create a test project
- IProject project = createProject("testMakeBranch", new String[] { "file1.txt", "file2.txt", "file3.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Make some local modifications including "cvs adds" and "cvs removes"
- addResources(project, new String[] {"folder1/c.txt"}, false);
- deleteResources(project, new String[] {"folder1/b.txt"}, false);
- changeResources(project, new String[] {"file2.txt"}, false);
-
- // Make the branch including a pre-version
- CVSTag version = new CVSTag("v1", CVSTag.BRANCH);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- makeBranch(new IResource[] {project}, version, branch, true);
-
- // Checkout a copy from the branch and version and compare
- IProject branchCopy = checkoutCopy(project, branch);
- IProject versionCopy = checkoutCopy(project, branch);
- assertEquals(branchCopy, versionCopy, true, false);
-
- // Commit the project, update the branch and compare
- commitProject(project);
- updateProject(branchCopy, null, false);
- assertEquals(branchCopy, project, false, true);
- }
-
- public void testPruning() throws TeamException, CoreException, IOException {
- // Create a project with empty folders
- CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(false);
- IProject project = createProject("testPruning", new String[] { "file.txt", "folder1/", "folder2/folder3/" });
-
- // Disable pruning, checkout a copy and ensure original and copy are the same
- IProject copy = checkoutCopy(project, "-copy");
- assertEquals(project, copy);
-
- // Enable pruning, update copy and ensure emtpy folders are gone
- CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(true);
- updateProject(copy, null, false);
- assertDoesNotExistInFileSystem(new IResource[] {copy.getFolder("folder1"), copy.getFolder("folder2"), copy.getFolder("folder2/folder3")});
-
- // Checkout another copy and ensure that the two copies are the same (with pruning enabled)
- IProject copy2 = checkoutCopy(project, "-copy2");
- assertEquals(copy, copy2);
-
- // Disable pruning, update copy and ensure directories come back
- CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(false);
- updateProject(copy, null, false);
- assertEquals(project, copy);
-
- // Enable pruning again since it's the default
- CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(true);
- }
-
- public void testGet() throws TeamException, CoreException, IOException {
-
- // Create a project
- IProject project = createProject("testGet", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // Checkout a copy and modify locally
- IProject copy = checkoutCopy(project, "-copy");
- //addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
- deleteResources(copy, new String[] {"deleted.txt"}, false);
- setContentsAndEnsureModified(copy.getFile("changed.txt"));
-
- // get the remote conetns
- replace(new IResource[] {copy}, null, true);
- assertEquals(project, copy);
- }
-
- public void testReadOnly() throws TeamException, CoreException, IOException {
- IProject project = createProject("testReadOnly", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- // Need to check the project out as read-only
- }
-
- public void testCleanLineDelimiters() throws TeamException, CoreException, IOException {
- // Create a project
- IProject project = getUniqueTestProject("testCleanLineDelimiters");
- IFile file = project.getFile("testfile");
- IProgressMonitor monitor = new NullProgressMonitor();
-
- // empty file
- setFileContents(file, "");
- CVSTeamProvider.cleanLineDelimiters(file, false, monitor);
- assertEqualsFileContents(file, "");
- CVSTeamProvider.cleanLineDelimiters(file, true, monitor);
- assertEqualsFileContents(file, "");
-
- // one byte
- setFileContents(file, "a");
- CVSTeamProvider.cleanLineDelimiters(file, false, monitor);
- assertEqualsFileContents(file, "a");
- CVSTeamProvider.cleanLineDelimiters(file, true, monitor);
- assertEqualsFileContents(file, "a");
-
- // single orphan carriage return (should be preserved)
- setFileContents(file, "\r");
- CVSTeamProvider.cleanLineDelimiters(file, false, monitor);
- assertEqualsFileContents(file, "\r");
- CVSTeamProvider.cleanLineDelimiters(file, true, monitor);
- assertEqualsFileContents(file, "\r");
-
- // single line feed
- setFileContents(file, "\n");
- CVSTeamProvider.cleanLineDelimiters(file, false, monitor);
- assertEqualsFileContents(file, "\n");
- CVSTeamProvider.cleanLineDelimiters(file, true, monitor);
- assertEqualsFileContents(file, "\r\n");
-
- // single carriage return line feed
- setFileContents(file, "\r\n");
- CVSTeamProvider.cleanLineDelimiters(file, true, monitor);
- assertEqualsFileContents(file, "\r\n");
- CVSTeamProvider.cleanLineDelimiters(file, false, monitor);
- assertEqualsFileContents(file, "\n");
-
- // mixed text with orphaned CR's
- setFileContents(file, "The \r\n quick brown \n fox \r\r\r\n jumped \n\n over \r\n the \n lazy dog.\r\n");
- CVSTeamProvider.cleanLineDelimiters(file, false, monitor);
- assertEqualsFileContents(file, "The \n quick brown \n fox \r\r\n jumped \n\n over \n the \n lazy dog.\n");
- setFileContents(file, "The \r\n quick brown \n fox \r\r\r\n jumped \n\n over \r\n the \n lazy dog.\r\n");
- CVSTeamProvider.cleanLineDelimiters(file, true, monitor);
- assertEqualsFileContents(file, "The \r\n quick brown \r\n fox \r\r\r\n jumped \r\n\r\n over \r\n the \r\n lazy dog.\r\n");
- }
-
- public void testKeywordSubstitution() throws TeamException, CoreException, IOException {
- testKeywordSubstitution(Command.KSUBST_BINARY); // -kb
- testKeywordSubstitution(Command.KSUBST_TEXT); // -ko
- testKeywordSubstitution(Command.KSUBST_TEXT_EXPAND); // -kkv
- }
-
- private void testKeywordSubstitution(KSubstOption ksubst) throws TeamException, CoreException, IOException {
- // setup some known file types
- Team.setAllTypes( new String[] {"xbin", "xtxt"}, new int[] {Team.BINARY, Team.TEXT});
-
- // create a test project
- IProject project = createProject("testKeywordSubstitution", new String[] { "dummy" });
- addResources(project, new String[] { "binary.xbin", "text.xtxt", "folder1/", "folder1/a.xtxt" }, true);
- addResources(project, new String[] { "added.xbin", "added.xtxt" }, false);
- assertHasKSubstOption(project, "binary.xbin", Command.KSUBST_BINARY);
- assertHasKSubstOption(project, "added.xbin", Command.KSUBST_BINARY);
- assertHasKSubstOption(project, "text.xtxt", CVSProviderPlugin.DEFAULT_TEXT_KSUBST_OPTION);
- assertHasKSubstOption(project, "folder1/a.xtxt", CVSProviderPlugin.DEFAULT_TEXT_KSUBST_OPTION);
- assertHasKSubstOption(project, "added.xtxt", CVSProviderPlugin.DEFAULT_TEXT_KSUBST_OPTION);
-
- // change keyword substitution
- Map map = new HashMap();
- map.put(project.getFile("binary.xbin"), ksubst);
- map.put(project.getFile("added.xbin"), ksubst);
- map.put(project.getFile("text.xtxt"), ksubst);
- map.put(project.getFile("folder1/a.xtxt"), ksubst);
- map.put(project.getFile("added.xtxt"), ksubst);
-
- waitMsec(1500);
- IStatus status = getProvider(project).setKeywordSubstitution(map, null, null);
- assertTrue("Status should be ok, was: " + status.toString(), status.isOK());
- assertHasKSubstOption(project, "binary.xbin", ksubst);
- assertHasKSubstOption(project, "text.xtxt", ksubst);
- assertHasKSubstOption(project, "folder1/a.xtxt", ksubst);
- assertHasKSubstOption(project, "added.xtxt", ksubst);
- assertHasKSubstOption(project, "added.xbin", ksubst);
-
- // verify that substitution mode changed remotely and "added.xtxt", "added.xbin" don't exist
- IProject copy = checkoutCopy(project, "-copy");
- assertHasKSubstOption(copy, "binary.xbin", ksubst);
- assertHasKSubstOption(copy, "text.xtxt", ksubst);
- assertHasKSubstOption(copy, "folder1/a.xtxt", ksubst);
- assertDoesNotExistInWorkspace(copy.getFile("added.xtxt"));
- assertDoesNotExistInWorkspace(copy.getFile("added.xbin"));
-
- // commit added files then checkout the copy again
- commitResources(project, new String[] { "added.xbin", "added.xtxt" });
- IProject copy2 = checkoutCopy(project, "-copy2");
- assertHasKSubstOption(copy2, "added.xtxt", ksubst);
- assertHasKSubstOption(copy2, "added.xbin", ksubst);
-
- IFileTypeInfo[] infos = Team.getDefaultTypes();
- String[] extensions = new String[infos.length];
- int[] types = new int[infos.length];
- for (int i = 0; i < infos.length; i++) {
- IFileTypeInfo info = infos[i];
- extensions[i] = info.getExtension();
- types[i] = info.getType();
- }
- Team.setAllTypes(extensions, types);
- }
-
- public void testKeywordSubsBinToText() throws TeamException, CoreException, IOException {
- //create a test project
- KSubstOption ksubst = Command.KSUBST_TEXT;
- IProject project = createProject("testKeywordSubsBinToText", new String[] { "dummy" });
- assertHasKSubstOption(project, "dummy", Command.KSUBST_BINARY);
-
- // change keyword substitution
- Map map = new HashMap();
- map.put(project.getFile("dummy"), ksubst);
-
- // change from binary to text should commit a new file with
- waitMsec(1500);
- IStatus status = getProvider(project).setKeywordSubstitution(map, null, null);
- assertTrue("Status should be ok, was: " + status.toString(), status.isOK());
- assertHasKSubstOption(project, "dummy", ksubst);
-
- IProject copy = checkoutCopy(project, "-copy");
- assertHasKSubstOption(copy, "dummy", ksubst);
- assertEquals(project, copy);
- }
-
- public static void setFileContents(IFile file, String string) throws CoreException {
- InputStream is = new ByteArrayInputStream(string.getBytes());
- if (file.exists()) {
- file.setContents(is, false /*force*/, true /*keepHistory*/, null);
- } else {
- file.create(is, false /*force*/, null);
- }
- }
-
- public static void assertEqualsFileContents(IFile file, String string) throws CoreException, IOException {
- String other = getFileContents(file);
- assertEquals(string, other);
- }
-
- public static void assertHasKSubstOption(IContainer container, String filename, KSubstOption ksubst)
- throws TeamException {
- IFile file = container.getFile(new Path(filename));
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
- ResourceSyncInfo info = cvsFile.getSyncInfo();
- assertEquals(ksubst, info.getKeywordMode());
- }
-
- public void testUnmap() throws CoreException, TeamException {
- // Create a project
- IProject project = createProject("testUnmap", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/", "folder1/folder2/deep.txt", "folder2/b.txt" });
- // delete a file and folder to create phantoms
- project.getFile("deleted.txt").delete(false, false, null);
- assertTrue(project.getFile("deleted.txt").isPhantom());
- project.getFolder("folder2").delete(false, false, null);
- assertTrue(project.getFolder("folder2").isPhantom());
- // unmap
- RepositoryProvider.unmap(project);
- // ensure that phantoms for the resoucrs no longer exist
- assertFalse(project.getFile("deleted.txt").isPhantom());
- assertFalse(project.getFolder("folder2").isPhantom());
-
- // Create a project
- project = createProject("testUnmap2", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/", "folder1/folder2/deep.txt", "folder2/b.txt" });
- // delete a deep folder to create phantoms
- project.getFolder("folder1/folder2").delete(false, false, null);
- assertTrue(project.getFolder("folder1/folder2").isPhantom());
- // unmap
- RepositoryProvider.unmap(project);
- // ensure that phantoms for the resources no longer exist
- assertFalse(project.getFolder("folder1/folder2").isPhantom());
- }
-
- public void testForBinaryLinefeedCorruption() throws CoreException, TeamException, IOException {
- String EOL = "\n";
- IProject project = createProject("testForBinaryLinefeedCorruption", new String[] { "binaryFile" });
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(project.getFile("binaryFile"));
- assertTrue(ResourceSyncInfo.isBinary(cvsFile.getSyncBytes()));
- setContentsAndEnsureModified(project.getFile("binaryFile"), "line 1" + EOL + "line 2");
- commitProject(project);
-
- // Checkout a copy and ensure the file was not corrupted
- IProject copy = checkoutCopy(project, "-copy");
- assertEquals(project, copy);
- }
-
- public void test33984CannotCommitAfterConflictsMergedLocally() throws CoreException, TeamException, IOException {
- String EOL = System.getProperty("line.separator");
-
- IProject project = createProject("test33984", new String[] { "a.txt", "b.txt" });
- setContentsAndEnsureModified(project.getFile("a.txt"), "line 1");
- setContentsAndEnsureModified(project.getFile("b.txt"), ("line 1" + EOL + "line 2" + EOL + "line3"));
-
- Map kMode = new HashMap();
- kMode.put(project.getFile("a.txt"), Command.KSUBST_TEXT);
- kMode.put(project.getFile("b.txt"), Command.KSUBST_TEXT);
- getProvider(project).setKeywordSubstitution(kMode, "", null);
-
- commitProject(project);
-
-
-
- // Checkout a copy and ensure the file was not corrupted
- IProject copy = checkoutCopy(project, "-copy");
- assertEquals(project, copy);
-
- // TEST 1: simulate modifying same file by different users
- // b.txt has non-conflicting changes
- setContentsAndEnsureModified(copy.getFile("b.txt"), ("line 1a" + EOL + "line 2" + EOL + "line3"));
-
- commitProject(copy);
-
- // user updates which would cause a merge with conflict, a commit should not be allowed
-
- setContentsAndEnsureModified(project.getFile("b.txt"), ("line 1" + EOL + "line 2" + EOL + "line3a"));
- updateProject(project, CVSTag.DEFAULT, false /* don't ignore local changes */);
- commitProject(project);
-
- // TEST 2: a.txt has conflicting changes
- setContentsAndEnsureModified(copy.getFile("a.txt"), "line 1dfgdfne3");
-
- commitProject(copy);
-
- // user updates which would cause a merge with conflict, a commit should not be allowed
- setContentsAndEnsureModified(project.getFile("a.txt"), "some other text");
- updateProject(project, CVSTag.DEFAULT, false /* don't ignore local changes */);
- try {
- commitProject(project);
- fail("should not be allowed to commit a resource with merged conflicts");
- } catch(TeamException e) {
- }
- }
-
- public void testTagExistsFailure() throws TeamException, CoreException, IOException {
- IProject project = createProject(new String[] { "a.txt", "b.txt" });
- CVSTag tag = new CVSTag("v1", CVSTag.VERSION);
- tagProject(project, tag, false);
-
- setContentsAndEnsureModified(project.getFile("a.txt"));
- commitProject(project);
-
- try {
- tagProject(project, tag, false/* don't force */);
- fail("The tag should have failed since the tag already exists.");
- } catch (TeamException e) {
- // This is what we expected
- assertTrue("This exception should be an error", e.getStatus().getSeverity() == IStatus.ERROR);
- }
-
- tagProject(project, tag, true /* force */);
- IProject copy = checkoutCopy(project, tag);
- assertEquals(project, copy);
- }
-
- public void testUpdateWithOverwrite() throws TeamException, CoreException {
- // Create a project and ad an unmanaged resource
- IProject project = createProject(new String[] { "a.txt", "b.txt" });
- buildResources(project, new String[] { "new.txt" }, false);
- // Checkout a copy and commit the same resource
- IProject copy = checkoutCopy(project, "-copy");
- addResources(copy, new String[] { "new.txt" }, true);
- IStatus status;
- try {
- // Use the regular update and ensure that it fails
- status = executeCommand(project, Command.UPDATE, Command.NO_LOCAL_OPTIONS);
- fail();
- } catch (CVSException e) {
- // This is expected as the creation of the file failed;
- }
- // Use the update and overwrite and ensure that it works
- status = executeCommand(project, Command.REPLACE, Command.NO_LOCAL_OPTIONS);
- assertTrue(status.isOK());
- }
-
- private IStatus executeCommand(IProject project, Update update, LocalOption[] options) throws CVSException {
- Session session = new Session(getRepository(), CVSWorkspaceRoot.getCVSFolderFor(project));
- session.open(DEFAULT_MONITOR);
- try {
- return update.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- options,
- new String[] { "." },
- null,
- DEFAULT_MONITOR);
- } finally {
- session.close();
- }
-
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ConcurrencyTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ConcurrencyTests.java
deleted file mode 100644
index 47370d8ef..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ConcurrencyTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.operations.FetchMembersOperation;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-import org.eclipse.ui.progress.IElementCollector;
-
-public class ConcurrencyTests extends EclipseTest {
-
- public ConcurrencyTests() {
- super();
- }
-
- public ConcurrencyTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(ConcurrencyTests.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new ConcurrencyTests(testName));
- }
- }
-
- public void testBackgroundMemberFetch() throws CoreException, InvocationTargetException, InterruptedException {
- IProject project = createProject("testBackgroundMemberFetch", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt", "folder2/folder3/", "folder2/folder3/b.txt", "folder2/folder3/c.txt"});
- ICVSRemoteFolder folder = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project);
- final List result = new ArrayList();
- final boolean[] done = new boolean[] { false };
- IElementCollector collector = new IElementCollector() {
- public void add(Object element, IProgressMonitor monitor) {
- result.add(element);
- }
- public void add(Object[] elements, IProgressMonitor monitor) {
- result.addAll(Arrays.asList(elements));
- }
- public void done() {
- done[0] = true;
- }
- };
-
- FetchMembersOperation operation = new FetchMembersOperation(null, folder, collector) {
- public void done(IJobChangeEvent event) {
- done[0] = true;
- super.done(event);
- }
- };
- operation.run();
- int count = 0;
- while (!done[0]) {
- Thread.sleep(1000);
- count++;
- if (count > 5) {
- fail("Fetch of memebers didn't complete in " + count + " seconds");
- }
- }
- assertTrue(result.size() == project.members().length);
- for (Iterator iter = result.iterator(); iter.hasNext();) {
- ICVSRemoteResource remote = (ICVSRemoteResource) iter.next();
- IResource local = project.findMember(remote.getName());
- assertNotNull(local);
- }
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java
deleted file mode 100644
index c74dbd5d2..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-/**
- * @version 1.0
- * @author ${user}
- */
-public class ImportTest extends EclipseTest {
-
- /**
- * Constructor for ImportTest.
- */
- public ImportTest() {
- super();
- }
-
- /**
- * Constructor for ImportTest.
- * @param name
- */
- public ImportTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ImportTest.class);
- return new CVSTestSetup(suite);
- //return new CVSTestSetup(new ImportTest("testReadOnly"));
- }
-
- // Assert that the two containers have equal contents
- protected void assertEquals(IContainer container1, IContainer container2) throws CoreException {
- assertEquals(container1.getName(), container2.getName());
- List members1 = new ArrayList();
- members1.addAll(Arrays.asList(container1.members()));
- members1.remove(container1.findMember("CVS"));
-
- List members2 = new ArrayList();
- members2.addAll(Arrays.asList(container2.members()));
- members2.remove(container2.findMember("CVS"));
-
- assertTrue(members1.size() == members2.size());
- for (int i=0;i<members1.size();i++) {
- IResource member1 = (IResource)members1.get(i);
- IResource member2 = container2.findMember(member1.getName());
- assertNotNull(member2);
- assertEquals(member1, member2);
- }
- }
-
- // Assert that the two files have equal contents
- protected void assertEquals(IFile file1, IFile file2) throws CoreException {
- assertEquals(file1.getName(), file2.getName());
- assertTrue(compareContent(file1.getContents(), file2.getContents()));
- }
-
- // Assert that the two projects have equal contents ignoreing the project name
- // and the .vcm_meta file
- protected void assertEquals(IProject container1, IProject container2) throws CoreException {
- List members1 = new ArrayList();
- members1.addAll(Arrays.asList(container1.members()));
- members1.remove(container1.findMember(".project"));
- members1.remove(container1.findMember("CVS"));
-
- List members2 = new ArrayList();
- members2.addAll(Arrays.asList(container2.members()));
- members2.remove(container2.findMember(".project"));
- members2.remove(container2.findMember("CVS"));
-
- assertTrue("Number of children differs for " + container1.getFullPath(), members1.size() == members2.size());
- for (int i=0;i<members1.size();i++) {
- IResource member1 = (IResource)members1.get(i);
- IResource member2 = container2.findMember(member1.getName());
- assertNotNull(member2);
- assertEquals(member1, member2);
- }
- }
- protected void assertEquals(IResource resource1, IResource resource2) throws CoreException {
- assertEquals(resource1.getType(), resource2.getType());
- if (resource1.getType() == IResource.FILE)
- assertEquals((IFile)resource1, (IFile)resource2);
- else
- assertEquals((IContainer)resource1, (IContainer)resource2);
- }
-
- public void testImportAndCheckout() throws TeamException, CoreException {
- // Create a test project and import it into cvs
- IProject project = getUniqueTestProject("testImport");
- IResource[] result = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt" }, true);
- importProject(project);
-
- // Check it out under a different name and validate that the results are the same
- IProject copy = getWorkspace().getRoot().getProject(project.getName() + "Copy");
- checkout(getRepository(), copy, project.getName(), null, DEFAULT_MONITOR);
- assertValidCheckout(copy);
- assertEquals(project, copy);
- }
-
- public void testCheckout() throws TeamException, CoreException, IOException {
- // Create a project and checkout a copy
- IProject project = createProject("testCheckout", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- IProject copy = checkoutCopy(project, "-copy");
-
- // 0. checkout the project again
- project = checkoutProject(project, null, null);
- assertEquals(project, copy, true, true);
-
- // 1. Delete the project but not it's contents and checkout the project again
- project.delete(false, false, DEFAULT_MONITOR);
- project = checkoutProject(project, null, null);
- assertEquals(project, copy, true, true);
-
- // 2. Delete the project and its contents and use the module name instead of the project
- project.delete(true, false, DEFAULT_MONITOR);
- project = checkoutProject(null, project.getName(), null);
- assertEquals(project, copy, true, true);
-
- // 3. Create a project in a custom location and check out over it
- project.delete(true, false, DEFAULT_MONITOR);
- IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(project.getName());
- //desc.setLocation(new Path("C:\\temp\\project"));
- project.create(desc, DEFAULT_MONITOR);
- project = checkoutProject(project, null, null);
- assertEquals(project, copy, true, true);
-
- // 4. Checkout something that doesn't contain a .project
- project.delete(true, false, DEFAULT_MONITOR);
- project = checkoutProject(null, project.getName() + "/folder1", null);
- //assertEquals(project, copy.getFolder("folder1"));
-
-
- }
-
- public void testRootShare() throws CoreException {
- // Create a test project
- IProject project = getUniqueTestProject(getName());
- IResource[] result = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt" }, true);
- // Share the project
- shareProject(getRepository(), project, null, DEFAULT_MONITOR);
- addResources(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt" }, true);
- // Checkout a copy ans test
- IProject copy = checkoutProject(getUniqueTestProject(getName() + "copy"), project.getName(), null);
- assertEquals(project, copy);
- }
-
- public void testNonRootShare() throws CoreException {
- // Create a test project
- IProject project = getUniqueTestProject(getName());
- IResource[] result = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt" }, true);
- // Share it as a non-root folder in the repository
- String moduleName = "root" + Long.toString(System.currentTimeMillis()) + "/" + project.getName();
- shareProject(getRepository(), project, moduleName, DEFAULT_MONITOR);
- addResources(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt" }, true);
- // Checkout a copy and test
- IProject copy = checkoutProject(getUniqueTestProject(getName() + "copy"), moduleName, null);
- assertEquals(project, copy);
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/IsModifiedTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/IsModifiedTests.java
deleted file mode 100644
index cc5c7c8e3..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/IsModifiedTests.java
+++ /dev/null
@@ -1,544 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.*;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.util.ResourceStateChangeListeners;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-/**
- * Test isModified on file, folders and projects.
- */
-public class IsModifiedTests extends EclipseTest {
-
- Set previouslyModified = new HashSet();
- Map changedResources = new HashMap();
- IResourceStateChangeListener listener = new IResourceStateChangeListener() {
- public void resourceSyncInfoChanged(IResource[] changedResources) {
- try {
- for (int i = 0; i < changedResources.length; i++) {
- IResource resource = changedResources[i];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- recordModificationState(cvsResource);
- recordParents(cvsResource);
- if (cvsResource.isFolder()) {
- recordChildren((ICVSFolder)cvsResource);
- }
- }
- } catch (CVSException e) {
- fail(e.getMessage());
- }
- }
- public void externalSyncInfoChange(IResource[] changedResources) {
- resourceSyncInfoChanged(changedResources);
- }
- private void recordChildren(ICVSFolder folder) {
- try {
- folder.accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- recordModificationState(file);
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- recordModificationState(folder);
- folder.acceptChildren(this);
- }
- });
- } catch (CVSException e) {
- fail(e.getMessage());
- }
- }
- private void recordParents(ICVSResource cvsResource) throws CVSException {
- if (cvsResource.getIResource().getType() == IResource.ROOT) return;
- recordModificationState(cvsResource);
- recordParents(cvsResource.getParent());
- }
- private void recordModificationState(ICVSResource cvsResource) throws CVSException {
- IsModifiedTests.this.changedResources.put(cvsResource.getIResource(), cvsResource.isModified(null) ? Boolean.TRUE : Boolean.FALSE);
- }
- public void resourceModified(IResource[] changedResources) {
- try {
- for (int i = 0; i < changedResources.length; i++) {
- IResource resource = changedResources[i];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- IsModifiedTests.this.changedResources.put(resource, cvsResource.isModified(null) ? Boolean.TRUE : Boolean.FALSE);
- recordParents(cvsResource);
- if (cvsResource.isFolder()) {
- recordChildren((ICVSFolder)cvsResource);
- }
- }
- } catch (CVSException e) {
- fail(e.getMessage());
- }
- }
- public void projectConfigured(IProject project) {
- }
- public void projectDeconfigured(IProject project) {
- }
- };
-
- /**
- * Constructor for CVSProviderTest
- */
- public IsModifiedTests() {
- super();
- }
-
- /**
- * Constructor for CVSProviderTest
- */
- public IsModifiedTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(IsModifiedTests.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new IsModifiedTests(testName));
- }
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- previouslyModified.clear();
- changedResources.clear();
- ResourceStateChangeListeners.getListener().addResourceStateChangeListener(listener);
- }
-
- /**
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- previouslyModified.clear();
- changedResources.clear();
- ResourceStateChangeListeners.getListener().removeResourceStateChangeListener(listener);
- super.tearDown();
- }
-
- /*
- * Assert that the modification state of the provided resources matches the
- * provided state and that the other are the opposite state.
- */
- private void assertModificationState(IContainer container, String[] resources, final boolean listedResourcesShouldBeModified) throws CVSException {
- final ICVSFolder rootFolder = CVSWorkspaceRoot.getCVSFolderFor(container);
- final List resourceList = new ArrayList();
- final Set modifiedResources = new HashSet();
- if (resources != null) {
- for (int i = 0; i < resources.length; i++) {
- String string = resources[i];
- resourceList.add(new Path(string));
- }
- }
- waitForIgnoreFileHandling();
- rootFolder.accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- assertModificationState(file);
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // find the deepest mistake
- folder.acceptChildren(this);
- assertModificationState(folder);
- }
- public void assertModificationState(ICVSResource resource) throws CVSException {
- IPath relativePath = new Path(resource.getRelativePath(rootFolder));
- boolean resourceModified = resource.isModified(null);
- boolean resourceListed = resourceList.contains(relativePath);
- assertTrue(resource.getIResource().getFullPath().toString()
- + (resourceModified ? " should not be modified but is" : " should be modified but isn't"),
- (listedResourcesShouldBeModified && (resourceModified == resourceListed)) ||
- (!listedResourcesShouldBeModified && (!resourceModified == resourceListed)));
-
-// Commented because the CVS core doesn't rely on resourceModify to be called.
-// IResource iResource = resource.getIResource();
-// if (resource.isModified()) {
-// modifiedResources.add(iResource);
-// if (!wasPreviouslyModified(iResource)) {
-// // the state has changed, make sure we got a notification
-// Boolean b = (Boolean)changedResources.get(iResource);
-// assertTrue("No notification received for state change of " + iResource.getFullPath().toString(),
-// b == Boolean.TRUE);
-// }
-// } else {
-// if (wasPreviouslyModified(iResource)) {
-// // the state has changed, make sure we got a notification
-// Boolean b = (Boolean)changedResources.get(iResource);
-// assertTrue("No notification received for state change of " + iResource.getFullPath().toString(),
-// b == Boolean.FALSE);
-// }
-// }
- }
- public boolean wasPreviouslyModified(IResource iResource) {
- return previouslyModified.contains(iResource);
- }
- });
- changedResources.clear();
- previouslyModified.clear();
- previouslyModified.addAll(modifiedResources);
- }
-
- /**
- * Assert that a project (and all it's children) is clean after it is
- * created and shared.
- *
- * @see org.eclipse.team.tests.ccvs.core.EclipseTest#createProject(java.lang.String, java.lang.String)
- */
- protected IProject createProject(String prefix, String[] resources) throws CoreException, TeamException {
- IProject project = super.createProject(prefix, resources);
- assertModificationState(project, null, true);
- return project;
- }
-
-
- public void testFileModifications() throws CoreException, TeamException {
- IProject project = createProject("testFileModifications", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- // change two files, commit one and revert the other
- setContentsAndEnsureModified(project.getFile("changed.txt"));
- assertModificationState(project, new String[] {".", "changed.txt"}, true);
- setContentsAndEnsureModified(project.getFile(new Path("folder1/a.txt")));
- assertModificationState(project, new String[] {".", "changed.txt", "folder1/", "folder1/a.txt"}, true);
- commitResources(project, new String[] {"folder1/a.txt"});
- assertModificationState(project, new String[] {".", "changed.txt"}, true);
- replace(new IResource[] {project.getFile("changed.txt")}, null, true);
- assertModificationState(project, null, true);
- }
-
- public void testFileDeletions() throws CoreException, TeamException {
- IProject project = createProject("testFileDeletions", new String[] { "changed.txt", "folder1/", "folder1/deleted.txt", "folder1/a.txt" });
- // delete and commit a file
- project.getFile("folder1/deleted.txt").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/deleted.txt"}, true);
- commitResources(project, new String[] {"folder1/deleted.txt"});
- assertModificationState(project, null, true);
- // modify, delete and revert a file
- setContentsAndEnsureModified(project.getFile("changed.txt"));
- assertModificationState(project, new String[] {".", "changed.txt"}, true);
- project.getFile("changed.txt").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "changed.txt"}, true);
- replace(new IResource[] {project.getFile("changed.txt")}, null, true);
- assertModificationState(project, null, true);
- // modify, delete and commit a file
- setContentsAndEnsureModified(project.getFile("changed.txt"));
- assertModificationState(project, new String[] {".", "changed.txt"}, true);
- project.getFile("changed.txt").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "changed.txt"}, true);
- commitResources(project, new String[] {"changed.txt"});
- assertModificationState(project, null, true);
- // delete, recreate and commit
- project.getFile("folder1/a.txt").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/a.txt"}, true);
- IResource[] addedResources = buildResources(project, new String[] {"folder1/a.txt"}, false);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/a.txt"}, true);
- commitResources(project, new String[] {"folder1/a.txt"});
- assertModificationState(project, null, true);
-
- }
-
- public void testFileAdditions() throws CoreException, TeamException {
- IProject project = createProject("testFileAdditions", new String[] { "changed.txt", "folder1/", "folder1/deleted.txt", "folder1/a.txt" });
- // create, add and commit a file
- IResource[] addedResources = buildResources(project, new String[] {"folder1/added.txt"}, false);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/added.txt"}, true);
- addResources(addedResources);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/added.txt"}, true);
- commitResources(project, new String[] {"folder1/added.txt"});
- assertModificationState(project, null, true);
- // create, add and delete a file
- addResources(project, new String[] {"added.txt"}, false);
- assertModificationState(project, new String[] {".", "added.txt"}, true);
- project.getFile("added.txt").delete(false, false, DEFAULT_MONITOR);
- assertModificationState(project, null, true);
- // create and delete a file
- addedResources = buildResources(project, new String[] {"folder1/another.txt"}, false);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/another.txt"}, true);
- project.getFile("folder1/another.txt").delete(false, false, DEFAULT_MONITOR);
- assertModificationState(project, null, true);
- // create and ignore a file
- addedResources = buildResources(project, new String[] {"ignored.txt"}, false);
- assertModificationState(project, new String[] {".", "ignored.txt"}, true);
- project.getFile(".cvsignore").create(new ByteArrayInputStream("ignored.txt".getBytes()), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", ".cvsignore"}, true);
- addResources(new IResource[] {project.getFile(".cvsignore")});
- assertModificationState(project, new String[] {".", ".cvsignore"}, true);
- commitResources(project, new String[] {".cvsignore"});
- assertModificationState(project, null, true);
- // delete the .cvsignore to see the modification come back
- project.getFile(".cvsignore").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "ignored.txt", ".cvsignore"}, true);
- commitResources(project, new String[] {".cvsignore"});
- assertModificationState(project, new String[] {".", "ignored.txt"}, true);
- // re-add the ignore and then delete the ignored
- project.getFile(".cvsignore").create(new ByteArrayInputStream("ignored.txt".getBytes()), false, DEFAULT_MONITOR);
- addResources(new IResource[] {project.getFile(".cvsignore")});
- assertModificationState(project, new String[] {".", ".cvsignore"}, true);
- commitResources(project, new String[] {".cvsignore"});
- assertModificationState(project, null, true);
- project.getFile("ignored.txt").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, null, true);
- // add the ignored file to version control
- buildResources(project, new String[] {"ignored.txt"}, false);
- assertModificationState(project, null, true);
- addResources(new IResource[] {project.getFile("ignored.txt")});
- assertModificationState(project, new String[] {".", "ignored.txt"}, true);
- commitProject(project);
- assertModificationState(project, null, true);
- }
-
- public void testFileMoveAndCopy() throws CoreException, TeamException {
- IProject project = createProject("testFileMoveAndCopy", new String[] { "changed.txt", "folder1/", "folder2/", "folder1/a.txt" });
- // move a file
- project.getFile("folder1/a.txt").move(project.getFile("folder2/a.txt").getFullPath(), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt"}, true);
- // commit the source
- commitResources(project, new String[] {"folder1/a.txt"});
- assertModificationState(project, new String[] {".", "folder2/", "folder2/a.txt"}, true);
- // copy the destination back to the source
- project.getFolder("folder1").create(false, true, DEFAULT_MONITOR);
- project.getFile("folder2/a.txt").copy(project.getFile("folder1/a.txt").getFullPath(), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt"}, true);
- // add the source, delete the destination and commit
- addResources(new IResource[] {project.getFile("folder1/a.txt")});
- project.getFile("folder2/a.txt").delete(false, DEFAULT_MONITOR);
- commitProject(project);
- assertModificationState(project, null, true);
- // Do the above without committing the source
- project.getFile("folder1/a.txt").move(project.getFile("folder2/a.txt").getFullPath(), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt"}, true);
- // copy the destination back to the source
- project.getFile("folder2/a.txt").copy(project.getFile("folder1/a.txt").getFullPath(), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder2/", "folder2/a.txt"}, true);
- addResources(new IResource[] {project.getFile("folder2/a.txt")});
- commitProject(project);
- assertModificationState(project, null, true);
- }
-
- public void testFolderAdditions() throws CoreException, TeamException {
- IProject project = createProject("testFileAdditions", new String[] { "changed.txt", "folder1/", "folder1/deleted.txt", "folder1/a.txt" });
- // create a folder
- project.getFolder("folder1/folder2").create(false, true, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder2/"}, true);
- addResources(new IResource[] {project.getFolder("folder1/folder2/")});
- assertModificationState(project, null, true);
-
- // create a folder
- project.getFolder("folder1/folder2/folder3").create(false, true, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder2/", "folder1/folder2/folder3"}, true);
- // add some children
- buildResources(project, new String[] {
- "folder1/folder2/folder3/add1.txt",
- "folder1/folder2/folder3/add2.txt",
- "folder1/folder2/folder3/folder4/",
- "folder1/folder2/folder3/folder5/"}, false);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder2/", "folder1/folder2/folder3",
- "folder1/folder2/folder3/add1.txt",
- "folder1/folder2/folder3/add2.txt",
- "folder1/folder2/folder3/folder4/",
- "folder1/folder2/folder3/folder5/"}, true);
- // delete some children
- project.getFile("folder1/folder2/folder3/add2.txt").delete(false, DEFAULT_MONITOR);
- project.getFolder("folder1/folder2/folder3/folder5/").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder2/", "folder1/folder2/folder3",
- "folder1/folder2/folder3/add1.txt",
- "folder1/folder2/folder3/folder4/"}, true);
- // add to version control
- addResources(new IResource[] {
- project.getFile("folder1/folder2/folder3/add1.txt"),
- project.getFolder("folder1/folder2/folder3/folder4/")});
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder2/", "folder1/folder2/folder3",
- "folder1/folder2/folder3/add1.txt"}, true);
- // commit
- commitResources(project, new String[] {"folder1/folder2/folder3/add1.txt"});
- assertModificationState(project, null, true);
-
- // create a folder
- project.getFolder("folder1/ignored").create(false, true, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/ignored/"}, true);
- // add some files
- buildResources(project, new String[] {"folder1/ignored/file.txt"}, false);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/ignored/", "folder1/ignored/file.txt"}, true);
- // ignore the folder
- project.getFile("folder1/.cvsignore").create(new ByteArrayInputStream("ignored".getBytes()), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/.cvsignore"}, true);
- addResources(new IResource[] {project.getFile("folder1/.cvsignore")});
- assertModificationState(project, new String[] {".", "folder1/", "folder1/.cvsignore"}, true);
- commitResources(project, new String[] {"folder1/.cvsignore"});
- assertModificationState(project, null, true);
- // delete the .cvsignore to see the modification come back
- project.getFile("folder1/.cvsignore").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/.cvsignore", "folder1/ignored/", "folder1/ignored/file.txt"}, true);
- commitResources(project, new String[] {"folder1/.cvsignore"});
- assertModificationState(project, new String[] {".", "folder1/", "folder1/ignored/", "folder1/ignored/file.txt"}, true);
- // re-add the .cvsignore and then delete the ignored
- project.getFile("folder1/.cvsignore").create(new ByteArrayInputStream("ignored".getBytes()), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/.cvsignore"}, true);
- addResources(new IResource[] {project.getFile("folder1/.cvsignore")});
- commitResources(project, new String[] {"folder1/.cvsignore"});
- assertModificationState(project, null, true);
- project.getFolder("folder/ignored").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, null, true);
- // add the ignored file to version control
- buildResources(project, new String[] {"folder1/ignored/file.txt"}, false);
- assertModificationState(project, null, true);
- addResources(new IResource[] {project.getFile("folder1/ignored/file.txt")});
- assertModificationState(project, new String[] {".", "folder1/", "folder1/ignored/", "folder1/ignored/file.txt"}, true);
- commitProject(project);
- assertModificationState(project, null, true);
- }
-
- public void testFolderDeletions() throws CoreException, TeamException {
- IProject project = createProject("testFileAdditions", new String[] { "changed.txt", "folder1/", "folder1/deleted.txt", "folder1/a.txt" });
- // create a folder
- project.getFolder("folder1/folder2").create(false, true, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder2/"}, true);
- // delete the folder
- project.getFolder("folder1/folder2").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, null, true);
-
- // create a folder
- project.getFolder("folder1/folder2").create(false, true, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder2/"}, true);
- // add some children
- buildResources(project, new String[] {"folder1/folder2/file.txt"}, false);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder2/", "folder1/folder2/file.txt"}, true);
- // delete the folder
- project.getFolder("folder1/folder2").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, null, true);
-
- // delete a shared folder with files
- project.getFolder("folder1").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/deleted.txt", "folder1/a.txt"}, true);
- // recreate folders and files
- project.getFolder("folder1").create(false, true, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/deleted.txt", "folder1/a.txt"}, true);
- replace(new IResource[] {project.getFile("folder1/deleted.txt"), project.getFile("folder1/a.txt")}, null, true);
- assertModificationState(project, null, true);
-
- // delete a shared folder with files
- project.getFolder("folder1").delete(false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/deleted.txt", "folder1/a.txt"}, true);
- // commit file deletions
- commitProject(project);
- assertModificationState(project, null, true);
- }
-
- public void testFolderMoveAndCopy() throws CoreException, TeamException {
- IProject project = createProject("testFolderMoveAndCopy", new String[] { "changed.txt", "folder1/", "folder2/", "folder1/a.txt" , "folder1/folder3/file.txt"});
- // move a file
- project.getFolder("folder1/folder3").move(project.getFolder("folder2/folder3").getFullPath(), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder3", "folder1/folder3/file.txt", "folder2/", "folder2/folder3/", "folder2/folder3/file.txt"}, true);
- // commit the source
- commitResources(project, new String[] {"folder1/folder3"});
- assertModificationState(project, new String[] {".", "folder2/", "folder2/folder3/", "folder2/folder3/file.txt"}, true);
- // copy the destination back to the source
- project.getFolder("folder2/folder3/").copy(project.getFolder("folder1/folder3").getFullPath(), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder3", "folder1/folder3/file.txt", "folder2/", "folder2/folder3/", "folder2/folder3/file.txt"}, true);
- // add the source, delete the destination and commit
- addResources(new IResource[] {project.getFile("folder1/folder3/file.txt")});
- project.getFolder("folder2/folder3").delete(false, DEFAULT_MONITOR);
- commitProject(project);
- assertModificationState(project, null, true);
- // Do the above without committing the source
- project.getFolder("folder1/folder3").move(project.getFolder("folder2/folder3").getFullPath(), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder1/", "folder1/folder3", "folder1/folder3/file.txt", "folder2/", "folder2/folder3/", "folder2/folder3/file.txt"}, true);
- // copy the destination back to the source
- project.getFolder("folder2/folder3/").copy(project.getFolder("folder1/folder3").getFullPath(), false, DEFAULT_MONITOR);
- assertModificationState(project, new String[] {".", "folder2/", "folder2/folder3/", "folder2/folder3/file.txt"}, true);
- addResources(new IResource[] {project.getFolder("folder2/folder3/")});
- commitProject(project);
- assertModificationState(project, null, true);
- }
-
- public void testUpdate() throws TeamException, CoreException, IOException {
- // Create a test project, import it into cvs and check it out
- IProject project = createProject("testUpdate", new String[] { "changed.txt", "merged.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // Check the project out under a different name
- IProject copy = checkoutCopy(project, "-copy");
- assertModificationState(copy, null, true);
-
- // Perform some operations on the copy and commit
- addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
- setContentsAndEnsureModified(copy.getFile("changed.txt"));
- setContentsAndEnsureModified(copy.getFile("merged.txt"));
- deleteResources(new IResource[] {copy.getFile("deleted.txt")});
- assertModificationState(copy, new String[] {".", "added.txt", "folder2/", "folder2/added.txt", "changed.txt", "merged.txt", "deleted.txt"}, true);
- commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE);
- assertModificationState(copy, null, true);
-
- // update the project and check status
- setContentsAndEnsureModified(project.getFile("merged.txt"));
- updateProject(project, null, false);
- assertModificationState(project, new String[] {".", "merged.txt"}, true);
- // can't commit because of merge
- // commitProject(project);
- // assertModificationState(project, null, true);
- }
-
- public void testUpdateIgnoreLocal() throws TeamException, CoreException, IOException {
- // Create a test project, import it into cvs and check it out
- IProject project = createProject("testUpdateIgnoreLocal", new String[] { "changed.txt", "merged.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // modifiy a file
- setContentsAndEnsureModified(project.getFile("changed.txt"));
- assertModificationState(project, new String[] {".", "changed.txt"}, true);
-
- // peform un update -C
- updateProject(project, null, true /* ignore local changes */);
- assertModificationState(project, null, true);
- }
-
- public void testExternalDeletion() throws CoreException, TeamException {
- IProject project = createProject("testExternalDeletion", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- IFile file = project.getFile("folder1/unmanaged.txt");
- file.create(new ByteArrayInputStream("stuff".getBytes()), false, DEFAULT_MONITOR);
- file.getLocation().toFile().delete();
- file.refreshLocal(IResource.DEPTH_ZERO, DEFAULT_MONITOR);
- assertTrue(!file.exists());
- assertModificationState(project, null, true);
- }
-
- public void testIgnoredAfterCheckout() throws TeamException, CoreException {
- // Bug 43938
- // Create a project and add a .cvsignore to it
- IProject project = createProject("testIgnoredAfterCheckout", new String[] { ".changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- project.getFile(".cvsignore").create(new ByteArrayInputStream("ignored".getBytes()), false, DEFAULT_MONITOR);
- addResources(new IResource[] {project.getFile(".cvsignore")});
- commitProject(project);
- assertModificationState(project, null, true);
- project.getFolder("ignored").create(false, true, DEFAULT_MONITOR);
- assertModificationState(project, null, true);
-
- // Checkout a copy and add the file to ensure it is ignored
- // Check the project out under a different name
- IProject copy = checkoutCopy(project, "-copy");
- assertModificationState(copy, null, true);
- copy.getFolder("ignored").create(false, true, DEFAULT_MONITOR);
- assertModificationState(copy, null, true);
- }
-
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/LinkResourcesTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/LinkResourcesTest.java
deleted file mode 100644
index 76833fc6a..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/LinkResourcesTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-
-import java.io.IOException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-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.Path;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-/**
- * Test linked resources
- */
-public class LinkResourcesTest extends EclipseTest {
-
- /**
- * Constructor for CVSProviderTest
- */
- public LinkResourcesTest() {
- super();
- }
-
- /**
- * Constructor for CVSProviderTest
- */
- public LinkResourcesTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(LinkResourcesTest.class);
- return new CVSTestSetup(suite);
- //return new CVSTestSetup(new WatchEditTest("testReadOnly"));
- }
-
-
- public void testMapSuccess() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("testLinkSuccess");
- buildResources(project, new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" }, true);
- IFolder folder = project.getFolder("link");
- folder.createLink(new Path("C:/temp"), IResource.ALLOW_MISSING_LOCAL, null);
-
- // Add CVS info to the project so the map doesn't log an error
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(project);
- cvsFolder.setFolderSyncInfo(new FolderSyncInfo("repo/root", ":pserver:name@host:/root", null, false));
- RepositoryProvider.map(project, CVSProviderPlugin.getTypeId());
- }
-
- public void testLinkSuccess() throws CoreException, TeamException {
- IProject project = createProject("testLinkFailure", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- IFolder folder = project.getFolder("link");
- folder.createLink(new Path("C:/temp"), IResource.ALLOW_MISSING_LOCAL, null);
- assertIsIgnored(folder, true);
- }
-
- public void testLinkCVSFolder() throws CoreException, TeamException, IOException {
- IProject source = createProject("testLinkSource", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- IProject sourceCopy = checkoutCopy(source, "copy");
- EclipseSynchronizer.getInstance().flush(source, true, DEFAULT_MONITOR);
- IProject target = createProject("testLinkTarget", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- IFolder folder = target.getFolder("link");
- folder.createLink(source.getLocation(), 0, null);
- assertEquals(sourceCopy, source);
- }
-}
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
deleted file mode 100644
index 82966a9e4..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-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.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.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-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.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteModule;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-import org.osgi.framework.Bundle;
-
-/**
- * This class tests the Command framework using simple CVS commands
- */
-public class ModuleTest extends EclipseTest {
-
- public static final String RESOURCE_PATH = "resources/CommandTest/";
-
- public ModuleTest() {
- super(null);
- }
-
- public ModuleTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ModuleTest.class);
- //return new CVSTestSetup(suite);
- return new CVSTestSetup(new ModuleTest("testAliasForFiles"));
- }
-
- private static boolean isSetUp = false;
-
- private static RemoteModule[] remoteModules;
-
- public void setUp() throws TeamException, CoreException, IOException {
- if (isSetUp) return;
-
- // upload the modules definitions file
- Bundle b = Platform.getBundle("org.eclipse.team.tests.cvs.core");
- URL url = b.getEntry(RESOURCE_PATH + "CVSROOT/modules");
-
- waitMsec(1000);
-
- IProject cvsroot = checkoutProject(null, "CVSROOT", null);
- InputStream in = url.openStream();
- try {
- cvsroot.getFile("modules").setContents(in, false, false, DEFAULT_MONITOR);
- } finally {
- in.close();
- }
- commitProject(cvsroot);
-
- uploadProject("common");
-
- remoteModules = RemoteModule.getRemoteModules(getRepository(), null, DEFAULT_MONITOR);
-
- isSetUp = 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());
-
- // 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, true /* open for modification */);
- try {
- Command.IMPORT.execute(s, Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {Command.makeArgumentOption(Command.MESSAGE_OPTION, "")},
- new String[] { projectName, "start", "vendor"},
- null,
- DEFAULT_MONITOR);
- } finally {
- s.close();
- }
-
- // delete the project locally
- project.delete(false /*deleteContent*/, false /*force*/, null);
- }
-
- // XXX Temporary method of checkout (i.e. with vcm_meta
- protected IProject checkoutProject(String projectName, CVSTag tag) throws TeamException, CoreException {
- IProject project = super.checkoutProject(getWorkspace().getRoot().getProject(projectName), null, tag);
- ICVSFolder parent = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
- ICVSResource vcmmeta = CVSWorkspaceRoot.getCVSResourceFor(project.getFile(".vcm_meta"));
- if ( ! vcmmeta.isManaged() && ! parent.getFolderSyncInfo().getIsStatic()) {
- addResources(new IResource[] {project.getFile(".vcm_meta")});
- waitMsec(1000);
- commitProject(project);
- }
- return project;
- }
-
- /*
- * Test the following definition
- *
- * # self referencing modules
- * project1 project1
- */
- public void testSelfReferencingModule() throws TeamException, CoreException, IOException {
- uploadProject("project1");
- IProject project1 = checkoutProject("project1", null);
- ICVSRemoteResource tree = CVSWorkspaceRoot.getRemoteTree(project1, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project1), tree, false, false);
- RemoteModule module = getRemoteModule("project1");
- assertEquals(Path.EMPTY, (RemoteFolder)tree, module, false);
- }
-
- /*
- * Test the following definition
- *
- * # checkout docs in flattened structure
- * docs -d docs common/docs
- * macros common/macros
- */
- public void testFlattenedStructure() throws TeamException, CoreException, IOException {
-
- IProject docs = checkoutProject("docs", null);
- ICVSRemoteResource tree = CVSWorkspaceRoot.getRemoteTree(docs, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(docs), tree, false, false);
- RemoteModule module = getRemoteModule("docs");
- assertEquals(Path.EMPTY, (RemoteFolder)tree, module, false);
-
- IProject macros = checkoutProject("macros", null);
- tree = CVSWorkspaceRoot.getRemoteTree(macros, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(macros), tree, false, false);
- module = getRemoteModule("macros");
- assertEquals(Path.EMPTY, (RemoteFolder)tree, module, false);
-
- }
-
- /*
- * Test the following definition
- *
- * # include docs with project
- * project2 project2 &docs
- * # only project2
- * project2-only project2
- */
- public void testIncludeAndExcludeDocs() throws TeamException, CoreException, IOException {
- uploadProject("project2");
- IProject project2 = checkoutProject("project2", null);
- ICVSRemoteResource tree = CVSWorkspaceRoot.getRemoteTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project2), tree, false, false);
-
- RemoteModule module = getRemoteModule("project2");
- assertEquals(Path.EMPTY, (RemoteFolder)tree, module, false);
-
- project2 = checkoutProject("project2-only", null);
- tree = CVSWorkspaceRoot.getRemoteTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project2), tree, false, false);
-
- module = getRemoteModule("project2-only");
- assertEquals(Path.EMPTY, (RemoteFolder)tree, module, false);
-
- }
-
- /*
- * Test the following definition
- *
- * # a use of alias
- * project3-src project3/src
- * project3-src_file -a project3-src/file.c mc-src/file.h
- * project3-sub project3/sub &project3-src_file
- */
- public void testAliasForFiles() throws TeamException, CoreException, IOException {
- uploadProject("project3");
- IProject project3 = checkoutProject("project3-sub", null);
- ICVSRemoteResource tree = CVSWorkspaceRoot.getRemoteTree(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 = CVSWorkspaceRoot.getRemoteTree(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 = CVSWorkspaceRoot.getRemoteTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
-// assertEquals("Local does not match remote", Session.getManagedResource(project3), (ICVSResource)tree.getRemote(), false, false);
- }
-
- /*
- * Test the following definition
- *
- * # using aliases to provide packaging
- * project7-common -a project7/common
- * project7-pc -a project7-common project7/pc
- * project7-linux -a project7-common project7/linux
- */
- public void testAliases() throws TeamException, CoreException, IOException {
- uploadProject("project7");
- IProject project7 = checkoutProject("project7-common", null);
- ICVSRemoteResource tree = CVSWorkspaceRoot.getRemoteTree(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 = CVSWorkspaceRoot.getRemoteTree(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 = CVSWorkspaceRoot.getRemoteTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
-// assertEquals("Local does not match remote", Session.getManagedResource(project7), (ICVSResource)tree.getRemote(), false, false);
- }
-
-
- /*
- * Test the following definition
- *
- * # simple use of module alias
- * project8-alias -a project8 common
- */
- public void testSimpleAlias() throws TeamException, CoreException, IOException {
- uploadProject("project8");
-
- // XXX Module checkout will not work yet
- // IProject project8 = checkoutProject("project8-alias", null);
-
- RemoteModule module = getRemoteModule("project8-alias");
- }
-
- public RemoteModule getRemoteModule(String moduleName) {
- for (int i = 0; i < remoteModules.length; i++) {
- RemoteModule module = remoteModules[i];
- // XXX shouldn't be getName
- if (module.getName().equals(moduleName))
- return module;
- }
- return null;
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
deleted file mode 100644
index ed7bd96eb..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.Test;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.*;
-import org.eclipse.team.internal.ccvs.ui.operations.CheckoutToRemoteFolderOperation;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class RemoteResourceTest extends EclipseTest {
-
- public RemoteResourceTest() {
- super();
- }
-
- public RemoteResourceTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return suite(RemoteResourceTest.class);
- }
-
- protected void assertRemoteMatchesLocal(String message, RemoteFolder remote, IContainer container) throws CVSException, IOException, CoreException {
- assertEquals(Path.EMPTY, (ICVSResource)remote, CVSWorkspaceRoot.getCVSFolderFor(container), false, false);
- }
-
- protected void getMembers(ICVSRemoteFolder folder, boolean deep) throws TeamException {
- ICVSRemoteResource[] children = folder.members(DEFAULT_MONITOR);
- if (deep) {
- for (int i=0;i<children.length;i++) {
- if (children[i].isContainer())
- getMembers((ICVSRemoteFolder)children[i], deep);
- }
- }
- }
-
- /**
- * RemoteFolderTreeBuilder test
- *
- * Perform some remote additions, changes and deletions
- */
- public void testSimpleChanges() throws TeamException, CoreException, IOException {
-
- // Create a test project and a copy of it
- IProject project = createProject("testRemoteTreeBuilder", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- IProject copy = checkoutCopy(project, "-copy");
-
- // Make some changes to the copy and commit
- IResource[] newResources = buildResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
- setContentsAndEnsureModified(copy.getFile("changed.txt"));
- CVSTeamProvider provider = getProvider(copy);
- addResources(newResources);
- deleteResources(new IResource[] {copy.getFile("deleted.txt")});
- commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE);
-
- // Build the remote tree from the original and ensure it matches the copy
- RemoteFolderTree tree = RemoteFolderTreeBuilder.buildRemoteTree(getRepository(), project, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertRemoteMatchesLocal("testSimpleChanges", tree, copy);
- }
-
- /**
- * RemoteFolderTreeBuilder test
- *
- * Create a remote tree from a local workspace with no remote changes.
- */
- public void testNoRemoteChanges() throws TeamException, CoreException, IOException {
- IProject project = createProject("testNoRemoteChanges", new String[] { "file1.txt", "file2.txt", "folder1/a.txt", "folder2/folder3/b.txt"});
- RemoteFolderTree tree = RemoteFolderTreeBuilder.buildRemoteTree(getRepository(), project, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertRemoteMatchesLocal("testNoRemoteChanges", tree, project);
- }
-
- /**
- * RemoteFolderTreeBuilder test
- *
- * Create a base remote tree from a local workspace with no remote changes.
- */
- public void testGetBase() throws TeamException, CoreException, IOException {
- IProject project = createProject("testGetBase", new String[] { "file1.txt", "file2.txt", "folder1/a.txt", "folder2/folder3/b.txt"});
- RemoteFolderTree tree = RemoteFolderTreeBuilder.buildBaseTree(getRepository(), CVSWorkspaceRoot.getCVSFolderFor(project), CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertRemoteMatchesLocal("testGetBase", tree, project);
- }
-
- /**
- * RemoteFolderTreeBuilder test
- *
- * Add a nested folder structure remotely and build the remote tree
- * from the root.
- */
- public void testFolderAddition() throws TeamException, CoreException, IOException {
-
- // Create a test project
- IProject project = createProject("testFolderAddition", new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt"});
-
- // Checkout and modify a copy
- IProject copy = checkoutCopy(project, "-copy");
- addResources(copy, new String[] { "folder2/folder3/b.txt" }, false);
- commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE);
-
- // Build the remote tree from the project
- RemoteFolderTree tree = RemoteFolderTreeBuilder.buildRemoteTree(getRepository(), project, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertRemoteMatchesLocal("testFolderAddition", tree, copy);
- }
-
- /**
- * RemoteFolderTreeBuilder test
- *
- * Add a nested folder structure remotely and build the remote tree
- * from a child
- */
- public void testNonRootBuild() throws CoreException, TeamException, IOException {
-
- // Create a test project
- IProject project = createProject("testNonRootBuild", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt", "folder2/folder3/", "folder2/folder3/b.txt", "folder2/folder3/c.txt"});
-
- // Checkout and modify a copy
- IProject copy = checkoutCopy(project, "-copy");
- setContentsAndEnsureModified(copy.getFile("folder2/folder3/c.txt"));
- addResources(copy, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(new IResource[] {copy.getFile("folder2/folder3/b.txt")});
- commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE);
-
- // Build the remote tree from the project
- RemoteFolderTree tree = RemoteFolderTreeBuilder.buildRemoteTree(getRepository(), project.getFolder("folder2"), CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertRemoteMatchesLocal("testNonRootBuild", tree, copy.getFolder("folder2"));
- }
-
- /**
- * RemoteResource test
- *
- */
- public void testGetRemoteResource() throws CoreException, TeamException, IOException {
- IProject project = createProject("testGetRemoteResource", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt", "folder2/folder3/", "folder2/folder3/b.txt", "folder2/folder3/c.txt"});
- ICVSRemoteResource file = CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("folder1/a.txt"));
- assertTrue("File should exist remotely", file.exists(DEFAULT_MONITOR));
- assertEquals(Path.EMPTY, (ICVSResource)file, (ICVSResource)CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("folder1/a.txt")), false, false);
- ICVSRemoteResource folder = CVSWorkspaceRoot.getRemoteResourceFor(project.getFolder("folder2/folder3/"));
- getMembers((ICVSRemoteFolder)folder, true);
- assertTrue("Folder should exist remotely", folder.exists(DEFAULT_MONITOR));
- // XXX this didn't work right. I'll need to check into it later
-// assertEquals("Remote folder should match local folder", (ICVSResource)folder, (ICVSResource)Client.getManagedFolder(project.getFolder("folder2/folder3/").getLocation().toFile()));
- }
-
- /*
- * Test that the fetch of a tagged tree matches what is checked out for that tag
- */
- public void testVersionTag() throws TeamException, CoreException, IOException {
- // Create a test project and version it
- CVSTag v1Tag = new CVSTag("v1", CVSTag.VERSION);
- IProject project = createProject("testVersionTag", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/folder3/c.txt"});
- tagProject(project, v1Tag, false);
-
- // Make some changes, additions (including folders) and deletions and commit
- IFile file = project.getFile("folder1/a.txt");
- file.setContents(getRandomContents(), false, false, null);
- addResources(project, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(project, new String[] {"folder1/b.txt"}, false);
- commitResources(new IResource[] {project}, IResource.DEPTH_INFINITE);
-
- // Fetch the remote tree for the version
- ICVSRemoteResource tree = CVSWorkspaceRoot.getRemoteTree(project, v1Tag, DEFAULT_MONITOR);
-
- // Check out the project version
- project = checkoutCopy(project, v1Tag);
-
- // Compare the two
- assertEquals(Path.EMPTY, tree, (ICVSResource)CVSWorkspaceRoot.getCVSResourceFor(project), false, false);
- }
-
- /*
- * Test the fetching of the contents of an empty file
- */
- public void testEmptyFile() throws TeamException, CoreException, IOException {
-
- // Create a project with an empty file
- IProject project = createProject("testEmptyFile", new String[] { "file.txt"});
- IFile file = project.getFile("file.txt");
- setContentsAndEnsureModified(file, "");
- commitResources(project, new String[] {"file.txt"});
-
- IResourceVariant remote = (IResourceVariant)CVSWorkspaceRoot.getRemoteResourceFor(file);
- InputStream in = remote.getStorage(DEFAULT_MONITOR).getContents();
- int count = 0;
- while(in.read() != -1) {
- count++;
- }
- assertTrue("Remote file should be empty", count==0);
- }
-
- /*
- * Test the fetching of the contents from multiple remote revisions of a file
- */
- public void testFileRevisions() throws TeamException, CoreException, IOException {
-
- // Create a project with an empty file
- IProject project = createProject("testFileRevisions", new String[] { "file.txt"});
- setContentsAndEnsureModified(project.getFile("file.txt"), "hi there");
- commitResources(project, new String[] {"file.txt"});
- setContentsAndEnsureModified(project.getFile("file.txt"), "bye there");
- commitResources(project, new String[] {"file.txt"});
-
- ICVSRemoteFile remote = (ICVSRemoteFile)CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("file.txt"));
- ILogEntry[] entries = remote.getLogEntries(DEFAULT_MONITOR);
- for (int i=0;i<entries.length;i++) {
- InputStream in = entries[i].getRemoteFile().getContents(DEFAULT_MONITOR);
-
- if (entries[i].getRevision().equals("1.2")) {
- int count = 0;
- byte[] buffer = new byte[1024];
- int c;
- while((c = in.read()) != -1) {
- buffer[count] = (byte)c;
- count++;
- }
- String contents = new String(buffer, 0, count);
- assertEquals("the contents of revision 1.2 are not equal", contents, "hi there");
- } else if (entries[i].getRevision().equals("1.3")) {
- int count = 0;
- byte[] buffer = new byte[1024];
- int c;
- while((c = in.read()) != -1) {
- buffer[count] = (byte)c;
- count++;
- }
- String contents = new String(buffer, 0, count);
- assertEquals("the contents of revision 1.3 are not equal", contents, "bye there");
- }
- }
- }
-
- public void testTag() throws TeamException, CoreException, IOException {
- IProject project = createProject("testTag", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/folder3/b.txt", "folder2/folder3/c.txt"});
-
- ICVSRemoteFolder remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project);
- CVSTag tag = new CVSTag("v1", CVSTag.VERSION);
- tagRemoteResource(remote, tag, false);
- ICVSRemoteFolder v1 = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteTree(project, tag, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, remote, v1, false);
-
- CVSTag tag2 = new CVSTag("v2", CVSTag.VERSION);
- tagRemoteResource(v1, tag2, false);
- ICVSRemoteFolder v2 = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteTree(project, tag2, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, remote, v2, false);
-
- // Test tag with existing
- setContentsAndEnsureModified(project.getFile("file1.txt"));
- commitProject(project);
- remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project);
- tagRemoteResource(remote, tag, true /* force */);
- v1 = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteTree(project, tag, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, remote, v1, false);
-
- // Test local tag with existing.
- setContentsAndEnsureModified(project.getFile("file1.txt"));
- commitProject(project);
- tagProject(project, tag2, true);
- IProject copy = checkoutCopy(project, tag2);
- assertEquals(project, copy, false, false);
- }
-
- public void testExists() throws TeamException, CoreException, IOException, InterruptedException {
- IProject project = createProject("testExists", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt", "folder2/folder3/", "folder2/folder3/b.txt", "folder2/folder3/c.txt"});
- ICVSRemoteResource resource1 = CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("file1.txt"));
- assertTrue(resource1.exists(DEFAULT_MONITOR));
- ICVSRemoteResource resource2 = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project.getFolder("folder2/folder3/"));
- assertTrue(resource2.exists(DEFAULT_MONITOR));
- deleteResources(project, new String[] {"file1.txt", "folder2/folder3/b.txt", "folder2/folder3/c.txt" }, true);
- assertTrue( ! resource1.exists(DEFAULT_MONITOR));
- assertTrue(resource2.exists(DEFAULT_MONITOR));
- if (CVSTestSetup.INITIALIZE_REPO) {
- CVSTestSetup.executeRemoteCommand(getRepository(), "rm -rf " + ((ICVSFolder)resource2).getFolderSyncInfo().getRemoteLocation());
- assertTrue( ! resource2.exists(DEFAULT_MONITOR));
- }
- }
-
-// /**
-// * Test building a sync tree using the RemoteFolderTreeBuilder using a remote resource as the
-// * starting point instead of a local one.
-// */
-// public void testBuildRemoteTree() throws TeamException, CoreException, IOException, InterruptedException {
-// // Create a project and then delete it locally
-// IProject project = createProject("testBuildRemoteTree", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt", "folder2/folder3/", "folder2/folder3/b.txt", "folder2/folder3/c.txt"});
-// String name = project.getName();
-// project.delete(true, false, DEFAULT_MONITOR);
-// // Create a remote resource for the project and build a sync tree from it
-// RemoteFolder folder = new RemoteFolder(null, getRepository(), new Path(name), null);
-// RemoteFolderTree tree = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)folder.getRepository(), folder, null, DEFAULT_MONITOR);
-// // Reload the project from the repository and ensure that the tree and project are equal.
-// checkoutProject(project, name, null);
-// assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project), tree, false, true);
-// }
-
- public void testCheckoutIntoRemoteFolder() throws CoreException, IOException, CVSException, InvocationTargetException, InterruptedException {
- IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/folder3/b.txt", "folder2/folder3/c.txt"});
-
- ICVSRemoteFolder remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project);
- remote = checkoutRemote(remote);
- assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project), remote, false, true);
-
- // Try a version
- CVSTag tag = new CVSTag("v1", CVSTag.VERSION);
- tagProject(project, tag, false);
- IProject copy = checkoutCopy(project, tag);
- setContentsAndEnsureModified(project.getFile("file1.txt"));
- commitProject(project);
- remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project);
- ((RemoteFolder)remote).setTag(tag);
- remote = checkoutRemote(remote);
- assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(copy), remote, false, true);
- }
-
- private ICVSRemoteFolder checkoutRemote(ICVSRemoteFolder remote) throws CVSException, InvocationTargetException, InterruptedException {
- return CheckoutToRemoteFolderOperation.checkoutRemoteFolder(null, remote, DEFAULT_MONITOR);
- }
-
- public void testContentFetchForLocalDeletion() throws TeamException, IOException, CoreException {
- IProject project = createProject(new String[] { "file1.txt"});
- String contents = "the file contents";
- setContentsAndEnsureModified(project.getFile("file1.txt"), contents);
- commitProject(project);
- project.getFile("file1.txt").delete(false, null);
- IResourceVariant remote = (IResourceVariant)CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("file1.txt"));
- String fetchedContents = asString(remote.getStorage(DEFAULT_MONITOR).getContents());
- assertEquals("Contents do not match", contents, fetchedContents);
- }
-
- /**
- * @param stream
- * @return
- */
- private String asString(InputStream stream) throws IOException {
- StringBuffer buffer = new StringBuffer();
- int b = stream.read();
- while (b != -1) {
- buffer.append((char)b);
- b = stream.read();
- }
- return buffer.toString();
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java
deleted file mode 100644
index 625185247..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-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.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class ResourceDeltaTest extends EclipseTest {
-
- /**
- * Constructor for ResourceDeltaTest.
- */
- public ResourceDeltaTest() {
- super();
- }
-
- /**
- * Constructor for ResourceDeltaTest.
- * @param name
- */
- public ResourceDeltaTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(ResourceDeltaTest.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new ResourceDeltaTest(testName));
- }
- }
-
- public void assertNotManaged(ICVSFile cvsFile) throws CVSException {
- assertTrue("File " + cvsFile.getName() + " should not be managed", ! cvsFile.isManaged());
- }
-
- public void assertNotManaged(ICVSFolder cvsFolder) throws CVSException {
- assertNotManaged(cvsFolder, false);
- }
-
- public void assertNotManaged(ICVSFolder cvsFolder, boolean rootManaged) throws CVSException {
- if (!rootManaged)
- assertTrue("Folder " + cvsFolder.getName() + " should not be managed", ! cvsFolder.isManaged());
- assertTrue("Folder " + cvsFolder.getName() + " should not be a cvs folder", ! cvsFolder.isCVSFolder());
- cvsFolder.acceptChildren(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- assertNotManaged(file);
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- assertNotManaged(folder, false);
- }
- });
- }
-
- public void assertAdditionMarkerFor(IResource resource, boolean exists) throws CoreException {
- // Addition markers are no longer used
- }
-
- public void assertDeletionMarkerFor(IResource resource, boolean exists) throws CoreException {
- }
-
- public void testOrphanedSubtree() throws TeamException, CoreException {
- IProject project = createProject("testOrphanedSubtree", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- IFolder folder = project.getFolder(new Path("folder1"));
- folder.move(new Path("moved"), false, false, null);
- folder = project.getFolder(new Path("moved"));
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder);
- assertNotManaged(cvsFolder);
- assertAdditionMarkerFor(folder, true);
- }
-
- public void testOrphanedSubsubtree() throws TeamException, CoreException {
- IProject project = createProject("testOrphanedSubsubtree", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- IFolder folder = project.getFolder(new Path("folder1"));
- IFolder target = project.getFolder("sub");
- target.create(false, true, null);
- folder.move(new Path("sub/moved"), false, false, null);
- folder = project.getFolder(new Path("sub/moved"));
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder);
- assertNotManaged(cvsFolder);
- assertAdditionMarkerFor(target, true);
- assertAdditionMarkerFor(folder, false);
- }
-
- public void testDeletionHandling() throws TeamException, CoreException {
- IProject project = createProject("testDeletionHandling", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- addResources(project, new String[] {"added.txt"}, false);
- assertAdditionMarkerFor(project.getFile("added.txt"), false);
- deleteResources(project, new String[] {"added.txt", "deleted.txt"}, false);
- ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(project.getFile("added.txt"));
- assertNotManaged(file);
- assertDeletionMarkerFor(project.getFile("added.txt"), false);
- file = CVSWorkspaceRoot.getCVSFileFor(project.getFile("deleted.txt"));
- assertTrue("File " + file.getName() + " should be managed", file.isManaged());
- ResourceSyncInfo info = file.getSyncInfo();
- assertTrue("File " + file.getName() + " should be marked as deleted", info.isDeleted());
- assertDeletionMarkerFor(project.getFile("deleted.txt"), true);
- }
-
- public void testFileAdditionHandling() throws TeamException, CoreException {
- IProject project = createProject("testFileAdditionHandling", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- deleteResources(project, new String[] {"deleted.txt"}, false);
- assertDeletionMarkerFor(project.getFile("deleted.txt"), true);
- addResources(project, new String[] {"deleted.txt"}, false);
- ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(project.getFile("deleted.txt"));
- assertTrue("File " + file.getName() + " should be managed", file.isManaged());
- ResourceSyncInfo info = file.getSyncInfo();
- assertTrue("File " + file.getName() + " should not be marked as deleted", ! info.isDeleted());
- assertTrue("File " + file.getName() + " should not be marked as addition", ! info.isAdded());
- assertDeletionMarkerFor(project.getFile("deleted.txt"), false);
- }
-
- public void testFolderAdditionHandling() throws TeamException, CoreException {
- IProject project = createProject("testFolderAdditionHandling", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- IFolder folder = project.getFolder("newfolder");
- folder.create(false, true, null);
- assertAdditionMarkerFor(folder, true);
- addResources(new IResource[] {folder});
- assertAdditionMarkerFor(folder, false);
- }
-
- /**
- * Method setContents is used to set the contents of a java.io.File so we
- * can test out-of-sync situations
- *
- * @param ioFile
- */
- private void setContents(File ioFile) throws IOException {
- // wait to ensure the timestamp differs from the one Core has
- waitMsec(1500);
- InputStream in = new BufferedInputStream(getRandomContents());
- OutputStream out = new BufferedOutputStream(new FileOutputStream(ioFile));
- try {
- int next = in.read();
- while (next != -1) {
- out.write(next);
- next = in.read();
- }
- } finally {
- out.close();
- }
- }
-
- /**
- * This tests maks sure that performing a CVS operation on a file that is
- * out-of-sync results in the proper exception.
- */
- public void testOperationOnOutOfSync() throws CoreException, TeamException, IOException {
- IProject project = createProject("testFolderAdditionHandling", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- IFile file = project.getFile("changed.txt");
- setContentsAndEnsureModified(file);
- File ioFile = file.getLocation().toFile();
- setContents(ioFile);
- try {
- updateProject(project, null, false);
- } catch (CVSException e) {
- // We expect to get an out-of-sync exception
- if (e.getStatus().getCode() != IResourceStatus.OUT_OF_SYNC_LOCAL)
- throw e;
- }
- }
-
- public void testAllCVSFolderRemoval() throws CoreException, TeamException {
- IProject project = createProject("testAllCVSFolderRemoval", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- // ensure that all th sync info is loaded
- EclipseSynchronizer.getInstance().ensureSyncInfoLoaded(new IResource[] {project}, IResource.DEPTH_INFINITE);
- // delete the CVS folders from the file system and refresh
- String[] cvsFolders = new String[] {"CVS", "folder1/CVS", "folder1/folder2/CVS"};
- deleteIOFiles(project, cvsFolders);
- // The project should no longer be managed
- assertNotManaged(CVSWorkspaceRoot.getCVSFolderFor(project));
- }
-
- public void testSomeCVSFolderRemoval() throws CoreException, TeamException {
- IProject project = createProject("testAllCVSFolderRemoval", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- // ensure that all th sync info is loaded
- EclipseSynchronizer.getInstance().ensureSyncInfoLoaded(new IResource[] {project}, IResource.DEPTH_INFINITE);
- // delete the CVS folders from the file system and refresh
- String[] cvsFolders = new String[] {"folder1/CVS", "folder1/folder2/CVS"};
- deleteIOFiles(project, cvsFolders);
- // The project should no longer be managed
- assertNotManaged(CVSWorkspaceRoot.getCVSFolderFor(project.getFolder("folder1")), true);
- }
-
- public void deleteIOFiles(IProject project, String[] cvsFolders)
- throws CoreException {
- IPath rootPath = project.getLocation();
- for (int i = 0; i < cvsFolders.length; i++) {
- String childPath = cvsFolders[i];
- IPath fullPath = rootPath.append(childPath);
- deepDelete(fullPath.toFile());
- }
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
-
- private static void deepDelete(File resource) {
- if (resource.isDirectory()) {
- File[] fileList = resource.listFiles();
- for (int i = 0; i < fileList.length; i++) {
- deepDelete(fileList[i]);
- }
- }
- resource.delete();
- }
-
- public void testCVSFodlersMarkedTeamPrivate() throws CoreException, TeamException {
- IProject project = createProject("testTeamPrivatefolders", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
-
- project.delete(false /* preserve contents */, true, null);
- project.create(null);
- project.open(null);
- project.accept(new IResourceProxyVisitor() {
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if(proxy.getName().equals("CVS")) {
- fail("all folders should be marked as team private. This one was not:" + proxy.requestResource().getFullPath());
- }
- return true;
- }
- }, 0);
- }
-
- public void testExternalDeletion() throws CoreException, TeamException {
- IProject project = createProject("testExternalDeletion", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/b.txt"});
- IFile file = project.getFile("folder1/a.txt");
- deepDelete(file.getLocation().toFile());
- file.refreshLocal(IResource.DEPTH_ZERO, DEFAULT_MONITOR);
- assertTrue(!file.exists());
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
- assertTrue(cvsFile.isManaged());
- byte[] syncBytes = cvsFile.getSyncBytes();
- assertTrue(ResourceSyncInfo.isDeletion(syncBytes));
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/WatchEditTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/WatchEditTest.java
deleted file mode 100644
index ddade19ed..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/WatchEditTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.provider;
-
-import java.io.IOException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-/**
- * Test the cvs watch/edit functionality
- */
-public class WatchEditTest extends EclipseTest {
-
- /**
- * Constructor for CVSProviderTest
- */
- public WatchEditTest() {
- super();
- }
-
- /**
- * Constructor for CVSProviderTest
- */
- public WatchEditTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(WatchEditTest.class);
- return new CVSTestSetup(suite);
- //return new CVSTestSetup(new WatchEditTest("testReadOnly"));
- }
-
- private void setReadOnly(boolean b) {
- CVSProviderPlugin.getPlugin().getPluginPreferences().setValue(CVSProviderPlugin.READ_ONLY, b);
- }
-
- /**
- * Method assertAllFilesReadOnly.
- * @param copy
- */
- private void assertAllFilesReadOnly(IContainer folder) throws CoreException {
- folder.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- assertTrue(resource.isReadOnly());
- }
- return true;
- }
- });
- }
-
- public void testReadOnlyCheckout() throws CoreException, TeamException {
- // Create a project
- IProject project = createProject("testReadOnlyCheckout", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- // XXX project will not be read-only at this point because "cvs add" followed by a "cvs commit" doesn't set the resource "read-only"
- IProject copy = checkoutCopy(project, "copy");
- assertReadOnly(new IResource[] {copy}, true /* isReadOnly */, true /* recurse */);
- }
-
- public void testEditUnedit() throws CoreException, TeamException, IOException {
- // Create a project
- IProject project = createProject("testEditUnedit", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- // XXX project will not be read-only at this point because "cvs add" followed by a "cvs commit" doesn't set the resource "read-only"
- IProject copy = checkoutCopy(project, "copy");
- assertReadOnly(new IResource[] {copy}, true /* isReadOnly */, true /* recurse */);
- editResources(copy, new String[] {"changed.txt", "deleted.txt"});
- setContentsAndEnsureModified(copy.getFile("changed.txt"));
- deleteResources(copy, new String[] {"deleted.txt"}, false);
- uneditResources(copy, new String[] {"changed.txt", "deleted.txt"});
- assertEquals(project, copy);
- }
-
- public void testCommit() throws CoreException, TeamException, IOException {
- // Create a project
- IProject project = createProject("testCommit", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- // XXX project will not be read-only at this point because "cvs add" followed by a "cvs commit" doesn't set the resource "read-only"
- IProject copy = checkoutCopy(project, "copy");
- editResources(copy, new String[] {"changed.txt"});
- setContentsAndEnsureModified(copy.getFile("changed.txt"));
- commitProject(copy);
- assertReadOnly(new IResource[] {copy.getFile("changed.txt")}, true /* isReadOnly */, true /* recurse */);
- }
-
- public void testEditMergeUnedit() throws CoreException, TeamException, IOException {
- // Create a project
- IProject project = createProject("testEditMergeUnedit", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- // XXX project will not be read-only at this point because "cvs add" followed by a "cvs commit" doesn't set the resource "read-only"
- IProject copy = checkoutCopy(project, "copy");
- IProject copy2 = checkoutCopy(project, "copy2");
- // Modify the second copy and commit changes
- editResources(copy2, new String[] {"changed.txt"});
- setContentsAndEnsureModified(copy2.getFile("changed.txt"));
- commitProject(copy2);
- // Edit first copy, merge then unedit
- editResources(copy, new String[] {"changed.txt"});
- setContentsAndEnsureModified(copy.getFile("changed.txt"));
- updateProject(copy, CVSTag.DEFAULT, false);
- // XXX Update may or may not make the file read-only so it may need to be re-edited
- if (copy.getFile("changed.txt").isReadOnly()) {
- editResources(copy, new String[] {"changed.txt"});
- }
- uneditResources(copy, new String[] {"changed.txt", "deleted.txt"});
- IFile backup = copy.getFile(".#changed.txt.1.1");
- if (backup.exists()) backup.delete(true, false, null);
- assertEquals(project, copy);
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- setReadOnly(true);
- }
-
- /**
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- setReadOnly(false);
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/AllTestsTeamSubscriber.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/AllTestsTeamSubscriber.java
deleted file mode 100644
index 4368eb558..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/AllTestsTeamSubscriber.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-import org.eclipse.team.tests.ccvs.ui.SynchronizeViewTestAdapter;
-
-public class AllTestsTeamSubscriber extends EclipseTest {
-
- public AllTestsTeamSubscriber() {
- super();
- }
-
- public AllTestsTeamSubscriber(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(CVSMergeSubscriberTest.suite());
- suite.addTest(CVSWorkspaceSubscriberTest.suite());
- suite.addTest(CVSCompareSubscriberTest.suite());
- suite.addTest(SyncSetTests.suite());
- CVSSyncSubscriberTest.setSyncSource(new SynchronizeViewTestAdapter());
- return new CVSTestSetup(suite);
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java
deleted file mode 100644
index 90d9d4108..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-
-/**
- * Tests the CVSMergeSubscriber
- */
-public class CVSCompareSubscriberTest extends CVSSyncSubscriberTest {
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(CVSCompareSubscriberTest.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new CVSCompareSubscriberTest(testName));
- }
- }
-
- public CVSCompareSubscriberTest() {
- super();
- }
-
- public CVSCompareSubscriberTest(String name) {
- super(name);
- }
-
- /**
- * Test the basic changes that can occur when comparing the local workspace to a remote
- * lineup.
- */
- public void testStandardChanges() throws InvocationTargetException, InterruptedException, CVSException, CoreException, IOException {
- // Create a test project
- IProject project = createProject("testCompareChanges", new String[]{"file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/deleted.txt"});
- // Checkout and branch a copy
- CVSTag tag = new CVSTag("v1", CVSTag.VERSION);
- tagProject(project, tag, true);
- // Modify the workspace
- addResources(project, new String[]{"addition.txt", "folderAddition/", "folderAddition/new.txt"}, true);
- deleteResources(project, new String[]{"folder1/a.txt"}, true);
- deleteResources(project, new String[] {"folder2/"}, true);
- // modify file1 - make two revisions
- appendText(project.getFile("file1.txt"), "Appended text 1", false);
- commitProject(project);
- appendText(project.getFile("file1.txt"), "Appended text 2", false);
- commitProject(project);
- // modify file2 in both branch and head and ensure it's merged properly
- appendText(project.getFile("file2.txt"), "appened text", false);
- commitProject(project);
- // create a merge subscriber
- CVSCompareSubscriber subscriber = getSyncInfoSource().createCompareSubscriber(project, tag);
- // check the sync states
- assertSyncEquals("testIncomingChanges", subscriber, project,
- new String[]{
- "file1.txt",
- "file2.txt",
- "folder1/",
- "folder1/b.txt",
- "folder1/a.txt",
- "addition.txt",
- "folderAddition/",
- "folderAddition/new.txt",
- "folder2/",
- "folder2/deleted.txt"}, true,
- new int[]{
- SyncInfo.CHANGE,
- SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.ADDITION,
- SyncInfo.DELETION,
- SyncInfo.IN_SYNC,
- SyncInfo.DELETION,
- SyncInfo.IN_SYNC,
- SyncInfo.ADDITION});
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- getSyncInfoSource().tearDown();
- super.tearDown();
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java
deleted file mode 100644
index 8b84acc6f..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java
+++ /dev/null
@@ -1,623 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-
-
-/**
- * Tests the CVSMergeSubscriber
- */
-public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest {
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(CVSMergeSubscriberTest.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new CVSMergeSubscriberTest(testName));
- }
- }
-
- public CVSMergeSubscriberTest() {
- super();
- }
-
- public CVSMergeSubscriberTest(String name) {
- super(name);
- }
-
- private IProject branchProject(IProject project, CVSTag root, CVSTag branch) throws TeamException {
- IProject copy = checkoutCopy(project, "-copy");
- tagProject(project, root, false);
- tagProject(project, branch, false);
- updateProject(copy, branch, false);
- return copy;
- }
-
- private void mergeResources(CVSMergeSubscriber subscriber, IProject project, String[] resourcePaths, boolean allowOverwrite) throws CoreException, TeamException, InvocationTargetException, InterruptedException {
- IResource[] resources = getResources(project, resourcePaths);
- SyncInfo[] infos = createSyncInfos(subscriber, resources);
- mergeResources(subscriber, infos, allowOverwrite);
- }
-
- private void mergeResources(Subscriber subscriber, SyncInfo[] infos, boolean allowOverwrite) throws TeamException, InvocationTargetException, InterruptedException {
- TestMergeUpdateOperation action = new TestMergeUpdateOperation(getElements(infos), allowOverwrite);
- action.run(DEFAULT_MONITOR);
- }
-
- /**
- * Test the basic incoming changes cases
- * - incoming addition
- * - incoming deletion
- * - incoming change
- * - incoming addition of a folder containing files
- */
- public void testIncomingChanges() throws InvocationTargetException, InterruptedException, CVSException, CoreException, IOException {
- // Create a test project
- IProject project = createProject("testIncomingChanges", new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject copy = branchProject(project, root, branch);
-
- // Modify the branch
- addResources(copy, new String[] {"addition.txt", "folderAddition/", "folderAddition/new.txt"}, true);
- deleteResources(copy, new String[] {"folder1/a.txt"}, true);
-
- // modify file1 - make two revisions
- appendText(copy.getFile("file1.txt"), "Appended text 1", false);
- commitProject(copy);
- appendText(copy.getFile("file1.txt"), "Appended text 2", false);
- commitProject(copy);
-
- // modify file2 in both branch and head and ensure it's merged properly
- appendText(copy.getFile("file2.txt"), "appened text", false);
- commitProject(copy);
- appendText(project.getFile("file2.txt"), "prefixed text", true);
- commitProject(project);
-
- // create a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
-
- // check the sync states
- assertSyncEquals("testIncomingChanges", subscriber, project,
- new String[]{"file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "addition.txt", "folderAddition/", "folderAddition/new.txt"},
- true,
- new int[]{
- SyncInfo.INCOMING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.INCOMING | SyncInfo.DELETION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION});
-
-
- // Perform a merge
- mergeResources(subscriber, project, new String[]{"file1.txt", "file2.txt", "folder1/a.txt", "addition.txt", "folderAddition/", "folderAddition/new.txt"}, true);
-
- // check the sync states for the workspace subscriber
- assertSyncEquals("testIncomingChanges", getWorkspaceSubscriber(), project,
- new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "addition.txt", "folderAddition/", "folderAddition/new.txt"},
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.OUTGOING | SyncInfo.ADDITION,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- assertEndsWith(project.getFile("file1.txt"), "Appended text 1" + eol + "Appended text 2");
- assertStartsWith(project.getFile("file2.txt"), "prefixed text");
- assertEndsWith(project.getFile("file2.txt"), "appened text");
- }
-
- /**
- * This tests tests that the cvs update command is sent properly with the two -j options to merge
- * contents between two revisions into the workspaoce.
- */
- public void test46007() throws InvocationTargetException, InterruptedException, CVSException, CoreException, IOException {
- // Create a test project
- IProject project = createProject("test46007", new String[] { "file1.txt" });
- appendText(project.getFile("file1.txt"), "dummy", true);
- commitProject(project);
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject copy = branchProject(project, root, branch);
-
- // modify file1
- appendText(copy.getFile("file1.txt"), "Appended text 1", true);
- commitProject(copy);
-
- CVSTag root2 = new CVSTag("v1", CVSTag.VERSION);
- tagProject(copy, root2, true);
- appendText(copy.getFile("file1.txt"), "Appended text 2", false);
- commitProject(copy);
- CVSTag root3 = new CVSTag("v2", CVSTag.VERSION);
- tagProject(copy, root3, true);
-
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root2, root3);
- assertSyncEquals("test46007", subscriber, project,
- new String[]{"file1.txt"},
- true,
- new int[]{SyncInfo.CONFLICTING | SyncInfo.CHANGE});
-
- mergeResources(subscriber, project, new String[]{"file1.txt"}, true);
-
- assertSyncEquals("test46007", getWorkspaceSubscriber(), project,
- new String[] { "file1.txt"},
- true, new int[] {SyncInfo.OUTGOING | SyncInfo.CHANGE});
-
- // the change made before v1 in the branch should not of been merged into the
- // workspace since the start/end points do not include those changed. Hence,
- // the two -j options sent to the cvs server.
- assertEndsWith(project.getFile("file1.txt"), "Appended text 2");
- assertStartsWith(project.getFile("file1.txt"), "dummy");
- }
-
- public void testMergableConflicts() throws IOException, TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a test project
- IProject project = createProject("testMergableConflicts", new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- setContentsAndEnsureModified(project.getFile("file1.txt"), "some text\nwith several lines\n");
- setContentsAndEnsureModified(project.getFile("file2.txt"), "some text\nwith several lines\n");
- commitProject(project);
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // modify the branch
- appendText(branchedProject.getFile("file1.txt"), "first line\n", true);
- appendText(branchedProject.getFile("file2.txt"), "last line\n", false);
- commitProject(branchedProject);
-
- // modify HEAD
- appendText(project.getFile("file1.txt"), "last line\n", false);
- commitProject(project);
- // have one local change
- appendText(project.getFile("file2.txt"), "first line\n", true);
-
- // create a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
-
- // check the sync states
- assertSyncEquals("testMergableConflicts", subscriber, project,
- new String[] { "file1.txt", "file2.txt"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE});
-
- // Perform a merge
- mergeResources(subscriber, project, new String[] {
- "file1.txt",
- "file2.txt"},
- false /* allow overwrite */);
-
- // check the sync states for the workspace subscriber
- assertSyncEquals("testMergableConflicts", getWorkspaceSubscriber(), project,
- new String[] { "file1.txt", "file2.txt"},
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.OUTGOING | SyncInfo.CHANGE});
-
- //TODO: How do we know if the right thing happened to the file contents?
- }
-
- public void testUnmergableConflicts() throws IOException, TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a test project
- IProject project = createProject("testUnmergableConflicts", new String[] { "delete.txt", "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- setContentsAndEnsureModified(project.getFile("file1.txt"), "some text\nwith several lines\n");
- setContentsAndEnsureModified(project.getFile("file2.txt"), "some text\nwith several lines\n");
- commitProject(project);
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // modify the branch
- appendText(branchedProject.getFile("file1.txt"), "first line\n", true);
- appendText(branchedProject.getFile("file2.txt"), "last line\n", false);
- addResources(branchedProject, new String[] {"addition.txt"}, false);
- deleteResources(branchedProject, new String[] {"delete.txt", "folder1/a.txt"}, false);
- setContentsAndEnsureModified(branchedProject.getFile("folder1/b.txt"));
- commitProject(branchedProject);
-
- // modify local workspace
- appendText(project.getFile("file1.txt"), "conflict line\n", true);
- setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
- deleteResources(project, new String[] {"delete.txt", "folder1/b.txt"}, false);
- addResources(project, new String[] {"addition.txt"}, false);
- appendText(project.getFile("file2.txt"), "conflict line\n", false);
-
- // create a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
-
- // check the sync states
- assertSyncEquals("testUnmergableConflicts", subscriber, project,
- new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC, /* TODO: is this OK */
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE});
-
- // TODO: Should actually perform the merge and check the results
- // However, this would require the changes to be redone
-
- // commit to modify HEAD
- commitProject(project);
-
- // check the sync states
- assertSyncEquals("testUnmergableConflicts", subscriber, project,
- new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC, /* TODO: is this OK */
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE});
-
- // Perform a merge
- mergeResources(subscriber, project, new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"}, true /* allow overwrite */);
-
- // check the sync states for the workspace subscriber
- assertSyncEquals("testUnmergableConflicts", getWorkspaceSubscriber(), project,
- new String[] { "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"},
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
- assertDeleted("testUnmergableConflicts", project, new String[] { "delete.txt" });
-
- //TODO: How do we know if the right thing happend to the file contents?
- }
-
- public void testLocalScrub() throws IOException, TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a test project
- IProject project = createProject("testLocalScrub", new String[] { "delete.txt", "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- setContentsAndEnsureModified(project.getFile("file1.txt"), "some text\nwith several lines\n");
- setContentsAndEnsureModified(project.getFile("file2.txt"), "some text\nwith several lines\n");
- commitProject(project);
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // modify the branch
- appendText(branchedProject.getFile("file1.txt"), "first line\n", true);
- appendText(branchedProject.getFile("file2.txt"), "last line\n", false);
- addResources(branchedProject, new String[] {"addition.txt"}, false);
- deleteResources(branchedProject, new String[] {"delete.txt", "folder1/a.txt"}, false);
- setContentsAndEnsureModified(branchedProject.getFile("folder1/b.txt"));
- commitProject(branchedProject);
-
- // create a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
-
- // check the sync states
- assertSyncEquals("testLocalScrub", subscriber, project,
- new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"},
- true, new int[] {
- SyncInfo.INCOMING | SyncInfo.DELETION,
- SyncInfo.INCOMING | SyncInfo.CHANGE,
- SyncInfo.INCOMING | SyncInfo.CHANGE,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.DELETION,
- SyncInfo.INCOMING | SyncInfo.CHANGE});
-
- // scrub the project contents
- IResource[] members = project.members();
- for (int i = 0; i < members.length; i++) {
- IResource resource = members[i];
- if (resource.getName().equals(".project")) continue;
- resource.delete(false, DEFAULT_MONITOR);
- }
-
- // update
- mergeResources(subscriber, project,
- new String[] {
- "delete.txt",
- "file1.txt",
- "file2.txt",
- "addition.txt",
- "folder1/a.txt",
- "folder1/b.txt"},
- true /* allow overwrite */);
-
- // commit
- commitProject(project);
- }
-
- public void testBug37546MergeWantsToDeleteNewDirectories() throws CVSException, CoreException {
- IProject project = createProject("testBug37546", new String[]{"file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- setContentsAndEnsureModified(project.getFile("file1.txt"), "some text\nwith several lines\n");
- commitProject(project);
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // modify the branch
- addResources(branchedProject, new String[] {"folder2/", "folder2/c.txt"}, true);
-
- // modify HEAD and add the same folder
- addResources(project, new String[] {"folder2/"}, true);
- addResources(project, new String[] {"folder3/"}, true);
- addResources(project, new String[] {"folder4/", "folder4/d.txt"}, false);
-
- // create a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
-
- assertSyncEquals("testBug37546", subscriber, project,
- new String[]{"folder2/", "folder2/c.txt", "folder3/", "folder4/", "folder4/d.txt"}, true,
- new int[]{
- SyncInfo.IN_SYNC,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.IN_SYNC, SyncInfo.IN_SYNC, SyncInfo.IN_SYNC});
- }
-
- /*Bug 53129
- Outgoing deletions in deleted folders are lost.
- */
- public void testOutgoingDeletionAfterMergeBug53129() throws TeamException, CoreException, InvocationTargetException, InterruptedException {
- IProject project = createProject("testBug53129", new String[]{"file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- setContentsAndEnsureModified(project.getFile("file1.txt"), "some text\nwith several lines\n");
- commitProject(project);
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // modify the branch
- deleteResources(branchedProject, new String[] {"folder1/a.txt", "folder1/b.txt"}, true);
-
- // create a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
-
- assertSyncEquals("testBug53129 - 1", subscriber, project,
- new String[]{"file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}, true,
- new int[]{
- SyncInfo.IN_SYNC, SyncInfo.IN_SYNC,
- SyncInfo.INCOMING | SyncInfo.DELETION,
- SyncInfo.INCOMING | SyncInfo.DELETION});
-
- mergeResources(subscriber, project, new String[]{"folder1/a.txt", "folder1/b.txt"}, true);
-
- assertSyncEquals("testBug53129 - 2", getWorkspaceSubscriber(), project,
- new String[]{"file1.txt", "folder1", "folder1/a.txt", "folder1/b.txt"}, true,
- new int[]{
- SyncInfo.IN_SYNC, SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.OUTGOING | SyncInfo.DELETION});
-
- IFolder f = project.getFolder("folder1");
- f.delete(true, null);
-
- assertSyncEquals("testBug53129 - 3", getWorkspaceSubscriber(), project,
- new String[]{"file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}, true,
- new int[]{
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.OUTGOING | SyncInfo.DELETION});
- }
-
- public void testDisconnectingProject() throws CoreException, IOException, TeamException, InterruptedException {
- // Create a test project (which commits it as well)
- // Create a test project
- IProject project = createProject("testDisconnect", new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- setContentsAndEnsureModified(project.getFile("file1.txt"), "some text\nwith several lines\n");
- setContentsAndEnsureModified(project.getFile("file2.txt"), "some text\nwith several lines\n");
- commitProject(project);
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // modify the branch
- appendText(branchedProject.getFile("file1.txt"), "first line\n", true);
- appendText(branchedProject.getFile("file2.txt"), "last line\n", false);
- commitProject(branchedProject);
-
- // create a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
-
- RepositoryProvider.unmap(project);
- assertProjectRemoved(subscriber, project);
- }
-
- public void testMarkAsMerged() throws IOException, TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a test project
- IProject project = createProject("testMarkAsMerged", new String[] { "delete.txt", "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- setContentsAndEnsureModified(project.getFile("file1.txt"), "some text\nwith several lines\n");
- setContentsAndEnsureModified(project.getFile("file2.txt"), "some text\nwith several lines\n");
- commitProject(project);
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // modify the branch
- appendText(branchedProject.getFile("file1.txt"), "first line\n", true);
- appendText(branchedProject.getFile("file2.txt"), "last line\n", false);
- addResources(branchedProject, new String[] {"addition.txt"}, false);
- deleteResources(branchedProject, new String[] {"delete.txt", "folder1/a.txt"}, false);
- setContentsAndEnsureModified(branchedProject.getFile("folder1/b.txt"));
- commitProject(branchedProject);
-
- // modify local workspace
- appendText(project.getFile("file1.txt"), "conflict line\n", true);
- setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
- setContentsAndEnsureModified(project.getFile("delete.txt"));
- addResources(project, new String[] {"addition.txt"}, false);
- appendText(project.getFile("file2.txt"), "conflict line\n", false);
-
- // create a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
-
- // check the sync states
- assertSyncEquals("testMarkAsMergedConflicts", subscriber, project,
- new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE});
-
- markAsMerged(subscriber, project, new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt"});
-
- // check the sync states
- assertSyncEquals("testMarkAsMerged", subscriber, project,
- new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- getSyncInfoSource().tearDown();
- super.tearDown();
- }
-
- public void testDeletedAddition() throws TeamException, CoreException, InvocationTargetException, InterruptedException {
- IProject project = createProject("testDeletedAddition", new String[]{"file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // add a file to the branch
- addResources(branchedProject, new String[] {"folder2/", "folder2/added.txt"}, true);
-
- // Setup a merge by creating a merge subscriber
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
- assertSyncEquals("testDeletedAddition", subscriber, project,
- new String[]{"folder2/", "folder2/added.txt"}, true,
- new int[]{
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION
- });
-
- // Merge the change with HEAD
- mergeResources(subscriber, project, new String[]{"folder2/", "folder2/added.txt"}, true);
- assertSyncEquals("testDeletedAddition", subscriber, project,
- new String[]{"folder2/", "folder2/added.txt"}, true,
- new int[]{
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC
- });
-
- // Delete the file from the branch
- deleteResources(branchedProject, new String[] {"folder2/added.txt"}, true);
- assertSyncEquals("testDeletedAddition", subscriber, project,
- new String[]{"folder2/", "folder2/added.txt"}, true,
- new int[]{
- SyncInfo.IN_SYNC,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE
- });
- }
-
- public void testFileAddedToBranch() throws InvocationTargetException, InterruptedException, CoreException, IOException {
- // Create a project
- IProject project = createProject(new String[] { "delete.txt", "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Checkout and branch a copy
- CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- IProject branchedProject = branchProject(project, root, branch);
-
- // Add a file to the branch
- addResources(branchedProject, new String[] {"folder2/", "folder2/added.txt"}, true);
-
- // Merge the file with HEAD but do not commit
- CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch);
- assertSyncEquals("testFileAddedToBranch", subscriber, project,
- new String[]{"folder2/", "folder2/added.txt"}, true,
- new int[]{
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION
- });
- mergeResources(subscriber, project, new String[]{"folder2/", "folder2/added.txt"}, true /* allow overwrite */);
-
- // Ensure HEAD matches branch
- assertContentsEqual(project, branchedProject);
-
- // Modify the file on the branch
- setContentsAndEnsureModified(branchedProject.getFile("folder2/added.txt"));
- commitProject(branchedProject);
-
- // Merge with HEAD again and commit afterwards
- assertSyncEquals("testFileAddedToBranch", subscriber, project,
- new String[]{"folder2/added.txt"}, true,
- new int[]{
- SyncInfo.CONFLICTING | SyncInfo.CHANGE
- });
- mergeResources(subscriber, project, new String[]{"folder2/added.txt"}, true /* allow overwrite */);
- commitProject(project);
-
- // Ensure HEAD matches branch
- assertContentsEqual(project, branchedProject);
-
- // Modify the file on the branch again
- setContentsAndEnsureModified(branchedProject.getFile("folder2/added.txt"));
- commitProject(branchedProject);
-
- // Merge with HEAD one last time
- assertSyncEquals("testFileAddedToBranch", subscriber, project,
- new String[]{"folder2/added.txt"}, true,
- new int[]{
- SyncInfo.CONFLICTING | SyncInfo.CHANGE
- });
- mergeResources(subscriber, project, new String[]{"folder2/added.txt"}, true /* allow overwrite */);
-
- // Ensure HEAD matches branch
- assertContentsEqual(project, branchedProject);
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java
deleted file mode 100644
index dfc760296..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.AssertionFailedError;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.ISubscriberChangeEvent;
-import org.eclipse.team.core.subscribers.ISubscriberChangeListener;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.subscribers.SubscriberChangeEvent;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber;
-import org.eclipse.team.internal.ccvs.ui.subscriber.ConfirmMergedOperation;
-import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-import org.eclipse.team.tests.ccvs.ui.SynchronizeViewTestAdapter;
-
-/**
- * Provides test methods common to CVS sync subscribers
- */
-public abstract class CVSSyncSubscriberTest extends EclipseTest {
-
- private ISubscriberChangeListener listener;
- private List accumulatedTeamDeltas = new ArrayList();
- private static SyncInfoSource source = new SynchronizeViewTestAdapter();
-
- public CVSSyncSubscriberTest() {
- super();
- }
-
- public CVSSyncSubscriberTest(String name) {
- super(name);
- }
-
- public static void setSyncSource(SyncInfoSource newSource) {
- source = newSource;
- }
-
- protected Subscriber getWorkspaceSubscriber() throws TeamException {
- return getSyncInfoSource().createWorkspaceSubscriber();
- }
-
- public SyncInfoSource getSyncInfoSource() {
- assertNotNull(source);
- return source;
- }
-
- protected void refresh(Subscriber subscriber, IResource resource) throws TeamException {
- getSyncInfoSource().refresh(subscriber, resource);
- }
-
- /*
- * Assert that the specified resources in the subscriber have the specified sync kind
- * Ignore conflict types if they are not specified in the assert statement
- */
- protected void assertSyncEquals(String message, Subscriber subscriber, IContainer root, String[] resourcePaths, boolean refresh, int[] syncKinds) throws CoreException, TeamException {
- assertTrue(resourcePaths.length == syncKinds.length);
- if (refresh) refresh(subscriber, root);
- IResource[] resources = getResources(root, resourcePaths);
- for (int i=0;i<resources.length;i++) {
- assertSyncEquals(message, subscriber, resources[i], syncKinds[i]);
- }
-
- }
-
- protected void assertSyncEquals(String message, Subscriber subscriber, IResource resource, int syncKind) throws TeamException {
- int conflictTypeMask = 0x0F; // ignore manual and auto merge sync types for now.
- SyncInfo info = getSyncInfo(subscriber, resource);
- int kind;
- int kindOther = syncKind & conflictTypeMask;
- if (info == null) {
- kind = SyncInfo.IN_SYNC;
- } else {
- kind = info.getKind() & conflictTypeMask;
- }
- assertTrue(message + ": improper sync state for " + resource + " expected " +
- SyncInfo.kindToString(kindOther) + " but was " +
- SyncInfo.kindToString(kind), kind == kindOther);
- }
-
- protected SyncInfo getSyncInfo(Subscriber subscriber, IResource resource) throws TeamException {
- return getSyncInfoSource().getSyncInfo(subscriber, resource);
- }
-
- /**
- * @param changes
- * @param resources
- */
- protected void assertSyncChangesMatch(ISubscriberChangeEvent[] changes, IResource[] resources) {
- // First, ensure that all the resources appear in the delta
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- boolean found = false;
- for (int j = 0; j < changes.length; j++) {
- ISubscriberChangeEvent delta = changes[j];
- if (delta.getResource().equals(resource)) {
- found = true;
- break;
- }
- }
- assertTrue("No change reported for " + resource, found);
- }
- // TODO: We'll worry about extra deltas later
-// // Next, ensure there are no extra deltas
-// List changedResources = new ArrayList(resources.length);
-// changedResources.addAll(Arrays.asList(resources));
-// for (int i = 0; i < changes.length; i++) {
-// TeamDelta change = changes[i];
-// IResource resource = change.getResource();
-// assertTrue("Unanticipated change reported for " + resource, changedResources.contains(resource));
-// }
- }
-
- /*
- * Assert that the named resources have no local resource or sync info
- */
- protected void assertDeleted(String message, IContainer root, String[] resourcePaths) throws CoreException, TeamException {
- IResource[] resources = getResources(root, resourcePaths);
- for (int i=0;i<resources.length;i++) {
- try {
- if (! resources[i].exists())
- break;
- } catch (AssertionFailedError e) {
- break;
- }
- assertTrue(message + ": resource " + resources[i] + " still exists in some form", false);
- }
- }
-
- public static class ResourceCondition {
- public boolean matches(IResource resource) throws CoreException, TeamException {
- return true;
- }
- }
-
- protected IResource[] collect(IResource[] resources, final ResourceCondition condition, int depth) throws CoreException, TeamException {
- final Set affected = new HashSet();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (resource.exists() || resource.isPhantom()) {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource r) throws CoreException {
- try {
- if (condition.matches(r)) {
- affected.add(r);
- }
- } catch (TeamException e) {
- throw new CoreException(e.getStatus());
- }
- return true;
- }
- }, depth, true /* include phantoms */);
- } else {
- if (condition.matches(resource)) {
- affected.add(resource);
- }
- }
- }
- return (IResource[]) affected.toArray(new IResource[affected.size()]);
- }
-
- /**
- * @param resources
- * @param condition
- * @return
- */
- protected IResource[] collectAncestors(IResource[] resources, ResourceCondition condition) throws CoreException, TeamException {
- Set affected = new HashSet();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- while (resource.getType() != IResource.ROOT) {
- if (condition.matches(resource)) {
- affected.add(resource);
- } else {
- break;
- }
- resource = resource.getParent();
- }
- }
- return (IResource[]) affected.toArray(new IResource[affected.size()]);
- }
-
- protected ISubscriberChangeEvent[] deregisterSubscriberListener(Subscriber subscriber) throws TeamException {
- subscriber.removeListener(listener);
- return (ISubscriberChangeEvent[]) accumulatedTeamDeltas.toArray(new SubscriberChangeEvent[accumulatedTeamDeltas.size()]);
- }
-
- protected ISubscriberChangeListener registerSubscriberListener(Subscriber subscriber) throws TeamException {
- listener = new ISubscriberChangeListener() {
- public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) {
- accumulatedTeamDeltas.addAll(Arrays.asList(deltas));
- }
- };
- accumulatedTeamDeltas.clear();
- subscriber.addListener(listener);
- return listener;
- }
-
- protected SyncInfo[] createSyncInfos(Subscriber subscriber, IResource[] resources) throws TeamException {
- SyncInfo[] result = new SyncInfo[resources.length];
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- result[i] = getSyncInfo(subscriber, resource);
- }
- return result;
- }
-
- protected void assertProjectRemoved(Subscriber subscriber, IProject project) throws TeamException {
- getSyncInfoSource().assertProjectRemoved(subscriber, project);
- }
-
- protected void markAsMerged(CVSSyncTreeSubscriber subscriber, IProject project, String[] resourcePaths) throws CoreException, TeamException, InvocationTargetException, InterruptedException {
- IResource[] resources = getResources(project, resourcePaths);
- SyncInfo[] infos = createSyncInfos(subscriber, resources);
- new ConfirmMergedOperation(null, getElements(infos)).run(DEFAULT_MONITOR);
- }
-
- protected IDiffElement[] getElements(SyncInfo[] infos) {
- SyncInfoModelElement[] elements = new SyncInfoModelElement[infos.length];
- for (int i = 0; i < elements.length; i++) {
- elements[i] = new SyncInfoModelElement(null, infos[i]);
- }
- return elements;
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java
deleted file mode 100644
index dfd282e78..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java
+++ /dev/null
@@ -1,1316 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.ISubscriberChangeEvent;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-
-/**
- * This class tests the CVSWorkspaceSubscriber
- */
-public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest {
-
- /**
- * Constructor for CVSProviderTest
- */
- public CVSWorkspaceSubscriberTest() {
- super();
- }
-
- /**
- * Constructor for CVSProviderTest
- */
- public CVSWorkspaceSubscriberTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(CVSWorkspaceSubscriberTest.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new CVSWorkspaceSubscriberTest(testName));
- }
- }
-
- protected CVSSyncTreeSubscriber getSubscriber() throws TeamException {
- return (CVSSyncTreeSubscriber)getWorkspaceSubscriber();
- }
-
- /* (non-Javadoc)
- *
- * The shareProject method is invoked when creating new projects.
- * @see org.eclipse.team.tests.ccvs.core.EclipseTest#shareProject(org.eclipse.core.resources.IProject)
- */
- protected void shareProject(final IProject project) throws TeamException, CoreException {
- mapNewProject(project);
- // Everything should be outgoing addition except he project
- assertSyncEquals(project.getName(), getSubscriber(), project, SyncInfo.IN_SYNC);
- assertAllSyncEquals(project.members(true), SyncInfo.OUTGOING | SyncInfo.ADDITION, IResource.DEPTH_INFINITE);
-
- commitNewProject(project);
- // Everything should be in-sync
- assertAllSyncEquals(project, SyncInfo.IN_SYNC, IResource.DEPTH_INFINITE);
- }
-
- protected void assertAllSyncEquals(final IResource rootResource, final int kind, int depth) throws CoreException {
- if (!rootResource.exists() && !rootResource.isPhantom()) {
- assertTrue(kind == SyncInfo.IN_SYNC);
- return;
- }
- rootResource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- assertSyncEquals(rootResource.getName(), getSubscriber(), resource, kind);
- return true;
- }
- }, depth, true);
- }
-
- private void assertAllSyncEquals(IResource[] resources, int kind, int depth) throws CoreException {
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- assertAllSyncEquals(resource, kind, depth);
- }
- }
-
- /* (non-Javadoc)
- *
- * Override to check that the proper sync state is achieved.
- *
- * @see org.eclipse.team.tests.ccvs.core.EclipseTest#setContentsAndEnsureModified(org.eclipse.core.resources.IFile)
- */
- protected void setContentsAndEnsureModified(IFile file) throws CoreException, TeamException {
- // The delta will indicate to any interested parties that the sync state of the
- // file has changed
- super.setContentsAndEnsureModified(file);
- assertSyncEquals("Setting contents: ", file, SyncInfo.OUTGOING | SyncInfo.CHANGE);
- }
-
- private void assertSyncEquals(String string, IProject project, String[] strings, boolean refresh, int[] kinds) throws CoreException, TeamException {
- assertSyncEquals(string, getSubscriber(), project, strings, refresh, kinds);
- }
-
- private void assertSyncEquals(IProject project, String[] strings, boolean refresh, int[] kinds) throws CoreException, TeamException {
- assertSyncEquals(getName(), getSubscriber(), project, strings, refresh, kinds);
- }
-
- private void assertSyncEquals(String message, IResource resource, int syncKind) throws TeamException {
- assertSyncEquals(message, getSubscriber(), resource, syncKind);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.EclipseTest#addResources(org.eclipse.core.resources.IResource[])
- */
- protected void addResources(IResource[] resources) throws TeamException, CVSException, CoreException {
- // first, get affected children
- IResource[] affectedChildren = collect(resources, new ResourceCondition() {
- public boolean matches(IResource resource) throws CoreException, TeamException {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- return (!cvsResource.isManaged() && !cvsResource.isIgnored());
- }
- }, IResource.DEPTH_INFINITE);
- // also get affected parents
- IResource[] affectedParents = collectAncestors(resources, new ResourceCondition() {
- public boolean matches(IResource resource) throws CoreException, TeamException {
- if (resource.getType() == IResource.PROJECT) return false;
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- return (!cvsResource.isManaged() && !cvsResource.isIgnored());
- }
- });
- Set affected = new HashSet();
- affected.addAll(Arrays.asList(affectedChildren));
- affected.addAll(Arrays.asList(affectedParents));
-
- registerSubscriberListener();
- super.addResources(resources);
- ISubscriberChangeEvent[] changes = deregisterSubscriberListener();
- assertSyncChangesMatch(changes, (IResource[]) affected.toArray(new IResource[affected.size()]));
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (resource.getType() == IResource.FILE) {
- assertSyncEquals("Add", resource, SyncInfo.OUTGOING | SyncInfo.ADDITION);
- } else {
- // TODO: a folder should be in sync but isn't handled properly
- assertSyncEquals("Add", resource, SyncInfo.IN_SYNC);
- }
-
- }
- }
-
- private void registerSubscriberListener() throws TeamException {
- registerSubscriberListener(getSubscriber());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.EclipseTest#deleteResources(org.eclipse.core.resources.IResource[])
- */
- protected void deleteResources(IResource[] resources) throws TeamException, CoreException {
- IResource[] affected = collect(resources, new ResourceCondition(), IResource.DEPTH_INFINITE);
- registerSubscriberListener();
- super.deleteResources(resources);
- ISubscriberChangeEvent[] changes = deregisterSubscriberListener();
- assertSyncChangesMatch(changes, affected);
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- // After deletion, folders should be in-sync while files should be outgoing deletions
- if (resource.getType() == IResource.FILE) {
- assertSyncEquals("Delete", resource, SyncInfo.OUTGOING | SyncInfo.DELETION);
- } else {
- assertSyncEquals("Delete", resource, SyncInfo.IN_SYNC);
- }
- }
- }
-
- private ISubscriberChangeEvent[] deregisterSubscriberListener() throws TeamException {
- return deregisterSubscriberListener(getSubscriber());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.EclipseTest#commitResources(org.eclipse.core.resources.IResource[])
- */
- protected void commitResources(IResource[] resources, int depth) throws TeamException, CVSException, CoreException {
- IResource[] affected = collect(resources, new ResourceCondition() {
- public boolean matches(IResource resource) throws CoreException, TeamException {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- return (!cvsResource.isFolder() && cvsResource.isManaged() && cvsResource.isModified(DEFAULT_MONITOR));
- }
- }, IResource.DEPTH_INFINITE);
- registerSubscriberListener();
- super.commitResources(resources, depth);
- ISubscriberChangeEvent[] changes = deregisterSubscriberListener();
- assertSyncChangesMatch(changes, affected);
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (resource.exists())
- assertSyncEquals("Commit", resource, SyncInfo.IN_SYNC);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.EclipseTest#unmanageResources(org.eclipse.core.resources.IResource[])
- */
- protected void unmanageResources(IResource[] resources) throws CoreException, TeamException {
- IResource[] affected = collect(resources, new ResourceCondition() {
- public boolean matches(IResource resource) throws CoreException, TeamException {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- return (cvsResource.isManaged());
- }
- }, IResource.DEPTH_INFINITE);
- registerSubscriberListener();
- super.unmanageResources(resources);
- ISubscriberChangeEvent[] changes = deregisterSubscriberListener();
- assertSyncChangesMatch(changes, affected);
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (resource.exists())
- assertSyncEquals("Unmanage", resource, SyncInfo.IN_SYNC);
- }
- }
-
- /******************************************************************
- * Subscriber Actions: commit/update and overide and commit/update
- * These actions are those contributed to the Synchronize View by
- * the CVS plugin.
- ******************************************************************/
- private SyncInfo[] createSyncInfos(IResource[] resources) throws TeamException {
- return createSyncInfos(getSubscriber(), resources);
- }
-
- public IResource[] update(IContainer container, String[] hierarchy) throws CoreException, TeamException, InvocationTargetException, InterruptedException {
- IResource[] resources = getResources(container, hierarchy);
- runSubscriberOperation(new TestUpdateOperation(getElements(resources)));
- return resources;
- }
-
- public IResource[] commit(IContainer container, String[] hierarchy) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- runSubscriberOperation(new TestCommitOperation(getElements(resources), false /* override */));
- return resources;
- }
-
- public IResource[] overrideAndUpdate(IContainer container, String[] hierarchy, boolean shouldPrompt) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- TestOverrideAndUpdateOperation action = new TestOverrideAndUpdateOperation(getElements(resources));
- runSubscriberOperation(action);
- assertTrue(shouldPrompt == action.isPrompted());
- return resources;
- }
-
- public IResource[] overrideAndCommit(IContainer container, String[] hierarchy, boolean shouldPrompt) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- TestCommitOperation action = new TestCommitOperation(getElements(resources), true /* override */);
- runSubscriberOperation(action);
- //assertTrue(shouldPrompt == action.isPrompted());
- return resources;
- }
-
- protected IDiffElement[] getElements(IResource[] resources) throws CoreException {
- SyncInfo[] syncResources = createSyncInfos(resources);
- return getElements(syncResources);
- }
-
- private void runSubscriberOperation(CVSSubscriberOperation op) throws CoreException {
- try {
- op.run();
- } catch (InvocationTargetException e) {
- throw CVSException.wrapException(e);
- } catch (InterruptedException e) {
- fail("Operation was interupted");
- }
- }
-
- /******************************************************************
- * Tests
- ******************************************************************/
-
- /*
- * Perform a simple test that checks for the different types of incoming changes
- */
- public void testIncomingChanges() throws IOException, TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a test project
- IProject project = createProject("testIncomingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Checkout and modify a copy
- IProject copy = checkoutCopy(project, "-copy");
- setContentsAndEnsureModified(copy.getFile("folder1/a.txt"));
- addResources(copy, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(copy, new String[] {"folder1/b.txt"}, false);
- commitProject(copy);
-
- // Get the sync tree for the project
- assertSyncEquals("testIncomingChanges", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.INCOMING | SyncInfo.CHANGE,
- SyncInfo.INCOMING | SyncInfo.DELETION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION});
-
- // Catch up to the incoming changes
- update(
- project,
- new String[] {
- "folder1/a.txt",
- "folder1/b.txt",
- "folder2/",
- "folder2/folder3/",
- "folder2/folder3/add.txt"});
-
- // Verify that we are in sync (except for "folder1/b.txt", which was deleted)
- assertSyncEquals("testIncomingChanges", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
-
- // Ensure "folder1/b.txt" was deleted
- assertDeleted("testIncomingChanges", project, new String[] {"folder1/b.txt"});
-
- // Verify that the copy equals the original
- assertEquals(project, copy);
- }
-
- /*
- * Perform a simple test that checks for the different types of outgoing changes
- */
- public void testOutgoingChanges() throws TeamException, CoreException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testOutgoingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Make some modifications
- setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
- addResources(project, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(project, new String[] {"folder1/b.txt"}, false);
-
- // Get the sync tree for the project
- assertSyncEquals("testOutgoingChanges", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.IN_SYNC, /* adding a folder creates it remotely */
- SyncInfo.IN_SYNC, /* adding a folder creates it remotely */
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- // Commit the changes
- commit(project, new String[] {"folder1/a.txt", "folder1/b.txt", "folder2/folder3/add.txt"});
-
- // Ensure we're in sync
- assertSyncEquals("testOutgoingChanges", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
-
- // Ensure deleted resource "folder1/b.txt" no longer exists
- assertDeleted("testOutgoingChanges", project, new String[] {"folder1/b.txt"});
- }
-
- public void testOverideAndUpdateSimple() throws CVSException, CoreException, IOException {
- IProject project = createProject("testOutgoingChangesOverideAndUpdate", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Make some modifications
- setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
- addResources(project, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(project, new String[] {"folder1/b.txt"}, false);
-
- // Get the sync tree for the project
- assertSyncEquals("testOutgoingChangesOverwrite", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.IN_SYNC, /* adding a folder creates it remotely */
- SyncInfo.IN_SYNC, /* adding a folder creates it remotely */
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- // Revert the changes
- overrideAndUpdate(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"}, true /* should prompt */);
-
- // Ensure we're in sync
- assertSyncEquals("testOutgoingChangesOverwrite", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
-
- // Ensure deleted resource is re-created
- assertExistsInWorkspace("testOutgoingChangesOverwrite", project.getFile(new Path("folder1/b.txt")));
-
- // Test conflicting changes
- IProject copy = checkoutCopy(project, "-copy");
- appendText(copy.getFile("file1.txt"), "prefix" + eol, true);
- setContentsAndEnsureModified(copy.getFile("folder1/a.txt"), "Use a custom string to avoid intermitant errors!");
- commitProject(copy);
-
- // Make the same modifications to the original (We need to test both M and C!!!)
- appendText(project.getFile("file1.txt"), eol + "postfix", false); // This will test merges (M)
- setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
-
- // Get the sync tree for the project
- assertSyncEquals("testFileConflict", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE });
-
- // Revert the changes
- overrideAndUpdate(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt"}, true /* should prompt */);
-
- assertSyncEquals("testFileConflict", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
- }
-
- /*
- * Perform a simple test that checks for the different types of outgoing changes
- */
- public void testOverrideOutgoingChanges() throws IOException, TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testOverrideOutgoingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- // Checkout a copy for later verification
- IProject original = checkoutCopy(project, "-copy");
-
- // Make some modifications
- setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
- addResources(project, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(project, new String[] {"folder1/b.txt"}, false);
-
- // Get the sync tree for the project
- assertSyncEquals("testOverrideOutgoingChanges", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.IN_SYNC, /* adding a folder creates it remotely */
- SyncInfo.IN_SYNC, /* adding a folder creates it remotely */
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- // Override the changes
- overrideAndUpdate(
- project,
- new String[] {
- "folder1/a.txt",
- "folder1/b.txt",
- "folder2/folder3/add.txt"},
- true /* should prompt */);
-
- // Ensure added resources no longer exist
- assertDeleted("testOverrideOutgoingChanges", project, new String[] {"folder2/", "folder2/folder3/","folder2/folder3/add.txt"});
-
- // Ensure other resources are in sync
- assertSyncEquals("testOverrideOutgoingChanges", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
-
- // Verify that the original has reverted to its original contents
- assertEquals(project, original);
- }
-
- /*
- * Perform a test that checks for outgoing changes that are CVS questionables (no add or remove)
- */
- public void testOutgoingQuestionables() throws TeamException, CoreException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testIncomingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Create a new file without adding it to version control
- buildResources(project, new String[] {"folder2/folder3/add.txt"}, false);
-
- // Delete a file without an explicit cvs remove
- // NOTE: This will result in an implicit cvs remove
- IFile file = project.getFile("folder1/b.txt");
- file.delete(true, DEFAULT_MONITOR);
-
- // Get the sync tree for the project
- assertSyncEquals("testOutgoingQuestionables", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.OUTGOING | SyncInfo.ADDITION,
- SyncInfo.OUTGOING | SyncInfo.ADDITION,
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- commit(project, new String[] {"folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"});
-
- // Ensure we are in sync
- assertSyncEquals("testOutgoingQuestionables", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
-
- // Ensure "folder1/b.txt" was deleted
- assertDeleted("testOutgoingQuestionables", project, new String[] {"folder1/b.txt"});
- }
-
- /*
- * Test simple file conflicts
- */
- public void testFileConflict() throws IOException, TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testFileConflict", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Set the contents of file1.txt to ensure proper merging
- setContentsAndEnsureModified(project.getFile("file1.txt"), "Use a custom string" + eol + " to ensure proper merging");
- commitProject(project);
-
- // Checkout a copy and make some modifications
- IProject copy = checkoutCopy(project, "-copy");
- appendText(copy.getFile("file1.txt"), "prefix" + eol, true);
- setContentsAndEnsureModified(copy.getFile("folder1/a.txt"), "Use a custom string to avoid intermitant errors!");
- commitProject(copy);
-
- // Make the same modifications to the original (We need to test both M and C!!!)
- appendText(project.getFile("file1.txt"), eol + "postfix", false); // This will test merges (M)
- setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
-
- // Get the sync tree for the project
- assertSyncEquals("testFileConflict", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE });
-
- // Catch up to the file1.txt conflict using UPDATE
- update(
- project,
- new String[] {"file1.txt"});
-
- assertSyncEquals("testFileConflict", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE });
-
- // Release the folder1/a.txt conflict by merging and then committing
- commit(project, new String[] {"file1.txt", "folder1/a.txt"});
-
- assertSyncEquals("testFileConflict", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC });
- }
-
- /*
- * Test conflicts involving additions
- */
- public void testAdditionConflicts() throws TeamException, CoreException, InvocationTargetException, InterruptedException {
-
- // CASE 1: The user adds (using CVS add) a remotely added file
- // (a) catchup is simply get?
- // (b) release must do a merge
- // CASE 2: The user adds (but not using cvs add) a remotely added file
- // (a) catchup is simply get?
- // (b) release must do a merge
- // CASE 3: The user adds a remotely added then deleted file
- // catchup is not applicable
- // release is normal
-
- // Create a test project (which commits it as well) and add an uncommited resource
- IProject project = createProject("testAdditionConflicts", new String[] { "file.txt"});
- addResources(project, new String[] { "add1a.txt", "add1b.txt" }, false);
- addResources(project, new String[] { "add3.txt" }, false);
- buildResources(project, new String[] {"add2a.txt", "add2b.txt"}, false);
-
- // Checkout a copy, add the same resource and commit
- IProject copy = checkoutCopy(project, "-copy");
- addResources(copy, new String[] { "add1a.txt", "add1b.txt", "add2a.txt", "add2b.txt", "add3.txt"}, true);
- deleteResources(copy, new String[] { "add3.txt"}, true);
-
- // Get the sync tree for the project
- assertSyncEquals("testAdditionConflicts", project,
- new String[] { "file.txt", "add1a.txt", "add1b.txt", "add2a.txt", "add2b.txt", "add3.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.OUTGOING | SyncInfo.ADDITION });
-
- // Commit conflicting add1b.txt and add2b.txt and outgoing add3.txt
- commit(project, new String[]{"add1b.txt", "add2b.txt", "add3.txt"});
-
- assertSyncEquals("testAdditionConflicts", project,
- new String[] { "file.txt", "add1b.txt", "add2b.txt", "add3.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC });
-
- // Catch-up to conflicting cases using UPDATE
- overrideAndUpdate(
- project,
- new String[] {"add1a.txt", "add2a.txt"},
- true /* should prompt */);
-
-
- assertSyncEquals("testAdditionConflicts", project,
- new String[] { "add1a.txt", "add2a.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC });
- }
-
- /*
- * Test conflicts involving deletions
- */
- public void testDeletionConflicts() throws TeamException, CoreException, InvocationTargetException, InterruptedException {
-
- // CASE 1: The user deletes a remotely modified file
- // (a) catchup must do an update
- // (b) release must do a merge
- // CASE 2: The user deletes (and removes) a remotely modified file
- // (a) catchup must do an unmanage and update
- // (b) release must do a merge
- // CASE 3: The user modified a remotely deleted file
- // (a) catchup must do an unmanage and local delete
- // (b) release must do a merge
- // CASE 4: The user deletes a remotely deleted file
- // (a) catchup can update (or unmanage?)
- // (b) release must unmanage
- // CASE 5: The user deletes (and removes) a remotely deleted file
- // (a) catchup can update (or unmanage?)
- // (b) release must unmanage
-
- // Perform the test case for case A first
-
- // Create a test project (which commits it as well) and delete the resource without committing
- IProject project = createProject("testDeletionConflictsA", new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"});
- IFile file = project.getFile("delete1.txt"); // WARNING: This does a "cvs remove"!!!
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] {"delete2.txt"}, false);
- setContentsAndEnsureModified(project.getFile("delete3.txt"));
- file = project.getFile("delete4.txt");
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] {"delete5.txt"}, false);
-
- // Checkout a copy and commit the deletion
- IProject copy = checkoutCopy(project, "-copy");
- setContentsAndEnsureModified(copy.getFile("delete1.txt"));
- setContentsAndEnsureModified(copy.getFile("delete2.txt"));
- deleteResources(copy, new String[] {"delete3.txt", "delete4.txt", "delete5.txt"}, false);
- commitProject(copy);
-
- // Get the sync tree for the project
- assertSyncEquals("testDeletionConflictsA", project,
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC });
-
- // Catch up to remote changes.
- overrideAndUpdate(
- project,
- new String[] {
- "delete1.txt",
- "delete2.txt",
- "delete3.txt",
- "delete4.txt",
- "delete5.txt"},
- true /* should be prompted */);
-
- assertSyncEquals("testDeletionConflictsA", project,
- new String[] { "delete1.txt", "delete2.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC });
-
- assertDeleted("testDeletionConflictsA", project, new String[] {"delete3.txt", "delete4.txt", "delete5.txt"});
-
- // Now redo the test case for case B
-
- // Create a test project (which commits it as well) and delete the resource without committing
- project = createProject("testDeletionConflictsB", new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"});
- file = project.getFile("delete1.txt");
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] {"delete2.txt"}, false);
- setContentsAndEnsureModified(project.getFile("delete3.txt"));
- file = project.getFile("delete4.txt");
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] {"delete5.txt"}, false);
-
- // Checkout a copy and commit the deletion
- copy = checkoutCopy(project, "-copy");
- setContentsAndEnsureModified(copy.getFile("delete1.txt"));
- setContentsAndEnsureModified(copy.getFile("delete2.txt"));
- deleteResources(copy, new String[] {"delete3.txt", "delete4.txt", "delete5.txt"}, false);
- commitProject(copy);
-
- // Get the sync tree for the project
- assertSyncEquals("testDeletionConflictsB", project,
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC });
-
- // Release the resources
- commit(project, new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"});
-
- assertSyncEquals("testDeletionConflictsB", project,
- new String[] { "delete3.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC });
-
- assertDeleted("testDeletionConflictsB", project, new String[] {"delete1.txt", "delete2.txt", "delete4.txt", "delete5.txt"});
- }
-
- /*
- * Test the creation and sync of an empty local project that has remote contents
- */
- public void testSyncOnEmptyProject() throws TeamException, CoreException {
- IProject project = createProject(new String[] { "file1.txt", "folder1/file2.txt"});
-
- // Make a new folder and map it to the same project
- IProject newProject = getUniqueTestProject("empty-" + getName());
- FolderSyncInfo info = CVSWorkspaceRoot.getCVSFolderFor(project).getFolderSyncInfo();
- CVSWorkspaceRoot.getCVSFolderFor(newProject).setFolderSyncInfo(info);
- RepositoryProvider.map(newProject, CVSProviderPlugin.getTypeId());
-
- // Assert that all resources are incoming additions
- assertSyncEquals(newProject,
- new String[] { "file1.txt", "folder1/", "folder1/file2.txt"},
- true, new int[] {
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION});
- }
-
- /*
- * Test syncing on a folder that has been deleted from the server
- */
- public void testSyncOnDeletedFolder() throws TeamException {
- }
-
- /*
- * Test syncing on a folder that is empty on the server and has been pruned, then added locally
- */
- public void testSyncOnPrunedFolder() throws TeamException {
- }
-
- /*
- * Test sync involving pruned directories
- */
- public void testSyncWithPruning() throws TeamException {
- }
-
- /*
- * Test a conflict with an incomming foler addition and an unmanaqged lcoal folder
- */
- public void testFolderConflict() throws TeamException, CoreException, InvocationTargetException, InterruptedException {
-
- // Create a test project (which commits it as well) and delete the resource without committing
- IProject project = createProject("testFolderConflict", new String[] { "file.txt"});
-
- // Checkout a copy and add some folders
- IProject copy = checkoutCopy(project, "-copy");
- addResources(copy, new String[] {"folder1/file.txt", "folder2/file.txt"}, true);
-
- // Add a folder to the original project (but not using cvs)
- IResource[] resources = buildResources(project, new String[] {"folder1/"});
- ((IFolder)resources[0]).create(false, true, DEFAULT_MONITOR);
-
- assertSyncEquals("testFolderConflict", project,
- new String[] { "file.txt", "folder1/", "folder1/file.txt", "folder2/", "folder2/file.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION});
-
- update(
- project,
- new String[] {"folder1/"});
-
- assertSyncEquals("testFolderConflict", project,
- new String[] { "file.txt", "folder1/", "folder1/file.txt", "folder2/", "folder2/file.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION});
- }
-
- /*
- * Test that a deleted file can still be deleted through the team provider
- */
- public void testOutgoingDeletion() throws TeamException, CoreException {
-
- // Create a test project (which commits it as well)
- IProject project = createProject("testOutgoingDeletion", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Delete a file
- IFile file = project.getFile("folder1/b.txt");
- file.delete(true, DEFAULT_MONITOR); // WARNING: As of 2002/03/05, this is equivalent to a cvs remove
-
- // Get the sync tree for the project
- assertSyncEquals("testOutgoingDeletion", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION});
-
- // Commit the deletion
- commit(project , new String[] {"folder1/b.txt"});
-
- // Get the sync tree again for the project and ensure others aren't effected
- assertSyncEquals("testOutgoingDeletion", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
-
- // Assert that deletion no longer appears in remote tree
- assertDeleted("testOutgoingDeletion", project, new String[] {"folder1/b.txt"});
- }
-
- /*
- * Test catching up to an incoming addition
- */
- public void testIncomingAddition() throws TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a test project
- IProject project = createProject("testIncomingAddition", new String[] { "file1.txt", "folder1/", "folder1/a.txt"});
-
- // Checkout and modify a copy
- IProject copy = checkoutCopy(project, "-copy");
- addResources(copy, new String[] { "folder1/add.txt" }, true);
-
- // Get the sync tree for the project
- assertSyncEquals("testIncomingAddition", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.INCOMING | SyncInfo.ADDITION});
-
- // Catch up to the addition by updating
- update(
- project,
- new String[] {"folder1/add.txt"});
-
- // Get the sync tree again for the project and ensure the added resource is in sync
- assertSyncEquals("testIncomingAddition", project,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC});
- }
-
- public void testSyncOnBranch() throws TeamException, CoreException, IOException {
-
- // Create a test project and a branch
- IProject project = createProject(new String[] { "file1.txt", "file2.txt", "file3.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- tagProject(project, branch, false /* force */);
- updateProject(project, branch, false);
-
- // Checkout and modify a copy
- IProject copy = checkoutCopy(project, branch);
- addResources(copy, new String[] {"addition.txt", "folderAddition/", "folderAddition/new.txt"}, true);
- deleteResources(copy, new String[] {"folder1/b.txt"}, true);
- changeResources(copy, new String[] {"file1.txt", "file2.txt"}, true);
-
- // Sync on the original and assert the result equals the copy
- assertSyncEquals(project, new String[] {
- "file1.txt",
- "file2.txt",
- "file3.txt",
- "folder1/",
- "folder1/a.txt",
- "folder1/b.txt",
- "addition.txt",
- "folderAddition/",
- "folderAddition/new.txt"},
- true,
- new int[] {
- SyncInfo.INCOMING | SyncInfo.CHANGE,
- SyncInfo.INCOMING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.INCOMING | SyncInfo.DELETION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION,
- SyncInfo.INCOMING | SyncInfo.ADDITION});
- }
-
- public void testRenameProject() throws TeamException, CoreException, IOException {
- String[] resourceNames = new String[] { "changed.txt", "folder1/", "folder1/a.txt" };
- int[] inSync = new int[] {SyncInfo.IN_SYNC, SyncInfo.IN_SYNC, SyncInfo.IN_SYNC};
- IProject project = createProject("testRenameProject", new String[] { "changed.txt", "folder1/", "folder1/a.txt" });
-
- assertSyncEquals("sync should be in sync", project, resourceNames, true, inSync);
- IProjectDescription desc = project.getDescription();
- String newName = project.getName() + "_renamed";
- desc.setName(newName);
- project.move(desc, false, null);
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(newName);
- assertTrue(project.exists());
- assertSyncEquals("sync should be in sync", project, resourceNames, true, inSync);
- }
-
- public void testDeleteProject() throws CoreException, IOException, TeamException, InterruptedException {
- String[] resourceNames = new String[] { "deleted.txt", "file1.txt", "folder1/", "folder1/a.txt" };
- int[] inSync = new int[] {SyncInfo.IN_SYNC, SyncInfo.IN_SYNC, SyncInfo.IN_SYNC, SyncInfo.IN_SYNC};
- IProject project = createProject("testDeleteProject", resourceNames);
- assertSyncEquals("sync should be in sync", project, resourceNames, true, inSync);
-
- // Make some modifications
- setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
- addResources(project, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(project, new String[] {"deleted.txt"}, false);
-
- // Get the sync tree for the project
- assertSyncEquals("testOutgoingChanges", project,
- new String[] { "file1.txt", "folder1/", "deleted.txt", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.IN_SYNC, /* adding a folder creates it remotely */
- SyncInfo.IN_SYNC, /* adding a folder creates it remotely */
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- project.delete(true, false, DEFAULT_MONITOR);
-
- assertProjectRemoved(getWorkspaceSubscriber(), project);
- }
-
- public void testFolderDeletion() throws TeamException, CoreException {
-
- IProject project = createProject("testFolderDeletion", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/file.txt"});
-
- // Delete a folder and ensure that the file is managed but doesn't exist
- // (Special behavior is provider by the CVS move/delete hook but this is not part of CVS core)
- project.getFolder("folder1").delete(false, false, null);
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project.getFolder("folder1"));
- assertTrue("Deleted folder not in proper state", ! folder.exists() && folder.isManaged() && folder.isCVSFolder());
-
- // The files should show up as outgoing deletions
- assertSyncEquals("testFolderDeletion sync check", project,
- new String[] { "folder1/", "folder1/a.txt", "folder1/folder2/", "folder1/folder2/file.txt"},
- true, new int[] { SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION});
-
- // commit folder1/a.txt
- commit(project, new String[] { "folder1/a.txt" });
-
- // Resync and verify that above file is gone and others remain the same
- assertSyncEquals("testFolderDeletion sync check", project,
- new String[] { "folder1/", "folder1/folder2/", "folder1/folder2/file.txt"},
- true, new int[] { SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.DELETION});
- assertDeleted("testFolderDeletion", project, new String[] {"folder1/a.txt"});
-
- // Commit folder1/folder2/file.txt
- commit(project, new String[] { "folder1/folder2/file.txt" });
-
- // Resync and verify that all are deleted
- assertDeleted("testFolderDeletion", project, new String[] {"folder1/", "folder1/folder2/", "folder1/folder2/file.txt"});
- }
- /**
- * There is special handling required when building a sync tree for a tag when there are undiscovered folders
- * that only contain other folders.
- */
- public void testTagRetrievalForFolderWithNoFile() throws TeamException, CoreException {
- IProject project = createProject("testTagRetrievalForFolderWithNoFile", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt"});
- // Checkout, branch and modify a copy
- IProject copy = checkoutCopy(project, "-copy");
- CVSTag version = new CVSTag("v1", CVSTag.BRANCH);
- CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH);
- makeBranch(new IResource[] {copy}, version, branch, true);
- addResources(copy, new String[] {"folder2/folder3/a.txt"}, true);
-
- // Fetch the tree corresponding to the branch using the original as the base.
- // XXX This will fail for CVSNT with directory pruning on
- refresh(getSubscriber(), project);
- }
-
- public void testIgnoredResource() throws CoreException, TeamException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testIgnoredResource", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Create a new file without adding it to version control
- buildResources(project, new String[] {"ignored.txt"}, false);
-
- // Get the sync tree for the project
- assertSyncEquals("testIgnoredResource", project,
- new String[] { "ignored.txt"},
- true, new int[] {SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- IFile ignores = project.getFile(".cvsignore");
- ignores.create(new ByteArrayInputStream("ignored.txt".getBytes()), false, DEFAULT_MONITOR);
- addResources(new IResource[] {ignores});
-
- assertSyncEquals("testIgnoredResource", project,
- new String[] { "ignored.txt", ".cvsignore"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
- }
-
- public void testRenameUnshared() throws CoreException, TeamException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testRenameUnshared", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Create a new file without adding it to version control
- buildResources(project, new String[] {"oldName.txt"}, false);
-
- // Get the sync tree for the project
- assertSyncEquals("testRenameUnshared", project,
- new String[] { "oldName.txt" },
- true, new int[] {SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- IFile rename = project.getFile("oldName.txt");
- rename.move(new Path("newName.txt"), false, false, DEFAULT_MONITOR);
-
- assertDeleted("testRenameUnshared", project, new String[] {"oldName.txt"});
-
- assertSyncEquals("testRenameUnshared", project,
- new String[] { "newName.txt"},
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
- }
-
- public void testOutgoingEmptyFolder() throws CoreException, TeamException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testOutgoingEmptyFolder", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Create an empty folder without adding it to version control
- buildResources(project, new String[] {"folder2/"}, false);
-
- assertSyncEquals("testOutgoingEmptyFolder", project,
- new String[] { "folder2/" },
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.ADDITION});
-
- commit(project, new String[] { "folder2" });
-
- assertSyncEquals("testOutgoingEmptyFolder", project,
- new String[] { "folder2/" },
- true, new int[] {
- SyncInfo.IN_SYNC});
-
- // Ensure that the folder still exists (i.e. wasn't pruned)
- assertTrue("Folder should still exist", project.getFolder("folder2").exists());
- }
-
- public void testDisconnectingProject() throws CoreException, TeamException, InterruptedException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testDisconnect", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project);
- RepositoryProvider.unmap(project);
- assertProjectRemoved(getWorkspaceSubscriber(), project);
- }
-
- /*
- * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=40221
- */
- public void testConflictingFolderDeletion() throws TeamException, CoreException {
- // Create a test project (which commits it as well)
- IProject project = createProject("testConflictingFolderDeletion", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // Checkout a copy
- IProject copy = checkoutCopy(project, "-copy");
-
- // Delete a folder in both projects and checkin one of the deletions
- deleteResources(project, new String[] { "folder1/" }, false /* checkin */);
- deleteResources(copy, new String[] { "folder1/" }, true /* checkin */);
-
- // The files should show up as outgoing deletions
- assertSyncEquals("testConflictingFolderDeletion sync check", project,
- new String[] { "folder1/", "folder1/a.txt", "folder1/b.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.IN_SYNC, /* conflicting deletions are handled automatically */
- SyncInfo.IN_SYNC});
- }
-
- public void testOverrideAndUpdateOutgoingAddition() throws TeamException, CoreException {
- // Create a test project (which commits it as well)
- IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- IFolder newFolder = project.getFolder("newFolder");
- newFolder.create(false, true, null);
- buildResources(newFolder, new String[] {"newFile"}, false);
- overrideAndUpdate(project, new String[] {"newFolder", "newFolder/newFile"}, true);
- assertDoesNotExistInFileSystem(newFolder);
- }
-
- public void testProjectClose() throws TeamException, CoreException {
- IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- setContentsAndEnsureModified(project.getFile("file1.txt"));
- assertSyncEquals("testProjectClose sync check", project,
- new String[] { "file1.txt"},
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- });
-
- project.close(null);
- assertProjectRemoved(getWorkspaceSubscriber(), project);
- }
-
- public void testUpdateBinaryConflict() throws TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a shared project with a binary file
- IProject project = createProject(new String[] { "binary.gif"});
- assertIsBinary(project.getFile("binary.gif"));
-
- // Checkout a copy, modify the binary file and commit
- IProject copy = checkoutCopy(project, "-copy");
- assertIsBinary(copy.getFile("binary.gif"));
- setContentsAndEnsureModified(copy.getFile("binary.gif"));
- commitProject(copy);
-
- // Modify the same binary file and ensure sync is correct
- setContentsAndEnsureModified(project.getFile("binary.gif"));
- assertSyncEquals("testProjectClose sync check", project,
- new String[] { "binary.gif"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- });
-
- // Perform an update and ensure the binary conflict is skipped
- update(project, new String[] { "binary.gif"});
- assertSyncEquals("testProjectClose sync check", project,
- new String[] { "binary.gif"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.CHANGE,
- });
- }
-
- private void assertIsBinary(IFile local) throws CVSException {
- ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)local);
- byte[] syncBytes = file.getSyncBytes();
- if (syncBytes != null) {
- assertTrue(ResourceSyncInfo.isBinary(syncBytes));
- }
- }
-
- public void testNestedMarkAsMerged() throws CoreException, InvocationTargetException, InterruptedException {
- // Create a project and checkout a copy
- IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- IProject copy = checkoutCopy(project, "-copy");
- // Add the same resources to both projects to create conflicting additions
- buildResources(project, new String[] { "folder2/", "folder2/file.txt", "folder2/file2.txt"}, false);
- addResources(copy, new String[] { "folder2/", "folder2/file.txt", "folder2/file2.txt"}, true);
- assertSyncEquals("testNestedMarkAsMerged sync check", project,
- new String[] { "folder2/", "folder2/file.txt", "folder2/file.txt"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION
- });
- markAsMerged(getSubscriber(), project, new String[] {"folder2/file.txt"});
- assertSyncEquals("testNestedMarkAsMerged sync check", project,
- new String[] { "folder2/", "folder2/file.txt", "folder2/file2.txt"},
- true, new int[] {
- SyncInfo.IN_SYNC,
- SyncInfo.OUTGOING | SyncInfo.CHANGE,
- SyncInfo.CONFLICTING | SyncInfo.ADDITION
- });
- }
-
- public void testMarkAsMergedOnBinaryFile() throws TeamException, CoreException, InvocationTargetException, InterruptedException {
- // Create a project and checkout a copy
- IProject project = createProject(new String[] { "file1.txt"});
- IProject copy = checkoutCopy(project, "-copy");
- // Add the same binary file to both projects to create a conflicting addition
- buildResources(project, new String[] {"binary.gif"}, false);
- addResources(copy, new String[] {"binary.gif"}, true);
- assertIsBinary(copy.getFile("binary.gif"));
- assertSyncEquals("testMarkAsMergedOnBinaryFile sync check", project,
- new String[] {"binary.gif"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.ADDITION
- });
- markAsMerged(getSubscriber(), project, new String[] {"binary.gif"});
- assertSyncEquals("testMarkAsMergedOnBinaryFile sync check", project,
- new String[] {"binary.gif"},
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.CHANGE
- });
- assertIsBinary(project.getFile("binary.gif"));
- // Unmanage the file and do it again
- // This tests the case were the contents are already cached locally
- CVSWorkspaceRoot.getCVSFileFor(project.getFile("binary.gif")).unmanage(DEFAULT_MONITOR);
- assertSyncEquals("testMarkAsMergedOnBinaryFile sync check", project,
- new String[] {"binary.gif"},
- true, new int[] {
- SyncInfo.CONFLICTING | SyncInfo.ADDITION
- });
- markAsMerged(getSubscriber(), project, new String[] {"binary.gif"});
- assertSyncEquals("testMarkAsMergedOnBinaryFile sync check", project,
- new String[] {"binary.gif"},
- true, new int[] {
- SyncInfo.OUTGOING | SyncInfo.CHANGE
- });
- assertIsBinary(project.getFile("binary.gif"));
- }
-
- /**
- * Bug 48467
- *
- * Files imported into CVS may have revision number 1.1.1.1.
- * A subsequent commit will raise the revision to 1.2.
- * We had code that would ignore the new sync bytes in the
- * sync view because the new revision was shorter than the old one.
- */
- public void testSyncAfterImport() throws CoreException {
- // First, use "cvs import" to add a project to CVS
- String[] resources = new String[] { "file.txt" };
- IProject project = getUniqueTestProject(getName());
- buildResources(project, resources, true);
- importProject(project);
-
- // Now, check out the project
- IProject copy = getWorkspace().getRoot().getProject(project.getName() + "copy");
- checkout(getRepository(), copy, project.getName(), null, DEFAULT_MONITOR);
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(copy.getFile("file.txt"));
- assertTrue("File in wrong state", cvsFile.isManaged() && cvsFile.getSyncInfo().getRevision().equals("1.1.1.1"));
-
- // Check out another and commit a change to the file
- IProject anotherCopy = checkoutCopy(copy, "another");
- cvsFile = CVSWorkspaceRoot.getCVSFileFor(anotherCopy.getFile("file.txt"));
- assertTrue("File in wrong state", cvsFile.isManaged() && cvsFile.getSyncInfo().getRevision().equals("1.1.1.1"));
- setContentsAndEnsureModified(anotherCopy.getFile("file.txt"));
- commitProject(anotherCopy);
-
- // Assert that the change shows up in original
- assertSyncEquals("testSyncAfterImport sync check", copy,
- new String[] {"file.txt"},
- true, new int[] {
- SyncInfo.INCOMING | SyncInfo.CHANGE
- });
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java
deleted file mode 100644
index c72e71ff8..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import java.util.*;
-
-import junit.framework.AssertionFailedError;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * This class acts as the source for the sync info used by the subscriber tests.
- * The purpose is to allow the sync info to be obtained directly from the subscriber
- * or through the sync set visible in the sync view.
- */
-public class SyncInfoSource {
-
- protected static IProgressMonitor DEFAULT_MONITOR = new NullProgressMonitor();
- protected List mergeSubscribers = new ArrayList();
- protected List compareSubscribers = new ArrayList();
-
- public CVSMergeSubscriber createMergeSubscriber(IProject project, CVSTag root, CVSTag branch) {
- CVSMergeSubscriber subscriber = new CVSMergeSubscriber(new IResource[] { project }, root, branch);
- mergeSubscribers.add(subscriber);
- return subscriber;
- }
-
- public CVSCompareSubscriber createCompareSubscriber(IProject project, CVSTag tag) {
- CVSCompareSubscriber subscriber = new CVSCompareSubscriber(new IResource[] { project }, tag);
- compareSubscribers.add(subscriber);
- return subscriber;
- }
-
- public Subscriber createWorkspaceSubscriber() throws TeamException {
- return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
- }
-
- /**
- * Return the sync info for the given subscriber for the given resource.
- */
- public SyncInfo getSyncInfo(Subscriber subscriber, IResource resource) throws TeamException {
- return subscriber.getSyncInfo(resource);
- }
-
- /**
- * Refresh the subscriber for the given resource
- */
- public void refresh(Subscriber subscriber, IResource resource) throws TeamException {
- subscriber.refresh(new IResource[] { resource}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
- }
-
- protected void assertProjectRemoved(Subscriber subscriber, IProject project) throws TeamException {
- IResource[] roots = subscriber.roots();
- for (int i = 0; i < roots.length; i++) {
- IResource resource = roots[i];
- if (resource.equals(project)) {
- throw new AssertionFailedError();
- }
- }
- }
-
- public void tearDown() {
- for (Iterator it = mergeSubscribers.iterator(); it.hasNext(); ) {
- CVSMergeSubscriber s = (CVSMergeSubscriber) it.next();
- s.cancel();
- }
- }
-
- /**
- * Recalculate a sync info from scratch
- */
- public void reset(Subscriber subscriber) throws TeamException {
- // Do nothing
-
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncSetTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncSetTests.java
deleted file mode 100644
index 039ddcedd..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncSetTests.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoSet;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-
-
-public class SyncSetTests extends CVSSyncSubscriberTest {
-
- public SyncSetTests() {
- super();
- }
-
- public SyncSetTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(SyncSetTests.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new SyncSetTests(testName));
- }
- }
-
- class TestSyncInfo extends SyncInfo {
- protected int calculateKind() throws TeamException {
- return 0;
- }
- public TestSyncInfo() throws TeamException {
- super(ResourcesPlugin.getWorkspace().getRoot(), null, null, null);
- }
- }
-
- /**
- * Test that ensures that SyncSet can be modified concurrently. This is a quick test
- * that doesn't validate the actual contents of the sync set.
- */
- public void testConcurrentAccessToSyncSet() throws Throwable {
- final SubscriberSyncInfoSet set = new SubscriberSyncInfoSet(null);
- final boolean[] done = {false};
- final IStatus[] error = {null};
-
- for(int numJobs = 0; numJobs < 10; numJobs++) {
- Job job = new Job("SyncSetTests" + numJobs) {
- public IStatus run(IProgressMonitor monitor) {
- while(! done[0]) {
- try {
- set.add(new TestSyncInfo());
- set.getSyncInfos(ResourcesPlugin.getWorkspace().getRoot(), IResource.DEPTH_INFINITE);
- set.getSyncInfo(ResourcesPlugin.getWorkspace().getRoot());
- set.getSyncInfos();
- } catch (Exception e) {
- error[0] = new Status(IStatus.ERROR, "this", 1, "", e);
- return error[0];
- }
- }
- return Status.OK_STATUS;
- }
- };
-
- job.addJobChangeListener(new JobChangeAdapter() {
- public void done(IJobChangeEvent event) {
- if(event.getResult() != Status.OK_STATUS) {
- error[0] = event.getResult();
- }
- }
- });
-
- job.schedule();
- }
-
- for(int i = 0; i < 10000; i++) {
- set.add(new TestSyncInfo());
- set.getSyncInfos(ResourcesPlugin.getWorkspace().getRoot(), IResource.DEPTH_INFINITE);
- set.getSyncInfo(ResourcesPlugin.getWorkspace().getRoot());
- set.getSyncInfos();
- set.members(ResourcesPlugin.getWorkspace().getRoot());
- set.clear();
- }
- done[0] = true;
- if(error[0] != null) {
- throw error[0].getException();
- }
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestCommitOperation.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestCommitOperation.java
deleted file mode 100644
index e7275f774..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestCommitOperation.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.synchronize.SyncInfoSet;
-import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager;
-import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceCommitOperation;
-
-class TestCommitOperation extends WorkspaceCommitOperation {
-
- private boolean prompted;
-
- public TestCommitOperation(IDiffElement[] elements, boolean override) {
- super(null, elements, override);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.actions.TeamOperation#canRunAsJob()
- */
- protected boolean canRunAsJob() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitOperation#promptForComment(org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager, org.eclipse.core.resources.IResource[])
- */
- protected String promptForComment(RepositoryManager manager, IResource[] resourcesToCommit) {
- return "dummy comment";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitOperation#promptForConflicts(org.eclipse.team.core.synchronize.SyncInfoSet)
- */
- protected int promptForConflicts(SyncInfoSet syncSet) {
- this.prompted = true;
- return 0; // ok to commit all conflicts
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitOperation#promptForResourcesToBeAdded(org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager, org.eclipse.core.resources.IResource[])
- */
- protected IResource[] promptForResourcesToBeAdded(RepositoryManager manager, IResource[] unadded) {
- return unadded;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitOperation#promptForConflictHandling(org.eclipse.team.core.synchronize.SyncInfoSet)
- */
- protected boolean promptForConflictHandling(SyncInfoSet syncSet) {
- return true;
- }
-
- public boolean isPrompted() {
- return this.prompted;
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestMergeUpdateOperation.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestMergeUpdateOperation.java
deleted file mode 100644
index c82f0bb18..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestMergeUpdateOperation.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import junit.framework.Assert;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.synchronize.SyncInfoSet;
-import org.eclipse.team.internal.ccvs.ui.subscriber.MergeUpdateOperation;
-
-
-class TestMergeUpdateOperation extends MergeUpdateOperation {
- boolean allowOverwrite = false;
-
- public TestMergeUpdateOperation(IDiffElement[] elements, boolean allowOverwrite) {
- super(null, elements, false /* prompt before update */);
- this.allowOverwrite = allowOverwrite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#promptForOverwrite(org.eclipse.team.core.synchronize.SyncInfoSet)
- */
- protected boolean promptForOverwrite(SyncInfoSet syncSet) {
- if (allowOverwrite) return true;
- if (syncSet.isEmpty()) return true;
- IResource[] resources = syncSet.getResources();
- Assert.fail(resources[0].getFullPath().toString() + " failed to merge properly");
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.actions.TeamOperation#canRunAsJob()
- */
- protected boolean canRunAsJob() {
- return false;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestOverrideAndUpdateOperation.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestOverrideAndUpdateOperation.java
deleted file mode 100644
index fbce4c751..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestOverrideAndUpdateOperation.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.team.core.synchronize.SyncInfoSet;
-import org.eclipse.team.internal.ccvs.ui.subscriber.OverrideAndUpdateSubscriberOperation;
-
-public class TestOverrideAndUpdateOperation extends OverrideAndUpdateSubscriberOperation {
-
- private boolean prompted = false;
-
- protected TestOverrideAndUpdateOperation(IDiffElement[] elements) {
- super(null, elements);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.actions.TeamOperation#canRunAsJob()
- */
- protected boolean canRunAsJob() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#promptForOverwrite(org.eclipse.team.core.synchronize.SyncInfoSet)
- */
- protected boolean promptForOverwrite(SyncInfoSet syncSet) {
- TestOverrideAndUpdateOperation.this.prompted = true;
- return true;
- }
-
- public boolean isPrompted() {
- return this.prompted;
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java
deleted file mode 100644
index 3f072bbf6..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.core.subscriber;
-
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.team.core.synchronize.SyncInfoSet;
-import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceUpdateOperation;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-class TestUpdateOperation extends WorkspaceUpdateOperation {
-
- protected TestUpdateOperation(IDiffElement[] elements) {
- super(null, elements, false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.actions.TeamOperation#canRunAsJob()
- */
- protected boolean canRunAsJob() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.subscriber.SafeUpdateOperation#warnAboutFailedResources(org.eclipse.team.core.synchronize.SyncInfoSet)
- */
- protected void warnAboutFailedResources(SyncInfoSet syncSet) {
- return;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#promptForOverwrite(org.eclipse.team.core.synchronize.SyncInfoSet)
- */
- protected boolean promptForOverwrite(SyncInfoSet syncSet) {
- EclipseTest.fail("Should never prompt on update, simply update nodes that are valid.");
- return false;
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/AllUITests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/AllUITests.java
deleted file mode 100644
index 0dcdb67bf..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/AllUITests.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class AllUITests extends EclipseTest {
-
- public AllUITests() {
- super();
- }
-
- public AllUITests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(CheckoutOperationTests.suite());
- suite.addTest(CompareOperationTests.suite());
- suite.addTest(MiscOperationsTests.suite());
- return suite;
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSOperationTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSOperationTest.java
deleted file mode 100644
index 08b878252..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSOperationTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.ui.operations.CVSOperation;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public abstract class CVSOperationTest extends EclipseTest {
-
- protected CVSOperationTest() {
- super();
- }
-
- protected CVSOperationTest(String name) {
- super(name);
- }
-
- protected void run(CVSOperation op) throws CVSException {
- executeHeadless(op);
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CheckoutOperationTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CheckoutOperationTests.java
deleted file mode 100644
index f54f50d75..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CheckoutOperationTests.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import java.io.IOException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.operations.CVSOperation;
-import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation;
-import org.eclipse.team.internal.ccvs.ui.operations.CheckoutSingleProjectOperation;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-
-public class CheckoutOperationTests extends CVSOperationTest {
-
- public CheckoutOperationTests() {
- }
-
- public CheckoutOperationTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(CheckoutOperationTests.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new CheckoutOperationTests(testName));
- }
- }
- public void testSimpleCheckout() throws CoreException, TeamException, IOException {
- IProject project = createProject("testSimpleCheckout", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // move the created project so we can do a simple checkout
- project.move(new Path("moved-project"), false /* force */, DEFAULT_MONITOR);
- IProject movedProject = ResourcesPlugin.getWorkspace().getRoot().getProject("moved-project");
-
- // checkout the project to the default location
- CVSOperation op = new CheckoutMultipleProjectsOperation(
- null /* shell */,
- new ICVSRemoteFolder[] { (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(movedProject) },
- null /*target location*/);
- run(op);
-
- assertEquals(project, movedProject);
- }
-
- public void testNonRootCheckout() throws CoreException, TeamException, IOException {
- IProject project = createProject("testNonRootCheckout", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
-
- // checkout the non-root folder as a project to the default location
- CVSOperation op = new CheckoutMultipleProjectsOperation(
- null /* shell */,
- new ICVSRemoteFolder[] { (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project.getFolder("folder1")) },
- null /*target location*/);
- run(op);
-
- IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject("folder1");
- assertTrue(newProject.exists());
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(newProject);
- FolderSyncInfo projectInfo = cvsFolder.getFolderSyncInfo();
- assertTrue(projectInfo != null);
- ICVSFolder cvsFolder2 = CVSWorkspaceRoot.getCVSFolderFor(project.getFolder("folder1"));
- FolderSyncInfo folderInfo = cvsFolder2.getFolderSyncInfo();
- assertTrue(folderInfo != null);
- assertTrue(projectInfo.equals(folderInfo));
- }
-
- public void testMulitpleCheckout() throws CoreException, TeamException {
- IProject project1 = createProject("testNonRootCheckout1", new String[] { "file.txt", "folder1/", "folder1/a.txt" });
- IProject project2 = createProject("testNonRootCheckout2", new String[] { "file2.txt", "folder2/", "folder2/b.txt" });
-
- // move the created project so we can do a simple checkout
- project1.move(new Path("moved-project1"), false /* force */, DEFAULT_MONITOR);
- IProject movedProject1 = ResourcesPlugin.getWorkspace().getRoot().getProject("moved-project1");
- project2.move(new Path("moved-project2"), false /* force */, DEFAULT_MONITOR);
- IProject movedProject2 = ResourcesPlugin.getWorkspace().getRoot().getProject("moved-project2");
-
-
- // checkout the project to the default location
- CVSOperation op = new CheckoutMultipleProjectsOperation(
- null /* shell */,
- new ICVSRemoteFolder[] {
- (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(movedProject1),
- (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(movedProject2)
- },
- null /*target location*/);
- run(op);
- }
-
- public void testCheckoutAs() throws TeamException, CoreException, IOException {
- IProject project = createProject("testCheckoutAs", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
- IProject copy = ResourcesPlugin.getWorkspace().getRoot().getProject(project.getName() + "-copy");
-
- // checkout the project to the default location
- CVSOperation op = new CheckoutSingleProjectOperation(
- null /* shell */,
- (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project),
- copy,
- null /*target location*/,
- false);
- run(op);
-
- assertEquals(project, copy);
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CompareOperationTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CompareOperationTests.java
deleted file mode 100644
index b21b745d0..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CompareOperationTests.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import java.util.*;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.operations.RemoteCompareOperation;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class CompareOperationTests extends CVSOperationTest {
-
- public class TestRemoteCompareOperation extends RemoteCompareOperation {
- private ICVSRemoteFolder leftTree, rightTree;
-
- public TestRemoteCompareOperation(IWorkbenchPart part, ICVSRemoteResource resource, CVSTag tag) {
- super(part, resource, tag);
- }
-
- /*
- * Override to prevent compare editor from opening and to capture the results
- */
- protected void openCompareEditor(ICVSRemoteFolder leftTree, ICVSRemoteFolder rightTree) {
- this.leftTree = leftTree;
- this.rightTree = rightTree;
- }
-
- public ICVSRemoteFolder getLeftTree() {
- return leftTree;
- }
-
- public ICVSRemoteFolder getRightTree() {
- return rightTree;
- }
-
- }
-
- public CompareOperationTests() {
- super();
- }
-
- public CompareOperationTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(CompareOperationTests.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new CompareOperationTests(testName));
- }
- }
-
-
- /**
- * Assert that the revisions of any files in the remote tree match the revisions in the local tree
- */
-
- private void assertRevisionsMatch(ICVSRemoteFolder folder, IProject project, String[] filePathsWithRevisions, String[] filePathsWithoutRevisions) throws CoreException {
- if (filePathsWithRevisions == null) filePathsWithRevisions = new String[0];
- if (filePathsWithoutRevisions == null) filePathsWithoutRevisions = new String[0];
- IResource[] filesWithRevisions = getResources(project, filePathsWithRevisions);
- IResource[] filesWithoutRevisions = getResources(project, filePathsWithoutRevisions);
- ICVSRemoteFile[] files= getAllFiles(folder);
- assertTrue("The number of remote files with differences does not match the expected number", files.length == (filePathsWithoutRevisions.length + filePathsWithRevisions.length));
- for (int i = 0; i < files.length; i++) {
- ICVSRemoteFile remoteFile = files[i];
- for (int j = 0; j < filesWithRevisions.length; j++) {
- IResource local = filesWithRevisions[j];
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)local);
- if (cvsFile.getRepositoryRelativePath().equals(remoteFile.getRepositoryRelativePath())) {
- ResourceSyncInfo info = cvsFile.getSyncInfo();
- assertNotNull(info);
- String localRevision = info.getRevision();
- assertNotNull(localRevision);
- String remoteRevision = files[i].getRevision();
- assertNotNull(remoteRevision);
- assertEquals("Revisions do not match for " + local.getProjectRelativePath(), localRevision, remoteRevision);
- }
- }
- for (int j = 0; j < filesWithoutRevisions.length; j++) {
- IResource local = filesWithoutRevisions[j];
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)local);
- if (cvsFile.getRepositoryRelativePath().equals(remoteFile.getRepositoryRelativePath())) {
- ResourceSyncInfo info = cvsFile.getSyncInfo();
- assertNotNull(info);
- String localRevision = info.getRevision();
- assertNotNull(localRevision);
- // Cannot assert anything about the remote revision
- }
- }
- }
- }
-
- private ICVSRemoteFile[] getAllFiles(ICVSRemoteFolder folder) {
- List result = new ArrayList();
- ICVSRemoteResource[] children = ((RemoteFolder)folder).getChildren();
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- ICVSRemoteResource resource = children[i];
- if (resource.isContainer()) {
- result.addAll(Arrays.asList(getAllFiles((ICVSRemoteFolder)resource)));
- } else {
- result.add(resource);
- }
- }
- }
- return (ICVSRemoteFile[]) result.toArray(new ICVSRemoteFile[result.size()]);
- }
-
- public void testCompareWithLatest() throws TeamException, CoreException {
- // Create a test project
- IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
- CVSTag v1 = new CVSTag("v1", CVSTag.VERSION);
- tagProject(project, v1, false);
-
- // Checkout and modify a copy (and commit the changes)
- IProject copy = checkoutCopy(project, "-copy");
- setContentsAndEnsureModified(copy.getFile("folder1/a.txt"));
- addResources(copy, new String[] { "folder1/newFile", "folder2/folder3/add.txt" }, false);
- deleteResources(copy, new String[] {"folder1/b.txt"}, false);
- commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE);
-
- // Run the compare operation of the project folder
- ICVSRemoteResource remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(project);
- TestRemoteCompareOperation op = new TestRemoteCompareOperation(null, remoteResource, v1);
- run(op);
- assertRevisionsMatch(op.getRightTree(), project, new String[] {"folder1/a.txt", "folder1/b.txt"}, null);
- assertRevisionsMatch(op.getLeftTree(), copy, new String[] {"folder1/a.txt" }, new String[] {"folder1/newFile", "folder2/folder3/add.txt" } /* files with no revision */);
-
-
- // Run the compare operation of the project folder the other way
- remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(project);
- remoteResource = ((ICVSRemoteFolder)remoteResource).forTag(v1);
- op = new TestRemoteCompareOperation(null, remoteResource, CVSTag.DEFAULT);
- run(op);
- assertRevisionsMatch(op.getLeftTree(), project, new String[] {"folder1/a.txt"}, new String[] {"folder1/b.txt"});
- assertRevisionsMatch(op.getRightTree(), copy, new String[] {"folder1/a.txt", "folder1/newFile", "folder2/folder3/add.txt" }, null /* files with no revision */);
-
- // Run the compare operation of a subfolder
- remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(project.getFolder("folder1"));
- op = new TestRemoteCompareOperation(null, remoteResource, v1);
- run(op);
- assertRevisionsMatch(op.getRightTree(), project, new String[] {"folder1/a.txt", "folder1/b.txt"}, null);
- assertRevisionsMatch(op.getLeftTree(), copy, new String[] {"folder1/a.txt"}, new String[] {"folder1/newFile" } /* files with no revision */);
-
- // Run the operation on a single file
- remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(copy.getFile("folder1/a.txt"));
- op = new TestRemoteCompareOperation(null, remoteResource, v1);
- run(op);
- assertRevisionsMatch(op.getRightTree(), project, new String[] {"folder1/a.txt"}, null);
- assertRevisionsMatch(op.getLeftTree(), copy, new String[] {"folder1/a.txt" }, null /* files with no revision */);
-
- // Run the operation on a single file using RemoteCompareOperation.getTag
- // to determine the tag
- remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(copy.getFile("folder1/a.txt"));
- op = new TestRemoteCompareOperation(null, remoteResource, RemoteCompareOperation.getTag(CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("folder1/a.txt"))));
- run(op);
- assertRevisionsMatch(op.getRightTree(), project, new String[] {"folder1/a.txt"}, null);
- assertRevisionsMatch(op.getLeftTree(), copy, new String[] {"folder1/a.txt" }, null /* files with no revision */);
-
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MenuEnablementTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MenuEnablementTest.java
deleted file mode 100644
index 4c0efec9b..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MenuEnablementTest.java
+++ /dev/null
@@ -1,497 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.ui.actions.*;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-import org.eclipse.ui.IActionDelegate;
-
-/**
- * Test the menu enablement code for the CVS menus
- */
-public class MenuEnablementTest extends EclipseTest {
-
- private static final int MANAGED = 1;
- private static final int ADDED = 2;
- private static final int UNMANAGED = 4;
- private static final int IGNORED = 8;
- private static final int SINGLE_ONLY = 16;
- private static final int FOLDERS = 32;
- private static final int FILES = 64;
- private static final int UNMANAGED_PARENT = 128;
-
- /**
- * Constructor for CVSProviderTest
- */
- public MenuEnablementTest() {
- super();
- }
-
- /**
- * Constructor for CVSProviderTest
- */
- public MenuEnablementTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(MenuEnablementTest.class);
- return new CVSTestSetup(suite);
- //return new CVSTestSetup(new MenuEnablementTest("testReadOnly"));
- }
-
- /**
- * Create a test project for the given action delegate. The structure of
- * this test project is used by the get resource methods to return resources
- * of the proper type.
- *
- * @param actionDelegate
- * @throws CoreException
- * @throws TeamException
- */
- private IProject createTestProject(IActionDelegate actionDelegate) throws CoreException, TeamException {
- String actionName = getName(actionDelegate);
- return createProject(actionName, new String[] { "file.txt", "folder1/", "folder1/a.txt" });
- }
-
- private List getManagedResources(IProject testProject, boolean includeFolders, boolean multiple) {
- List result = new ArrayList();
- if (includeFolders) {
- result.add(testProject.getFolder("folder1"));
- } else {
- result.add(testProject.getFile("folder1/a.txt"));
- }
- if (multiple) {
- result.add(testProject.getFile("file.txt"));
- }
- return result;
- }
-
- private List getAddedResources(IProject testProject) throws CoreException, TeamException {
- List result = new ArrayList();
- IFile file = testProject.getFile("added.txt");
- if (!file.exists()) {
- addResources(testProject, new String[] {"added.txt"}, false);
- }
- result.add(file);
- return result;
- }
-
- private List getIgnoredResources(IProject testProject) throws CoreException, TeamException {
- List result = new ArrayList();
- IFile file = testProject.getFile("ignored.txt");
- if (!file.exists()) {
- file.create(getRandomContents(), false, null);
- }
- result.add(file);
- IFile ignoreFile = testProject.getFile(".cvsignore");
- InputStream contents = new ByteArrayInputStream("ignored.txt".getBytes());
- if (ignoreFile.exists()) {
- ignoreFile.setContents(contents, false, false, null);
- } else {
- ignoreFile.create(contents, false, null);
- }
- return result;
- }
-
- private List getUnmanagedResources(IProject testProject) throws CoreException, TeamException {
- List result = new ArrayList();
- IFile file = testProject.getFile("unmanaged.txt");
- if (!file.exists()) {
- file.create(getRandomContents(), false, null);
- }
- result.add(file);
- return result;
- }
-
- /**
- * Method getResourceWithUnmanagedParent.
- * @param project
- * @return Collection
- */
- private List getResourceWithUnmanagedParent(IProject project) throws CoreException {
- List result = new ArrayList();
- IFolder folder = project.getFolder("newFolder");
- if(!folder.exists()) folder.create(false, true, null);
- IFile file = folder.getFile("unmanaged.txt");
- if (!file.exists()) {
- file.create(getRandomContents(), false, null);
- }
- result.add(file);
- return result;
- }
-
- private List getOverlappingResources(IProject testProject, boolean includeFiles) {
- List result = new ArrayList();
- result.add(testProject);
- result.add(testProject.getFolder("folder1"));
- if (includeFiles) {
- result.add(testProject.getFile("folder1/a.txt"));
- }
- return result;
- }
-
- private ISelection asSelection(List resources) {
- return new StructuredSelection(resources);
- }
-
- private String getName(IActionDelegate actionDelegate) {
- return actionDelegate.getClass().getName();
- }
-
- /**
- * Assert that the enablement for the given IActionDelegate and ISelection
- * match that provided as expectedEnablement.
- *
- * @param actionDelegate
- * @param selection
- * @param expectedEnablement
- */
- private void assertEnablement(IActionDelegate actionDelegate, ISelection selection, boolean expectedEnablement) {
- IAction action = new Action() {};
- actionDelegate.selectionChanged(action, selection);
- assertEquals(getName(actionDelegate) + " enablement wrong!", expectedEnablement, action.isEnabled());
- }
-
- /**
- * Method assertEnablement.
- * @param action
- * @param project
- * @param IGNORED
- * @param b
- */
- private void assertEnablement(IActionDelegate action, IProject project, int kind, boolean expectedEnablement) throws CoreException, TeamException {
- List resources = new ArrayList();
- boolean multiple = (kind & SINGLE_ONLY) == 0;
- boolean includeFolders = ((kind & FOLDERS) > 0) || ((kind & FILES) == 0);
- if ((kind & MANAGED) > 0) {
- resources.addAll(getManagedResources(project, includeFolders, multiple));
- }
- if ((kind & UNMANAGED) > 0) {
- resources.addAll(getUnmanagedResources(project));
- }
- if ((kind & IGNORED) > 0) {
- resources.addAll(getIgnoredResources(project));
- }
- if ((kind & ADDED) > 0) {
- resources.addAll(getAddedResources(project));
- }
- if ((kind & UNMANAGED_PARENT) > 0) {
- resources.addAll(getResourceWithUnmanagedParent(project));
- }
- ensureAllSyncInfoLoaded(project);
- assertEnablement(action, asSelection(resources), expectedEnablement);
- }
-
- /**
- * Method ensureAllSyncInfoLoaded.
- * @param project
- */
- private void ensureAllSyncInfoLoaded(IProject project) throws CVSException {
- EclipseSynchronizer.getInstance().ensureSyncInfoLoaded(new IResource[] {project}, IResource.DEPTH_INFINITE);
- }
-
- /**
- * Assert that the action is disabled for the reasons common to all menu
- * actions.
- *
- * @param action
- * @param project
- */
- public void assertDisabledForCommonReasons(IActionDelegate action, IProject project) throws CoreException {
- assertDisabledForNoSelection(action);
- assertDisabledForFolderFileOverlap(action, project);
- assertDisabledForClosedProject(action, project);
- assertDisabledForNonCVSProject(action);
- }
-
- private void assertDisabledForNoSelection(IActionDelegate actionDelegate) {
- assertEnablement(actionDelegate, StructuredSelection.EMPTY, false /* expected enablement */);
- }
-
- private void assertDisabledForFolderFileOverlap(IActionDelegate action, IProject project) {
- List resources = getOverlappingResources(project, true /* include files */);
- assertEnablement(action, asSelection(resources), false /* enabled */);
- }
-
- private void assertDisabledForClosedProject(IActionDelegate action, IProject project) throws CoreException {
- project.close(null);
- List resources = new ArrayList();
- resources.add(project);
- assertEnablement(action, asSelection(resources), false /* enabled */);
- project.open(null);
- }
-
- private void assertDisabledForNonCVSProject(IActionDelegate action) throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("Non-CVS");
- if (!project.exists())
- project.create(null);
- List resources = new ArrayList();
- resources.add(project);
- assertEnablement(action, asSelection(resources), false /* enabled */);
- }
-
- private void assertEnabledForFolderOnlyOverlap(IActionDelegate action, IProject project) {
- List resources = getOverlappingResources(project, false /* include files */);
- assertEnablement(action, asSelection(resources), true /* enabled */);
- }
-
- public void testAddAction() throws CoreException, TeamException {
- IActionDelegate action = new AddAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnablement(action, project, MANAGED, false /* expected enablement */);
- assertEnablement(action, project, ADDED, false /* expected enablement */);
- assertEnablement(action, project, IGNORED, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | IGNORED, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | SINGLE_ONLY, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, true /* expected enablement */);
- }
-
- public void testBranchAction() throws CoreException, TeamException {
- IActionDelegate action = new BranchAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, true /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- }
-
- public void testCommitAction() throws CoreException, TeamException {
- IActionDelegate action = new CommitAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, true /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, true /* expected enablement */);
- }
-
- public void testCompareWithRevison() throws CoreException, TeamException {
- IActionDelegate action = new CompareWithRevisionAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnablement(action, project, MANAGED | FILES | SINGLE_ONLY, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | FOLDERS | FILES, false /* expected enablement */);
- assertEnablement(action, project, MANAGED | FOLDERS | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, MANAGED | FILES, false /* expected enablement */);
- assertEnablement(action, project, ADDED | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, IGNORED | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- }
-
- public void testCompareWithTagAction() throws CoreException, TeamException {
- IActionDelegate action = new CompareWithTagAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- // true is expected for ignored resources whose parent is not ignored
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- }
-
- public void testGenerateDiffAction() throws CoreException, TeamException {
- IActionDelegate action = new GenerateDiffFileAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnablement(action, project, MANAGED | FILES | SINGLE_ONLY, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | FOLDERS | FILES, false /* expected enablement */);
- assertEnablement(action, project, MANAGED | FOLDERS | SINGLE_ONLY, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | FILES, false /* expected enablement */);
- assertEnablement(action, project, ADDED | SINGLE_ONLY, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | SINGLE_ONLY, true /* expected enablement */);
- assertEnablement(action, project, IGNORED | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- }
-
- /*
- * Should be the same as testAdd
- */
- public void testIgnoreAction() throws CoreException, TeamException {
- IActionDelegate action = new IgnoreAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnablement(action, project, MANAGED, false /* expected enablement */);
- assertEnablement(action, project, ADDED, false /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | SINGLE_ONLY, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, true /* expected enablement */);
- }
-
- public void testMergeAction() throws CoreException, TeamException {
- IActionDelegate action = new MergeAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- }
-
- public void testReplaceWithRemoteAction() throws CoreException, TeamException {
- IActionDelegate action = new ReplaceWithRemoteAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, false /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, false /* expected enablement */);
- // true is expected for ignored resources whose parent is not ignored
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- // true is expected for ignored resources whose parent is not ignored
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- }
-
- /*
- * Should be the same as testCompareWithTagAction
- */
- public void testReplaceWithTagAction() throws CoreException, TeamException {
- IActionDelegate action = new ReplaceWithTagAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- // true is expected for ignored resources whose parent is not ignored
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- }
-
- public void testKeywordSubstitutionAction() throws CoreException, TeamException {
- IActionDelegate action = new SetKeywordSubstitutionAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- }
-
- public void testShowInHistory() throws CoreException, TeamException {
- IActionDelegate action = new ShowResourceInHistoryAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnablement(action, project, MANAGED | FILES | SINGLE_ONLY, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | FOLDERS | FILES, false /* expected enablement */);
- assertEnablement(action, project, MANAGED | FOLDERS | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, MANAGED | FILES, false /* expected enablement */);
- assertEnablement(action, project, ADDED | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, IGNORED | SINGLE_ONLY, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- }
-
- public void testSyncAction() throws CoreException, TeamException {
- IActionDelegate action = new SyncAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, true /* expected enablement */);
- // true is expected for ignored resources whose parent is not ignored
- assertEnablement(action, project, IGNORED, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, true /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- // true is expected for ignored resources whose parent is not ignored
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, true /* expected enablement */);
- }
-
- public void testTagAction() throws CoreException, TeamException {
- IActionDelegate action = new TagLocalAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, false /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- }
-
- public void testUnmanageAction() throws CoreException, TeamException {
- IActionDelegate action = new UnmanageAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- List resources = new ArrayList();
- resources.add(project);
- ensureAllSyncInfoLoaded(project);
- assertEnablement(action, asSelection(resources), true);
- }
-
- public void testUpdateAction() throws CoreException, TeamException {
- IActionDelegate action = new UpdateAction();
- IProject project = createTestProject(action);
- assertDisabledForCommonReasons(action, project);
- assertEnabledForFolderOnlyOverlap(action, project);
- assertEnablement(action, project, MANAGED, true /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED, false /* expected enablement */);
- assertEnablement(action, project, MANAGED | ADDED | UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED | MANAGED | IGNORED, false /* expected enablement */);
- assertEnablement(action, project, UNMANAGED_PARENT, false /* expected enablement */);
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MiscOperationsTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MiscOperationsTests.java
deleted file mode 100644
index 505219ca8..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/MiscOperationsTests.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.ui.operations.DisconnectOperation;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-
-/**
- * Miscellaneous operation tests
- */
-public class MiscOperationsTests extends CVSOperationTest {
-
- public MiscOperationsTests() {
- super();
- }
-
- public MiscOperationsTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(MiscOperationsTests.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new MiscOperationsTests(testName));
- }
- }
-
- public void testDisconnect() throws TeamException, CoreException {
- IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
-
- // First, disconnect but leave the CVS folders
- run(new DisconnectOperation(null, new IProject[] {project }, false));
- assertNull(RepositoryProvider.getProvider(project));
- assertTrue(project.getFolder("CVS").exists());
-
- // Next, disconnect and purge the CVS folders
- RepositoryProvider.map(project, CVSProviderPlugin.getTypeId());
- run(new DisconnectOperation(null, new IProject[] {project }, true));
- assertNull(RepositoryProvider.getProvider(project));
- assertTrue(project.getFolder("folder1").exists());
- assertTrue(project.getFile("file1.txt").exists());
- assertTrue(!project.getFolder("CVS").exists());
- }
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java
deleted file mode 100644
index 4717dac2c..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import junit.framework.AssertionFailedError;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.synchronize.SyncInfoSet;
-import org.eclipse.team.core.synchronize.SyncInfoTree;
-import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber;
-import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant;
-import org.eclipse.team.internal.ccvs.ui.subscriber.MergeSynchronizeParticipant;
-import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant;
-import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.synchronize.SubscriberParticipantPage;
-import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
-import org.eclipse.team.internal.ui.synchronize.SynchronizeView;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-import org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource;
-import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.ISynchronizeManager;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference;
-import org.eclipse.team.ui.synchronize.ISynchronizeView;
-import org.eclipse.team.ui.synchronize.SubscriberParticipant;
-import org.eclipse.team.ui.synchronize.WorkspaceScope;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.IPage;
-
-/**
- * SyncInfoSource that obtains SyncInfo from the SynchronizeView's SyncSet.
- */
-public class SynchronizeViewTestAdapter extends SyncInfoSource {
-
- public SynchronizeViewTestAdapter() {
- IWorkbenchPage activePage = TeamUIPlugin.getActivePage();
- try {
- activePage.showView(ISynchronizeView.VIEW_ID);
- } catch (PartInitException e) {
- throw new AssertionFailedError("Cannot show sync view in active page");
- }
- }
-
- public SyncInfo getSyncInfo(Subscriber subscriber, IResource resource) throws TeamException {
- // Wait for the collector
- SyncInfoSet set = getCollector(subscriber).getSyncInfoSet();
- // Obtain the sync info from the viewer to ensure that the
- // entire chain has the proper state
- SyncInfo info = internalGetSyncInfo(subscriber, resource);
- // Do a sanity check on the collected sync info
- if (info == null) {
- info = subscriber.getSyncInfo(resource);
- if ((info != null && info.getKind() != SyncInfo.IN_SYNC)) {
- throw new AssertionFailedError(
- "Sync state for "
- + resource.getFullPath()
- + " was "
- + SyncInfo.kindToString(info.getKind())
- + " but resource was not collected");
- }
- } else {
- SyncInfo realInfo = subscriber.getSyncInfo(resource);
- if (info.getKind() != realInfo.getKind()) {
- throw new AssertionFailedError(
- "Collected sync state for "
- + resource.getFullPath()
- + " was "
- + SyncInfo.kindToString(info.getKind())
- + " but the real state was "
- + SyncInfo.kindToString(realInfo.getKind()));
- }
- }
- return info;
- }
-
- private SubscriberParticipant getParticipant(Subscriber subscriber) {
- // show the sync view
- ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants();
- for (int i = 0; i < participants.length; i++) {
- ISynchronizeParticipant participant;
- try {
- participant = participants[i].getParticipant();
- } catch (TeamException e) {
- return null;
- }
- if(participant instanceof SubscriberParticipant) {
- if(((SubscriberParticipant)participant).getSubscriber() == subscriber) {
- return (SubscriberParticipant)participant;
- }
- }
- }
- return null;
- }
-
- private SubscriberSyncInfoCollector getCollector(Subscriber subscriber) {
- SubscriberParticipant participant = getParticipant(subscriber);
- if (participant == null) return null;
- SubscriberSyncInfoCollector syncInfoCollector = participant.getSubscriberSyncInfoCollector();
- EclipseTest.waitForSubscriberInputHandling(syncInfoCollector);
- return syncInfoCollector;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#assertProjectRemoved(org.eclipse.team.core.subscribers.TeamSubscriber, org.eclipse.core.resources.IProject)
- */
- protected void assertProjectRemoved(Subscriber subscriber, IProject project) throws TeamException {
- super.assertProjectRemoved(subscriber, project);
- SyncInfoTree set = getCollector(subscriber).getSyncInfoSet();
- if (set.hasMembers(project)) {
- throw new AssertionFailedError("The sync set still contains resources from the deleted project " + project.getName());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#createMergeSubscriber(org.eclipse.core.resources.IProject, org.eclipse.team.internal.ccvs.core.CVSTag, org.eclipse.team.internal.ccvs.core.CVSTag)
- */
- public CVSMergeSubscriber createMergeSubscriber(IProject project, CVSTag root, CVSTag branch) {
- CVSMergeSubscriber mergeSubscriber = super.createMergeSubscriber(project, root, branch);
- ISynchronizeManager synchronizeManager = TeamUI.getSynchronizeManager();
- SubscriberParticipant participant = new MergeSynchronizeParticipant(mergeSubscriber);
- synchronizeManager.addSynchronizeParticipants(
- new ISynchronizeParticipant[] {participant});
- IWorkbenchPage activePage = TeamUIPlugin.getActivePage();
- try {
- ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID);
- view.display(participant);
- } catch (PartInitException e) {
- throw new AssertionFailedError("Cannot show sync view in active page");
- }
- return mergeSubscriber;
- }
-
- public Subscriber createWorkspaceSubscriber() throws TeamException {
- ISynchronizeManager synchronizeManager = TeamUI.getSynchronizeManager();
- ISynchronizeParticipantReference[] participants = synchronizeManager.get(WorkspaceSynchronizeParticipant.ID);
- if (participants.length > 0) {
- return ((SubscriberParticipant)participants[0].getParticipant()).getSubscriber();
- }
- SubscriberParticipant participant = new WorkspaceSynchronizeParticipant(new WorkspaceScope());
- synchronizeManager.addSynchronizeParticipants(
- new ISynchronizeParticipant[] {participant});
- IWorkbenchPage activePage = TeamUIPlugin.getActivePage();
- try {
- ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID);
- view.display(participant);
- } catch (PartInitException e) {
- throw new AssertionFailedError("Cannot show sync view in active page");
- }
- return participant.getSubscriber();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#createCompareSubscriber(org.eclipse.core.resources.IProject, org.eclipse.team.internal.ccvs.core.CVSTag)
- */
- public CVSCompareSubscriber createCompareSubscriber(IProject project, CVSTag tag) {
- CVSCompareSubscriber s = super.createCompareSubscriber(project, tag);
- ISynchronizeManager synchronizeManager = TeamUI.getSynchronizeManager();
- SubscriberParticipant participant = new CompareParticipant(s);
- synchronizeManager.addSynchronizeParticipants(
- new ISynchronizeParticipant[] {participant});
- IWorkbenchPage activePage = TeamUIPlugin.getActivePage();
- try {
- ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID);
- view.display(participant);
- } catch (PartInitException e) {
- throw new AssertionFailedError("Cannot show sync view in active page");
- }
- return s;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#tearDown()
- */
- public void tearDown() {
- ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants();
- for (int i = 0; i < participants.length; i++) {
- try {
- ISynchronizeParticipantReference ref = participants[i];
- if(ref.getParticipant().getId().equals(CVSMergeSubscriber.ID)) {
- TeamUI.getSynchronizeManager().removeSynchronizeParticipants(new ISynchronizeParticipant[] {ref.getParticipant()});
- }
- } catch (TeamException e) {
- return;
- }
- }
- // Process all async events that may have been generated above
- while (Display.getCurrent().readAndDispatch()) {};
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#refresh(org.eclipse.team.core.subscribers.TeamSubscriber, org.eclipse.core.resources.IResource)
- */
- public void refresh(Subscriber subscriber, IResource resource) throws TeamException {
- super.refresh(subscriber, resource);
- // Getting the collector waits for the subscriber input handlers
- getCollector(subscriber);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource#reset()
- */
- public void reset(Subscriber subscriber) throws TeamException {
- super.reset(subscriber);
- getCollector(subscriber).reset();
- }
-
- private SyncInfo internalGetSyncInfo(Subscriber subscriber, IResource resource) {
- try {
- SubscriberParticipant participant = getParticipant(subscriber);
- IWorkbenchPage activePage = TeamUIPlugin.getActivePage();
- ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID);
- IPage page = ((SynchronizeView)view).getPage(participant);
- if (page instanceof SubscriberParticipantPage) {
- SubscriberParticipantPage subscriberPage = (SubscriberParticipantPage)page;
- ISelection selection = subscriberPage.getViewerAdvisor().getModelManager().getSelection(new Object[] { resource });
- if (!selection.isEmpty() && selection instanceof StructuredSelection) {
- StructuredSelection ss = (StructuredSelection)selection;
- Object o = ss.getFirstElement();
- if (o instanceof SyncInfoModelElement) {
- return ((SyncInfoModelElement)o).getSyncInfo();
- }
- }
- }
- } catch (PartInitException e) {
- throw new AssertionFailedError("Cannot show sync view in active page");
- }
- return null;
- }
-}

Back to the top