Skip to content

Commit 46febbb

Browse files
committed
Migrate org.eclipse.ui.tests.keys to JUnit5
* Updated imports to use org.junit.jupiter.api.*. * Replaced @before with @beforeeach and @after with @AfterEach. * Replaced @ignore with @disabled. * Converted @rule CloseTestWindowsRule to @ExtendWith(CloseTestWindowsExtension.class). * Updated assertions to follow the JUnit 5 argument order (expected, actual, message).
1 parent e358cd6 commit 46febbb

18 files changed

+303
-384
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingInteractionsTest.java

Lines changed: 62 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.tests.keys;
1515

16-
import static org.junit.Assert.assertEquals;
17-
import static org.junit.Assert.assertFalse;
18-
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.assertTrue;
1919

2020
import java.util.HashSet;
2121
import java.util.Locale;
@@ -30,9 +30,9 @@
3030
import org.eclipse.jface.bindings.Scheme;
3131
import org.eclipse.jface.bindings.TriggerSequence;
3232
import org.eclipse.jface.util.Util;
33-
import org.junit.After;
34-
import org.junit.Before;
35-
import org.junit.Test;
33+
import org.junit.jupiter.api.AfterEach;
34+
import org.junit.jupiter.api.BeforeEach;
35+
import org.junit.jupiter.api.Test;
3636

3737
/**
3838
* Test cases covering the various interaction between bindings. Bindings that
@@ -59,7 +59,7 @@ public final class BindingInteractionsTest {
5959
* Creates a new context manager and a binding manager for use in the test
6060
* cases.
6161
*/
62-
@Before
62+
@BeforeEach
6363
public void doSetUp() {
6464
contextManager = new ContextManager();
6565
bindingManager = new BindingManager(contextManager,
@@ -69,7 +69,7 @@ public void doSetUp() {
6969
/**
7070
* Releases the context manager and binding manager for garbage collection.
7171
*/
72-
@After
72+
@AfterEach
7373
public void doTearDown() {
7474
contextManager = null;
7575
bindingManager = null;
@@ -106,12 +106,10 @@ public void testConflict() throws NotDefinedException {
106106
TriggerSequence[] activeBindings = bindingManager
107107
.getActiveBindingsFor(binding1.getParameterizedCommand());
108108
assertFalse(binding1.equals(binding2));
109-
assertTrue("Neither binding should be active",
110-
activeBindings.length == 0);
109+
assertTrue(activeBindings.length == 0, "Neither binding should be active");
111110
activeBindings = bindingManager.getActiveBindingsFor(binding2
112111
.getParameterizedCommand());
113-
assertTrue("Neither binding should be active",
114-
activeBindings.length == 0);
112+
assertTrue(activeBindings.length == 0, "Neither binding should be active");
115113
}
116114

117115
/**
@@ -147,27 +145,24 @@ public void testContextOverride() throws NotDefinedException {
147145
final Set<String> activeContextIds = new HashSet<>();
148146
activeContextIds.add("parent");
149147
contextManager.setActiveContextIds(activeContextIds);
150-
assertEquals(
151-
"When only the parent context is active, only the parent binding is active.",
152-
binding1, bindingManager
153-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
148+
assertEquals(binding1,
149+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
150+
"When only the parent context is active, only the parent binding is active.");
154151

155152
// Only "child"
156153
activeContextIds.clear();
157154
activeContextIds.add("child");
158155
contextManager.setActiveContextIds(activeContextIds);
159-
assertEquals(
160-
"When only the child context is active, only the child binding is active.",
161-
binding2, bindingManager
162-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
156+
assertEquals(binding2,
157+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
158+
"When only the child context is active, only the child binding is active.");
163159

164160
// Both "parent" and "child"
165161
activeContextIds.add("parent");
166162
contextManager.setActiveContextIds(activeContextIds);
167-
assertEquals(
168-
"When both contexts are active, only the child binding is active.",
169-
binding2, bindingManager
170-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
163+
assertEquals(binding2,
164+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
165+
"When both contexts are active, only the child binding is active.");
171166
}
172167

173168
/**
@@ -197,8 +192,8 @@ public void testDeletedBinding() throws NotDefinedException {
197192
final Binding binding2 = new TestBinding("system", "na", "na", null,
198193
null, Binding.SYSTEM, null);
199194
bindingManager.addBinding(binding2);
200-
assertEquals("The user should be able to remove bindings", null,
201-
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
195+
assertEquals(null,
196+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE), "The user should be able to remove bindings");
202197
}
203198

204199
/**
@@ -235,11 +230,9 @@ public void testDeletedBindingAllowsParent() throws NotDefinedException {
235230
final Binding parentBinding = new TestBinding("parentCommand", "na",
236231
"parent", null, null, Binding.SYSTEM, null);
237232
bindingManager.addBinding(parentBinding);
238-
assertEquals(
239-
"The user should be able to remove bindings to allow a parent binding",
240-
"parentCommand", bindingManager.getPerfectMatch(
241-
TestBinding.TRIGGER_SEQUENCE).getParameterizedCommand()
242-
.getId());
233+
assertEquals("parentCommand",
234+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE).getParameterizedCommand().getId(),
235+
"The user should be able to remove bindings to allow a parent binding");
243236
}
244237

245238
/**
@@ -276,10 +269,9 @@ public void testDeletedBindingPlatform() throws NotDefinedException {
276269
final Binding platformSpecific = new TestBinding("platformSpecific",
277270
na, na, null, Util.getWS(), Binding.SYSTEM, null);
278271
bindingManager.addBinding(platformSpecific);
279-
assertEquals(
280-
"We should be able to change a binding on a particular platform",
281-
platformSpecific, bindingManager
282-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
272+
assertEquals(platformSpecific,
273+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
274+
"We should be able to change a binding on a particular platform");
283275
}
284276

285277
/**
@@ -316,10 +308,9 @@ public void testDeletedBindingUnnecessarily() throws NotDefinedException {
316308
bindings[1] = binding2;
317309
bindings[2] = binding3;
318310
bindingManager.setBindings(bindings);
319-
assertEquals(
320-
"A binding should not cause a deletion if its locale or platform doesn't match",
321-
binding2, bindingManager
322-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
311+
assertEquals(binding2,
312+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
313+
"A binding should not cause a deletion if its locale or platform doesn't match");
323314
}
324315

325316
/**
@@ -353,8 +344,8 @@ public void testDeletedBindingWithAddition() throws NotDefinedException {
353344
final Binding binding3 = new TestBinding("user", "na", "na", null,
354345
null, Binding.USER, null);
355346
bindingManager.addBinding(binding3);
356-
assertEquals("The user redefine a particular binding", binding3,
357-
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
347+
assertEquals(binding3,
348+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE), "The user redefine a particular binding");
358349
}
359350

360351
/**
@@ -388,9 +379,8 @@ public void testDeletedBindingWithUserOverride() throws NotDefinedException {
388379
context.getId(), null, bindingManager.getPlatform(),
389380
Binding.USER, null);
390381
bindingManager.addBinding(userOverride);
391-
assertEquals("The user redefine a binding deleted in the system",
392-
userOverride, bindingManager
393-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
382+
assertEquals(userOverride,
383+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE), "The user redefine a binding deleted in the system");
394384

395385
}
396386

@@ -435,8 +425,8 @@ public void testDoubleDeletedBinding() {
435425
bindingManager.addBinding(wrongDeletion);
436426

437427
// Test that the deletion worked.
438-
assertEquals("The parent should not be active", null, bindingManager
439-
.getPerfectMatch(binding.getTriggerSequence()));
428+
assertEquals(null, bindingManager
429+
.getPerfectMatch(binding.getTriggerSequence()), "The parent should not be active");
440430
}
441431

442432
/**
@@ -478,12 +468,10 @@ public void testDoubleParent() throws NotDefinedException {
478468
bindingManager.addBinding(childBinding);
479469

480470
// Test to see that only the child is active.
481-
assertTrue("The parent should not be active",
482-
bindingManager.getActiveBindingsFor(parentBinding
483-
.getParameterizedCommand()).length == 0);
484-
assertTrue("The child should be active",
485-
bindingManager.getActiveBindingsFor(childBinding
486-
.getParameterizedCommand()).length != 0);
471+
assertTrue(bindingManager.getActiveBindingsFor(parentBinding
472+
.getParameterizedCommand()).length == 0, "The parent should not be active");
473+
assertTrue(bindingManager.getActiveBindingsFor(childBinding
474+
.getParameterizedCommand()).length != 0, "The child should be active");
487475
}
488476

489477
/**
@@ -517,10 +505,9 @@ public void testLocaleOverride() throws NotDefinedException {
517505
final Binding binding3 = new TestBinding("locale-specific", "na", "na",
518506
Locale.getDefault().toString(), null, Binding.SYSTEM, null);
519507
bindingManager.addBinding(binding3);
520-
assertEquals(
521-
"A plug-in developer should be able to change a binding for a locale",
522-
binding3, bindingManager
523-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
508+
assertEquals(binding3,
509+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
510+
"A plug-in developer should be able to change a binding for a locale");
524511
}
525512

526513
/**
@@ -554,10 +541,9 @@ public void testPlatformOverride() throws NotDefinedException {
554541
final Binding binding3 = new TestBinding("platform-specific", "na",
555542
"na", null, Util.getWS(), Binding.SYSTEM, null);
556543
bindingManager.addBinding(binding3);
557-
assertEquals(
558-
"A plug-in developer should be able to change a binding for a platform",
559-
binding3, bindingManager
560-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
544+
assertEquals(binding3,
545+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
546+
"A plug-in developer should be able to change a binding for a platform");
561547
}
562548

563549
/**
@@ -598,9 +584,8 @@ public void testSchemeOverride() throws NotDefinedException {
598584
final Binding binding2 = new TestBinding("parent", "parent", "na",
599585
null, null, Binding.SYSTEM, null);
600586
bindingManager.addBinding(binding2);
601-
assertEquals("The binding from the child scheme should be active",
602-
binding1, bindingManager
603-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
587+
assertEquals(binding1,
588+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE), "The binding from the child scheme should be active");
604589
}
605590

606591
/**
@@ -641,9 +626,8 @@ public void testSchemeOverrideDifferentContexts()
641626
final Binding binding2 = new TestBinding("child", childScheme.getId(),
642627
parentContext.getId(), null, null, Binding.SYSTEM, null);
643628
bindingManager.addBinding(binding2);
644-
assertEquals("The binding from the child scheme should be active",
645-
binding2, bindingManager
646-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
629+
assertEquals(binding2,
630+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE), "The binding from the child scheme should be active");
647631
}
648632

649633
/**
@@ -684,9 +668,8 @@ public void testSchemeOverrideDifferentTypes() throws NotDefinedException {
684668
final Binding binding2 = new TestBinding("parent", "parent", "na",
685669
null, null, Binding.USER, null);
686670
bindingManager.addBinding(binding2);
687-
assertEquals("The binding from the child scheme should be active",
688-
binding1, bindingManager
689-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
671+
assertEquals(binding1,
672+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE), "The binding from the child scheme should be active");
690673
}
691674

692675
/**
@@ -722,26 +705,23 @@ public void testSiblingContextConflict() throws NotDefinedException {
722705
final Set<String> activeContextIds = new HashSet<>();
723706
activeContextIds.add("sibling1");
724707
contextManager.setActiveContextIds(activeContextIds);
725-
assertEquals(
726-
"When only the first sibling is active, only the first binding is active",
727-
binding1, bindingManager
728-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
708+
assertEquals(binding1,
709+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
710+
"When only the first sibling is active, only the first binding is active");
729711

730712
// Other sibling active
731713
activeContextIds.clear();
732714
activeContextIds.add("sibling2");
733715
contextManager.setActiveContextIds(activeContextIds);
734-
assertEquals(
735-
"When only the second sibling is active, only the second binding is active",
736-
binding2, bindingManager
737-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
716+
assertEquals(binding2,
717+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE),
718+
"When only the second sibling is active, only the second binding is active");
738719

739720
// Both siblings are active
740721
activeContextIds.add("sibling1");
741722
contextManager.setActiveContextIds(activeContextIds);
742-
assertEquals("When both contexts are active, a conflict should occur",
743-
null, bindingManager
744-
.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
723+
assertEquals(null,
724+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE), "When both contexts are active, a conflict should occur");
745725
}
746726

747727
/**
@@ -779,7 +759,7 @@ public void testUserOverride() throws NotDefinedException {
779759
final Binding binding2 = new TestBinding("system", "na", "na", null,
780760
null, Binding.SYSTEM, null);
781761
bindingManager.addBinding(binding2);
782-
assertEquals("The user-defined binding should be active", binding1,
783-
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
762+
assertEquals(binding1,
763+
bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE), "The user-defined binding should be active");
784764
}
785765
}

0 commit comments

Comments
 (0)