Skip to content

Commit c3b375a

Browse files
committed
Migration of org.eclipse.e4.ui.bindings.tests to JUnit5
Changes the suite, the dependencies and the test files to Jupiter API
1 parent f6c723f commit c3b375a

File tree

7 files changed

+38
-46
lines changed

7 files changed

+38
-46
lines changed

tests/org.eclipse.e4.ui.bindings.tests/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Import-Package: org.eclipse.e4.core.commands,
88
org.eclipse.e4.ui.services,
99
org.eclipse.jface.bindings,
1010
org.eclipse.jface.bindings.keys,
11+
org.junit.jupiter.api;version="[5.12.0,6.0.0)",
12+
org.junit.platform.suite.api;version="[1.12.0,2.0.0)",
1113
org.osgi.framework;version="1.5.0"
1214
Require-Bundle: org.eclipse.core.commands;bundle-version="3.12.400",
13-
org.junit,
1415
org.eclipse.e4.ui.bindings;bundle-version="0.14.600",
1516
org.eclipse.swt;bundle-version="3.130.0",
1617
org.eclipse.e4.core.contexts,

tests/org.eclipse.e4.ui.bindings.tests/src/org/eclipse/e4/ui/bindings/tests/BindingCreateTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.ui.bindings.tests;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertNotNull;
19-
import static org.junit.Assert.assertNull;
17+
import static org.junit.jupiter.api.Assertions.*;
18+
import org.junit.jupiter.api.AfterEach;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
2021

2122
import java.util.HashMap;
2223
import java.util.Map;
@@ -31,9 +32,6 @@
3132
import org.eclipse.e4.ui.services.ContextServiceAddon;
3233
import org.eclipse.jface.bindings.Binding;
3334
import org.eclipse.jface.bindings.TriggerSequence;
34-
import org.junit.After;
35-
import org.junit.Before;
36-
import org.junit.Test;
3735

3836
@SuppressWarnings("restriction")
3937
public class BindingCreateTest {
@@ -48,7 +46,7 @@ public class BindingCreateTest {
4846
private TriggerSequence seq, emptySeq;
4947
private Map<String,String> emptyAttrs, schemeOnly, schemeAndTypeAttrs;
5048

51-
@Before
49+
@BeforeEach
5250
public void setUp() {
5351
IEclipseContext globalContext = TestUtil.getGlobalContext();
5452
workbenchContext = globalContext.createChild("workbenchContext");
@@ -78,7 +76,7 @@ public void setupTestVars() {
7876
schemeAndTypeAttrs.put(EBindingService.TYPE_ATTR_TAG, "user");
7977
}
8078

81-
@After
79+
@AfterEach
8280
public void tearDown() {
8381
workbenchContext.dispose();
8482
workbenchContext = null;

tests/org.eclipse.e4.ui.bindings.tests/src/org/eclipse/e4/ui/bindings/tests/BindingLookupTest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.ui.bindings.tests;
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.assertNull;
21-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.*;
2218

2319
import java.util.ArrayList;
2420
import java.util.Collection;
@@ -42,9 +38,9 @@
4238
import org.eclipse.e4.ui.services.EContextService;
4339
import org.eclipse.jface.bindings.Binding;
4440
import org.eclipse.jface.bindings.TriggerSequence;
45-
import org.junit.After;
46-
import org.junit.Before;
47-
import org.junit.Test;
41+
import org.junit.jupiter.api.AfterEach;
42+
import org.junit.jupiter.api.BeforeEach;
43+
import org.junit.jupiter.api.Test;
4844

4945
@SuppressWarnings("restriction")
5046
public class BindingLookupTest {
@@ -74,7 +70,7 @@ private void defineCommands(IEclipseContext context) {
7470
cs.defineCommand(TEST_ID2, "ID2", null, category, null);
7571
}
7672

77-
@Before
73+
@BeforeEach
7874
public void setUp() {
7975
IEclipseContext globalContext = TestUtil.getGlobalContext();
8076
workbenchContext = globalContext.createChild("workbenchContext");
@@ -107,7 +103,7 @@ private void defineBindingTables(IEclipseContext context) {
107103
btm.addTable(new BindingTable(cm.getContext(ID_DIALOG), application));
108104
}
109105

110-
@After
106+
@AfterEach
111107
public void tearDown() {
112108
workbenchContext.dispose();
113109
workbenchContext = null;

tests/org.eclipse.e4.ui.bindings.tests/src/org/eclipse/e4/ui/bindings/tests/BindingTableTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*******************************************************************************/
1616
package org.eclipse.e4.ui.bindings.tests;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertFalse;
20-
import static org.junit.Assert.assertNotEquals;
21-
import static org.junit.Assert.assertNotNull;
22-
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.assertNotEquals;
21+
import static org.junit.jupiter.api.Assertions.assertNotNull;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2323

2424
import java.util.ArrayList;
2525
import java.util.Collection;
@@ -41,8 +41,8 @@
4141
import org.eclipse.jface.bindings.Binding;
4242
import org.eclipse.jface.bindings.keys.KeyBinding;
4343
import org.eclipse.jface.bindings.keys.KeySequence;
44-
import org.junit.Before;
45-
import org.junit.Test;
44+
import org.junit.jupiter.api.BeforeEach;
45+
import org.junit.jupiter.api.Test;
4646

4747
@SuppressWarnings("restriction")
4848
public class BindingTableTests {
@@ -93,7 +93,7 @@ public class BindingTableTests {
9393
static IEclipseContext workbenchContext;
9494
private MApplication application;
9595

96-
@Before
96+
@BeforeEach
9797
public void setUp() throws Exception {
9898
IEclipseContext globalContext = TestUtil.getGlobalContext();
9999
workbenchContext = globalContext.createChild("workbenchContext");
@@ -389,7 +389,7 @@ private Binding getTestBinding(String commandId) {
389389

390390
private void assertContextSet(ContextSet set, String[] contextIds) {
391391
List<Context> contexts = set.getContexts();
392-
assertEquals(contexts.toString(), contextIds.length, contexts.size());
392+
assertEquals(contextIds.length, contexts.size(), contexts.toString());
393393
for (int i = 0; i < contextIds.length; i++) {
394394
assertEquals(contextIds[i], contexts.get(i).getId());
395395
}

tests/org.eclipse.e4.ui.bindings.tests/src/org/eclipse/e4/ui/bindings/tests/BindingTestSuite.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.ui.bindings.tests;
1616

17-
import org.junit.runner.RunWith;
18-
import org.junit.runners.Suite;
17+
import org.junit.platform.suite.api.SelectClasses;
18+
import org.junit.platform.suite.api.Suite;
1919

20-
@RunWith(Suite.class)
21-
@Suite.SuiteClasses({
20+
@Suite
21+
@SelectClasses({
2222
BindingLookupTest.class,
2323
KeyDispatcherTest.class,
2424
BindingTableTests.class,
2525
BindingCreateTest.class,
2626
KeyAssistDialogTest.class })
27-
2827
public class BindingTestSuite {
2928
}

tests/org.eclipse.e4.ui.bindings.tests/src/org/eclipse/e4/ui/bindings/tests/KeyAssistDialogTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*******************************************************************************/
1414
package org.eclipse.e4.ui.bindings.tests;
1515

16-
import static org.junit.Assert.assertFalse;
17-
import static org.junit.Assert.assertTrue;
16+
import static org.junit.jupiter.api.Assertions.assertFalse;
17+
import static org.junit.jupiter.api.Assertions.assertTrue;
1818
import static org.mockito.Mockito.mock;
1919
import static org.mockito.Mockito.when;
2020

@@ -27,7 +27,7 @@
2727
import org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher;
2828
import org.eclipse.jface.bindings.Binding;
2929
import org.eclipse.jface.bindings.keys.KeySequence;
30-
import org.junit.Test;
30+
import org.junit.jupiter.api.Test;
3131

3232
@SuppressWarnings("restriction")
3333
public class KeyAssistDialogTest {

tests/org.eclipse.e4.ui.bindings.tests/src/org/eclipse/e4/ui/bindings/tests/KeyDispatcherTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
*******************************************************************************/
1616
package org.eclipse.e4.ui.bindings.tests;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertFalse;
20-
import static org.junit.Assert.assertTrue;
18+
import static org.junit.jupiter.api.Assertions.*;
19+
import org.junit.jupiter.api.AfterEach;
20+
import org.junit.jupiter.api.BeforeEach;
21+
import org.junit.jupiter.api.Disabled;
22+
import org.junit.jupiter.api.Test;
2123

2224
import java.util.HashMap;
2325
import java.util.Map;
@@ -50,10 +52,6 @@
5052
import org.eclipse.swt.widgets.Event;
5153
import org.eclipse.swt.widgets.Listener;
5254
import org.eclipse.swt.widgets.Shell;
53-
import org.junit.After;
54-
import org.junit.Before;
55-
import org.junit.Ignore;
56-
import org.junit.Test;
5755

5856
@SuppressWarnings("restriction")
5957
public class KeyDispatcherTest {
@@ -129,7 +127,7 @@ private Binding createDefaultBinding(EBindingService bs,
129127
return bs.createBinding(sequence, command, ID_WINDOW, attrs);
130128
}
131129

132-
@Before
130+
@BeforeEach
133131
public void setUp() {
134132
display = Display.getDefault();
135133
IEclipseContext globalContext = TestUtil.getGlobalContext();
@@ -169,7 +167,7 @@ private void defineBindingTables(IEclipseContext context) {
169167
btm.addTable(new BindingTable(cm.getContext(ID_DIALOG), application));
170168
}
171169

172-
@After
170+
@AfterEach
173171
public void tearDown() {
174172
workbenchContext.dispose();
175173
workbenchContext = null;
@@ -236,7 +234,7 @@ public void testExecuteMultiStrokeBinding() {
236234
}
237235

238236
@Test
239-
@Ignore
237+
@Disabled
240238
public void TODOtestKeyDispatcherReset() throws Exception {
241239
assertFalse(twoStrokeHandler.q2);
242240

0 commit comments

Comments
 (0)