Skip to content

Commit d284eeb

Browse files
HeikoKlareakurtakov
authored andcommitted
Migrate org.eclipse.e4.core.commands.tests to JUnit 5
- Exchange annotations including test suites - Exchange assertions
1 parent c2f75c4 commit d284eeb

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

tests/org.eclipse.e4.core.commands.tests/E4Command Tests Suite.launch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
2323
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
2424
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
25-
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
25+
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit5"/>
2626
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
27-
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
27+
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
2828
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.e4.core.commands.tests.CommandTestSuite"/>
2929
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.e4.core.commands.tests"/>
3030
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17
77
Require-Bundle: org.eclipse.core.commands,
88
org.eclipse.e4.core.commands,
99
org.eclipse.core.runtime,
10-
org.junit,
1110
org.eclipse.e4.core.di
1211
Import-Package: jakarta.inject;version="[2.0.0,3.0.0)",
1312
org.eclipse.e4.core.contexts,
14-
org.osgi.framework;version="[1.5.0,2.0.0)"
13+
org.osgi.framework;version="[1.5.0,2.0.0)",
14+
org.junit.jupiter.api,
15+
org.junit.platform.suite.api
1516
Bundle-ActivationPolicy: lazy
1617
Bundle-Localization: plugin
1718
Eclipse-BundleShape: dir

tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/CommandTestSuite.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.core.commands.tests;
1616

17-
import org.junit.runner.RunWith;
18-
import org.junit.runners.Suite;
19-
import org.junit.runners.Suite.SuiteClasses;
20-
21-
@RunWith(Suite.class)
22-
@SuiteClasses({
23-
DefineCommandsTest.class,
24-
HandlerTest.class })
17+
import org.junit.platform.suite.api.SelectClasses;
18+
import org.junit.platform.suite.api.Suite;
2519

20+
@Suite
21+
@SelectClasses({ //
22+
DefineCommandsTest.class, //
23+
HandlerTest.class, //
24+
})
2625
public class CommandTestSuite {
2726
}

tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/DefineCommandsTest.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*******************************************************************************/
1616
package org.eclipse.e4.core.commands.tests;
1717

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

2121
import java.util.HashMap;
2222
import java.util.Map;
@@ -32,9 +32,9 @@
3232
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
3333
import org.eclipse.e4.core.contexts.EclipseContextFactory;
3434
import org.eclipse.e4.core.contexts.IEclipseContext;
35-
import org.junit.After;
36-
import org.junit.Before;
37-
import org.junit.Test;
35+
import org.junit.jupiter.api.AfterEach;
36+
import org.junit.jupiter.api.BeforeEach;
37+
import org.junit.jupiter.api.Test;
3838
import org.osgi.framework.FrameworkUtil;
3939

4040
public class DefineCommandsTest {
@@ -46,15 +46,15 @@ public class DefineCommandsTest {
4646

4747
private IEclipseContext workbenchContext;
4848

49-
@Before
49+
@BeforeEach
5050
public void setUp() {
5151
IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(this.getClass()).getBundleContext());
5252
IEclipseContext globalContext = serviceContext.createChild();
5353
workbenchContext = globalContext.createChild("workbenchContext");
5454
ContextInjectionFactory.make(CommandServiceAddon.class, workbenchContext);
5555
}
5656

57-
@After
57+
@AfterEach
5858
public void tearDown() {
5959
workbenchContext.dispose();
6060
}
@@ -65,14 +65,14 @@ public void testCreateCommands() throws NotDefinedException {
6565
assertNotNull(cs);
6666
assertNotNull(cs.defineCategory(TEST_CAT1, "CAT1", null));
6767
Category category = cs.getCategory(TEST_CAT1);
68-
assertNotNull("need category", category);
69-
assertNotNull("command1", cs.defineCommand(TEST_ID1, "ID1", null, category, null));
70-
assertNotNull("command2", cs.defineCommand(TEST_ID2, "ID2", null, category, null));
68+
assertNotNull(category, "need category");
69+
assertNotNull(cs.defineCommand(TEST_ID1, "ID1", null, category, null), "command1");
70+
assertNotNull(cs.defineCommand(TEST_ID2, "ID2", null, category, null), "command2");
7171
Command cmd1 = cs.getCommand(TEST_ID1);
72-
assertNotNull("get command1", cmd1);
72+
assertNotNull(cmd1, "get command1");
7373
assertEquals("ID1", cmd1.getName());
74-
assertNotNull("get command2", cs.getCommand(TEST_ID2));
75-
assertNotNull("parameterized command", cs.createCommand(TEST_ID1, null));
74+
assertNotNull(cs.getCommand(TEST_ID2), "get command2");
75+
assertNotNull(cs.createCommand(TEST_ID1, null), "parameterized command");
7676
}
7777

7878
@Test
@@ -110,7 +110,7 @@ public boolean isOptional() {
110110
assertNotNull(command);
111111
assertNotNull(createdParamizedCommand);
112112
Command cmd1 = cs.getCommand(TEST_ID1_WITH_PARAMETERS);
113-
assertNotNull("get command1", cmd1);
113+
assertNotNull(cmd1, "get command1");
114114
}
115115

116116

@@ -123,14 +123,14 @@ public void testCreateWithSecondContexts() throws NotDefinedException {
123123
assertNotNull(cs);
124124
assertNotNull(cs.defineCategory(TEST_CAT1, "CAT1", null));
125125
Category category = cs.getCategory(TEST_CAT1);
126-
assertNotNull("need category", category);
127-
assertNotNull("command1", cs.defineCommand(TEST_ID1, "ID1", null, category, null));
128-
assertNotNull("command2", cs.defineCommand(TEST_ID2, "ID2", null, category, null));
126+
assertNotNull(category, "need category");
127+
assertNotNull(cs.defineCommand(TEST_ID1, "ID1", null, category, null), "command1");
128+
assertNotNull(cs.defineCommand(TEST_ID2, "ID2", null, category, null), "command2");
129129

130130
Command cmd1 = cs.getCommand(TEST_ID1);
131-
assertNotNull("get command1", cmd1);
131+
assertNotNull(cmd1, "get command1");
132132
assertEquals("ID1", cmd1.getName());
133-
assertNotNull("get command2", cs.getCommand(TEST_ID2));
133+
assertNotNull(cs.getCommand(TEST_ID2), "get command2");
134134
}
135135

136136
@Test
@@ -140,14 +140,14 @@ public void testCreateWithTwoContexts() throws NotDefinedException {
140140
assertNotNull(cs);
141141
assertNotNull(cs.defineCategory(TEST_CAT1, "CAT1", null));
142142
Category category = cs.getCategory(TEST_CAT1);
143-
assertNotNull("need category", category);
144-
assertNotNull("command1", cs.defineCommand(TEST_ID1, "ID1", null, category, null));
145-
assertNotNull("command2", cs.defineCommand(TEST_ID2, "ID2", null, category, null));
143+
assertNotNull(category, "need category");
144+
assertNotNull(cs.defineCommand(TEST_ID1, "ID1", null, category, null), "command1");
145+
assertNotNull(cs.defineCommand(TEST_ID2, "ID2", null, category, null), "command2");
146146

147147
cs = workbenchContext.get(ECommandService.class);
148148
Command cmd1 = cs.getCommand(TEST_ID1);
149-
assertNotNull("get command1", cmd1);
149+
assertNotNull(cmd1, "get command1");
150150
assertEquals("ID1", cmd1.getName());
151-
assertNotNull("get command2", cs.getCommand(TEST_ID2));
151+
assertNotNull(cs.getCommand(TEST_ID2), "get command2");
152152
}
153153
}

tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/HandlerTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
******************************************************************************/
1616
package org.eclipse.e4.core.commands.tests;
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 java.util.Collections;
2424

@@ -36,9 +36,9 @@
3636
import org.eclipse.e4.core.di.annotations.CanExecute;
3737
import org.eclipse.e4.core.di.annotations.Execute;
3838
import org.eclipse.e4.core.di.annotations.Optional;
39-
import org.junit.After;
40-
import org.junit.Before;
41-
import org.junit.Test;
39+
import org.junit.jupiter.api.AfterEach;
40+
import org.junit.jupiter.api.BeforeEach;
41+
import org.junit.jupiter.api.Test;
4242
import org.osgi.framework.FrameworkUtil;
4343

4444
import jakarta.inject.Named;
@@ -53,7 +53,7 @@ public class HandlerTest {
5353

5454
private IEclipseContext workbenchContext;
5555

56-
@Before
56+
@BeforeEach
5757
public void setUp() {
5858
IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(this.getClass()).getBundleContext());
5959
IEclipseContext globalContext = serviceContext.createChild();
@@ -62,7 +62,7 @@ public void setUp() {
6262
defineCommands(workbenchContext);
6363
}
6464

65-
@After
65+
@AfterEach
6666
public void tearDown() {
6767
workbenchContext.dispose();
6868
}

0 commit comments

Comments
 (0)