Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-09-22 19:44:19 +0000
committerStephan Herrmann2012-09-22 19:44:19 +0000
commit7b935330763aeaf767b983d7fde5bf4a764b0193 (patch)
treef1df35cf4e540dbd92b51769f9a3a9ed731c78e2 /testplugins
parent5a399c44ffa19b28a3a9a5bdca11ab35e45fb0d4 (diff)
downloadorg.eclipse.objectteams-7b935330763aeaf767b983d7fde5bf4a764b0193.tar.gz
org.eclipse.objectteams-7b935330763aeaf767b983d7fde5bf4a764b0193.tar.xz
org.eclipse.objectteams-7b935330763aeaf767b983d7fde5bf4a764b0193.zip
Bug 367605 - [refactoring] missing update of base import during renaming
or moving a base class - fix an omission in one of ImportRewrite.create - new role (nested team) in MoveAdaptor to detect base imports on this path, too. - test
Diffstat (limited to 'testplugins')
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/plugin.xml5
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/AllTests.java3
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/MoveBaseClassTests.java132
3 files changed, 139 insertions, 1 deletions
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/plugin.xml b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/plugin.xml
index cd30ebb7b..4ded421fe 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/plugin.xml
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/plugin.xml
@@ -24,6 +24,11 @@
class="org.eclipse.objectteams.otdt.ui.tests.refactoring.move.MoveRoleTests"
icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
</team>
+ <team
+ activation="NONE"
+ class="org.eclipse.objectteams.otdt.ui.tests.refactoring.move.MoveBaseClassTests"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
</aspectBinding>
<aspectBinding
icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/AllTests.java
index be3077a97..b3557f744 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/AllTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/AllTests.java
@@ -27,7 +27,7 @@ import junit.framework.TestSuite;
/**
* @author brcan
*
- * Runs all OT-specific refactoring tests and corresponding eclipse refactoring tests
+ * Runs all OT-specific refactoring tests for this package (move)
*/
public class AllTests
{
@@ -45,6 +45,7 @@ public class AllTests
suite.addTest(org.eclipse.objectteams.otdt.ui.tests.refactoring.move.MoveInstanceMethodTests.suite());
suite.addTest(org.eclipse.objectteams.otdt.ui.tests.refactoring.move.MoveStaticMethodTests.suite());
suite.addTest(org.eclipse.objectteams.otdt.ui.tests.refactoring.move.MoveRoleTests.suite());
+ suite.addTest(org.eclipse.objectteams.otdt.ui.tests.refactoring.move.MoveBaseClassTests.suite());
return suite;
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/MoveBaseClassTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/MoveBaseClassTests.java
new file mode 100644
index 000000000..c0d6a7b5b
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/MoveBaseClassTests.java
@@ -0,0 +1,132 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2012 Stephan Herrmann.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Stephan Herrmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.ui.tests.refactoring.move;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
+import org.eclipse.jdt.ui.tests.refactoring.ParticipantTesting;
+import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
+import org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper;
+
+import base org.eclipse.jdt.ui.tests.refactoring.ccp.MoveTest;
+
+// see Bug 367605 - [refactoring] missing update of base import during renaming or moving a base class
+@SuppressWarnings("restriction")
+public team class MoveBaseClassTests extends TestCase {
+
+ @SuppressWarnings("decapsulation")
+ protected class MoveBaseClass playedBy MoveTest {
+
+ void setUp() -> void setUp();
+
+ void tearDown() -> void tearDown();
+
+ public MoveBaseClass() {
+ base(MoveBaseClass.class.getName());
+ }
+
+ @SuppressWarnings("inferredcallout")
+ public void testDestination_yes_baseTypeToDifferentPackage() throws Exception{
+ ParticipantTesting.reset();
+ IPackageFragment packB = getRoot().createPackageFragment("b", true, null);
+ IPackageFragment packBTemp = getRoot().createPackageFragment("b.temp", true, null);
+ ICompilationUnit cuB= packB.createCompilationUnit("B.java", "package b;public class B {}", true, null);
+ ICompilationUnit cuT= getPackageP().createCompilationUnit("T1.java",
+ "package p;\n" +
+ "import base b.B;\n" +
+ "team class T1{void foo(){}protected class Role playedBy B{}}",
+ false, new NullProgressMonitor());
+ try {
+ IType baseType = cuB.getTypes()[0];
+ IJavaElement[] javaElements= {baseType};
+ IResource[] resources= {};
+ JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries());
+
+ Object destination= packBTemp;
+ verifyValidDestination(ref, destination);
+
+ RefactoringStatus status= performRefactoring(ref, true);
+ assertEquals(null, status);
+
+ // expect that base import has been updated in cuT:
+ String expectedSource2=
+ "package p;\n" +
+ "import base b.temp.B;\n" +
+ "team class T1{void foo(){}protected class Role playedBy B{}}";
+ assertEqualLines("source compare failed", expectedSource2, cuT.getSource());
+
+ } finally {
+ performDummySearch();
+ safeDelete(cuT);
+ safeDelete(packBTemp.getCompilationUnit("B.java"));
+ }
+ }
+ }
+
+ private MoveBaseClass mover;
+ private boolean projectInitialized = false;
+
+ public MoveBaseClassTests() {
+ this.mover = new MoveBaseClass();
+ }
+ public static Test suite() {
+ return new RefactoringTestSetup(new TestSuite(MoveBaseClassTests.class));
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new RefactoringTestSetup(someTest);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ setupProject();
+ this.mover.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ this.mover.tearDown();
+ }
+
+ void setupProject() throws Exception {
+ if (!this.projectInitialized) {
+ this.projectInitialized = true;
+ IJavaProject javaProj = RefactoringTestSetup.getProject();
+ JavaProjectHelper.addNatureToProject(javaProj.getProject(), JavaCore.OTJ_NATURE_ID, null);
+ OTREContainer.initializeOTJProject(javaProj.getProject());
+ }
+ }
+
+ public void testDestination_yes_roleTypeToDifferentTeam() throws Exception {
+ this.mover.testDestination_yes_baseTypeToDifferentPackage();
+ }
+
+}

Back to the top