Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-10-20 19:55:38 +0000
committerMichael Valenta2003-10-20 19:55:38 +0000
commita2a169b8a23d6cad0ac857387dcacf4099493389 (patch)
tree19f3c98932ed1aa4892f985a4b6d8ba436bdcaaf /tests/org.eclipse.team.tests.core
parentfa4d066e7036b86610bebf162c3b829c6ccd49ee (diff)
downloadeclipse.platform.team-a2a169b8a23d6cad0ac857387dcacf4099493389.tar.gz
eclipse.platform.team-a2a169b8a23d6cad0ac857387dcacf4099493389.tar.xz
eclipse.platform.team-a2a169b8a23d6cad0ac857387dcacf4099493389.zip
Extracted Target code from team plugins and placed it
in the team.webdav plugin
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/build.properties2
-rw-r--r--tests/org.eclipse.team.tests.core/ftp.properties17
-rw-r--r--tests/org.eclipse.team.tests.core/plugin.xml10
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java41
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java3
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java100
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java707
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java237
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetTestSetup.java108
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java62
-rw-r--r--tests/org.eclipse.team.tests.core/test.xml32
-rw-r--r--tests/org.eclipse.team.tests.core/webdav.properties17
12 files changed, 5 insertions, 1331 deletions
diff --git a/tests/org.eclipse.team.tests.core/build.properties b/tests/org.eclipse.team.tests.core/build.properties
index 992cef9f9..926d9a39d 100644
--- a/tests/org.eclipse.team.tests.core/build.properties
+++ b/tests/org.eclipse.team.tests.core/build.properties
@@ -9,4 +9,4 @@
# IBM Corporation - initial API and implementation
###############################################################################
source.teamtests.jar=src/
-bin.includes=about.html,plugin.xml,*.jar,test.xml, ftp.properties, webdav.properties \ No newline at end of file
+bin.includes=about.html,plugin.xml,*.jar,test.xml \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.core/ftp.properties b/tests/org.eclipse.team.tests.core/ftp.properties
deleted file mode 100644
index 472424eb4..000000000
--- a/tests/org.eclipse.team.tests.core/ftp.properties
+++ /dev/null
@@ -1,17 +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
-###############################################################################
-target=org.eclipse.team.ftp
-test_dir=target
-location=ftp://@host@/path
-username=@user@
-password=@password@
-connectionTimeout=6000
-passive=true \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.core/plugin.xml b/tests/org.eclipse.team.tests.core/plugin.xml
index 67f74ae07..a11a75dcd 100644
--- a/tests/org.eclipse.team.tests.core/plugin.xml
+++ b/tests/org.eclipse.team.tests.core/plugin.xml
@@ -84,15 +84,5 @@
id="org.eclipse.team.tests.core.linking">
</repository>
</extension>
-<!-- *************** Test application **************** -->
- <extension
- id="testapplication"
- point="org.eclipse.core.runtime.applications">
- <application>
- <run
- class="org.eclipse.team.tests.ftp.TestApplication">
- </run>
- </application>
- </extension>
</plugin>
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java
deleted file mode 100644
index dcdd61a43..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java
+++ /dev/null
@@ -1,41 +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.core;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
-
-public class AllTargetTests extends EclipseWorkspaceTest {
-
- /**
- * Constructor for AllTargetTests.
- */
- public AllTargetTests() {
- super();
- }
-
- /**
- * Constructor for AllTargetTests.
- * @param name
- */
- public AllTargetTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(TargetProviderTests.suite());
- suite.addTest(RemoteResourceTests.suite());
- suite.addTest(SyncElementTest.suite());
- return new TargetTestSetup(suite);
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java
index 99d1a4718..1738eead5 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java
@@ -31,9 +31,6 @@ public class AllTeamTests extends EclipseWorkspaceTest {
super(name);
}
- /*
- * ORDER IS IMPORTANT: Run compatibility and resource tests before any other!!!
- */
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(RepositoryProviderTests.suite());
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java
deleted file mode 100644
index 8a666baee..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java
+++ /dev/null
@@ -1,100 +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.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-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.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.TargetProvider;
-
-/**
- * A set of test cases for org.eclipse.team.core.sync.IRemoteResource
- */
-public class RemoteResourceTests extends TeamTest {
- public RemoteResourceTests() {
- super();
- }
- public RemoteResourceTests(String name) {
- super(name);
- }
- public static Test suite() {
- TestSuite suite = new TestSuite(RemoteResourceTests.class);
- return new TargetTestSetup(suite);
- }
-
- protected IProject createAndPut(String projectPrefix, String[] resourceNames) throws CoreException, TeamException {
- IProject project = getUniqueTestProject(projectPrefix);
- IResource[] resources = buildResources(project, resourceNames, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- return project;
- }
-
- public void testGetName() throws CoreException, TeamException {
- IProject project = createAndPut("getname", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
- TargetProvider target = getProvider(project);
- IRemoteResource remote = target.getRemoteResource();
- assertEquals(project.getName(), remote.getName());
- }
- public void testIsContainerSuccess() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("iscontainer");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- IRemoteResource remote = target.getRemoteResource();
- assertTrue(remote.isContainer());
- }
- public void testIsContainerFail() throws CoreException, TeamException {
- IProject project = createAndPut("iscontainer", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
- TargetProvider target = getProvider(project);
- IRemoteResource remote = target.getRemoteResourceFor(project.getFile("file1.txt"));
- assertTrue(!remote.isContainer());
- }
- public void testGetContents() throws CoreException, TeamException {
- IProject project = createAndPut("getname", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
- TargetProvider target = getProvider(project);
- IRemoteResource remote = target.getRemoteResourceFor(project.getFile("file1.txt"));
- InputStream jin = remote.getContents(DEFAULT_MONITOR);
- try {
- while (jin.available() > 0) {
- jin.read();
- }
- } catch (IOException e) {
- System.out.flush();
- e.printStackTrace(System.err);
- fail("Couldn't read from the input stream.");
- }
- }
- public void testMembers() throws CoreException, TeamException {
- IProject project = createAndPut("getname", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
- TargetProvider target = getProvider(project);
- IRemoteResource remote = target.getRemoteResource();
- IRemoteResource[] altResources = remote.members(DEFAULT_MONITOR);
- for (int i = 0; i < altResources.length; i++) {
- assertEquals(altResources[i], project.findMember(altResources[i].getName()));
- }
- }
- /**
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- properties=TargetTestSetup.properties;
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
deleted file mode 100644
index 756159d7a..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
+++ /dev/null
@@ -1,707 +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.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import junit.framework.AssertionFailedError;
-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.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.ILocalSyncElement;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.core.sync.RemoteSyncElement;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.core.target.UrlUtil;
-
-public class SyncElementTest extends TeamTest {
- /*
- * Constructor for SyncElementTest.
- */
- public SyncElementTest() {
- super();
- }
-
- /*
- * Constructor for SyncElementTest.
- * @param name
- */
- public SyncElementTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(SyncElementTest.class);
- return new TargetTestSetup(suite);
- //return new CVSTestSetup(new SyncElementTest("testAdditionConflicts"));
- }
- /*
- * Get the child in the sync tree
- */
- protected ILocalSyncElement getChild(ILocalSyncElement tree, IPath path) throws TeamException {
- if (path.segmentCount() == 0)
- return tree;
- ILocalSyncElement[] children = tree.members(DEFAULT_MONITOR);
- for (int i = 0; i < children.length; i++) {
- if (children[i].getName().equals(path.segment(0)))
- return getChild(children[i], path.removeFirstSegments(1));
- }
- assertTrue("Child " + path.toString() + " does not exist", false);
- return null;
- }
-
- /*
- * Assert that the specified resources in the tree have the specified sync kind
- * Ignore conflict types if they are not specified in the assert statement
- */
- public void assertSyncEquals(String message, ILocalSyncElement tree, String[] resources, int[] syncKinds, int granularity)
- throws TeamException {
- assertTrue(resources.length == syncKinds.length);
- for (int i = 0; i < resources.length; i++) {
- int conflictTypeMask = 0x0F; // ignore manual and auto merge sync types for now.
- ILocalSyncElement child = getChild(tree, new Path(resources[i]));
- int kind = child.getSyncKind(granularity, DEFAULT_MONITOR) & conflictTypeMask;
- int kindOther = syncKinds[i] & conflictTypeMask;
- assertTrue(
- message
- + ": improper sync state for "
- + resources[i]
- + " expected "
- + RemoteSyncElement.kindToString(kindOther)
- + " but was "
- + RemoteSyncElement.kindToString(kind),
- kind == kindOther);
- }
- }
-
- public void assertSyncEquals(String message, ILocalSyncElement tree, String[] resources, int[] syncKinds) throws TeamException {
- assertSyncEquals(message, tree, resources, syncKinds, ILocalSyncElement.GRANULARITY_TIMESTAMP);
- }
-
- /*
- * Assert that the named resources have no local resource or sync info
- */
- public void assertDeleted(String message, IRemoteSyncElement tree, String[] resources) throws CoreException, TeamException {
- for (int i = 0; i < resources.length; i++) {
- try {
- getChild(tree, new Path(resources[i]));
- } catch (AssertionFailedError e) {
- break;
- }
- assertTrue(message + ": resource " + resources[i] + " still exists in some form", false);
- }
- }
-
- IRemoteSyncElement getRemoteSyncTree(IProject project, IProgressMonitor monitor) throws TeamException {
- return getProvider(project).getRemoteSyncElement(project);
- }
- protected IProject checkoutCopy(IProject project, String postfix) throws CoreException,TeamException {
- TargetProvider provider = getProvider(project);
- IProject result = getUniqueTestProject(project.getName()+postfix);
- TargetManager.map(result, provider.getSite(), UrlUtil.getTrailingPath(provider.getURL(), provider.getSite().getURL()));
- TargetProvider target = TargetManager.getProvider(result);
- target.get(new IResource[] { result }, null);
- return result;
- }
- protected void getResourcesFromTarget(IProject project, String[] resourceNames)throws TeamException,CoreException {
- TargetProvider provider=getProvider(project);
- IResource[] resources=getResources(project,resourceNames);
- provider.get(resources,null);
- }
- protected void putResourcesOntoTarget(IProject project, String[] resourceNames)throws TeamException,CoreException {
- TargetProvider provider=getProvider(project);
- IResource[] resources=getResources(project,resourceNames);
- provider.put(resources,null);
- }
- /**
- * Add the resources to an existing container and optionally upload them to the remote server
- */
- public IResource[] addResources(IProject container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- IResource[] newResources = buildResources(container, hierarchy, false);
- if (checkin) getProvider(container).put(newResources, DEFAULT_MONITOR);
- return newResources;
- }
- /**
- * Delete the resources from an existing container and optionally add the changes to the remote server
- */
- public IResource[] deleteResources(IProject container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- for (int i = 0; i < resources.length; i++) {
- resources[0].delete(true, null);
- }
- if (checkin) getProvider(container).put(resources, DEFAULT_MONITOR);
- return resources;
- }
- /*
- * Perform a simple test that checks for the different types of incoming changes
- */
- public void testIncomingChanges() throws TeamException, CoreException, IOException {
- // Create a test project
- IProject project = createAndPut("testIncomingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Checkout and modify a copy
- IProject copy = checkoutCopy(project, "-copy");
- IFile file = copy.getFile("folder1/a.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(new ByteArrayInputStream("This will be different".getBytes()), false, false, null);
- addResources(copy, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(copy, new String[] { "folder1/b.txt" }, false);
- sleep(1500); // Wait so that timestamp of modified file differs from original
- putResourcesOntoTarget(copy,new String[] { "folder1/a.txt","folder2/folder3/add.txt","folder1/b.txt" });
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testIncomingChanges",
- tree,
- new String[] {
- "file1.txt",
- "folder1/",
- "folder1/a.txt",
- "folder1/b.txt",
- "folder2/",
- "folder2/folder3/",
- "folder2/folder3/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION });
-
- // Verify that we are in sync (except for "folder1/b.txt", which was deleted)
- getResourcesFromTarget(project,
- new String[] {
- "file1.txt",
- "folder1/",
- "folder1/a.txt",
- "folder1/b.txt",
- "folder2/",
- "folder2/folder3/",
- "folder2/folder3/add.txt" });
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testIncomingChanges",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC });
-
- // Ensure "folder1/b.txt" was deleted
- assertDeleted("testIncomingChanges", tree, 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 = createAndPut("testIncomingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Make some modifications
- IFile file = project.getFile("folder1/a.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null);
- addResources(project, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(project, new String[] { "folder1/b.txt" }, false);
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testOutgoingChanges",
- tree,
- new String[] {
- "file1.txt",
- "folder1/",
- "folder1/a.txt",
- "folder1/b.txt",
- "folder2/",
- "folder2/folder3/",
- "folder2/folder3/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION });
-
- // Commit the changes
- putResourcesOntoTarget(project, new String[] { "folder1/a.txt", "folder1/b.txt", "folder2/folder3/add.txt" });
-
- // Ensure we're in sync
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testOutgoingChanges",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC });
-
- // Ensure deleted resource "folder1/b.txt" no longer exists
- assertDeleted("testOutgoingChanges", tree, new String[] { "folder1/b.txt" });
- }
-
- /*
- * Test simple file conflicts
- */
- public void testFileConflict() throws TeamException, CoreException, IOException {
- // Create a test project (which commits it as well)
- IProject project = createAndPut("testFileConflict", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Checkout a copy and make some modifications
- IProject copy = checkoutCopy(project, "-copy");
- IFile file = copy.getFile("file1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "prefix\n", true);
- file = copy.getFile("folder1/a.txt");
- file.setContents(new ByteArrayInputStream("Use a custom string to avoid intermitant errors!".getBytes()), false, false, null);
- getProvider(copy).put(new IResource[] { copy }, DEFAULT_MONITOR);
-
- // Make the same modifications to the original (We need to test both M and C!!!)
- file = project.getFile("file1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "\npostfix", false); // This will test merges (M)
- file = project.getFile("folder1/a.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null); // This will test conflicts (C)
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFileConflict",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE });
-
- // Catch up to the file1.txt conflict using UPDATE with ignoreLocalChanges
- getResourcesFromTarget(project, new String[] { "file1.txt" });
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFileConflict",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE });
-
- // Release the folder1/a.txt conflict uploading
- getProvider(project).put(new IResource[] { project.getFile("folder1/a.txt")}, DEFAULT_MONITOR);
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFileConflict",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
- }
-
- /*
- * Test conflicts involving additions
- */
- public void testAdditionConflicts() throws TeamException, CoreException {
- // 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 = createAndPut("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); //useless code!???
-
- // 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
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testAdditionConflicts",
- tree,
- new String[] { "file.txt", "add1a.txt", "add1b.txt", "add2a.txt", "add2b.txt", "add3.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION });
-
- getProvider(project).put(
- new IResource[] { project.getFile("add1b.txt"), project.getFile("add2b.txt"), project.getFile("add3.txt")},
- DEFAULT_MONITOR);
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testAdditionConflicts",
- tree,
- new String[] { "file.txt", "add1b.txt", "add2b.txt", "add3.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
-
- IFile file = project.getFile("add1a.txt");
- file.delete(false, DEFAULT_MONITOR);
- file = project.getFile("add2a.txt");
- file.delete(false, DEFAULT_MONITOR);
- getResourcesFromTarget(project, new String[] { "add1a.txt","add2a.txt" });//This replaces the chunk commented out below:
- /*getProvider(project).update(
- new IResource[] { project.getFile("add1a.txt"), project.getFile("add2a.txt")},
- new Command.LocalOption[] { Command.DO_NOT_RECURSE },
- null,
- true, //createBackups
- DEFAULT_MONITOR
- );*/
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testAdditionConflicts",
- tree,
- new String[] { "add1a.txt", "add2a.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
- }
-
- /*
- * Test conflicts involving deletions
- */
- public void testDeletionConflicts() throws TeamException, CoreException {
-
- // 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 =
- createAndPut(
- "testDeletionConflictsA",
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" });
- IFile file = project.getFile("delete1.txt");
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] { "delete2.txt" }, false);
- file = project.getFile("delete3.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(new ByteArrayInputStream("unique text for delete3.txt".getBytes()), false, false, null);
- 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");
- file = copy.getFile("delete1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(new ByteArrayInputStream("unique text for delete1.txt".getBytes()), false, false, null);
- file = copy.getFile("delete2.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(new ByteArrayInputStream("unique text for delete2.txt".getBytes()), false, false, null);
- deleteResources(copy, new String[] { "delete3.txt", "delete4.txt", "delete5.txt" }, false);
- getProvider(copy).put(new IResource[] { copy }, DEFAULT_MONITOR);
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testDeletionConflictsA",
- tree,
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT });
-
- // Catch up to remote changes.
-
- project.getFile("delete3.txt").delete(false, DEFAULT_MONITOR);
-
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testDeletionConflictsA",
- tree,
- new String[] { "delete1.txt", "delete2.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT });
- assertDeleted("testDeletionConflictsA", tree, 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 =
- createAndPut(
- "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);
- file = project.getFile("delete3.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null);
- 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");
- file = copy.getFile("delete1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null);
- file = copy.getFile("delete2.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null);
- deleteResources(copy, new String[] { "delete3.txt", "delete4.txt", "delete5.txt" }, false);
- getProvider(copy).put(new IResource[] { copy }, DEFAULT_MONITOR);
-
- // Get the sync tree for the project
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testDeletionConflictsB",
- tree,
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC });
-
- // Release the resources
-
- putResourcesOntoTarget(project, new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" });
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals("testDeletionConflictsB", tree, new String[] { "delete3.txt" }, new int[] { IRemoteSyncElement.IN_SYNC });
- assertDeleted("testDeletionConflictsB", tree, new String[] { "delete1.txt", "delete2.txt", "delete4.txt", "delete5.txt" });
- }
-
- /*
- * 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 = createAndPut("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
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testOutgoingDeletion",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION });
-
- // Commit the deletion
- getProvider(file.getProject()).put(new IResource[] { file }, DEFAULT_MONITOR);
-
- // Get the sync tree again for the project and ensure others aren't effected
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testOutgoingDeletion",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
-
- // Assert that deletion no longer appears in remote tree
- assertDeleted("testOutgoingDeletion", tree, new String[] { "folder1/b.txt" });
- }
-
- /*
- * Test catching up to an incoming addition
- */
- public void testIncomingAddition() throws TeamException, CoreException {
- // Create a test project
- IProject project = createAndPut("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
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testIncomingAddition",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION });
-
- // Get the resource from the tree
- ILocalSyncElement element = getChild(tree, new Path("folder1/add.txt"));
-
- // Catch up to the addition by updating
- getResourcesFromTarget(project, new String[] { "folder1/add.txt" });
-
- // Get the sync tree again for the project and ensure the added resource is in sync
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testIncomingAddition",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/add.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
- }
-
- /*
- * Test changes using a granularity of contents
- */
- public void testGranularityContents() throws TeamException, CoreException, IOException {
- // Create a test project (which commits it as well)
- IProject project =
- createAndPut("testGranularityContents", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Checkout a copy and make some modifications
- IProject copy = checkoutCopy(project, "-copy");
- IFile file = copy.getFile("file1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "a", true);
- file = copy.getFile("folder1/a.txt");
- file.setContents(getRandomContents(), false, false, null);
- putResourcesOntoTarget(copy, new String[] { "file1.txt","folder1/a.txt" });
-
- // Make the same modifications to the original
- file = project.getFile("file1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "a", false);
- file = project.getFile("folder1/a.txt");
- file.setContents(new ByteArrayInputStream("unique text".getBytes()), false, false, null);
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testGranularityContents",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE },
- IRemoteSyncElement.GRANULARITY_CONTENTS);
- }
-
- public void testRenameProject() throws TeamException, CoreException, IOException {
- String[] resourceNames = new String[] { "changed.txt", "folder1/", "folder1/a.txt" };
- int[] inSync = new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC };
- IProject project = createAndPut("testRenameProject", new String[] { "changed.txt", "folder1/", "folder1/a.txt" });
-
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals("sync should be in sync", tree, resourceNames, 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());
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals("sync should be in sync", tree, resourceNames, inSync);
- }
-
- public void testFolderDeletion() throws TeamException, CoreException {
-
- IProject project =
- createAndPut(
- "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
- project.getFolder("folder1").delete(false, false, null);
-
- // The folders and files should show up as outgoing deletions
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFolderDeletion sync check",
- tree,
- new String[] { "folder1", "folder1/a.txt", "folder1/folder2", "folder1/folder2/file.txt" },
- new int[] {
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION });
-
- // commit folder1/a.txt
- putResourcesOntoTarget(project, new String[] { "folder1/a.txt" });
-
- // Resync and verify that above file is gone and others remain the same
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFolderDeletion sync check",
- tree,
- new String[] { "folder1", "folder1/folder2", "folder1/folder2/file.txt" },
- new int[] {
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION });
- assertDeleted("testFolderDeletion", tree, new String[] { "folder1/a.txt" });
-
- // Commit folder1/folder2/file.txt
- putResourcesOntoTarget(project, new String[] { "folder1/", "folder1/folder2/", "folder1/folder2/file.txt" });
-
- // Resync and verify that all are deleted
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertDeleted("testFolderDeletion", tree, new String[] { "folder1", "folder1/folder2", "folder1/folder2/file.txt" });
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
deleted file mode 100644
index a70a8342d..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
+++ /dev/null
@@ -1,237 +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.core;
-
-import java.net.MalformedURLException;
-
-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.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.core.target.UrlUtil;
-
-/**
- * A set of test cases for org.eclipse.team.core.target.TargetProvider
- */
-public class TargetProviderTests extends TeamTest {
-
-
- public TargetProviderTests() {
- super();
- }
- public TargetProviderTests(String name) {
- super(name);
- }
- public static Test suite() {
- TestSuite suite = new TestSuite(TargetProviderTests.class);
- return new TargetTestSetup(suite);
- //return new TargetTestSetup(new TargetProviderTests("testPutAndGet"));
- }
- /**
- * Tests the link between the target & the site for consistency.
- * @throws CoreException
- * @throws TeamException
- */
- public void testProjectMapping() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("projectmapping");
- TargetProvider target = createProvider(project);
- assertTrue(getSite().equals(target.getSite()));
- TargetManager.unmap(project);
- assertNull(TargetManager.getProvider(project));
- }
- /**
- * Tests the getURL() method on TargetProvider.
- * @throws CoreException
- * @throws TeamException
- */
- public void testUrlRetrieval() throws CoreException, TeamException, MalformedURLException {
- IProject project = getNamedTestProject("urlretrieval");
- TargetManager.map(project, getSite(), new Path(properties.getProperty("test_dir")));
- TargetProvider target = TargetManager.getProvider(project);
- String goodurl = UrlUtil.concat(properties.getProperty("location"), new Path(properties.getProperty("test_dir"))).toString();
- assertEquals(goodurl, target.getURL().toString());
- }
- /**
- * Verifies that the get() and put() methods on the TargetProvider works as expected.
- * @throws CoreException
- * @throws TeamException
- */
- public void testPutAndGet() throws CoreException, TeamException {
- // test put
- IProject project = getUniqueTestProject("get");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, DEFAULT_MONITOR);
- assertLocalEqualsRemote(project);
- // test get on a new project
- project.delete(true, true, DEFAULT_MONITOR);
- project.create(DEFAULT_MONITOR);
- project.open(DEFAULT_MONITOR);
- target = createProvider(project);
- target.get(new IResource[] { project }, DEFAULT_MONITOR);
- assertLocalEqualsRemote(project);
- }
- /**
- * Verifies that canGet() and canPut() returns accurate values.
- * @throws CoreException
- * @throws TeamException
- */
- public void testCanGetAndCanPut() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("canget");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- for (int i = 0; i < resources.length; i++) {
- assertTrue(target.canPut(resources[i]));
- }
- target.put(resources, DEFAULT_MONITOR);
- project.delete(true, true, DEFAULT_MONITOR);
- project.create(DEFAULT_MONITOR);
- project.open(DEFAULT_MONITOR);
- target = createProvider(project);
- for (int i = 0; i < resources.length; i++) {
- assertTrue(target.canGet(resources[i]));
- }
- target.get(new IResource[] { project }, null);
- }
- /**
- * Tests bahavior of isOutOfDate() for correctness
- * @throws CoreException
- * @throws TeamException
- */
- public void testIsOutOfDate() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("outdated");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- sleep(1501);
- IProject dupeProject = getUniqueTestProject("outdated");
- IResource[] freshResources = buildResources(dupeProject, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetManager.map(dupeProject, getSite(), new Path(properties.getProperty("test_dir")).append(project.getName()));
- TargetProvider dupeTarget = TargetManager.getProvider(dupeProject);
- dupeTarget.put(freshResources, null);
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType() == IResource.FILE)
- assertTrue(target.isOutOfDate(resources[i], DEFAULT_PROGRESS_MONITOR));
- }
- }
- /**
- * Tests bahavior of isDirty() for correctness
- * @throws CoreException
- * @throws TeamException
- */
- public void testIsDirty() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("dirty");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- sleep(1501);
- resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType()==IResource.FILE) assertTrue(resources[i].getName(),target.isDirty(resources[i]));
- }
- }
- public void testOverwrite() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("overwrite");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- //Create resources with the same names but different content & upload them in the same spot:
- resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- target.put(resources, null);
-
- IProject dupeProject = getUniqueTestProject("overwrite");
- TargetManager.map(dupeProject, getSite(), new Path(properties.getProperty("test_dir")).append(project.getName()));
- IResource[] freshResources = buildEmptyResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider dupeTarget = TargetManager.getProvider(dupeProject);
- dupeTarget.get(new IResource[] { dupeProject }, null);
- for (int i = 0; i < resources.length; i++) {
- assertEquals(resources[i],freshResources[i]);
- }
- }
- public void testIsDirtyWhenDeleted() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("dirty");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- for (int i = 0; i < resources.length; i++) {
- resources[i].delete(true, null);
- }
- sleep(1501);
- resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType()==IResource.FILE) assertTrue(resources[i].getName(),target.isDirty(resources[i]));
- }
- }
- public void testIsOutOfDateWhenDeleted() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("outdated");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- for (int i = 0; i < resources.length; i++) {
- resources[i].delete(true, null);
- }
- sleep(1501);
- IProject dupeProject = getUniqueTestProject("outdated");
- IResource[] freshResources = buildResources(dupeProject, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetManager.map(dupeProject, getSite(), new Path(properties.getProperty("test_dir")).append(project.getName()));
- TargetProvider dupeTarget = TargetManager.getProvider(dupeProject);
- dupeTarget.put(freshResources, null);
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType() == IResource.FILE)
- assertTrue(target.isOutOfDate(resources[i], DEFAULT_PROGRESS_MONITOR));
- }
- }
- public void testPutWithPhantoms() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("put");
- IResource[] resources = buildEmptyResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- for (int i = 0; i < resources.length; i++) {
- resources[i].delete(true, null);
- }
- try {
- target.put(resources, null);
- for (int i = 0; i < resources.length; i++) {
- assertTrue(!target.getRemoteResourceFor(resources[i]).exists(null));
- }
- } catch (TeamException e) {} catch (RuntimeException e) {
- fail("Putting files that don't exist locally should delete them remotely");
- }
- }
- public void testGetWithPhantoms() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("get");
- String[] testFileNames=new String[] { "file1.txt", "folder1/", "folder1/b.txt" };
- IResource[] resources = buildResources(project, testFileNames, false);
- TargetProvider target = createProvider(project);
- try {
- target.get(new IResource[] { project }, null);
- IResource[] phantoms=getResources(project,testFileNames);
- for (int i = 0; i < phantoms.length; i++) {
- assertTrue(!project.getFile(testFileNames[i]).exists());
- }
- } catch (TeamException e) {
- fail("Getting files that don't exist remotely should delete them locally");
- }
- }
- /**
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- properties=TargetTestSetup.properties;
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetTestSetup.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetTestSetup.java
deleted file mode 100644
index b18dd00cc..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetTestSetup.java
+++ /dev/null
@@ -1,108 +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.core;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Properties;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.ISiteFactory;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-
-/**
- * A set of test cases for org.eclipse.team.core.sync.IRemoteResource
- */
-public class TargetTestSetup extends TestSetup {
-
- public static Properties properties;
- static {
- loadProperties();
- }
-
- public static void loadProperties() {
- properties = new Properties();
- String propertiesFile = System.getProperty("eclipse.target.properties");
- if (propertiesFile == null)
- return;
- File file = new File(propertiesFile);
- if (file.isDirectory())
- file = new File(file, "target.properties");
- try {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- try {
- for (String line;(line = reader.readLine()) != null;) {
- int sep = line.indexOf("=");
- String property = line.substring(0, sep).trim();
- String value = line.substring(sep + 1).trim();
- properties.setProperty(property, value);
- }
- } finally {
- reader.close();
- }
- } catch (Exception e) {
- System.err.println("Could not read repository properties file: " + file.getAbsolutePath());
- }
- }
-
- public TargetTestSetup(Test test) {
- super(test);
- }
- /**
- * Retrieves the Site object that the TargetProvider is contained in.
- * @return Site
- */
- Site getSite() {
- try {
- URL url = new URL(properties.getProperty("location"));
- return TargetManager.getSite(properties.getProperty("target"), url);
- } catch (MalformedURLException e) {
- return null;
- }
- }
- /**
- * This method runs before starting the entire test suite.
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- Site location;
- ISiteFactory factory = TargetManager.getSiteFactory(properties.getProperty("target"));
- assertNotNull(factory);
- Site[] locations = TargetManager.getSites();
-
- if (locations.length == 0) {
- Site l = factory.newSite(properties);
- TargetManager.addSite(l);
- }
- location = getSite();
-
- //clean up the directory:
- IRemoteTargetResource remote=location.getRemoteResource().getFolder(properties.getProperty("test_dir"));
- IRemoteResource[] children=remote.members(null);
- for (int i = 0; i < children.length; i++) {
- ((IRemoteTargetResource)children[i]).delete(null);
- }
-
- TargetProvider target = location.newProvider(new Path(properties.getProperty("test_dir")));
- assertNotNull(target);
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
index 5bf347208..3370456bb 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
@@ -14,12 +14,9 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -30,21 +27,15 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
public class TeamTest extends EclipseWorkspaceTest {
protected static IProgressMonitor DEFAULT_MONITOR = new NullProgressMonitor();
protected static final IProgressMonitor DEFAULT_PROGRESS_MONITOR = new NullProgressMonitor();
- Properties properties;
public TeamTest() {
super();
@@ -52,13 +43,7 @@ public class TeamTest extends EclipseWorkspaceTest {
public TeamTest(String name) {
super(name);
}
- /**
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- properties = TargetTestSetup.properties;
- }
+
protected IProject getNamedTestProject(String name) throws CoreException {
IProject target = getWorkspace().getRoot().getProject(name);
if (!target.exists()) {
@@ -77,18 +62,7 @@ public class TeamTest extends EclipseWorkspaceTest {
protected IStatus getTeamTestStatus(int severity) {
return new Status(severity, "org.eclipse.team.tests.core", 0, "team status", null);
}
- /**
- * Retrieves the Site object that the TargetProvider is contained in.
- * @return Site
- */
- Site getSite() {
- try {
- URL url = new URL(properties.getProperty("location"));
- return TargetManager.getSite(properties.getProperty("target"), url);
- } catch (MalformedURLException e) {
- return null;
- }
- }
+
/**
* Creates filesystem 'resources' with the given names and fills them with random text.
* @param container An object that can hold the newly created resources.
@@ -161,21 +135,7 @@ public class TeamTest extends EclipseWorkspaceTest {
return "these are my contents";
}
}
- public TargetProvider createProvider(IProject project) throws TeamException {
- // Ensure the remote folder exists
- IRemoteTargetResource remote = getSite().getRemoteResource().getFolder(
- new Path(properties.getProperty("test_dir")).append(project.getName()).toString());
- if (! remote.exists(null)) {
- remote.mkdirs(null);
- }
- TargetManager.map(project, getSite(), new Path(properties.getProperty("test_dir")).append(project.getName()));
- TargetProvider target = getProvider(project);
- return target;
- }
-
- public TargetProvider getProvider(IProject project) throws TeamException {
- return TargetManager.getProvider(project);
- }
+
public void sleep(int ms) {
try {
@@ -184,14 +144,7 @@ public class TeamTest extends EclipseWorkspaceTest {
System.err.println("Testing was rudely interrupted.");
}
}
- void assertLocalEqualsRemote(IProject project) throws CoreException, TeamException {
- IProject newProject = getNamedTestProject("equals");
- TargetProvider target = TargetManager.getProvider(project);
- IResource[] localResources = project.members();
- for (int i = 0; i < localResources.length; i++) {
- assertEquals(target.getRemoteResourceFor(localResources[i]), localResources[i]);
- }
- }
+
// Assert that the two containers have equal contents
protected void assertEquals(IRemoteResource container1, IResource container2) throws CoreException, TeamException {
if (container2.getType() == IResource.FILE) {
@@ -207,13 +160,6 @@ public class TeamTest extends EclipseWorkspaceTest {
}
}
}
- protected IProject createAndPut(String projectPrefix, String[] resourceNames) throws CoreException, TeamException {
- IProject project = getUniqueTestProject(projectPrefix);
- IResource[] resources = buildResources(project, resourceNames, false);
- TargetProvider target = createProvider(project);
- target.put(resources, DEFAULT_MONITOR);
- return project;
- }
public void appendText(IResource resource, String text, boolean prepend) throws CoreException, IOException {
IFile file = (IFile) resource;
diff --git a/tests/org.eclipse.team.tests.core/test.xml b/tests/org.eclipse.team.tests.core/test.xml
index bc792fd2a..3418c9378 100644
--- a/tests/org.eclipse.team.tests.core/test.xml
+++ b/tests/org.eclipse.team.tests.core/test.xml
@@ -31,38 +31,6 @@
</target>
- <!-- This target defines the FTP tests that need to be run. -->
- <target name="ftpsuite">
- <property name="location" value="${eclipse-home}/team_test_workspace"/>
- <delete dir="${location}" quiet="true"/>
-
- <!-- Session Test ** FTP ** -->
- <property name="classname" value="org.eclipse.team.tests.core.TargetProviderTests"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.team.tests.core"/>
- <property name="classname" value="org.eclipse.team.tests.core.TargetProviderTests"/>
- <property name="vmargs" value="-Declipse.target.properties=${team-home}/ftp.properties"/>
- </ant>
- <move file="${eclipse-home}/${classname}.xml" tofile="${eclipse-home}/${classname}-ftp.xml"/>
- </target>
-
- <!-- This target defines the WebDAV tests that need to be run. -->
- <target name="webdavsuite">
- <property name="location" value="${eclipse-home}/team_test_workspace"/>
- <delete dir="${location}" quiet="true"/>
-
- <!-- Session Test ** WebDAV ** -->
- <property name="classname" value="org.eclipse.team.tests.core.TargetProviderTests"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.team.tests.core"/>
- <property name="classname" value="${classname}"/>
- <property name="vmargs" value="-Declipse.target.properties=${team-home}/webdav.properties"/>
- </ant>
- <move file="${eclipse-home}/${classname}.xml" tofile="${eclipse-home}/${classname}-webdav.xml"/>
- </target>
-
<!-- This target holds code to cleanup the testing environment after the tests -->
<!-- have been run. You can use this to delete temporary files that are created. -->
<target name="cleanup">
diff --git a/tests/org.eclipse.team.tests.core/webdav.properties b/tests/org.eclipse.team.tests.core/webdav.properties
deleted file mode 100644
index a81f09182..000000000
--- a/tests/org.eclipse.team.tests.core/webdav.properties
+++ /dev/null
@@ -1,17 +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
-###############################################################################
-target=org.eclipse.team.webdav
-test_dir=target
-location=http://@host@/path
-httpClient.username=@user@
-httpClient.password=@password@
-httpClient.proxyURL=
-httpClient.connectionTimeout=6000 \ No newline at end of file

Back to the top