Bug 558313 - Update some tests in refactoring to junit 4 (c)
Change-Id: Ib3516ad987d0b29af36470531957b706cbdec911
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
depends-on: Ic26f4f421ced761146240a3b309acad109a7a635
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests17.java
index d774ace..5a6d36e 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests17.java
@@ -24,12 +24,13 @@
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
import org.eclipse.jdt.ui.tests.refactoring.rules.Java17Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
public class ChangeTypeRefactoringTests17 extends ChangeTypeRefactoringTests {
@Rule
- public Java17Setup js= new Java17Setup();
+ public RefactoringTestSetup js= new Java17Setup();
@Override
protected String getTestFileName(boolean positive, boolean input) {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java
index b42bb29..d955874 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java
@@ -48,6 +48,7 @@
import org.eclipse.jdt.internal.corext.refactoring.code.ConvertAnonymousToNestedRefactoring;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.ui.tests.refactoring.rules.Java15Setup;
public class ConvertAnonymousToNestedTests extends GenericRefactoringTest {
@@ -61,7 +62,7 @@
}
@Rule
- public Java15Setup js=new Java15Setup();
+ public RefactoringTestSetup js= new Java15Setup();
private String getSimpleTestFileName(boolean canInline, boolean input){
String fileName = "A_" + getName();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests18.java
index f025e48..6db7653 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests18.java
@@ -22,6 +22,7 @@
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
@@ -29,7 +30,7 @@
private static final String REFACTORING_PATH= "ConvertAnonymousToNested18/";
@Rule
- public Java18Setup js= new Java18Setup();
+ public RefactoringTestSetup js= new Java18Setup();
@Override
protected String getRefactoringPath() {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
index 3622281..8309c79 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,17 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.Hashtable;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
@@ -34,38 +43,25 @@
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class ExtractInterfaceTests extends RefactoringTest {
-
- private static final Class<ExtractInterfaceTests> clazz= ExtractInterfaceTests.class;
+public class ExtractInterfaceTests extends GenericRefactoringTest {
private static final String REFACTORING_PATH= "ExtractInterface/";
private Hashtable<String, String> fOldOptions;
protected boolean fGenerateAnnotations= false;
- public ExtractInterfaceTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new RefactoringTestSetup(someTest);
- }
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setup() throws Exception {
StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID,
"${package_declaration}" +
System.getProperty("line.separator", "\n") +
@@ -85,9 +81,8 @@
JavaCore.setOptions(options);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void after() throws Exception {
JavaCore.setOptions(fOldOptions);
fOldOptions= null;
}
@@ -124,7 +119,7 @@
IMethod[] extractedMethods= getMethods(clas, extractedMethodNames, extractedSignatures);
IField[] extractedFields= getFields(clas, extractedFieldNames);
processor.setExtractedMembers(merge(extractedMethods, extractedFields));
- assertEquals("was supposed to pass", null, performRefactoring(ref));
+ assertNull("was supposed to pass", performRefactoring(ref));
for (int i= 0; i < cus.length; i++) {
String expected= getFileContents(getOutputTestFileName(cuNames[i]));
@@ -151,7 +146,7 @@
processor.setExtractedMembers(processor.getExtractableMembers());
processor.setReplace(replaceOccurrences);
processor.setAnnotations(fGenerateAnnotations);
- assertEquals("was supposed to pass", null, performRefactoring(ref));
+ assertNull("was supposed to pass", performRefactoring(ref));
assertEqualLines("incorrect changes in " + className,
getFileContents(getOutputTestFileName(className)),
cu.getSource());
@@ -169,7 +164,7 @@
processor.setTypeName(newInterfaceName);
if (extractAll)
processor.setExtractedMembers(processor.getExtractableMembers());
- assertTrue("was not supposed to pass", performRefactoring(ref) != null);
+ assertNotNull("was not supposed to pass", performRefactoring(ref));
assertEquals("was not supposed to fail with different severity", expectedSeverity, performRefactoring(ref).getSeverity());
}
@@ -180,275 +175,340 @@
}
//---------------tests ----------------------
+ @Test
public void test0() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test1() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test2() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test3() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test4() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test5() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test6() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test7() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test8() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test9() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test10() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test11() throws Exception{
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test12() throws Exception{
validatePassingTest("A", "I", true, true);
}
+ @Test
public void test13() throws Exception{
validatePassingTest("A", "I", true, true);
}
+ @Test
public void test14() throws Exception{
standardPassingTest();
}
+ @Test
public void test15() throws Exception{
String[] names= new String[]{"m", "m1"};
String[][] signatures= new String[][]{new String[0], new String[0]};
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, null);
}
+ @Test
public void test16() throws Exception{
standardPassingTest();
}
+ @Test
public void test17() throws Exception{
standardPassingTest();
}
+ @Test
public void test18() throws Exception{
standardPassingTest();
}
+ @Test
public void test19() throws Exception{
standardPassingTest();
}
+ @Test
public void test20() throws Exception{
String[] names= new String[]{"m", "m1"};
String[][] signatures= new String[][]{new String[0], new String[0]};
validatePassingTest("A", new String[]{"A"},"I", true, names, signatures, null);
}
+ @Test
public void test21() throws Exception{
validatePassingTest("A", "I", true, true);
}
+ @Test
public void test22() throws Exception{
validatePassingTest("A", "I", true, true);
}
+ @Test
public void test23() throws Exception{
validatePassingTest("A", "I", true, true);
}
+ @Test
public void test24() throws Exception{
standardPassingTest();
}
+ @Test
public void test25() throws Exception{
validatePassingTest("A", "I", true, true);
}
+ @Test
public void test26() throws Exception{
standardPassingTest();
}
+ @Test
public void test27() throws Exception{
standardPassingTest();
}
+ @Test
public void test28() throws Exception{
standardPassingTest();
}
+ @Test
public void test29() throws Exception{
standardPassingTest();
}
+ @Test
public void test30() throws Exception{
standardPassingTest();
}
+ @Test
public void test31() throws Exception{
standardPassingTest();
}
+ @Test
public void test32() throws Exception{
standardPassingTest();
}
+ @Test
public void test33() throws Exception{
standardPassingTest();
}
+ @Test
public void test34() throws Exception{
standardPassingTest();
}
+ @Test
public void test35() throws Exception{
standardPassingTest();
}
+ @Test
public void test36() throws Exception{
standardPassingTest();
}
+ @Test
public void test37() throws Exception{
standardPassingTest();
}
+ @Test
public void test38() throws Exception{
standardPassingTest();
}
+ @Test
public void test39() throws Exception{
standardPassingTest();
}
+ @Test
public void test40() throws Exception{
standardPassingTest();
}
+ @Test
public void test41() throws Exception{
standardPassingTest();
}
+ @Test
public void test42() throws Exception{
standardPassingTest();
}
+ @Test
public void test43() throws Exception{
standardPassingTest();
}
+ @Test
public void test44() throws Exception{
standardPassingTest();
}
+ @Test
public void test45() throws Exception{
standardPassingTest();
}
+ @Test
public void test46() throws Exception{
standardPassingTest();
}
+ @Test
public void test47() throws Exception{
standardPassingTest();
}
+ @Test
public void test48() throws Exception{
standardPassingTest();
}
+ @Test
public void test49() throws Exception{
standardPassingTest();
}
+ @Test
public void test50() throws Exception{
standardPassingTest();
}
+ @Test
public void test51() throws Exception{
standardPassingTest();
}
+ @Test
public void test52() throws Exception{
standardPassingTest();
}
+ @Test
public void test53() throws Exception{
standardPassingTest();
}
+ @Test
public void test54() throws Exception{
String[] names= new String[]{"m"};
String[][] signatures= new String[][]{new String[0]};
validatePassingTest("A", new String[]{"A", "A1"}, "I", true, names, signatures, null);
}
+ @Test
public void test55() throws Exception{
String[] names= new String[]{"m"};
String[][] signatures= new String[][]{new String[0]};
validatePassingTest("A", new String[]{"A", "A1"}, "I", true, names, signatures, null);
}
+ @Test
public void test56() throws Exception{
String[] names= new String[]{"m"};
String[][] signatures= new String[][]{new String[0]};
validatePassingTest("A", new String[]{"A", "A1"}, "I", true, names, signatures, null);
}
+ @Test
public void test57() throws Exception{
String[] names= new String[]{"m"};
String[][] signatures= new String[][]{new String[0]};
validatePassingTest("A", new String[]{"A", "A1"}, "I", true, names, signatures, null);
}
+ @Test
public void test58() throws Exception{
standardPassingTest();
}
+ @Test
public void test59() throws Exception{
// printTestDisabledMessage("bug 22946 ");
standardPassingTest();
}
+ @Test
public void test60() throws Exception{
standardPassingTest();
}
+ @Test
public void test61() throws Exception{
standardPassingTest();
}
+ @Test
public void test62() throws Exception{
standardPassingTest();
}
+ @Test
public void test63() throws Exception{
standardPassingTest();
}
+ @Test
public void test64() throws Exception{
// printTestDisabledMessage("test for 23105");
String[] names= new String[]{"m"};
@@ -456,15 +516,18 @@
validatePassingTest("A", new String[]{"A", "Inter"}, "I", true, names, signatures, null);
}
+ @Test
public void test65() throws Exception{
// printTestDisabledMessage("test for 23105");
standardPassingTest();
}
+ @Test
public void test66() throws Exception{
standardPassingTest();
}
+ @Test
public void test67() throws Exception{
// printTestDisabledMessage("test for 23105");
String[] names= new String[]{"m"};
@@ -472,28 +535,33 @@
validatePassingTest("A", new String[]{"A", "Outer", "Inter"}, "I", true, names, signatures, null);
}
+ @Test
public void test68() throws Exception{
String[] names= new String[]{"m"};
String[][] signatures= new String[][]{new String[0]};
validatePassingTest("A", new String[]{"A", "As"}, "I", true, names, signatures, null);
}
+ @Test
public void test69() throws Exception{
String[] names= new String[]{"m"};
String[][] signatures= new String[][]{new String[0]};
validatePassingTest("A", new String[]{"A", "As"}, "I", true, names, signatures, null);
}
+ @Test
public void test70() throws Exception{
standardPassingTest();
}
+ @Test
public void test71() throws Exception{
String[] names= new String[]{"m"};
String[][] signatures= new String[][]{new String[0]};
validatePassingTest("A", new String[]{"A", "As"}, "I", true, names, signatures, null);
}
+ @Test
public void test72() throws Exception{
// printTestDisabledMessage("bug 23705");
String[] names= new String[]{"m"};
@@ -501,6 +569,7 @@
validatePassingTest("A", new String[]{"A", "As"}, "I", true, names, signatures, null);
}
+ @Test
public void test73() throws Exception{
// printTestDisabledMessage("bug 23953");
String[] names= new String[]{"amount"};
@@ -508,6 +577,7 @@
validatePassingTest("A", new String[]{"A", "B", "OldInterface"}, "I", true, names, signatures, null);
}
+ @Test
public void test74() throws Exception{
// printTestDisabledMessage("bug 23953");
String[] names= new String[]{"amount"};
@@ -515,6 +585,7 @@
validatePassingTest("A", new String[]{"A", "B", "OldInterface"}, "I", true, names, signatures, null);
}
+ @Test
public void test75() throws Exception{
// printTestDisabledMessage("bug 23953");
String[] names= new String[]{"amount"};
@@ -522,6 +593,7 @@
validatePassingTest("A", new String[]{"A", "B", "C"}, "I", true, names, signatures, null);
}
+ @Test
public void test76() throws Exception{
// printTestDisabledMessage("bug 23953");
String[] names= new String[]{"amount"};
@@ -529,6 +601,7 @@
validatePassingTest("A", new String[]{"A", "B", "C"}, "I", true, names, signatures, null);
}
+ @Test
public void test77() throws Exception{
// printTestDisabledMessage("Waiting for new type constraints infrastructure");
String[] names= new String[]{"amount"};
@@ -536,6 +609,7 @@
validatePassingTest("A.Inner", new String[]{"A", "B"}, "I", true, names, signatures, null);
}
+ @Test
public void test78() throws Exception{
// printTestDisabledMessage("bug 23705");
String[] names= new String[]{"m"};
@@ -543,13 +617,16 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, null);
}
- public void test79() throws Exception{
+
+ @Test
+ public void test79() throws Exception{
// printTestDisabledMessage("bug 23697");
String[] names= new String[]{"getFoo", "foo"};
String[][] signatures= new String[][]{new String[0], new String[]{"QA;"}};
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, null);
}
+ @Test
public void test80() throws Exception{
// printTestDisabledMessage("bug 33223");
String[] names= new String[]{"f", "fz", "f1", "f1z", "f11", "f2"};
@@ -558,6 +635,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test81() throws Exception{
// printTestDisabledMessage("bug 33878 extract interface: incorrect handling of arrays ");
String[] names= {};
@@ -566,6 +644,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test82() throws Exception{
// printTestDisabledMessage("bug 33878 extract interface: incorrect handling of arrays ");
String[] names= {};
@@ -574,6 +653,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test83() throws Exception{
// printTestDisabledMessage("bug 33878 extract interface: incorrect handling of arrays ");
String[] names= {};
@@ -582,6 +662,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test84() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -590,6 +671,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test85() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -598,6 +680,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test86() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -606,6 +689,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test87() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -614,6 +698,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test88() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -622,6 +707,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test89() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -630,6 +716,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test90() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -638,6 +725,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test91() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -646,6 +734,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test92() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -654,6 +743,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test93() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -662,6 +752,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test94() throws Exception{
// printTestDisabledMessage("bug 34931 Extract Interface does not update all references ");
String[] names= {};
@@ -670,6 +761,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test95() throws Exception{
String[] names= {};
String[][] signatures= {{}};
@@ -677,6 +769,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test96() throws Exception{
String[] names= {};
String[][] signatures= {{}};
@@ -684,6 +777,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test97() throws Exception{
//printTestDisabledMessage("bug 40373");
String[] names= {"foo"};
@@ -692,6 +786,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void test98() throws Exception{
//test for 41464
String[] names= new String[]{"foo"};
@@ -699,23 +794,27 @@
validatePassingTest("Foo", new String[]{"Foo", "Bar"}, "IFoo", true, names, signatures, null);
}
+ @Test
public void test99() throws Exception{
String[] names= new String[]{};
String[][] signatures= new String[][]{};
validatePassingTest("C", new String[]{"A", "B", "C"}, "I", true, names, signatures, null);
}
+ @Test
public void test100() throws Exception{
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=47785
validatePassingTest("A", "I", true, false);
}
+ @Test
public void test101() throws Exception{
String[] names= new String[]{};
String[][] signatures= new String[][]{};
validatePassingTest("C", new String[]{"A", "B", "C"}, "I", true, names, signatures, null);
}
+ @Test
public void test102() throws Exception{
String[] names= new String[]{};
String[][] signatures= new String[][]{};
@@ -723,6 +822,7 @@
validatePassingTest("C", new String[]{"A", "B", "C"}, "I", true, names, signatures, null);
}
+ @Test
public void test103() throws Exception{
String[] names= new String[]{};
String[][] signatures= new String[][]{};
@@ -730,6 +830,7 @@
validatePassingTest("C", new String[]{"A", "B", "C"}, "I", true, names, signatures, null);
}
+ @Test
public void test104() throws Exception {
// bug 195817
String[] names= new String[]{ "m1" };
@@ -738,6 +839,7 @@
validatePassingTest("A", new String[]{"A", "B"}, "I", true, names, signatures, null);
}
+ @Test
public void test105() throws Exception{
// bug 195817
String[] names= new String[]{ "m2" };
@@ -746,6 +848,7 @@
validatePassingTest("A", new String[]{"A", "B"}, "I", true, names, signatures, null);
}
+ @Test
public void test106() throws Exception {
// bug 195817
String[] names= new String[]{ "m1" };
@@ -754,6 +857,7 @@
validatePassingTest("A", new String[]{"A", "B"}, "I", true, names, signatures, null);
}
+ @Test
public void test107() throws Exception{
// bug 195817
String[] names= new String[]{ "m2" };
@@ -762,31 +866,35 @@
validatePassingTest("A", new String[]{"A", "B"}, "I", true, names, signatures, null);
}
+ @Test
public void test108() throws Exception{
// bug 195817
fGenerateAnnotations= true; // should not generate because project is 1.5
standardPassingTest();
}
+ @Test
public void test109() throws Exception{
// Generate @Override in 1.6 project
fGenerateAnnotations= true;
- RefactoringTestSetup refactoringTestSetup= new RefactoringTestSetup(null);
+ RefactoringTestSetup refactoringTestSetup= new RefactoringTestSetup();
try {
JavaProjectHelper.addRTJar16(getRoot().getJavaProject());
standardPassingTest();
- refactoringTestSetup.tearDown();
+ refactoringTestSetup.after();
} finally {
- refactoringTestSetup.setUp();
+ refactoringTestSetup.before();
}
}
+ @Test
public void test110() throws Exception{
validatePassingTest("A", "I", true, true);
}
+ @Test
public void testPaperExample0() throws Exception{
String[] names= new String[]{"add", "addAll", "iterator"};
String[][] signatures= new String[][]{new String[]{"QComparable;"}, new String[]{"QA;"}, new String[0]};
@@ -794,6 +902,7 @@
validatePassingTest("A", new String[]{"A"}, "Bag", true, names, signatures, fieldNames);
}
+ @Test
public void testPaperExample1() throws Exception{
String[] names= new String[]{"add", "addAll", "iterator"};
String[][] signatures= new String[][]{new String[]{"QComparable;"}, new String[]{"QA;"}, new String[0]};
@@ -801,6 +910,7 @@
validatePassingTest("A", new String[]{"A"}, "Bag", true, names, signatures, fieldNames);
}
+ @Test
public void testPaperExampleSimplified0() throws Exception{
String[] names= new String[]{};
String[][] signatures= {{}};
@@ -809,6 +919,7 @@
}
+ @Test
public void testConditional1() throws Exception {
String[] names= new String[]{};
String[][] signatures= {{}};
@@ -816,6 +927,7 @@
validatePassingTest("X", new String[]{"A", "X"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testConditional2() throws Exception {
String[] names= new String[]{ "dot" };
String[][] signatures= {new String[]{"QX;"}};
@@ -823,34 +935,43 @@
validatePassingTest("X", new String[]{"A", "X"}, "I", true, names, signatures, fieldNames);
}
- public void testConstant80() throws Exception{
+
+ @Test
+ public void testConstant80() throws Exception{
String[] names= null;
String[][] signatures= null;
String[] fieldNames= {"X"};
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
- public void testConstant81() throws Exception{
+
+ @Test
+ public void testConstant81() throws Exception{
String[] names= null;
String[][] signatures= null;
String[] fieldNames= {"X"};
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
- public void testConstant82() throws Exception{
+
+ @Test
+ public void testConstant82() throws Exception{
String[] names= null;
String[][] signatures= null;
String[] fieldNames= {"X"};
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
- public void testConstant83() throws Exception{
+
+ @Test
+ public void testConstant83() throws Exception{
String[] names= null;
String[][] signatures= null;
String[] fieldNames= {"X"};
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testConstant84() throws Exception{
String[] names= null;
String[][] signatures= null;
@@ -858,6 +979,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testConstant85() throws Exception{
String[] names= null;
String[][] signatures= null;
@@ -865,6 +987,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testConstant86() throws Exception{
String[] names= null;
String[][] signatures= null;
@@ -872,6 +995,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testConstant87() throws Exception{
String[] names= null;
String[][] signatures= null;
@@ -879,6 +1003,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testConstant88() throws Exception{
String[] names= null;
String[][] signatures= null;
@@ -886,6 +1011,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testInterface0() throws Exception{
String[] names= {"m"};
String[][] signatures= {new String[0]};
@@ -893,6 +1019,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testInterface1() throws Exception{
String[] names= {"m"};
String[][] signatures= {new String[0]};
@@ -900,6 +1027,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testInterface2() throws Exception{
String[] names= {"m"};
String[][] signatures= {new String[0]};
@@ -907,6 +1035,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, names, signatures, fieldNames);
}
+ @Test
public void testInterface3() throws Exception{
String[] methodNames= {"m", "m1", "m2", "m4", "m5"};
String[][] signatures= {new String[0], new String[0], new String[0], new String[0], new String[0]};
@@ -914,6 +1043,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, methodNames, signatures, fieldNames);
}
+ @Test
public void testInterface4() throws Exception{
// printTestDisabledMessage("cannot yet update references (in methods) to itself if it's an interface");
String[] methodNames= {"a"};
@@ -922,6 +1052,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, methodNames, signatures, fieldNames);
}
+ @Test
public void testInterface5() throws Exception{
String[] methodNames= {"a"};
String[][] signatures= {new String[0]};
@@ -929,6 +1060,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, methodNames, signatures, fieldNames);
}
+ @Test
public void testInterface6() throws Exception{
String[] methodNames= {"foo0", "foo1", "foo2", "foo3"};
String[][] signatures= {new String[0], new String[0], new String[0], new String[0]};
@@ -936,6 +1068,7 @@
validatePassingTest("A", new String[]{"A"}, "I", true, methodNames, signatures, fieldNames);
}
+ @Test
public void testFail1() throws Exception{
validateFailingTest("A", "I", true, RefactoringStatus.FATAL);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests18.java
index f5e465a..0f89afd 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests18.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2016 IBM Corporation and others.
+ * Copyright (c) 2014, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,10 +13,16 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -31,37 +37,32 @@
import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor;
-import org.eclipse.jdt.ui.tests.core.NoSuperTestsSuite;
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
public class ExtractInterfaceTests18 extends ExtractInterfaceTests {
-
- private static final Class<ExtractInterfaceTests18> clazz= ExtractInterfaceTests18.class;
-
private static final String REFACTORING_PATH= "ExtractInterface18/";
- public ExtractInterfaceTests18(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new Java18Setup(new NoSuperTestsSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java18Setup(someTest);
- }
+ @Rule
+ public RefactoringTestSetup js= new Java18Setup();
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
+ @Test
public void testExtractInterfaceFromInterface1() throws Exception {
validatePassingTest("A", "B", true, true);
}
+ @Test
public void testExtractInterfaceFromInterface2() throws Exception {
String className= "A";
String extendingInterfaceName= "I1";
@@ -96,7 +97,7 @@
processor.setReplace(true);
processor.setAnnotations(false);
RefactoringStatus performRefactoring= performRefactoring(ref);
- assertEquals("was supposed to pass", null, performRefactoring);
+ assertNull("was supposed to pass", performRefactoring);
assertEqualLines("incorrect changes in " + className,
getFileContents(getOutputTestFileName(className)),
cu.getSource());
@@ -108,11 +109,13 @@
}
+ @Test
public void testExtractInterfaceFromClass() throws Exception {
validatePassingTest("A", "B", true, true);
}
// bug 394551
+ @Test
public void testExtractInterfaceFromClass2() throws Exception {
fGenerateAnnotations= true;
String[] names= new String[] { "m" };
@@ -120,10 +123,12 @@
validatePassingTest("A", new String[] { "A" }, "I", true, names, signatures, null);
}
+ @Test
public void testExtractInterfaceFromAbstractClass() throws Exception {
validatePassingTest("A", "B", true, true);
}
+ @Test
public void testLambda1() throws Exception {
// bug 488420
String[] names= new String[] { "m1" };
@@ -131,6 +136,7 @@
validatePassingTest("X", new String[] { "X", "Util" }, "I", true, names, signatures, null);
}
+ @Test
public void testLambda2() throws Exception {
// bug 488420
String[] names= new String[] { "m1" };
@@ -138,6 +144,7 @@
validatePassingTest("X", new String[] { "X", "Util" }, "I", true, names, signatures, null);
}
+ @Test
public void testMethodRef1() throws Exception {
// bug 489170
String[] names= new String[] { "methodN" };
@@ -145,6 +152,7 @@
validatePassingTest("X", new String[] { "X", "Util" }, "I", true, names, signatures, null);
}
+ @Test
public void testMethodRef2() throws Exception {
// bug 489170
String[] names= new String[] { "m1" };
@@ -152,6 +160,7 @@
validatePassingTest("X", new String[] { "X", "Util" }, "I", true, names, signatures, null);
}
+ @Test
public void testMethodRef3() throws Exception {
// bug 489170
String[] names= new String[] { "m1" };
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java
index 841a25c..144ead1 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java
@@ -82,7 +82,7 @@
public abstract class GenericRefactoringTest {
@Rule
- public TestName tn=new TestName();
+ public TestName tn= new TestName();
/**
* If <code>true</code> a descriptor is created from the change.
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/GoToNextPreviousMemberActionTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/GoToNextPreviousMemberActionTests.java
index 0a876e4..7747698 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/GoToNextPreviousMemberActionTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/GoToNextPreviousMemberActionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,35 +13,31 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.actions;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.GoToNextPreviousMemberAction;
-public class GoToNextPreviousMemberActionTests extends RefactoringTest{
-
- private static final Class<GoToNextPreviousMemberActionTests> clazz= GoToNextPreviousMemberActionTests.class;
+public class GoToNextPreviousMemberActionTests extends GenericRefactoringTest{
private static final String REFACTORING_PATH= "GoToNextPreviousMemberAction/";
- public GoToNextPreviousMemberActionTests(String name){
- super(name);
- }
+
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
private String getSimpleTestFileName(){
return "A_" + getName() + ".java";
}
@@ -74,46 +70,57 @@
}
//----
+ @Test
public void testPrevious0() throws Exception{
helperPrevious(6, 5, 5, 11);
}
+ @Test
public void testPrevious1() throws Exception{
helperPrevious(8, 5, 7, 6);
}
+ @Test
public void testPrevious2() throws Exception{
helperPrevious(3, 1, 3, 1);
}
+ @Test
public void testPrevious3() throws Exception{
helperPrevious(15, 9, 13, 6);
}
+ @Test
public void testPrevious4() throws Exception{
helperPrevious(19, 1, 18, 9);
}
+ @Test
public void testPrevious5() throws Exception{
helperPrevious(31, 10, 27, 10);
}
+ @Test
public void testPrevious6() throws Exception{
helperPrevious(35, 3, 34, 2);
}
+ @Test
public void testNext0() throws Exception{
helperNext(3, 1, 4, 7);
}
+ @Test
public void testNext1() throws Exception{
helperNext(27, 10, 31, 10);
}
+ @Test
public void testNext2() throws Exception{
helperNext(35, 2, 35, 2);
}
+ @Test
public void testNext3() throws Exception{
helperNext(19, 1, 20, 13);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/AllTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/AllTests.java
index b994439..9eda64d 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/AllTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,19 +13,13 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.changes;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TrackPositionTest.class,
+ TextDiffContentTest.class
+})
public class AllTests {
-
- public static Test suite ( ) {
- TestSuite suite= new TestSuite(AllTests.class.getName());
- suite.addTest(TrackPositionTest.suite());
- suite.addTest(TextDiffContentTest.suite());
- return suite;
- }
}
-
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TextDiffContentTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TextDiffContentTest.java
index f1c6299..9ee0f99 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TextDiffContentTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TextDiffContentTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,9 +15,10 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.changes;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -38,8 +39,7 @@
* empty. Otherwise, the current content and preview content
* have differing affected ranges and spurious changes appear.
*/
-public class TextDiffContentTest extends TestCase {
-
+public class TextDiffContentTest {
private static final String MODIFIED_SOURCE_CONTENTS =
"// my file\n"+
"\n"+
@@ -54,10 +54,6 @@
"\n"+
"// other stuff\n";
- public static Test suite() {
- return new TestSuite(TextDiffContentTest.class);
- }
-
private DocumentChange fDocumentChange;
private Document fDocument;
@@ -74,9 +70,8 @@
private TextEditChangeGroup fChange3;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
fDocument = new Document(MODIFIED_SOURCE_CONTENTS);
fDocumentChange = new DocumentChange("Changes to document", fDocument);
@@ -134,6 +129,7 @@
group.getRegion(), true, context, new NullProgressMonitor());
}
+ @Test
public void testEmptySourceRangeNoContext() throws Exception {
String src = getSource(fEdit1.getRegion(), 0);
String preview = getPreview(fChange1, 0);
@@ -141,6 +137,7 @@
assertEquals("\tFinalCall();", preview);
}
+ @Test
public void testEmptySourceRangeNoContext2() throws Exception {
String src = getSource(fEdit2.getRegion(), 0);
String preview = getPreview(fChange2, 0);
@@ -148,6 +145,7 @@
assertEquals("// add comment", preview);
}
+ @Test
public void testEmptySourceRangeContext() throws Exception {
String src = getSource(fEdit1.getRegion(), 2);
String preview = getPreview(fChange1, 2);
@@ -161,6 +159,7 @@
" }\n",
preview);
}
+ @Test
public void testEmptySourceRangeContext2() throws Exception {
String src = getSource(fEdit2.getRegion(), 2);
String preview = getPreview(fChange2, 2);
@@ -171,6 +170,7 @@
preview);
}
+ @Test
public void testEmptyTargetRangeNoContext() throws Exception {
String src = getSource(fEdit3.getRegion(), 0);
String preview = getPreview(fChange3, 0);
@@ -178,6 +178,7 @@
assertEquals("", preview);
}
+ @Test
public void testEmptyTargetRangeContext() throws Exception {
String src = getSource(fEdit3.getRegion(), 2);
String preview = getPreview(fChange3, 2);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TrackPositionTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TrackPositionTest.java
index e4728fa..96bb687 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TrackPositionTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TrackPositionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.changes;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertFalse;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -30,35 +33,26 @@
import org.eclipse.jdt.internal.corext.refactoring.changes.TextChangeCompatibility;
-public class TrackPositionTest extends TestCase {
-
- private static final Class<TrackPositionTest> THIS= TrackPositionTest.class;
+public class TrackPositionTest {
private static final String NN= "N.N";
private IDocument fDocument;
private DocumentChange fChange;
- public TrackPositionTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(THIS);
- }
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fDocument= new Document("0123456789");
fChange= new DocumentChange(NN, fDocument);
fChange.setKeepPreviewEdits(true);
fChange.initializeValidationData(new NullProgressMonitor());
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
fChange= null;
}
+ @Test
public void test1() throws Exception {
TextEdit edit= new ReplaceEdit(2, 2, "xyz");
TextChangeCompatibility.addTextEdit(fChange, NN, edit);
@@ -66,18 +60,19 @@
assertEquals(edit.getRegion(), 2, 3);
}
+ @Test
public void test2() throws Exception {
TextEdit edit= new ReplaceEdit(5, 3, "xy");
TextChangeCompatibility.addTextEdit(fChange, NN, edit);
IDocument preview= fChange.getPreviewDocument(new NullProgressMonitor());
- assertEquals(fDocument.get(), "0123456789");
- assertEquals(preview.get(), "01234xy89");
+ Assert.assertEquals("0123456789", fDocument.get());
+ Assert.assertEquals("01234xy89", preview.get());
assertEquals(fChange.getPreviewEdit(edit).getRegion(), 5, 2);
}
private void executeChange() throws Exception {
try {
- assertTrue(!fChange.isValid(new NullProgressMonitor()).hasFatalError());
+ assertFalse(fChange.isValid(new NullProgressMonitor()).hasFatalError());
fChange.perform(new NullProgressMonitor());
} finally {
fChange.dispose();
@@ -85,7 +80,7 @@
}
private static void assertEquals(IRegion r, int offset, int length) {
- assertEquals("Offset", offset, r.getOffset());
- assertEquals("Length", length, r.getLength());
+ Assert.assertEquals("Offset", offset, r.getOffset());
+ Assert.assertEquals("Length", length, r.getLength());
}
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/AllTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/AllTests.java
index b003f8d..9b02c64 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/AllTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,15 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.extensions;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ ExtensionPointTests.class
+})
public class AllTests {
-
- public static Test suite() {
- TestSuite suite= new TestSuite(AllTests.class.getName());
- suite.addTest(ExtensionPointTests.suite());
- return suite;
- }
}
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTestSetup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTestSetup.java
index c383b0f..1d97e4a 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTestSetup.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTestSetup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,35 +13,28 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.extensions;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
+import org.junit.rules.ExternalResource;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.core.runtime.CoreException;
+
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
-
-public class ExtensionPointTestSetup extends TestSetup {
-
+public class ExtensionPointTestSetup extends ExternalResource {
private IJavaProject fJavaProject;
private IPackageFragmentRoot fRoot;
private static final String CONTAINER= "src";
- public ExtensionPointTestSetup(Test test) {
- super(test);
- }
-
public IPackageFragmentRoot getRoot() {
return fRoot;
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ protected void before() throws Exception {
fJavaProject= JavaProjectHelper.createJavaProject("TestProject", "bin");
JavaProjectHelper.addRTJar(fJavaProject);
fRoot= JavaProjectHelper.addSourceContainer(fJavaProject, CONTAINER);
@@ -52,8 +45,11 @@
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
- JavaProjectHelper.delete(fJavaProject);
+ protected void after() {
+ try {
+ JavaProjectHelper.delete(fJavaProject);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTests.java
index ad394a7..cdecc16 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.extensions;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.core.runtime.Path;
@@ -33,13 +34,11 @@
import org.eclipse.jdt.internal.corext.refactoring.base.JavaStringStatusContext;
import org.eclipse.jdt.internal.corext.refactoring.util.JavaStatusContext;
+public class ExtensionPointTests {
+ @Rule
+ public ExtensionPointTestSetup eps= new ExtensionPointTestSetup();
-public class ExtensionPointTests extends TestCase {
-
- public static Test suite() {
- return new ExtensionPointTestSetup(new TestSuite(ExtensionPointTests.class));
- }
-
+ @Test
public void testJavaStringStatusContextViewer() throws Exception {
JavaStringStatusContext context= new JavaStringStatusContext("test", new SourceRange(0, 0));
StatusContextViewerDescriptor descriptor= StatusContextViewerDescriptor.get(context);
@@ -47,6 +46,7 @@
assertNotNull(descriptor.createViewer());
}
+ @Test
public void testJavaStatusContextViewer() throws Exception {
IPackageFragment pack= getTestPackage();
ICompilationUnit unit= pack.createCompilationUnit(