Adjust test suite after JDT/UI's migration to JUnit4
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/AllTests.java
index 1f76bad..af4d8bf 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/AllTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/AllTests.java
@@ -20,29 +20,24 @@
**********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* @author anklam
*
* @version $Id: AllTests.java 23495 2010-02-05 23:15:16Z stephan $
*/
-public class AllTests
-{
- public static Test suite()
- {
- TestSuite suite = new TestSuite(
- "All UI Tests");
- //$JUnit-BEGIN$
- suite.addTest(org.eclipse.objectteams.otdt.ui.tests.contentprovider.AllTests.suite());
- suite.addTest(org.eclipse.objectteams.otdt.ui.tests.typecreator.AllTests.suite());
- suite.addTest(org.eclipse.objectteams.otdt.ui.tests.hierarchy.contentprovider.AllTests.suite());
- suite.addTest(org.eclipse.objectteams.otdt.ui.tests.callinmarker.CallinMarkerTests.suite());
- suite.addTest(org.eclipse.objectteams.otdt.ui.tests.core.OrganizeImportsTest.suite());
- suite.addTest(org.eclipse.objectteams.otdt.ui.tests.core.CodeCompletionTest.suite());
- suite.addTest(org.eclipse.objectteams.otdt.ui.tests.core.OTQuickFixTest.suite());
- //$JUnit-END$
- return suite;
- }
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ org.eclipse.objectteams.otdt.ui.tests.contentprovider.AllTests.class,
+ org.eclipse.objectteams.otdt.ui.tests.typecreator.AllTests.class,
+ org.eclipse.objectteams.otdt.ui.tests.hierarchy.contentprovider.AllTests.class,
+ org.eclipse.objectteams.otdt.ui.tests.callinmarker.CallinMarkerTests.class,
+ org.eclipse.objectteams.otdt.ui.tests.core.OrganizeImportsTest.class,
+ org.eclipse.objectteams.otdt.ui.tests.core.CodeCompletionTest.class,
+ org.eclipse.objectteams.otdt.ui.tests.core.OTQuickFixTest.class,
+})
+public class AllTests {
+
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/AddImportQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/AddImportQuickFixTest.java
index 753b26b..5959979 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/AddImportQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/AddImportQuickFixTest.java
@@ -20,10 +20,10 @@
**********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests.core;
-import java.util.ArrayList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.util.ArrayList;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -33,36 +33,25 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
import org.eclipse.jface.text.IDocument;
import org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.internal.Workbench;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class AddImportQuickFixTest extends OTQuickFixTest {
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
- private static final Class THIS= AddImportQuickFixTest.class;
-
-
- public AddImportQuickFixTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
-
+ @Test
public void testChangeFQNToBaseImport1() throws Exception {
// base:
IPackageFragment pack1base= fSourceFolder.createPackageFragment("test.base1", false, null);
@@ -110,6 +99,7 @@
}
// ROFI variant:
+ @Test
public void testChangeFQNToBaseImport2() throws Exception {
// base:
IPackageFragment pack1base= fSourceFolder.createPackageFragment("test.base1", false, null);
@@ -173,6 +163,7 @@
}
// Bug 348076 - [assist][rewrite] changing import to import base not working when package name contains "base"
+ @Test
public void testChangeImportToBaseImport1() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -222,6 +213,7 @@
}
/* Adding a base import to a team on behalf of a role file. */
+ @Test
public void testAddBaseImportForRofi1() throws Exception {
// base:
IPackageFragment pack1base= fSourceFolder.createPackageFragment("test.base", false, null);
@@ -268,6 +260,7 @@
}
// this time files already have content
+ @Test
public void testAddBaseImportForRofi2() throws Exception {
StringBuffer buf;
// base:
@@ -331,6 +324,7 @@
}
// for role types rather than proposing an import change type to anchored:
+ @Test
public void testChangeTypeToAnchored1() throws CoreException {
StringBuffer buf;
// team:
@@ -381,6 +375,7 @@
}
// for role types rather than proposing an import change type to anchored (role file):
+ @Test
public void testChangeTypeToAnchored2() throws CoreException {
StringBuffer buf;
// team:
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CallinQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CallinQuickFixTest.java
index 8e8e2ea..9245ad1 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CallinQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CallinQuickFixTest.java
@@ -24,43 +24,31 @@
import java.util.Hashtable;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
+import org.junit.Rule;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.junit.Test;
/**
* Test OT-specific quickfixes and quick assist (here: callin related issues).
* @author stephan
* @since 1.2.8
*/
+@RunWith(JUnit4.class)
public class CallinQuickFixTest extends OTQuickFixTest {
- private static final Class THIS= CallinQuickFixTest.class;
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
- public CallinQuickFixTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
-
@Override
protected void addOptions(Hashtable options) {
super.addOptions(options);
@@ -69,6 +57,7 @@
}
/* Suppressing a warning re exception thrown from guard predicate. */
+ @Test
public void testSuppressWarning1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -120,6 +109,7 @@
}
/* Adjust a callin modifier to the bound role method (after -> replace). */
+ @Test
public void testChangeCallinModifier1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -177,6 +167,7 @@
}
/* Remove signatures from a callin binding. */
+ @Test
public void testRemoveSignatures1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -223,6 +214,7 @@
/* Do not propose to remove signatures from a callin binding, where argument is used in a predicate. */
+ @Test
public void testRemoveSignatures2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -254,6 +246,7 @@
/* Remove signatures from a callin binding despite guard predicate (no arg used). */
+ @Test
public void testRemoveSignatures3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -301,6 +294,7 @@
}
/* Remove signatures with type parameters from a callin binding. */
+ @Test
public void testRemoveSignatures4() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -347,6 +341,7 @@
// Remove signatures from a callin binding, comment present.
// see Bug 370656 - [assist] remove signatures from method binding chokes on inline comment
+ @Test
public void testRemoveSignatures5() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -397,6 +392,7 @@
}
/* Add signatures to a callin binding. */
+ @Test
public void testAddSignatures1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -442,6 +438,7 @@
}
/* Add signatures to a callin binding, w/ type arguments. */
+ @Test
public void testAddSignatures2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -487,6 +484,7 @@
}
// Bug 355274 - [assist] make the add signatures assist smarter vis-a-vis ambiguous method bindings
+ @Test
public void testAddSignatures3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -538,6 +536,7 @@
// Bug 355274 - [assist] make the add signatures assist smarter vis-a-vis ambiguous method bindings
// type conversions involved
+ @Test
public void testAddSignatures4() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CalloutQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CalloutQuickFixTest.java
index db180e4..244711b 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CalloutQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CalloutQuickFixTest.java
@@ -19,46 +19,35 @@
**********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests.core;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* Test OT-specific quickfixes and quick assists (here: callout related issues).
* @author stephan
* @since 1.2.8
*/
+@RunWith(JUnit4.class)
public class CalloutQuickFixTest extends OTQuickFixTest {
-
- private static final Class THIS= CalloutQuickFixTest.class;
-
- public CalloutQuickFixTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
@Override
protected void addOptions(Hashtable options) {
@@ -67,6 +56,7 @@
}
/* Converting a field read to explicitly use a callout-to-field. */
+ @Test
public void testConvertFieldAccessToCalloutCall1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -125,6 +115,7 @@
/* Converting a field read (this-qualified) to explicitly use a callout-to-field. */
+ @Test
public void testConvertFieldAccessToCalloutCall2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -184,6 +175,7 @@
}
/* Converting a field assignment to explicitly use a callout-to-field. */
+ @Test
public void testConvertFieldAccessToCalloutCall3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -243,6 +235,7 @@
}
/* Converting a field assignment (this-qualified) to explicitly use a callout-to-field. */
+ @Test
public void testConvertFieldAccessToCalloutCall4() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -303,6 +296,7 @@
/* Convert field access to call to existing callout-to-field. */
+ @Test
public void testConvertFieldAccessToCalloutCall5() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -366,6 +360,7 @@
}
/* Convert field assignment to call to existing callout-to-field. */
+ @Test
public void testConvertFieldAccessToCalloutCall6() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -430,6 +425,7 @@
/* Remove signatures from a callout to field. */
+ @Test
public void testRemoveSignatures1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -471,6 +467,7 @@
}
/* Add signatures to a callout. */
+ @Test
public void testAddSignatures1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -512,6 +509,7 @@
}
/* Add signatures to a callout to field. */
+ @Test
public void testAddSignatures2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CodeCompletionTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CodeCompletionTest.java
index 1711828..a7c1ecd 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CodeCompletionTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/CodeCompletionTest.java
@@ -19,13 +19,16 @@
**********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests.core;
-import static org.eclipse.jdt.internal.codeassist.RelevanceConstants.*;
+import static org.eclipse.jdt.internal.codeassist.RelevanceConstants.R_CASE;
+import static org.eclipse.jdt.internal.codeassist.RelevanceConstants.R_DEFAULT;
+import static org.eclipse.jdt.internal.codeassist.RelevanceConstants.R_EXPECTED_TYPE;
+import static org.eclipse.jdt.internal.codeassist.RelevanceConstants.R_INTERESTING;
+import static org.eclipse.jdt.internal.codeassist.RelevanceConstants.R_METHOD_OVERIDE;
+import static org.eclipse.jdt.internal.codeassist.RelevanceConstants.R_NON_RESTRICTED;
+import static org.eclipse.jdt.internal.codeassist.RelevanceConstants.R_RESOLVED;
import java.util.Hashtable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
@@ -34,8 +37,8 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
+import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
@@ -78,6 +81,9 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
/**
* Tests for code completion including the UI part
* i.e., testing the actual rewriting and also selections.
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/JavaQuickFixTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/JavaQuickFixTests.java
index de8af3c..06233a6 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/JavaQuickFixTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/JavaQuickFixTests.java
@@ -15,6 +15,9 @@
**********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -33,40 +36,29 @@
import org.eclipse.jdt.internal.ui.text.correction.proposals.NewCUUsingWizardProposal;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
import org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal;
import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.osgi.framework.Bundle;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Testing whether standard Java quickfixes work in OT/J code, too.
*
* @author stephan
* @since 0.7.0
*/
+@RunWith(JUnit4.class)
public class JavaQuickFixTests extends OTQuickFixTest {
- private static final Class THIS= JavaQuickFixTests.class;
- public JavaQuickFixTests(String name) {
- super(name);
- }
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test suite() {
- return allTests();
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
-
private String ANNOTATION_JAR_PATH;
void setupForNullAnnotations(boolean isPlainJava) throws IOException, JavaModelException {
@@ -106,6 +98,7 @@
// the following three test try to reproduce Bug 311890 - [assist] support "create class" quickfix for OT/J references
// create a class for an unresolved playedBy declaration
+ @Test
public void testCreateClass1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -136,6 +129,7 @@
}
// create a class for an unresolved playedBy declaration in a nested role
+ @Test
public void testCreateClass2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -169,6 +163,7 @@
// create a class for an unresolved playedBy declaration
+ @Test
public void testCreateClass3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -200,6 +195,7 @@
}
// Bug 348574 - [quickfix] implement abstract methods from tsuper
+ @Test
public void testAddAbstractMethods1() throws CoreException {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -260,6 +256,7 @@
// Bug 348574 - [quickfix] implement abstract methods from tsuper
// abstract static method
+ @Test
public void testAddAbstractMethods2() throws CoreException {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -318,6 +315,7 @@
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
+ @Test
public void testExtractPotentiallyNullField1() throws Exception {
setupForNullAnnotations(true/*plainJava*/);
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/ModifierCorrectionsQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/ModifierCorrectionsQuickFixTest.java
index 42961c1..50653ca 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/ModifierCorrectionsQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/ModifierCorrectionsQuickFixTest.java
@@ -13,14 +13,16 @@
import java.util.ArrayList;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* Test OT-specific quickfixes (here: modifier corrections).
@@ -28,30 +30,14 @@
* @since 1.2.1
*/
// structure OT_COPY_PASTE from {@link org.eclipse.jdt.ui.tests.quickfix.ModifierCorrectionsQuickFixTest}
+@RunWith(JUnit4.class)
public class ModifierCorrectionsQuickFixTest extends OTQuickFixTest {
-
- private static final Class<ModifierCorrectionsQuickFixTest> THIS= ModifierCorrectionsQuickFixTest.class;
-
-
- public ModifierCorrectionsQuickFixTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
-
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
/* calling a non-public role constructor from the team. */
+ @Test
public void testRoleCtorCalled1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -89,6 +75,7 @@
}
/* calling a non-public role constructor from a sibling role. */
+ @Test
public void testRoleCtorCalled2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -130,6 +117,7 @@
}
/* calling a non-public role constructor from a sibling role file. */
+ @Test
public void testRoleCtorCalled3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
IPackageFragment pack1T= fSourceFolder.createPackageFragment("test1.T", false, null);
@@ -171,6 +159,7 @@
}
/* a non-public constructor of a role file is called from a sibling role. */
+ @Test
public void testRoleCtorCalled4() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
IPackageFragment pack1T= fSourceFolder.createPackageFragment("test1.T", false, null);
@@ -210,6 +199,7 @@
}
/* calling a non-public role constructor as externalized. */
+ @Test
public void testRoleCtorCalled5() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -250,6 +240,7 @@
}
/* calling a non-public role method on externalized. */
+ @Test
public void testRoleMethodCalled() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -289,6 +280,7 @@
assertEqualString(preview, buf.toString());
}
+ @Test
public void testCalloutToPrivate() throws Exception {
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf = new StringBuffer();
@@ -336,6 +328,7 @@
}
+ @Test
public void testCalloutViaExternalized() throws Exception {
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf = new StringBuffer();
@@ -380,6 +373,7 @@
}
/** @SuppressWarnings("bindingconventions") was added a wrong location. */
+ @Test
public void testSuppressWarnings1() throws Exception {
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf = new StringBuffer();
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OTJavadocQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OTJavadocQuickFixTest.java
index 5fe0a5f..a9a2f1d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OTJavadocQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OTJavadocQuickFixTest.java
@@ -23,51 +23,40 @@
import java.util.ArrayList;
import java.util.Hashtable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
+import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.testplugin.TestOptions;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
+import org.eclipse.objectteams.otdt.ui.tests.core.rule.ProjectTestSetup;
import org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* largely inspired by org.eclipse.jdt.ui.tests.quickfix.JavadocQuickFixTest.
* @author stephan
* @since 1.2.5
*/
+@RunWith(JUnit4.class)
public class OTJavadocQuickFixTest extends OTQuickFixTest {
- private static final Class THIS= OTJavadocQuickFixTest.class;
-
- public OTJavadocQuickFixTest(String name) {
- super(name);
- }
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
-
- @SuppressWarnings("unchecked")
+ @Before
@Override
- protected void setUp() throws Exception {
- Hashtable options= TestOptions.getDefaultOptions();
+ public void setUp() throws Exception {
+ Hashtable<String,String> options= TestOptions.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.ERROR);
@@ -116,6 +105,7 @@
// SH}
}
+ @Test
public void testMissingRoleTag1() throws Exception {
IPackageFragment teamPkg = fSourceFolder.createPackageFragment("test1.MyTeam", false, null);
teamPkg.createCompilationUnit("MyRole.java",
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OTQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OTQuickFixTest.java
index 10f24c8..c149a4d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OTQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OTQuickFixTest.java
@@ -20,12 +20,12 @@
**********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.util.Hashtable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
@@ -42,30 +42,29 @@
import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
import org.eclipse.objectteams.otdt.core.ext.OTJavaNature;
import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
+import org.eclipse.objectteams.otdt.ui.tests.core.rule.ProjectTestSetup;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ ModifierCorrectionsQuickFixTest.class,
+ CalloutQuickFixTest.class,
+ CallinQuickFixTest.class,
+ UnresolvedMethodsQuickFixTest.class,
+ OTJavadocQuickFixTest.class,
+ AddImportQuickFixTest.class,
+ JavaQuickFixTests.class,
+ PrecedenceQuickFixTest.class,
+ StatementQuickFixTest.class,
+})
public class OTQuickFixTest extends QuickFixTest {
protected IJavaProject fJProject1;
protected IPackageFragmentRoot fSourceFolder;
-
- public OTQuickFixTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite= new TestSuite();
- suite.addTest(ModifierCorrectionsQuickFixTest.suite());
- suite.addTest(CalloutQuickFixTest.suite());
- suite.addTest(CallinQuickFixTest.suite());
- suite.addTest(UnresolvedMethodsQuickFixTest.suite());
- suite.addTest(OTJavadocQuickFixTest.suite());
- suite.addTest(AddImportQuickFixTest.suite());
- suite.addTest(JavaQuickFixTests.suite());
- suite.addTest(PrecedenceQuickFixTest.suite());
- suite.addTest(StatementQuickFixTest.suite());
- return suite;
- }
public static final String OT_RUNTIME_PATH;
public static final String OTRE_JAR_PATH;
@@ -85,8 +84,9 @@
options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
}
- protected void setUp() throws Exception {
- Hashtable options= TestOptions.getDefaultOptions();
+ @Before
+ public void setUp() throws Exception {
+ Hashtable<String,String> options= TestOptions.getDefaultOptions();
addOptions(options);
JavaCore.setOptions(options);
@@ -101,8 +101,9 @@
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
-
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath());
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OrganizeImportsTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OrganizeImportsTest.java
index bbed2b6..a2530a2 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OrganizeImportsTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/OrganizeImportsTest.java
@@ -20,11 +20,10 @@
**********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests.core;
-import java.util.Hashtable;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.Hashtable;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
@@ -36,14 +35,20 @@
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.jdt.core.search.TypeNameMatch;
import org.eclipse.jdt.core.manipulation.OrganizeImportsOperation;
import org.eclipse.jdt.core.manipulation.OrganizeImportsOperation.IChooseImportQuery;
+import org.eclipse.jdt.core.search.TypeNameMatch;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
+import org.eclipse.objectteams.otdt.ui.tests.core.rule.ProjectTestSetup;
import org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper;
import org.eclipse.objectteams.otdt.ui.tests.util.TestOptions;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.osgi.service.prefs.BackingStoreException;
/**
@@ -54,40 +59,21 @@
*
* @author brcan
*/
-public class OrganizeImportsTest extends TestCase
+@RunWith(JUnit4.class)
+public class OrganizeImportsTest
{
- private IJavaProject _project;
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
- public OrganizeImportsTest(String name)
- {
- super(name);
- }
+ private IJavaProject _project;
- public static Test allTests()
- {
- return new ProjectTestSetup(new TestSuite(OrganizeImportsTest.class));
- }
- public static Test suite()
- {
- if (true)
- {
- return allTests();
- }
- else
- {
- TestSuite suite = new TestSuite();
- suite.addTest(new OrganizeImportsTest("testVisibility_bug56704"));
- return new ProjectTestSetup(suite);
- }
- }
-
- @SuppressWarnings("unchecked")
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
_project = ProjectTestSetup.getProject();
- Hashtable options = TestOptions.getFormatterOptions();
+ Hashtable<String,String> options = TestOptions.getFormatterOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE,
String.valueOf(99));
JavaCore.setOptions(options);
@@ -150,6 +136,7 @@
}
//OT-specific tests
+ @Test
public void testTypeReferenceInRoleclass1() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -200,6 +187,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
+ @Test
public void testTypeReferenceInRoleclass2() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -261,6 +249,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
+ @Test
public void testTypeReferenceInRoleclass3() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -317,6 +306,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
+ @Test
public void testTypeReferenceInRoleclass4() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -371,6 +361,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
+ @Test
public void testTypeReferenceInRoleclass5() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -421,6 +412,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
/** playedBy inner base class - role and base have same name. */
+ @Test
public void testTypeReferenceInRoleclass6() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -481,6 +473,7 @@
}
// base import for role file
+ @Test
public void testTypeReferenceInRoleclass7() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -539,6 +532,7 @@
}
// Bug 355302 - organize import deletes required base import
+ @Test
public void testTypeReferenceInRoleclass8() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -600,6 +594,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
+ @Test
public void testCalloutToStatic() throws Exception
{
IPackageFragmentRoot sourceFolder = JavaProjectHelper
@@ -661,6 +656,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
+ @Test
public void testStaticImportInGuard1() throws CoreException, BackingStoreException {
IPackageFragmentRoot sourceFolder = JavaProjectHelper
.addSourceContainer(_project, "src");
@@ -712,6 +708,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
+ @Test
public void testStaticImportInGuard2() throws CoreException, BackingStoreException {
IPackageFragmentRoot sourceFolder = JavaProjectHelper
.addSourceContainer(_project, "src");
@@ -772,6 +769,7 @@
// Trac 19: organize imports must preserve a base import,
// even if role and base have the same name and the role
// is also referenced from a sibling role.
+ @Test
public void testRoleHidesBase1() throws CoreException, BackingStoreException {
IPackageFragmentRoot sourceFolder = JavaProjectHelper
.addSourceContainer(_project, "src");
@@ -826,6 +824,7 @@
assertEqualString(cu.getSource(), buf.toString());
}
+ @Test
public void testImportRole() throws CoreException, BackingStoreException {
IPackageFragmentRoot sourceFolder = JavaProjectHelper.addSourceContainer(_project, "src");
@@ -876,6 +875,7 @@
}
// Bug 311432 - Inferred callouts to private static fields make OrganizeImports to import private fields
+ @Test
public void testDontImportStaticField() throws CoreException, BackingStoreException {
IPackageFragmentRoot sourceFolder = JavaProjectHelper.addSourceContainer(_project, "src");
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/PrecedenceQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/PrecedenceQuickFixTest.java
index 4990d35..8414447 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/PrecedenceQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/PrecedenceQuickFixTest.java
@@ -18,13 +18,16 @@
import java.util.ArrayList;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
@@ -32,27 +35,15 @@
* @author stephan
* @since 0.7.0
*/
+@RunWith(JUnit4.class)
public class PrecedenceQuickFixTest extends OTQuickFixTest {
- private static final Class THIS= PrecedenceQuickFixTest.class;
- public PrecedenceQuickFixTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test suite() {
- return allTests();
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
// QuickFix adds a binding-level precedence declaration,
// one callin label already exists, other label is generated.
+ @Test
public void testAddPlainBindingPrecedence() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -76,7 +67,7 @@
ICompilationUnit cu= pack1.createCompilationUnit("T1.java", buf.toString(), false, null);
CompilationUnit astRoot= getASTRoot(cu);
- ArrayList proposals= collectCorrections(cu, astRoot);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
@@ -99,6 +90,7 @@
}
// QuickFix adds a binding-level "precedence after" declaration
+ @Test
public void testAddAfterBindingPrecedence() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -122,7 +114,7 @@
ICompilationUnit cu= pack1.createCompilationUnit("T1.java", buf.toString(), false, null);
CompilationUnit astRoot= getASTRoot(cu);
- ArrayList proposals= collectCorrections(cu, astRoot);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
@@ -145,6 +137,7 @@
}
// QuickFix adds a role-level precedence declaration
+ @Test
public void testAddAfterRolePrecedence() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -170,7 +163,7 @@
ICompilationUnit cu= pack1.createCompilationUnit("T1.java", buf.toString(), false, null);
CompilationUnit astRoot= getASTRoot(cu);
- ArrayList proposals= collectCorrections(cu, astRoot);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/StatementQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/StatementQuickFixTest.java
index 25307cc..903525b 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/StatementQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/StatementQuickFixTest.java
@@ -21,33 +21,23 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.objectteams.otdt.ui.tests.core.rule.ProjectTestSetup;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
+@RunWith(JUnit4.class)
public class StatementQuickFixTest extends OTQuickFixTest {
- private static final Class THIS= StatementQuickFixTest.class;
-
- public StatementQuickFixTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
/* add a return statement to a role method (callin).
* See https://bugs.eclipse.org/311339
*/
+ @Test
public void testAddReturnInCallinMethod() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -70,7 +60,7 @@
ICompilationUnit cuteam = pack1.createCompilationUnit("T1.java", buf.toString(), false, null);
CompilationUnit astRoot= getASTRoot(cuteam);
- ArrayList proposals= collectCorrections(cuteam, astRoot);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cuteam, astRoot);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/UnresolvedMethodsQuickFixTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/UnresolvedMethodsQuickFixTest.java
index bed78ee..ba1b0e7 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/UnresolvedMethodsQuickFixTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/UnresolvedMethodsQuickFixTest.java
@@ -20,12 +20,12 @@
**********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.util.ArrayList;
import java.util.Hashtable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -37,34 +37,25 @@
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedCorrectionProposal;
import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
-
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* Testing corrections for unresolved methods in OT specific contexts.
* @author stephan
* @since 1.2.1
*/
+@RunWith(JUnit4.class)
public class UnresolvedMethodsQuickFixTest extends OTQuickFixTest {
- private static final Class<UnresolvedMethodsQuickFixTest> THIS= UnresolvedMethodsQuickFixTest.class;
-
- public UnresolvedMethodsQuickFixTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(THIS));
- }
- public static Test suite() {
- return allTests();
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
+ @Rule
+ public ProjectTestSetup projectsetup = new ProjectTestSetup();
@Override
protected void addOptions(Hashtable options) {
@@ -76,6 +67,7 @@
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
}
+ @Test
public void testMethodInSameType() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -134,6 +126,7 @@
assertEqualString(preview, buf.toString());
}
+ @Test
public void testMethodInDifferentClass1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -178,6 +171,7 @@
}
/* See Trac #12 */
+ @Test
public void testMethodInDifferentClass2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -224,6 +218,7 @@
assertEqualString(preview, buf.toString());
}
+ @Test
public void testTSuperConstructor() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -283,6 +278,7 @@
}
// static callin method created
+ @Test
public void testCallinMethod1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -339,6 +335,7 @@
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
// non-static callin method created
+ @Test
public void testCallinMethod2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -398,6 +395,7 @@
// non-static non-callin method created (base side)
// Bug 316665 - [quickfix] create method from unresolved replace callin RHS adds "callin" modifier
+ @Test
public void testCallinMethod3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -457,6 +455,7 @@
}
// Bug 329988 - Quickfix method generation on missing replace callin method generates wrong method
// callin method created from short callin binding -> need to infer method signature
+ @Test
public void testUnresolvedCallinMapping1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -500,6 +499,7 @@
// Bug 329988 - Quickfix method generation on missing replace callin method generates wrong method
// missing base method created (short callin binding)
+ @Test
public void testUnresolvedCallinMapping2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -542,6 +542,7 @@
// Bug 329988 - Quickfix method generation on missing replace callin method generates wrong method
// non-static callin method created (short callin binding) - lifting/lowering involved
+ @Test
public void testUnresolvedCallinMapping3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -602,6 +603,7 @@
// Bug 329988 - Quickfix method generation on missing replace callin method generates wrong method
// missing base method created (short callout binding)
+ @Test
public void testUnresolvedCallout1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -643,6 +645,7 @@
// Bug 329988 - Quickfix method generation on missing replace callin method generates wrong method
// missing base method created (short callout binding) - translation involved
+ @Test
public void testUnresolvedCallout2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -682,6 +685,7 @@
}
// Bug 339520 - [quickfix] creating a role constructor via quickfix creates ';' instead of body
+ @Test
public void testRoleInstanceCreation1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -737,6 +741,7 @@
/* some orig tests for use in OT-variants:
*
+ @Test
public void testConstructorInvocation() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -772,6 +777,7 @@
}
+ @Test
public void testSuperMethodInvocation() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/rule/ProjectTestSetup.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/rule/ProjectTestSetup.java
new file mode 100644
index 0000000..0b6c0c8
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests/src/org/eclipse/objectteams/otdt/ui/tests/core/rule/ProjectTestSetup.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Fraunhofer FIRST - extended API and implementation
+ * Technical University Berlin - extended API and implementation
+ *******************************************************************************/
+package org.eclipse.objectteams.otdt.ui.tests.core.rule;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.util.CoreUtility;
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.testplugin.TestOptions;
+import org.junit.rules.ExternalResource;
+
+//{OT_COPY_PASTE: Copy of class org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup
+/**
+ * Sets up an 1.5 project with rtstubs15.jar and compiler, code formatting, code generation, and template options.
+ */
+public class ProjectTestSetup extends ExternalResource {
+
+ public static final String PROJECT_NAME= "TestSetupProject";
+
+ public static IJavaProject getProject() {
+ IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
+ return JavaCore.create(project);
+ }
+
+ public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
+ IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_15);
+//{ObjectTeams: OTRE:
+ IPath otrePath = new Path("OTRE");
+/* orig:
+ return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], true) };
+ :giro */
+ return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], true), JavaCore.newContainerEntry(otrePath) };
+// SH}
+ }
+
+
+ private IJavaProject fJProject;
+
+ private boolean fAutobuilding;
+
+ @Override
+ protected void before() throws Throwable {
+
+ if (projectExists()) { // allow nesting of ProjectTestSetups
+ return;
+ }
+
+ fAutobuilding = CoreUtility.setAutoBuilding(false);
+
+ fJProject= createAndInitializeProject();
+
+ JavaCore.setOptions(TestOptions.getDefaultOptions());
+ TestOptions.initializeCodeGenerationOptions();
+ JavaPlugin.getDefault().getCodeTemplateStore().load();
+ }
+
+ protected boolean projectExists() {
+ return getProject().exists();
+ }
+
+ protected IJavaProject createAndInitializeProject() throws CoreException {
+//{ObjectTeams: create an OT project and keep otre.jar (don't overwrite with setRawClasspath)
+/* orig:
+ IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME, "bin");
+ javaProject.setRawClasspath(getDefaultClasspath(), null);
+ :giro */
+ IJavaProject javaProject= org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper.createOTJavaProject(PROJECT_NAME, "bin");
+ JavaProjectHelper.addRTJar(javaProject);
+//gbr}
+ TestOptions.initializeProjectOptions(javaProject);
+ return javaProject;
+ }
+
+ @Override
+ protected void after() {
+ if (fJProject != null) {
+ try {
+ JavaProjectHelper.delete(fJProject);
+ CoreUtility.setAutoBuilding(fAutobuilding);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
+//gbr}
\ No newline at end of file