aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-07-19 04:32:42 -0400
committerAlexander Kurtakov2018-07-19 04:32:42 -0400
commit67ef33c03ef80d5d6123ce952be41e98b842e89f (patch)
tree709c1c8dc18c4a4bd0802f7583e4eb90f3f975a0
parent877b838e1db19298f37c6c2ee4ee8c5f8e1c1f8a (diff)
downloadeclipse.platform.runtime-67ef33c03ef80d5d6123ce952be41e98b842e89f.tar.gz
eclipse.platform.runtime-67ef33c03ef80d5d6123ce952be41e98b842e89f.tar.xz
eclipse.platform.runtime-67ef33c03ef80d5d6123ce952be41e98b842e89f.zip
Convert ExpressionTestsPluginUnloading to JUnit 4.Y20180720-0300I20180719-2000
Change-Id: Ic502c7bb713bc709f25ed7d855249628acf1ef3b Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTestsPluginUnloading.java49
1 files changed, 23 insertions, 26 deletions
diff --git a/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTestsPluginUnloading.java b/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTestsPluginUnloading.java
index a6b44d292..352f3fb3b 100644
--- a/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTestsPluginUnloading.java
+++ b/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTestsPluginUnloading.java
@@ -10,19 +10,23 @@
*******************************************************************************/
package org.eclipse.core.internal.expressions.tests;
-import java.util.ArrayList;
-import java.util.Collections;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.FixMethodOrder;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.junit.runners.MethodSorters;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.eclipse.core.internal.expressions.ExpressionPlugin;
import org.eclipse.core.internal.expressions.Expressions;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
/**
* Tests for cache used in {@link Expressions#isInstanceOf(Object, String)}.
@@ -30,25 +34,13 @@ import junit.framework.TestSuite;
* <b>WARNING:</b> These tests start, stop, and re-start the <code>com.ibm.icu</code> bundle.
* Don't include these in another test suite!
*/
-public class ExpressionTestsPluginUnloading extends TestCase {
-
- public static Test suite() {
- TestSuite suite= new TestSuite(ExpressionTestsPluginUnloading.class);
- // ensure lexicographical ordering:
- ArrayList<Test> tests = Collections.list(suite.tests());
- Collections.sort(tests, (o1, o2) -> ((TestCase) o1).getName().compareTo(((TestCase) o2).getName()));
- TestSuite result= new TestSuite();
- for (Test test : tests) {
- result.addTest(test);
- }
- return result;
- }
-
- public ExpressionTestsPluginUnloading(String name) {
- super(name);
- }
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ExpressionTestsPluginUnloading {
+ @Rule
+ public TestName name = new TestName();
+ @Test
public void test01PluginStopping() throws Exception {
Bundle bundle= getBundle("com.ibm.icu");
@@ -66,6 +58,7 @@ public class ExpressionTestsPluginUnloading extends TestCase {
doTestInstanceofICUDecimalFormat(bundle);
}
+ @Test
public void test02MultipleClassloaders() throws Exception {
Bundle expr= getBundle("org.eclipse.core.expressions.tests");
Bundle icu= getBundle("com.ibm.icu");
@@ -87,8 +80,12 @@ public class ExpressionTestsPluginUnloading extends TestCase {
private void assertInstanceOf(Object obj, String isInstance, String isNotInstance) throws Exception {
Class<?> clazz = obj.getClass();
- System.out.println("ExpressionTestsPluginUnloading#" + getName() + "() - " + clazz.getName() + ": " + clazz.hashCode());
- System.out.println("ExpressionTestsPluginUnloading#" + getName() + "() - ClassLoader: " + clazz.getClassLoader().hashCode());
+ System.out.println(
+ "ExpressionTestsPluginUnloading#" + name.getMethodName() + "() - " + clazz.getName() + ": "
+ + clazz.hashCode());
+ System.out.println(
+ "ExpressionTestsPluginUnloading#" + name.getMethodName() + "() - ClassLoader: "
+ + clazz.getClassLoader().hashCode());
for (int i= 0; i < 2; i++) { // test twice, second time is cached:
assertTrue(Expressions.isInstanceOf(obj, isInstance));