Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-08-11 13:26:09 +0000
committerStephan Herrmann2012-08-11 13:26:09 +0000
commitbbd06a961329133604a68cfd41d482a8c7aafd26 (patch)
treebc09c50ceaaad285f5bdc7fea400c1273a75e529 /testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring
parentc189f3f52c86ddf49b4243581f06f25cd5524919 (diff)
downloadorg.eclipse.objectteams-bbd06a961329133604a68cfd41d482a8c7aafd26.tar.gz
org.eclipse.objectteams-bbd06a961329133604a68cfd41d482a8c7aafd26.tar.xz
org.eclipse.objectteams-bbd06a961329133604a68cfd41d482a8c7aafd26.zip
Bug 386814 - [refactoring] pull-up should distinguish callouts that can
be pull-up vs. abstract decl. - when pullup of callout is requested, check: - is destination type a bound role? - is the base member accessible via the destination's base? - also report when a base member of a referenced callout cannot be resolved (rather than throwing NPE).
Diffstat (limited to 'testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring')
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/pullup/PullUpTests.java50
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/in/B.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/in/T.java13
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/out/B.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/out/T.java20
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B0.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B1.java1
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B2.java3
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/T.java13
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B0.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B1.java1
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B2.java3
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/T.java16
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B0.java2
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B1.java1
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B2.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/T.java13
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B0.java2
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B1.java1
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B2.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/T.java16
21 files changed, 177 insertions, 2 deletions
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/pullup/PullUpTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/pullup/PullUpTests.java
index 947c724d3..ef4613737 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/pullup/PullUpTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/pullup/PullUpTests.java
@@ -221,15 +221,25 @@ public class PullUpTests extends RefactoringTest {
private void performPullUp_failing(String[] cuNames, String[] methodNames, String[][] signatures, String[] fieldNames, boolean deleteAllInSourceType,
boolean deleteAllMatchingMethods, int targetClassIndex, String nameOfDeclaringType) throws Exception {
+ performPullUp_failing(cuNames, methodNames, signatures, null,
+ fieldNames, deleteAllInSourceType, deleteAllMatchingMethods, targetClassIndex, nameOfDeclaringType,
+ null);
+ }
+ private void performPullUp_failing(String[] cuNames, String[] methodNames, String[][] signatures, boolean[] makeAbstract, String[] fieldNames, boolean deleteAllInSourceType,
+ boolean deleteAllMatchingMethods, int targetClassIndex, String nameOfDeclaringType, String[] errorMessages)
+ throws Exception
+ {
ICompilationUnit[] cus = createCUs(cuNames);
try {
IType declaringType = getType(cus[0], nameOfDeclaringType);
- IMethod[] methods = getMethods(declaringType, methodNames, signatures);
+ IMethod[] methods = getMethods(declaringType, methodNames, signatures, makeAbstract, false);
IField[] fields = getFields(declaringType, fieldNames);
IMember[] members = merge(methods, fields);
PullUpRefactoringProcessor processor = createRefactoringProcessor(members);
+ if (makeAbstract != null)
+ processor.setAbstractMethods(getMethods(declaringType, methodNames, signatures, makeAbstract, true));
Refactoring ref = processor.getRefactoring();
setTargetClass(processor, targetClassIndex);
@@ -243,7 +253,15 @@ public class PullUpTests extends RefactoringTest {
assertNotNull("precondition was supposed to fail.", result);
assertTrue("precondition was supposed to fail.", !result.isOK());
assertNotNull("precondition result is expected to contain an error.", result.getEntryMatchingSeverity(RefactoringStatus.ERROR));
-
+ if (errorMessages != null) {
+ int i=0;
+ for(RefactoringStatusEntry entry : result.getEntries()) {
+ if (entry.isFatalError()) {
+ assertEquals("Wrong error message", errorMessages[i++], entry.getMessage());
+ }
+ }
+ assertEquals("Wrong number of error messages", errorMessages.length, i);
+ }
} finally {
performDummySearch();
for (int i = 0; i < cus.length; i++) {
@@ -347,4 +365,32 @@ public class PullUpTests extends RefactoringTest {
new boolean[] {false, true, true},
new String[0], true, true, 0, "RSub");
}
+ // Bug 386814 - [refactoring] pull-up should distinguish callouts that can be pull-up vs. abstract decl.
+ public void testPullUpCallout1() throws Exception {
+ performPullUp_failing(new String[] {"T", "B"},
+ new String[]{"foo", "getS1", "getS2"},
+ new String[][] { new String[0], new String[0], new String[0] },
+ new boolean[] {false, false, true}, // true pull up of callout not possible
+ new String[0], true, true, 0, "RSub",
+ new String[]{"The callout binding 'getS1() -> String s' can only be moved to a bound role (OTJLD \uFFFD3.1.(a))."});
+ }
+ // Bug 386814 - [refactoring] pull-up should distinguish callouts that can be pull-up vs. abstract decl.
+ public void testPullUpCallout2() throws Exception {
+ performPullUp_pass(new String[] {"T", "B0", "B1", "B2"},
+ new String[]{"foo", "getS1", "getS2"},
+ new String[][] { new String[0], new String[0], new String[0] },
+ new boolean[] {false, false, false}, // true pull up of callout
+ new String[0], true, true, 0, "RSub");
+ }
+ // Bug 386814 - [refactoring] pull-up should distinguish callouts that can be pull-up vs. abstract decl.
+ public void testPullUpCallout3() throws Exception {
+ performPullUp_failing(new String[] {"T", "B0", "B1", "B2"},
+ new String[]{"foo", "getS1", "getS2"},
+ new String[][] { new String[0], new String[0], new String[0] },
+ new boolean[] {false, false, false}, // true pull up of callout, which are NOT available in super base (B1)
+ new String[0], true, true, 0, "RSub",
+ new String[]{
+ "The callout binding 'getS1() -> String s' cannot be moved to class 'RSuper', because the the bound base member 's' will not be accessible after refactoring (OTJLD \uFFFD3.1.(a)).",
+ "The callout binding 'getS2() -> getS()' cannot be moved to class 'RSuper', because the the bound base member 'getS' will not be accessible after refactoring (OTJLD \uFFFD3.1.(a))."});
+ }
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/in/B.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/in/B.java
new file mode 100644
index 000000000..2f8b9309b
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/in/B.java
@@ -0,0 +1,4 @@
+public class B {
+ String s;
+ String getS() { return s; }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/in/T.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/in/T.java
new file mode 100644
index 000000000..b2af6c4fc
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/in/T.java
@@ -0,0 +1,13 @@
+public team class T {
+ protected class RSuper {
+
+ }
+ protected class RSub extends RSuper playedBy B {
+ String getS1() -> get String s;
+ String getS2() -> String getS();
+ void foo()
+ {
+ System.out.println(getS1()+getS2());
+ }
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/out/B.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/out/B.java
new file mode 100644
index 000000000..2f8b9309b
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/out/B.java
@@ -0,0 +1,4 @@
+public class B {
+ String s;
+ String getS() { return s; }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/out/T.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/out/T.java
new file mode 100644
index 000000000..3779040ab
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout1/out/T.java
@@ -0,0 +1,20 @@
+public team class T {
+ protected abstract class RSuper {
+
+ protected abstract String getS2();
+
+ protected abstract String getS1();
+
+ void foo()
+ {
+ System.out.println(getS1()+getS2());
+ }
+
+ }
+ protected class RSub extends RSuper playedBy B {
+ @Override
+ protected String getS1() -> get String s;
+ @Override
+ protected String getS2() -> String getS();
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B0.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B0.java
new file mode 100644
index 000000000..9e1f146ad
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B0.java
@@ -0,0 +1,4 @@
+public class B0 {
+ String s;
+ String getS() { return s; }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B1.java
new file mode 100644
index 000000000..6c662a942
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B1.java
@@ -0,0 +1 @@
+public class B1 extends B0 {} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B2.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B2.java
new file mode 100644
index 000000000..bc621e569
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/B2.java
@@ -0,0 +1,3 @@
+public class B2 extends B1 {
+
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/T.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/T.java
new file mode 100644
index 000000000..90559dfa3
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/in/T.java
@@ -0,0 +1,13 @@
+public team class T {
+ protected class RSuper playedBy B1 {
+
+ }
+ protected class RSub extends RSuper playedBy B2 {
+ String getS1() -> get String s;
+ String getS2() -> String getS();
+ void foo()
+ {
+ System.out.println(getS1()+getS2());
+ }
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B0.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B0.java
new file mode 100644
index 000000000..9e1f146ad
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B0.java
@@ -0,0 +1,4 @@
+public class B0 {
+ String s;
+ String getS() { return s; }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B1.java
new file mode 100644
index 000000000..6c662a942
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B1.java
@@ -0,0 +1 @@
+public class B1 extends B0 {} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B2.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B2.java
new file mode 100644
index 000000000..bc621e569
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/B2.java
@@ -0,0 +1,3 @@
+public class B2 extends B1 {
+
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/T.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/T.java
new file mode 100644
index 000000000..cf742b021
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout2/out/T.java
@@ -0,0 +1,16 @@
+public team class T {
+ protected class RSuper playedBy B1 {
+
+ String getS1() -> get String s;
+
+ String getS2() -> String getS();
+
+ void foo()
+ {
+ System.out.println(getS1()+getS2());
+ }
+
+ }
+ protected class RSub extends RSuper playedBy B2 {
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B0.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B0.java
new file mode 100644
index 000000000..45f5ca1ed
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B0.java
@@ -0,0 +1,2 @@
+public class B0 {
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B1.java
new file mode 100644
index 000000000..6c662a942
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B1.java
@@ -0,0 +1 @@
+public class B1 extends B0 {} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B2.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B2.java
new file mode 100644
index 000000000..32a9444d5
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/B2.java
@@ -0,0 +1,4 @@
+public class B2 extends B1 {
+ String s;
+ String getS() { return s; }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/T.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/T.java
new file mode 100644
index 000000000..90559dfa3
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/in/T.java
@@ -0,0 +1,13 @@
+public team class T {
+ protected class RSuper playedBy B1 {
+
+ }
+ protected class RSub extends RSuper playedBy B2 {
+ String getS1() -> get String s;
+ String getS2() -> String getS();
+ void foo()
+ {
+ System.out.println(getS1()+getS2());
+ }
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B0.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B0.java
new file mode 100644
index 000000000..45f5ca1ed
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B0.java
@@ -0,0 +1,2 @@
+public class B0 {
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B1.java
new file mode 100644
index 000000000..6c662a942
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B1.java
@@ -0,0 +1 @@
+public class B1 extends B0 {} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B2.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B2.java
new file mode 100644
index 000000000..32a9444d5
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/B2.java
@@ -0,0 +1,4 @@
+public class B2 extends B1 {
+ String s;
+ String getS() { return s; }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/T.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/T.java
new file mode 100644
index 000000000..cf742b021
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/PullUp/testPullUpCallout3/out/T.java
@@ -0,0 +1,16 @@
+public team class T {
+ protected class RSuper playedBy B1 {
+
+ String getS1() -> get String s;
+
+ String getS2() -> String getS();
+
+ void foo()
+ {
+ System.out.println(getS1()+getS2());
+ }
+
+ }
+ protected class RSub extends RSuper playedBy B2 {
+ }
+} \ No newline at end of file

Back to the top