Skip to content

Commit 3aaa3cf

Browse files
committed
Migrate org.eclipse.e4.core.tests to JUnit 5 (javax + jakarta variant)
- Add ContextPerformanceTest to test suite - Remove location markers
1 parent 02ffafb commit 3aaa3cf

File tree

115 files changed

+656
-634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+656
-634
lines changed

runtime/tests/org.eclipse.e4.core.javax.tests/META-INF/MANIFEST.MF

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ Bundle-ActivationPolicy: lazy
1717
Bundle-RequiredExecutionEnvironment: JavaSE-17
1818
Import-Package: javax.annotation;version="[1.3.0,2.0.0)",
1919
javax.inject;version="[1.0.0,2.0.0)",
20-
junit.framework;version="[4.13.0,5.0.0)",
2120
org.assertj.core.api,
2221
org.eclipse.osgi.service.datalocation,
2322
org.eclipse.osgi.service.debug,
24-
org.junit;version="[4.13.0,5.0.0)",
25-
org.junit.runner;version="[4.13.0,5.0.0)",
26-
org.junit.runners;version="[4.13.0,5.0.0)",
23+
org.junit.jupiter.api;version="[5.12.0,6.0.0)",
24+
org.junit.jupiter.api.function;version="[5.12.0,6.0.0)",
25+
org.junit.platform.suite.api;version="[1.12.0,2.0.0)",
2726
org.osgi.framework;version="[1.10.0,2.0.0)",
2827
org.osgi.service.component;version="1.3.0",
2928
org.osgi.service.component.propertytypes;version="[1.4.0,2.0.0)",

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/ActivationTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
package org.eclipse.e4.core.internal.tests.contexts;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertNull;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
import static org.junit.jupiter.api.Assertions.assertNull;
2020

2121
import javax.inject.Inject;
2222
import javax.inject.Named;
@@ -25,7 +25,7 @@
2525
import org.eclipse.e4.core.contexts.EclipseContextFactory;
2626
import org.eclipse.e4.core.contexts.IEclipseContext;
2727
import org.eclipse.e4.core.contexts.RunAndTrack;
28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

3030
public class ActivationTest {
3131

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.core.internal.tests.contexts;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertNull;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertNull;
1919

2020
import org.eclipse.e4.core.contexts.ContextFunction;
2121
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
2222
import org.eclipse.e4.core.contexts.EclipseContextFactory;
2323
import org.eclipse.e4.core.contexts.IEclipseContext;
2424
import org.eclipse.e4.core.internal.tests.contexts.inject.ObjectBasic;
25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

2727
/**
2828
* Tests for the basic context functionality

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.core.internal.tests.contexts;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertTrue;
1919

2020
import org.eclipse.e4.core.contexts.ContextFunction;
2121
import org.eclipse.e4.core.contexts.EclipseContextFactory;
2222
import org.eclipse.e4.core.contexts.IEclipseContext;
2323
import org.eclipse.e4.core.internal.contexts.EclipseContext;
24-
import org.junit.Before;
25-
import org.junit.Test;
24+
import org.junit.jupiter.api.BeforeEach;
25+
import org.junit.jupiter.api.Test;
2626

2727
@SuppressWarnings("restriction")
2828
public class DependenciesLeakTest {
@@ -48,7 +48,7 @@ public String toString() {
4848
private IEclipseContext perspectiveContext;
4949
private IEclipseContext partContext;
5050

51-
@Before
51+
@BeforeEach
5252
public void setUp() throws Exception {
5353
windowContext = EclipseContextFactory.create("Window");
5454
perspectiveContext = windowContext.createChild("Perspective");

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/EclipseContextTest.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.core.internal.tests.contexts;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertFalse;
19-
import static org.junit.Assert.assertNull;
20-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertFalse;
19+
import static org.junit.jupiter.api.Assertions.assertNull;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
2121

2222
import org.eclipse.e4.core.contexts.ContextFunction;
2323
import org.eclipse.e4.core.contexts.EclipseContextFactory;
2424
import org.eclipse.e4.core.contexts.IEclipseContext;
2525
import org.eclipse.e4.core.contexts.RunAndTrack;
2626
import org.eclipse.e4.core.di.IInjector;
2727
import org.eclipse.e4.core.internal.contexts.EclipseContext;
28-
import org.junit.Before;
29-
import org.junit.Test;
28+
import org.junit.jupiter.api.BeforeEach;
29+
import org.junit.jupiter.api.Test;
3030
import org.osgi.framework.FrameworkUtil;
3131

3232
@SuppressWarnings("restriction")
@@ -44,7 +44,7 @@ public Object compute(IEclipseContext context, String contextKey) {
4444

4545
private int runCounter;
4646

47-
@Before
47+
@BeforeEach
4848
public void setUp() throws Exception {
4949
parentContext = EclipseContextFactory.create("EclipseContextTest" + "-parent");
5050
context = parentContext.createChild("EclipseContextTest");
@@ -53,18 +53,18 @@ public void setUp() throws Exception {
5353

5454
@Test
5555
public void testContainsKey() {
56-
assertFalse("1.0", context.containsKey("function"));
57-
assertFalse("1.1", context.containsKey("separator"));
56+
assertFalse(context.containsKey("function"));
57+
assertFalse(context.containsKey("separator"));
5858

5959
context.set("separator", ",");
60-
assertTrue("2.1", context.containsKey("separator"));
60+
assertTrue(context.containsKey("separator"));
6161

6262
// null value is still a value
6363
context.set("separator", null);
64-
assertTrue("3.0", context.containsKey("separator"));
64+
assertTrue(context.containsKey("separator"));
6565

6666
context.remove("separator");
67-
assertFalse("4.0", context.containsKey("separator"));
67+
assertFalse(context.containsKey("separator"));
6868
}
6969

7070
@Test

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/NeutralValueTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
*******************************************************************************/
1414
package org.eclipse.e4.core.internal.tests.contexts;
1515

16-
import static org.junit.Assert.assertEquals;
17-
import static org.junit.Assert.assertFalse;
18-
import static org.junit.Assert.assertNotEquals;
19-
import static org.junit.Assert.assertTrue;
16+
import static org.junit.jupiter.api.Assertions.assertEquals;
17+
import static org.junit.jupiter.api.Assertions.assertFalse;
18+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
19+
import static org.junit.jupiter.api.Assertions.assertTrue;
2020

2121
import java.util.HashSet;
2222
import java.util.Set;
2323

2424
import org.eclipse.e4.core.internal.contexts.ConcurrentNeutralValueMap;
2525
import org.eclipse.e4.core.internal.contexts.ConcurrentNeutralValueMap.Value;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
@SuppressWarnings("restriction")
2929
public class NeutralValueTest {

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
package org.eclipse.e4.core.internal.tests.contexts;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertFalse;
20-
import static org.junit.Assert.assertNull;
21-
import static org.junit.Assert.assertTrue;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
import static org.junit.jupiter.api.Assertions.assertFalse;
20+
import static org.junit.jupiter.api.Assertions.assertNull;
21+
import static org.junit.jupiter.api.Assertions.assertTrue;
2222

2323
import javax.inject.Inject;
2424
import javax.inject.Named;
@@ -29,7 +29,7 @@
2929
import org.eclipse.e4.core.contexts.IEclipseContext;
3030
import org.eclipse.e4.core.contexts.RunAndTrack;
3131
import org.eclipse.e4.core.internal.tests.contexts.inject.ObjectSuperClass;
32-
import org.junit.Test;
32+
import org.junit.jupiter.api.Test;
3333

3434
/**
3535
* Test for changing a context's parent.
@@ -54,7 +54,7 @@ public void testContextFunctionInParentRemove() {
5454
assertEquals(2, ((Integer) child.get("sum")).intValue());
5555
child.setParent(EclipseContextFactory.create());
5656
assertEquals(6, ((Integer) parent.get("sum")).intValue());
57-
assertNull("Expected null but was: " + child.get("sum"), child.get("sum"));
57+
assertNull(child.get("sum"), "Expected null but was: " + child.get("sum"));
5858
}
5959

6060
/**

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
package org.eclipse.e4.core.internal.tests.contexts;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertNotNull;
20-
import static org.junit.Assert.assertTrue;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
import static org.junit.jupiter.api.Assertions.assertNotNull;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
2121

2222
import java.util.ArrayList;
2323
import java.util.List;
@@ -27,8 +27,8 @@
2727
import org.eclipse.e4.core.contexts.IEclipseContext;
2828
import org.eclipse.e4.core.contexts.RunAndTrack;
2929
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
30-
import org.junit.After;
31-
import org.junit.Test;
30+
import org.junit.jupiter.api.AfterEach;
31+
import org.junit.jupiter.api.Test;
3232

3333
/**
3434
* Tests for {@link org.eclipse.e4.core.contexts.RunAndTrack}.
@@ -118,7 +118,7 @@ private IEclipseContext[] createNextLevel(IEclipseContext parent, String prefix,
118118
return contexts;
119119
}
120120

121-
@After
121+
@AfterEach
122122
public void tearDown() throws Exception {
123123
for (IEclipseContext context : createdContexts) {
124124
context.dispose();

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/StrongIterableTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
package org.eclipse.e4.core.internal.tests.contexts;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertFalse;
19-
import static org.junit.Assert.assertNotNull;
20-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertFalse;
19+
import static org.junit.jupiter.api.Assertions.assertNotNull;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
2121

2222
import java.lang.ref.Reference;
2323
import java.lang.ref.WeakReference;
@@ -30,7 +30,7 @@
3030
import java.util.stream.StreamSupport;
3131

3232
import org.eclipse.e4.core.internal.contexts.StrongIterable;
33-
import org.junit.Test;
33+
import org.junit.jupiter.api.Test;
3434

3535
@SuppressWarnings("restriction")
3636
public class StrongIterableTest {

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ActivationInjectionTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
package org.eclipse.e4.core.internal.tests.contexts.inject;
1717

18-
import static org.junit.Assert.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
1919

2020
import javax.inject.Inject;
2121
import javax.inject.Named;
@@ -26,7 +26,7 @@
2626
import org.eclipse.e4.core.contexts.EclipseContextFactory;
2727
import org.eclipse.e4.core.contexts.IEclipseContext;
2828
import org.eclipse.e4.core.di.annotations.Optional;
29-
import org.junit.Test;
29+
import org.junit.jupiter.api.Test;
3030

3131
public class ActivationInjectionTest {
3232

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.core.internal.tests.contexts.inject;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertNotNull;
19-
import static org.junit.Assert.assertNull;
20-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertNotNull;
19+
import static org.junit.jupiter.api.Assertions.assertNull;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
2121

2222
import javax.annotation.PostConstruct;
2323
import javax.annotation.PreDestroy;
@@ -29,7 +29,7 @@
2929
import org.eclipse.e4.core.contexts.IEclipseContext;
3030
import org.eclipse.e4.core.di.annotations.Execute;
3131
import org.eclipse.e4.core.di.annotations.Optional;
32-
import org.junit.Test;
32+
import org.junit.jupiter.api.Test;
3333
/**
3434
* Tests for the basic context injection functionality
3535
*/

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug317183Test.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
package org.eclipse.e4.core.internal.tests.contexts.inject;
1717

18-
import static org.junit.Assert.assertTrue;
18+
import static org.junit.jupiter.api.Assertions.assertTrue;
1919

2020
import org.eclipse.e4.core.contexts.EclipseContextFactory;
2121
import org.eclipse.e4.core.contexts.IEclipseContext;
2222
import org.eclipse.e4.core.contexts.RunAndTrack;
23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424

2525
public class Bug317183Test {
2626

runtime/tests/org.eclipse.e4.core.javax.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ComplexDisposalTest.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
******************************************************************************/
1515
package org.eclipse.e4.core.internal.tests.contexts.inject;
1616

17-
import static org.junit.Assert.assertEquals;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
1818

1919
import javax.annotation.PreDestroy;
2020
import javax.inject.Inject;
@@ -24,7 +24,7 @@
2424
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
2525
import org.eclipse.e4.core.contexts.EclipseContextFactory;
2626
import org.eclipse.e4.core.contexts.IEclipseContext;
27-
import org.junit.Test;
27+
import org.junit.jupiter.api.Test;
2828

2929
/**
3030
* See bug 296337: duplicate disposal of an object
@@ -66,9 +66,9 @@ public void testU() {
6666

6767
assertEquals(0, test.getCount());
6868
context.dispose();
69-
assertEquals("Context disposed, @PreDestroy should've been called", 1, test.getCount());
69+
assertEquals(1, test.getCount(), "Context disposed, @PreDestroy should've been called");
7070
parentContext.dispose();
71-
assertEquals("Parent context disposed, @PreDestroy should not have been called again", 1, test.getCount());
71+
assertEquals(1, test.getCount(), "Parent context disposed, @PreDestroy should not have been called again");
7272
}
7373

7474
@Test
@@ -81,9 +81,9 @@ public void testV() {
8181

8282
assertEquals(0, test.getCount());
8383
context.dispose();
84-
assertEquals("Context disposed, @PreDestroy should've been called", 1, test.getCount());
84+
assertEquals(1, test.getCount(), "Context disposed, @PreDestroy should've been called");
8585
parentContext.dispose();
86-
assertEquals("Parent context disposed, @PreDestroy should not have been called again", 1, test.getCount());
86+
assertEquals(1, test.getCount(), "Parent context disposed, @PreDestroy should not have been called again");
8787
}
8888

8989
@Test
@@ -97,8 +97,8 @@ public void testW() {
9797

9898
assertEquals(0, test.getCount());
9999
context.dispose();
100-
assertEquals("Context disposed, @PreDestroy should've been called", 1, test.getCount());
100+
assertEquals(1, test.getCount(), "Context disposed, @PreDestroy should've been called");
101101
parentContext.dispose();
102-
assertEquals("Parent context disposed, @PreDestroy should not have been called again", 1, test.getCount());
102+
assertEquals(1, test.getCount(), "Parent context disposed, @PreDestroy should not have been called again");
103103
}
104104
}

0 commit comments

Comments
 (0)