Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-11-21 16:17:17 +0000
committerMichael Valenta2002-11-21 16:17:17 +0000
commit3cc26a480a5b19ce68924f844723e83392e175ba (patch)
treedef9244eee3e8f764be15f801d9ae42c6dc198f4 /tests/org.eclipse.team.tests.core
parent4c0d066d0e222d4662189fb15681b6073c8e9402 (diff)
downloadeclipse.platform.team-3cc26a480a5b19ce68924f844723e83392e175ba.tar.gz
eclipse.platform.team-3cc26a480a5b19ce68924f844723e83392e175ba.tar.xz
eclipse.platform.team-3cc26a480a5b19ce68924f844723e83392e175ba.zip
Update test cases for linked resources and persistent properties
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/plugin.xml77
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderOtherSport.java1
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java124
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderWithLinking.java57
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java2
5 files changed, 175 insertions, 86 deletions
diff --git a/tests/org.eclipse.team.tests.core/plugin.xml b/tests/org.eclipse.team.tests.core/plugin.xml
index 71caa17fa..a1cf25186 100644
--- a/tests/org.eclipse.team.tests.core/plugin.xml
+++ b/tests/org.eclipse.team.tests.core/plugin.xml
@@ -54,47 +54,42 @@
</test>
</extension>
-
- <extension
- id="bic-provider"
- name="Bic Provider"
- point="org.eclipse.core.resources.natures">
- <runtime>
- <run
- class="org.eclipse.team.tests.core.RepositoryProviderBic">
- </run>
- </runtime>
- <one-of-nature
- id="org.eclipse.team.repository-provider">
- </one-of-nature>
- </extension>
- <extension
- id="naish-provider"
- name="Naish Provider"
- point="org.eclipse.core.resources.natures">
- <runtime>
- <run
- class="org.eclipse.team.tests.core.RepositoryProviderNaish">
- </run>
- </runtime>
- <one-of-nature
- id="org.eclipse.team.repository-provider">
- </one-of-nature>
- </extension>
- <extension
- id="other"
- name="Bad Set Provider"
- point="org.eclipse.core.resources.natures">
- <runtime>
- <run
- class="org.eclipse.team.tests.core.RepositoryProviderOtherSport">
- </run>
- </runtime>
- <one-of-nature
- id="some set">
- </one-of-nature>
- </extension>
-
+ <!-- *************** Repository Providers **************** -->
+ <extension
+ point="org.eclipse.team.core.repository">
+ <repository
+ id="org.eclipse.team.tests.core.bic-provider"
+ class="org.eclipse.team.tests.core.RepositoryProviderBic">
+ </repository>
+ </extension>
+
+ <extension
+ point="org.eclipse.team.core.repository">
+ <repository
+ id="org.eclipse.team.tests.core.naish-provider"
+ class="org.eclipse.team.tests.core.RepositoryProviderNaish">
+ </repository>
+ </extension>
+
+ <!-- *************** Bad provider that is not registered ****************
+ <extension
+ point="org.eclipse.team.core.repository">
+ <repository
+ id="org.eclipse.team.tests.core.other"
+ class="org.eclipse.team.tests.core.RepositoryProviderOtherSport">
+ </repository>
+ </extension>
+ -->
+
+ <extension
+ point="org.eclipse.team.core.repository">
+ <repository
+ id="org.eclipse.team.tests.core.linking"
+ class="org.eclipse.team.tests.core.RepositoryProviderWithLinking">
+ </repository>
+ </extension>
+
+ <!-- *************** Test application **************** -->
<extension
id="testapplication"
point="org.eclipse.core.runtime.applications">
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderOtherSport.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderOtherSport.java
index ac3c119bb..9ff6d2d80 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderOtherSport.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderOtherSport.java
@@ -10,7 +10,6 @@
******************************************************************************/
package org.eclipse.team.tests.core;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.team.core.RepositoryProvider;
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java
index c1f9dc7ee..3b22db842 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java
@@ -18,12 +18,14 @@ import java.util.List;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFileModificationValidator;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.team.IMoveDeleteHook;
import org.eclipse.core.resources.team.IResourceTree;
@@ -31,7 +33,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.Team;
import org.eclipse.team.core.TeamException;
public class RepositoryProviderTests extends TeamTest {
@@ -60,33 +61,29 @@ public class RepositoryProviderTests extends TeamTest {
IProject project = getUniqueTestProject("testGetProviderGeneric1");
IProject project2 = getUniqueTestProject("testGetProviderGeneric2");
- // test that adding a non-team nature will not return a provider
- Team.addNatureToProject(project, RepositoryProviderOtherSport.NATURE_ID, null);
- assertTrue(RepositoryProvider.getProvider(project) == null);
+ // test that adding a non registered provider doesn't work
+ boolean good = false;
+ try {
+ RepositoryProvider.map(project, RepositoryProviderOtherSport.NATURE_ID);
+ } catch (TeamException e) {
+ good = true;
+ }
+ assertTrue(good);
// adding a valid team provider should be fine
- Team.addNatureToProject(project, RepositoryProviderBic.NATURE_ID, null);
- Team.addNatureToProject(project2, RepositoryProviderNaish.NATURE_ID, null);
+ RepositoryProvider.map(project, RepositoryProviderNaish.NATURE_ID);
+ RepositoryProvider.map(project2, RepositoryProviderNaish.NATURE_ID);
RepositoryProvider provider1 = RepositoryProvider.getProvider(project);
RepositoryProvider provider2 = RepositoryProvider.getProvider(project2);
- assertTrue(provider1 != null && provider1.getID().equals(RepositoryProviderBic.NATURE_ID));
+ assertTrue(provider1 != null && provider1.getID().equals(RepositoryProviderNaish.NATURE_ID));
assertTrue(provider2 != null && provider2.getID().equals(RepositoryProviderNaish.NATURE_ID));
assertTrue(provider1.getProject().equals(project) && provider2.getProject().equals(project2));
- // adding another provider should be prohibited by core
- try {
- Team.addNatureToProject(project, RepositoryProviderNaish.NATURE_ID, null);
- fail("cannot add two team providers to the same project");
- } catch(TeamException e) {
- provider1 = RepositoryProvider.getProvider(project);
- assertTrue(provider1 != null && provider1.getID().equals(RepositoryProviderBic.NATURE_ID));
- }
-
- // adding another non-team provider should be ok but should not be returned as a provider
- Team.addNatureToProject(project2, RepositoryProviderOtherSport.NATURE_ID, null);
- provider2 = RepositoryProvider.getProvider(project2);
- assertTrue(provider2 != null && provider2.getID().equals(RepositoryProviderNaish.NATURE_ID));
-
+ // remapping a provider is allowed
+ RepositoryProvider.map(project, RepositoryProviderBic.NATURE_ID);
+ provider1 = RepositoryProvider.getProvider(project);
+ assertTrue(provider1 != null && provider1.getID().equals(RepositoryProviderBic.NATURE_ID));
+
// closed or non-existant projects cannot be associated with a provider
IProject closedProject = getUniqueTestProject("testGetProviderGenericClosed");
IProject nonExistantProject = ResourcesPlugin.getWorkspace().getRoot().getProject("nonExistant");
@@ -95,8 +92,8 @@ public class RepositoryProviderTests extends TeamTest {
assertTrue(RepositoryProvider.getProvider(nonExistantProject) == null);
// removing the nature removes the provider association
- Team.removeNatureFromProject(project, RepositoryProviderBic.NATURE_ID, null);
- Team.removeNatureFromProject(project2, RepositoryProviderNaish.NATURE_ID, null);
+ RepositoryProvider.unmap(project);
+ RepositoryProvider.unmap(project2);
assertTrue(RepositoryProvider.getProvider(project)==null);
assertTrue(RepositoryProvider.getProvider(project2)==null);
}
@@ -105,24 +102,12 @@ public class RepositoryProviderTests extends TeamTest {
IProject project1 = getUniqueTestProject("testGetProviderById_1");
IProject project2 = getUniqueTestProject("testGetProviderById_2");
- // test that adding a non-team nature will not return a provider
- Team.addNatureToProject(project1, RepositoryProviderOtherSport.NATURE_ID, null);
- assertTrue(RepositoryProvider.getProvider(project1, RepositoryProviderOtherSport.NATURE_ID) == null);
-
// adding a valid team provider should be fine
- Team.addNatureToProject(project1, RepositoryProviderBic.NATURE_ID, null);
- Team.addNatureToProject(project2, RepositoryProviderNaish.NATURE_ID, null);
+ RepositoryProvider.map(project1, RepositoryProviderBic.NATURE_ID);
+ RepositoryProvider.map(project2, RepositoryProviderNaish.NATURE_ID);
assertTrue(RepositoryProvider.getProvider(project1, RepositoryProviderBic.NATURE_ID)!=null);
assertTrue(RepositoryProvider.getProvider(project2, RepositoryProviderNaish.NATURE_ID)!=null);
- // adding another provider should be prohibited by core
- try {
- Team.addNatureToProject(project1, RepositoryProviderNaish.NATURE_ID, null);
- fail("cannot add two team providers to the same project");
- } catch(TeamException e) {
- assertTrue(RepositoryProvider.getProvider(project1, RepositoryProviderBic.NATURE_ID)!=null);
- }
-
// closed or non-existant projects cannot be associated with a provider
IProject closedProject = getUniqueTestProject("testGetProviderGenericClosed");
IProject nonExistantProject = ResourcesPlugin.getWorkspace().getRoot().getProject("nonExistant");
@@ -131,8 +116,8 @@ public class RepositoryProviderTests extends TeamTest {
assertTrue(RepositoryProvider.getProvider(nonExistantProject, "id") == null);
// removing the nature removes the provider association
- Team.removeNatureFromProject(project1, RepositoryProviderBic.NATURE_ID, null);
- Team.removeNatureFromProject(project2, RepositoryProviderNaish.NATURE_ID, null);
+ RepositoryProvider.unmap(project1);
+ RepositoryProvider.unmap(project2);
assertTrue(RepositoryProvider.getProvider(project1, RepositoryProviderBic.NATURE_ID)==null);
assertTrue(RepositoryProvider.getProvider(project2, RepositoryProviderNaish.NATURE_ID)==null);
}
@@ -141,7 +126,7 @@ public class RepositoryProviderTests extends TeamTest {
IProject project = getUniqueTestProject("testFileModificationValidator");
// adding a valid team provider should be fine
- Team.addNatureToProject(project, RepositoryProviderBic.NATURE_ID, null);
+ RepositoryProvider.map(project, RepositoryProviderBic.NATURE_ID);
RepositoryProviderBic bicProvider = (RepositoryProviderBic)RepositoryProvider.getProvider(project, RepositoryProviderBic.NATURE_ID);
assertTrue(bicProvider!=null);
@@ -190,7 +175,7 @@ public class RepositoryProviderTests extends TeamTest {
final IProject project = getUniqueTestProject("testMoveDeleteHook");
// adding a valid team provider should be fine
- Team.addNatureToProject(project, RepositoryProviderBic.NATURE_ID, null);
+ RepositoryProvider.map(project, RepositoryProviderBic.NATURE_ID);
RepositoryProviderBic bicProvider = (RepositoryProviderBic)RepositoryProvider.getProvider(project, RepositoryProviderBic.NATURE_ID);
assertTrue(bicProvider!=null);
@@ -249,9 +234,9 @@ public class RepositoryProviderTests extends TeamTest {
final IProject projectC = getUniqueTestProject("testMoveDeleteHookBetweenProjects_C");
// adding a valid team provider should be fine
- Team.addNatureToProject(projectA, RepositoryProviderBic.NATURE_ID, null);
+ RepositoryProvider.map(projectA, RepositoryProviderBic.NATURE_ID);
final RepositoryProviderBic bicProvider = (RepositoryProviderBic)RepositoryProvider.getProvider(projectA, RepositoryProviderBic.NATURE_ID);
- Team.addNatureToProject(projectB, RepositoryProviderNaish.NATURE_ID, null);
+ RepositoryProvider.map(projectB, RepositoryProviderNaish.NATURE_ID);
final RepositoryProviderNaish naishProvider = (RepositoryProviderNaish)RepositoryProvider.getProvider(projectB, RepositoryProviderNaish.NATURE_ID);
assertTrue(bicProvider!=null && naishProvider!=null);
@@ -329,4 +314,57 @@ public class RepositoryProviderTests extends TeamTest {
assertTrue(calledProjectA[i] && calledProjectB[i]==false);
}
}
+
+ 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(getRandomLocation(), IResource.ALLOW_MISSING_LOCAL, null);
+ RepositoryProviderWithLinking.setCanHandleLinking(true);
+ RepositoryProvider.map(project, RepositoryProviderWithLinking.TYPE_ID);
+ }
+
+ public void testLinkSuccess() throws CoreException, TeamException {
+ IProject project = getUniqueTestProject("testLinkSuccess");
+ buildResources(project, new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" }, true);
+ RepositoryProviderWithLinking.setCanHandleLinking(true);
+ RepositoryProvider.map(project, RepositoryProviderWithLinking.TYPE_ID);
+ IFolder folder = project.getFolder("link");
+ folder.createLink(getRandomLocation(), IResource.ALLOW_MISSING_LOCAL, null);
+ }
+
+ public void testMapFailure() 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(getRandomLocation(), IResource.ALLOW_MISSING_LOCAL, null);
+ try {
+ RepositoryProviderWithLinking.setCanHandleLinking(false);
+ RepositoryProvider.map(project, RepositoryProviderWithLinking.TYPE_ID);
+ } catch (TeamException e) {
+ if (e.getStatus().getCode() != IResourceStatus.LINKING_NOT_ALLOWED) {
+ throw e;
+ }
+ return;
+ }
+ fail("Link should be disallowed");
+ }
+
+ public void testLinkFailure() throws CoreException, TeamException {
+ IProject project = getUniqueTestProject("testLinkSuccess");
+ buildResources(project, new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" }, true);
+ RepositoryProviderWithLinking.setCanHandleLinking(false);
+ RepositoryProvider.map(project, RepositoryProviderWithLinking.TYPE_ID);
+ IFolder folder = project.getFolder("link");
+ try {
+ folder.createLink(getRandomLocation(), IResource.ALLOW_MISSING_LOCAL, null);
+ } catch (CoreException e) {
+ if (e.getStatus().getCode() != IResourceStatus.LINKING_NOT_ALLOWED) {
+ throw e;
+ }
+ return;
+ }
+ fail("Link should be disallowed");
+ }
+
} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderWithLinking.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderWithLinking.java
new file mode 100644
index 000000000..3d1d7082d
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderWithLinking.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
+package org.eclipse.team.tests.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.team.core.RepositoryProvider;
+
+/**
+ * This class is used to text resource linking
+ */
+public class RepositoryProviderWithLinking extends RepositoryProvider {
+
+ final public static String TYPE_ID = "org.eclipse.team.tests.core.linking";
+
+ private static boolean canHandleLinking = false;
+
+ /**
+ * @see org.eclipse.team.core.RepositoryProvider#configureProject()
+ */
+ public void configureProject() throws CoreException {
+ }
+ /**
+ * @see org.eclipse.team.core.RepositoryProvider#getID()
+ */
+ public String getID() {
+ return TYPE_ID;
+ }
+ /**
+ * @see org.eclipse.core.resources.IProjectNature#deconfigure()
+ */
+ public void deconfigure() throws CoreException {
+ }
+
+ /**
+ * Sets the canHandleLinking.
+ * @param canHandleLinking The canHandleLinking to set
+ */
+ public static void setCanHandleLinking(boolean canHandleLinking) {
+ RepositoryProviderWithLinking.canHandleLinking = canHandleLinking;
+ }
+
+ /**
+ * @see org.eclipse.team.core.RepositoryProvider#canHandleLinkedResources()
+ */
+ public boolean canHandleLinkedResources() {
+ return canHandleLinking;
+ }
+
+}
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 c673ba36b..d478350f7 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
@@ -179,7 +179,7 @@ public class TeamTest extends EclipseWorkspaceTest {
public void sleep(int ms) {
try {
- Thread.currentThread().sleep(ms);
+ Thread.sleep(ms);
} catch (InterruptedException e) {
System.err.println("Testing was rudely interrupted.");
}

Back to the top