Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-10-22 14:54:17 +0000
committerMichael Valenta2003-10-22 14:54:17 +0000
commit2eb76c226da3ac930122c29d1c16c7a3083697fe (patch)
treeefb38d8e49e7df3c0f38cf2209c917dbd4cf8c30 /tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team
parenta2286f98c4e2ef45800dfe7ba51a825ab564e2d5 (diff)
downloadeclipse.platform.team-2eb76c226da3ac930122c29d1c16c7a3083697fe.tar.gz
eclipse.platform.team-2eb76c226da3ac930122c29d1c16c7a3083697fe.tar.xz
eclipse.platform.team-2eb76c226da3ac930122c29d1c16c7a3083697fe.zip
41738: Comparing two remote versions can result in many connectionsRoot_SynchronizeViewPageBook20031011
Diffstat (limited to 'tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team')
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java7
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/AllUIUnitTests.java1
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CVSOperationTest.java30
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CheckoutOperationTests.java73
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CompareOperationTests.java184
5 files changed, 248 insertions, 47 deletions
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
index 2f3a4bc85..ba0bb474b 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
@@ -348,6 +348,13 @@ public class EclipseTest extends EclipseWorkspaceTest {
}
/*
+ * 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 {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/AllUIUnitTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/AllUIUnitTests.java
index 40eaa011a..71e9d07d7 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/AllUIUnitTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/AllUIUnitTests.java
@@ -28,6 +28,7 @@ public class AllUIUnitTests extends EclipseTest {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(CheckoutOperationTests.suite());
+ suite.addTest(CompareOperationTests.suite());
return suite;
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CVSOperationTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CVSOperationTest.java
new file mode 100644
index 000000000..a87ac7882
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CVSOperationTest.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.unit;
+
+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/unit/CheckoutOperationTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CheckoutOperationTests.java
index c333f7d8d..48057d8bf 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CheckoutOperationTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CheckoutOperationTests.java
@@ -20,7 +20,6 @@ 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.CVSException;
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;
@@ -29,9 +28,8 @@ 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;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-public class CheckoutOperationTests extends EclipseTest {
+public class CheckoutOperationTests extends CVSOperationTest {
public CheckoutOperationTests() {
}
@@ -57,15 +55,11 @@ public class CheckoutOperationTests extends EclipseTest {
IProject movedProject = ResourcesPlugin.getWorkspace().getRoot().getProject("moved-project");
// checkout the project to the default location
- try {
- CVSOperation op = new CheckoutMultipleProjectsOperation(
- null /* shell */,
- new ICVSRemoteFolder[] { (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(movedProject) },
- null /*target location*/);
- run(op);
- } catch (InterruptedException e) {
- fail("Operation should not have been interrupted");
- }
+ CVSOperation op = new CheckoutMultipleProjectsOperation(
+ null /* shell */,
+ new ICVSRemoteFolder[] { (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(movedProject) },
+ null /*target location*/);
+ run(op);
assertEquals(project, movedProject);
}
@@ -74,15 +68,11 @@ public class CheckoutOperationTests extends EclipseTest {
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
- try {
- CVSOperation op = new CheckoutMultipleProjectsOperation(
- null /* shell */,
- new ICVSRemoteFolder[] { (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project.getFolder("folder1")) },
- null /*target location*/);
- run(op);
- } catch (InterruptedException e) {
- fail("Operation should not have been interrupted");
- }
+ 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());
@@ -107,18 +97,14 @@ public class CheckoutOperationTests extends EclipseTest {
// checkout the project to the default location
- try {
- CVSOperation op = new CheckoutMultipleProjectsOperation(
- null /* shell */,
- new ICVSRemoteFolder[] {
- (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(movedProject1),
- (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(movedProject2)
- },
- null /*target location*/);
- run(op);
- } catch (InterruptedException e) {
- fail("Operation should not have been interrupted");
- }
+ 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 {
@@ -126,22 +112,15 @@ public class CheckoutOperationTests extends EclipseTest {
IProject copy = ResourcesPlugin.getWorkspace().getRoot().getProject(project.getName() + "-copy");
// checkout the project to the default location
- try {
- CVSOperation op = new CheckoutSingleProjectOperation(
- null /* shell */,
- (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project),
- copy,
- null /*target location*/,
- false);
- run(op);
- } catch (InterruptedException e) {
- fail("Operation should not have been interrupted");
- }
+ CVSOperation op = new CheckoutSingleProjectOperation(
+ null /* shell */,
+ (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project),
+ copy,
+ null /*target location*/,
+ false);
+ run(op);
assertEquals(project, copy);
}
- private void run(CVSOperation op) throws CVSException, InterruptedException {
- executeHeadless(op);
- }
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CompareOperationTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CompareOperationTests.java
new file mode 100644
index 000000000..c7c21b58a
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/unit/CompareOperationTests.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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.unit;
+
+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.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
+import org.eclipse.team.internal.ccvs.core.ICVSFile;
+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
+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.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;
+
+public class CompareOperationTests extends CVSOperationTest {
+
+ public class TestRemoteCompareOperation extends RemoteCompareOperation {
+ private ICVSRemoteFolder leftTree, rightTree;
+
+ public TestRemoteCompareOperation(Shell shell, ICVSRemoteResource resource, CVSTag tag) {
+ super(shell, 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);
+ getProvider(copy).checkin(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
+
+ // 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(project.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 */);
+
+ }
+
+}

Back to the top