Skip to content

Commit

Permalink
Migrate org.eclipse.core.expressions.tests to JUnit 5
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoKlare committed Jan 22, 2024
1 parent 6f3a47b commit c064002
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Export-Package:
org.eclipse.core.internal.expressions.tests
Require-Bundle:
org.eclipse.core.expressions;bundle-version="[3.4.100,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.junit;bundle-version="3.8.2"
Import-Package: org.assertj.core.api
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)"
Import-Package: org.assertj.core.api,
org.junit.jupiter.api,
org.junit.jupiter.api.function,
org.junit.platform.suite.api
Bundle-RequiredExecutionEnvironment: JavaSE-17
Eclipse-BundleShape: dir
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
*******************************************************************************/
package org.eclipse.core.internal.expressions.tests;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

@RunWith(Suite.class)
@SuiteClasses({ PropertyTesterTests.class, ExpressionTests.class, ExpressionInfoTests.class,
CountExpressionTest.class })
@Suite
@SelectClasses({ //
PropertyTesterTests.class, //
ExpressionTests.class, //
ExpressionInfoTests.class, //
CountExpressionTest.class, //
})
public class AllExpressionTests {

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*******************************************************************************/
package org.eclipse.core.internal.expressions.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.eclipse.core.expressions.CountExpression;
import org.eclipse.core.expressions.EvaluationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static java.util.function.Predicate.not;
import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.eclipse.core.expressions.AndExpression;
import org.eclipse.core.expressions.CountExpression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.net.URL;
import java.util.AbstractCollection;
Expand All @@ -33,7 +33,7 @@
import java.util.LinkedList;
import java.util.List;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.osgi.framework.FrameworkUtil;

import org.w3c.dom.Document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
package org.eclipse.core.internal.expressions.tests;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
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 static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestMethodOrder;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
Expand All @@ -37,11 +37,15 @@
* Don't include these in another test suite!
*/
@SuppressWarnings("restriction")
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class ExpressionTestsPluginUnloading {

@Rule
public TestName name = new TestName();
private String name;

@BeforeEach
public void setupTestName(TestInfo testInfo) {
name = testInfo.getDisplayName();
}

@Test
public void test01PluginStopping() throws Exception {
Expand Down Expand Up @@ -109,10 +113,10 @@ private void assertInstanceOf(Object obj, String isInstance, String isNotInstanc
Class<?> clazz = obj.getClass();

System.out.println(
"ExpressionTestsPluginUnloading#" + name.getMethodName() + "() - " + clazz.getName() + ": "
"ExpressionTestsPluginUnloading#" + name + "() - " + clazz.getName() + ": "
+ clazz.hashCode());
System.out.println(
"ExpressionTestsPluginUnloading#" + name.getMethodName() + "() - ClassLoader: "
"ExpressionTestsPluginUnloading#" + name + "() - ClassLoader: "
+ clazz.getClassLoader().hashCode());

for (int i= 0; i < 2; i++) { // test twice, second time is cached:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
package org.eclipse.core.internal.expressions.tests;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.osgi.framework.Bundle;

import org.eclipse.core.expressions.EvaluationContext;
Expand All @@ -44,7 +44,7 @@ public class PropertyTesterTests {
// Needs additional local test plug-ins
private static final boolean TEST_DYNAMIC_AND_ACTIVATION= false;

@Before
@BeforeEach
public void setUp() throws Exception {
a= new A();
b= new B();
Expand Down

0 comments on commit c064002

Please sign in to comment.