Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferguson2008-03-03 11:37:36 +0000
committerAndrew Ferguson2008-03-03 11:37:36 +0000
commit90846e6bfa87c27ceef67ade5c5e3eecd24784d6 (patch)
treeeebfd4229b9ea0a7bf892d992e6c7c55381c72c2 /core/org.eclipse.cdt.ui.tests
parent6a00c1115475fe99f692c9e18519981effcc1d34 (diff)
downloadorg.eclipse.cdt-90846e6bfa87c27ceef67ade5c5e3eecd24784d6.tar.gz
org.eclipse.cdt-90846e6bfa87c27ceef67ade5c5e3eecd24784d6.tar.xz
org.eclipse.cdt-90846e6bfa87c27ceef67ade5c5e3eecd24784d6.zip
221109: Apply fix and add regression
Diffstat (limited to 'core/org.eclipse.cdt.ui.tests')
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/CommentOwnerManagerTests.java342
1 files changed, 205 insertions, 137 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/CommentOwnerManagerTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/CommentOwnerManagerTests.java
index d442d4af5e7..99cc0ab0dde 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/CommentOwnerManagerTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/CommentOwnerManagerTests.java
@@ -13,10 +13,15 @@ package org.eclipse.cdt.ui.tests.text.doctools;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwnershipListener;
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
import org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner;
@@ -30,14 +35,14 @@ public class CommentOwnerManagerTests extends BaseTestCase {
IDocCommentOwner OWNER_3;
DocCommentOwnerManager manager;
- ICProject projectA, projectB, projectC;
+ IProject projectA, projectB, projectC;
protected void setUp() throws Exception {
manager= DocCommentOwnerManager.getInstance();
- projectA= CProjectHelper.createCCProject("projectA", null);
- projectB= CProjectHelper.createCCProject("projectB", null);
- projectC= CProjectHelper.createCCProject("projectC", null);
+ projectA= CProjectHelper.createCCProject("projectA", null).getProject();
+ projectB= CProjectHelper.createCCProject("projectB", null).getProject();
+ projectC= CProjectHelper.createCCProject("projectC", null).getProject();
IDocCommentOwner[] owners= manager.getRegisteredOwners();
OWNER_1= manager.getOwner("org.cdt.test.DCOM1");
@@ -47,13 +52,13 @@ public class CommentOwnerManagerTests extends BaseTestCase {
protected void tearDown() throws Exception {
if(projectA != null) {
- CProjectHelper.delete(projectA);
+ CProjectHelper.delete(CoreModel.getDefault().create(projectA));
}
if(projectB != null) {
- CProjectHelper.delete(projectB);
+ CProjectHelper.delete(CoreModel.getDefault().create(projectB));
}
if(projectC != null) {
- CProjectHelper.delete(projectC);
+ CProjectHelper.delete(CoreModel.getDefault().create(projectC));
}
}
@@ -62,57 +67,57 @@ public class CommentOwnerManagerTests extends BaseTestCase {
}
public void testProjectLevel() throws Exception {
- manager.setCommentOwner(projectA.getProject(), OWNER_3, true);
- manager.setCommentOwner(projectB.getProject(), OWNER_2, true);
- manager.setCommentOwner(projectC.getProject(), OWNER_1, true);
+ manager.setCommentOwner(projectA, OWNER_3, true);
+ manager.setCommentOwner(projectB, OWNER_2, true);
+ manager.setCommentOwner(projectC, OWNER_1, true);
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
- manager.setCommentOwner(projectA.getProject(), OWNER_2, true);
- manager.setCommentOwner(projectB.getProject(), OWNER_1, true);
- manager.setCommentOwner(projectC.getProject(), OWNER_3, true);
+ manager.setCommentOwner(projectA, OWNER_2, true);
+ manager.setCommentOwner(projectB, OWNER_1, true);
+ manager.setCommentOwner(projectC, OWNER_3, true);
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
- projectA.getProject().close(NPM);
- projectB.getProject().close(NPM);
- projectC.getProject().close(NPM);
+ projectA.close(NPM);
+ projectB.close(NPM);
+ projectC.close(NPM);
- projectA.getProject().open(NPM);
- projectB.getProject().open(NPM);
- projectC.getProject().open(NPM);
+ projectA.open(NPM);
+ projectB.open(NPM);
+ projectC.open(NPM);
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
}
public void testBoundaryConditions1() throws Exception {
@@ -130,136 +135,199 @@ public class CommentOwnerManagerTests extends BaseTestCase {
}
public void testWorkspaceRootLevel() throws Exception {
- manager.setCommentOwner(projectA.getProject(), null, true);
- manager.setCommentOwner(projectB.getProject(), null, true);
- manager.setCommentOwner(projectC.getProject(), null, true);
+ manager.setCommentOwner(projectA, null, true);
+ manager.setCommentOwner(projectB, null, true);
+ manager.setCommentOwner(projectC, null, true);
manager.setWorkspaceCommentOwner(OWNER_1);
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
manager.setWorkspaceCommentOwner(OWNER_2);
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
manager.setWorkspaceCommentOwner(OWNER_3);
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
- manager.setCommentOwner(projectA.getProject(), OWNER_3, true);
- manager.setCommentOwner(projectB.getProject(), OWNER_2, true);
- manager.setCommentOwner(projectC.getProject(), OWNER_1, true);
+ manager.setCommentOwner(projectA, OWNER_3, true);
+ manager.setCommentOwner(projectB, OWNER_2, true);
+ manager.setCommentOwner(projectC, OWNER_1, true);
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
manager.setWorkspaceCommentOwner(NullDocCommentOwner.INSTANCE);
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_3.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
- manager.setCommentOwner(projectA.getProject(), null, true);
+ manager.setCommentOwner(projectA, null, true);
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
- manager.setCommentOwner(projectC.getProject(), null, true);
+ manager.setCommentOwner(projectC, null, true);
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_2.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
- manager.setCommentOwner(projectB.getProject(), null, true);
+ manager.setCommentOwner(projectB, null, true);
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(NullDocCommentOwner.INSTANCE.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
+
+ manager.setWorkspaceCommentOwner(OWNER_1);
+
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getFolder("foo/bar")).getID());
+
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getFolder("foo/bar")).getID());
+
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFile("foo/bar/baz")).getID());
+ assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getFolder("foo/bar")).getID());
+ }
+
+ public void testDocListenerEvents_221109() {
+ TestListener tl= new TestListener();
+ manager.setCommentOwner(projectA, null, true);
+ manager.setCommentOwner(projectB, null, true);
+ manager.setCommentOwner(projectC, null, true);
manager.setWorkspaceCommentOwner(OWNER_1);
+ manager.addListener(tl);
+
+ tl.reset();
+ manager.setCommentOwner(projectA, OWNER_1, true);
+ assertEquals(0, tl.prjEvents);
+ assertEquals(0, tl.wkspcEvents);
+
+ tl.reset();
+ manager.setCommentOwner(projectA, OWNER_2, true);
+ assertEquals(1, tl.prjEvents);
+ assertEquals(0, tl.wkspcEvents);
+
+ tl.reset();
+ manager.setCommentOwner(projectA, OWNER_3, true);
+ assertEquals(1, tl.prjEvents);
+ assertEquals(0, tl.wkspcEvents);
+
+ tl.reset();
+ manager.setCommentOwner(projectA, OWNER_1, true);
+ assertEquals(1, tl.prjEvents);
+ assertEquals(0, tl.wkspcEvents);
+
+ tl.reset();
+ manager.setCommentOwner(ResourcesPlugin.getWorkspace().getRoot(), OWNER_2, true);
+ assertEquals(0, tl.prjEvents);
+ assertEquals(1, tl.wkspcEvents);
+
+ tl.reset();
+ manager.setWorkspaceCommentOwner(OWNER_3);
+ assertEquals(0, tl.prjEvents);
+ assertEquals(1, tl.wkspcEvents);
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectA.getProject().getFolder("foo/bar")).getID());
+ tl.reset();
+ manager.setWorkspaceCommentOwner(OWNER_3);
+ assertEquals(0, tl.prjEvents);
+ assertEquals(0, tl.wkspcEvents);
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectB.getProject().getFolder("foo/bar")).getID());
+ manager.removeListener(tl);
+ }
+}
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject()).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFile("foo/bar/baz")).getID());
- assertEquals(OWNER_1.getID(), manager.getCommentOwner(projectC.getProject().getFolder("foo/bar")).getID());
+class TestListener implements IDocCommentOwnershipListener {
+ public int prjEvents, wkspcEvents;
+ public void ownershipChanged(IResource resource,
+ boolean submappingsRemoved, IDocCommentOwner oldOwner,
+ IDocCommentOwner newOwner) {
+ prjEvents++;
+ }
+ public void workspaceOwnershipChanged(IDocCommentOwner oldOwner,
+ IDocCommentOwner newOwner) {
+ wkspcEvents++;
+ }
+ public void reset() {
+ prjEvents= wkspcEvents= 0;
}
}

Back to the top