Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2011-12-27 11:17:48 +0000
committerStephan Herrmann2011-12-27 11:17:48 +0000
commit1437f3b477d90032b1ab3c67a691de78ab0aeee2 (patch)
tree21694a548516b901b41d454e70e2557db7bbf738 /testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring
parentd2cecfdbfe86fb966ffe98d400c216449c7c71aa (diff)
downloadorg.eclipse.objectteams-1437f3b477d90032b1ab3c67a691de78ab0aeee2.tar.gz
org.eclipse.objectteams-1437f3b477d90032b1ab3c67a691de78ab0aeee2.tar.xz
org.eclipse.objectteams-1437f3b477d90032b1ab3c67a691de78ab0aeee2.zip
Test & fix for Bug 316698 - [refactoring] Refactoring for moving a role
class doesn't handle base imports
Diffstat (limited to 'testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring')
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/META-INF/MANIFEST.MF3
-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.java1
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/MoveRoleTests.java128
4 files changed, 136 insertions, 1 deletions
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/META-INF/MANIFEST.MF b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/META-INF/MANIFEST.MF
index f75dbf6b0..bc7e6b63c 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/META-INF/MANIFEST.MF
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/META-INF/MANIFEST.MF
@@ -31,6 +31,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jdt.core.manipulation,
org.eclipse.jdt.ui.tests,
org.eclipse.objectteams.otequinox,
- org.eclipse.objectteams.otequinox
+ org.eclipse.objectteams.otequinox,
+ org.eclipse.objectteams.otdt
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
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 e33444217..cd30ebb7b 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/plugin.xml
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/plugin.xml
@@ -19,6 +19,11 @@
class="org.eclipse.objectteams.otdt.ui.tests.refactoring.adapt.JdtTests.ChangeSignature"
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.MoveRoleTests"
+ 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 f99b76be5..be3077a97 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
@@ -44,6 +44,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());
return suite;
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/MoveRoleTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/MoveRoleTests.java
new file mode 100644
index 000000000..3ef9e32fb
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/move/MoveRoleTests.java
@@ -0,0 +1,128 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2011 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;
+
+@SuppressWarnings("restriction")
+public team class MoveRoleTests extends TestCase {
+
+ @SuppressWarnings("decapsulation")
+ protected class MoveRole playedBy MoveTest {
+
+ void setUp() -> void setUp();
+
+ void tearDown() -> void tearDown();
+
+ public MoveRole() {
+ base(MoveRole.class.getName());
+ }
+
+ @SuppressWarnings("inferredcallout")
+ public void testDestination_yes_roleTypeToDifferentTeam() throws Exception{
+ ParticipantTesting.reset();
+ IPackageFragment packB = getRoot().createPackageFragment("b", true, null);
+ packB.createCompilationUnit("B.java", "package b;public class B {}", true, null);
+ ICompilationUnit cu1= getPackageP().createCompilationUnit("T1.java", "package p;import base b.B;team class T1{void foo(){}protected class Role playedBy B{}}", false, new NullProgressMonitor());
+ ICompilationUnit cu2= getPackageP().createCompilationUnit("T2.java", "package p;team class T2{void bar(){}}", false, new NullProgressMonitor());
+ try {
+ IType teamType = cu1.getTypes()[0];
+ IType roleType = teamType.getType("Role");
+ IJavaElement[] javaElements= { roleType };
+ IResource[] resources= {};
+ JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries());
+
+ Object destination= cu2.getTypes()[0];
+ verifyValidDestination(ref, destination);
+
+ RefactoringStatus status= performRefactoring(ref, true);
+ assertEquals(null, status);
+
+ // expect that base import has been added to cu2:
+ String expectedSource2= "package p;\nimport base b.B;\nteam class T2{protected class Role playedBy B{}\n\nvoid bar(){}}";
+ assertEqualLines("source compare failed", expectedSource2, cu2.getSource());
+
+ // expect that base import has been removed from cu1:
+ String expectedSource1= "package p;team class T1{void foo(){}}";
+ assertEqualLines("source compare failed", expectedSource1, cu1.getSource());
+
+ } finally {
+ performDummySearch();
+ safeDelete(cu2);
+ }
+ }
+ }
+
+ private MoveRole mover;
+ private boolean projectInitialized = false;
+
+ public MoveRoleTests() {
+ this.mover = new MoveRole();
+ }
+ public static Test suite() {
+ return new RefactoringTestSetup(new TestSuite(MoveRoleTests.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_roleTypeToDifferentTeam();
+ }
+
+}

Back to the top