Skip to content

Commit 8cfdecd

Browse files
committed
Migrate tests to JUnit 5
1 parent c114f15 commit 8cfdecd

18 files changed

+93
-92
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/PatternUtilTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
package org.eclipse.ui.tests.activities;
1717

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

2121
import java.util.regex.Pattern;
2222

2323
import org.eclipse.ui.internal.activities.PatternUtil;
24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525

2626
/**
2727
* Test for:

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/UtilTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.tests.activities;
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.HashMap;
2222
import java.util.HashSet;
@@ -40,9 +40,9 @@
4040
import org.eclipse.ui.contexts.IContextActivation;
4141
import org.eclipse.ui.contexts.IContextService;
4242
import org.eclipse.ui.services.IEvaluationService;
43-
import org.junit.After;
44-
import org.junit.Before;
45-
import org.junit.Test;
43+
import org.junit.jupiter.api.AfterEach;
44+
import org.junit.jupiter.api.BeforeEach;
45+
import org.junit.jupiter.api.Test;
4646

4747
/**
4848
* Tests various utility methods on WorkbenchActivityHelper as well as other misc. activities functionality.
@@ -607,12 +607,12 @@ public void testSetEnabledExpressionActivity() {
607607
evalService.removeSourceProvider(testSourceProvider);
608608
}
609609

610-
@Before
610+
@BeforeEach
611611
public void setUp() throws Exception {
612612
rememberedSet = getActivityManager().getEnabledActivityIds();
613613
}
614614

615-
@After
615+
@AfterEach
616616
public void tearDown() throws Exception {
617617
PlatformUI.getWorkbench().getActivitySupport().setEnabledActivityIds(
618618
rememberedSet);

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorDescriptorTest.java

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

16-
import static org.junit.Assert.assertNotNull;
16+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1717

1818
import org.eclipse.ui.IEditorDescriptor;
1919
import org.eclipse.ui.IFileEditorMapping;
2020
import org.eclipse.ui.PlatformUI;
2121
import org.eclipse.ui.tests.harness.util.ArrayUtil;
22-
import org.junit.Before;
23-
import org.junit.Test;
22+
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.Test;
2424

2525
public class IEditorDescriptorTest {
2626
IEditorDescriptor[] fEditors;
2727

28-
@Before
28+
@BeforeEach
2929
public void setUp() {
3030
IFileEditorMapping mapping = (IFileEditorMapping) ArrayUtil
3131
.pickRandom(PlatformUI.getWorkbench().getEditorRegistry()

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IFileEditorMappingTest.java

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

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

2020
import org.eclipse.ui.IEditorDescriptor;
2121
import org.eclipse.ui.IFileEditorMapping;
2222
import org.eclipse.ui.PlatformUI;
2323
import org.eclipse.ui.tests.harness.util.ArrayUtil;
24-
import org.junit.Before;
25-
import org.junit.Ignore;
26-
import org.junit.Test;
24+
import org.junit.jupiter.api.BeforeEach;
25+
import org.junit.jupiter.api.Disabled;
26+
import org.junit.jupiter.api.Test;
2727

2828
public class IFileEditorMappingTest {
2929
private IFileEditorMapping[] fMappings;
3030

31-
@Before
31+
@BeforeEach
3232
public void setUp() {
3333
fMappings = PlatformUI.getWorkbench().getEditorRegistry()
3434
.getFileEditorMappings();
@@ -78,7 +78,7 @@ public void testGetImageDescriptor() throws Throwable {
7878

7979
//how do i set the default editor?
8080
@Test
81-
@Ignore
81+
@Disabled
8282
public void testGetDefaultEditor() throws Throwable {
8383
for (IFileEditorMapping fMapping : fMappings) {
8484
assertNotNull(fMapping.getDefaultEditor());

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPerspectiveDescriptorTest.java

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

16-
import static org.junit.Assert.assertNotNull;
17-
import static org.junit.Assert.assertTrue;
16+
import static org.junit.jupiter.api.Assertions.assertNotNull;
17+
import static org.junit.jupiter.api.Assertions.assertTrue;
1818

1919
import org.eclipse.jface.resource.ImageDescriptor;
2020
import org.eclipse.ui.IPerspectiveDescriptor;
2121
import org.eclipse.ui.PlatformUI;
22-
import org.junit.Before;
23-
import org.junit.Test;
22+
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.Test;
2424

2525
public class IPerspectiveDescriptorTest {
2626

2727
private IPerspectiveDescriptor[] fPerspectives;
2828

29-
@Before
29+
@BeforeEach
3030
public void setUp() {
3131
fPerspectives = PlatformUI
3232
.getWorkbench().getPerspectiveRegistry().getPerspectives();

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/XMLMementoTest.java

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

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

2020
import java.io.IOException;
2121
import java.io.Reader;
@@ -25,7 +25,7 @@
2525
import org.eclipse.ui.IMemento;
2626
import org.eclipse.ui.WorkbenchException;
2727
import org.eclipse.ui.XMLMemento;
28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

3030
/**
3131
* Testing XMLMemento (see bug 93262). Emphasis is on ensuring that the 3.1
@@ -52,8 +52,9 @@ public class XMLMementoTest {
5252
@Test
5353
public void testCreateReadRootReaderExceptionCases() {
5454
assertThrows(WorkbenchException.class, () -> XMLMemento.createReadRoot(new StringReader("Invalid format")));
55-
assertThrows("no exception even though there is noe element", WorkbenchException.class,
56-
() -> XMLMemento.createReadRoot(new StringReader("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>")));
55+
assertThrows(WorkbenchException.class,
56+
() -> XMLMemento.createReadRoot(new StringReader("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>")),
57+
"no exception even though there is noe element");
5758
assertThrows(WorkbenchException.class, () ->
5859
XMLMemento.createReadRoot(new Reader() {
5960

@@ -479,7 +480,7 @@ public void testIllegalKeys() {
479480

480481
for (final String key : illegalKeys) {
481482
XMLMemento memento = XMLMemento.createWriteRoot("foo");
482-
assertThrows("should fail with illegal key", Exception.class, () -> memento.putString(key, "some string"));
483+
assertThrows(Exception.class, () -> memento.putString(key, "some string"), "should fail with illegal key");
483484
}
484485
}
485486

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug73756Test.java

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

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

2020
import java.text.MessageFormat;
2121
import java.util.ResourceBundle;
@@ -26,8 +26,8 @@
2626
import org.eclipse.ui.statushandlers.StatusAdapter;
2727
import org.eclipse.ui.statushandlers.StatusManager;
2828
import org.eclipse.ui.tests.statushandlers.TestStatusHandler;
29-
import org.junit.Before;
30-
import org.junit.Test;
29+
import org.junit.jupiter.api.BeforeEach;
30+
import org.junit.jupiter.api.Test;
3131

3232
/**
3333
* A tests whether is active will log an exception if the command is not
@@ -50,7 +50,7 @@ public final class Bug73756Test {
5050

5151
private static String PLUGIN_ID = "org.eclipse.jface";
5252

53-
@Before
53+
@BeforeEach
5454
public void doTearDown() throws Exception {
5555
TestStatusHandler.uninstall();
5656
}
@@ -77,7 +77,7 @@ public final void testUndefinedCommandIsActiveLogged() throws Exception {
7777
* Checks whether the last handled status is correct
7878
*/
7979
private void assertStatusAdapter(StatusAdapter statusAdapter) {
80-
assertNotNull("A warning should have been logged.", statusAdapter);
80+
assertNotNull(statusAdapter, "A warning should have been logged.");
8181
IStatus status = statusAdapter.getStatus();
8282
assertEquals(status.getSeverity(), SEVERITY);
8383
assertEquals(status.getPlugin(), PLUGIN_ID);

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandManagerTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
package org.eclipse.ui.tests.commands;
1616

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

1919
import org.eclipse.core.commands.Category;
2020
import org.eclipse.core.commands.Command;
@@ -23,7 +23,7 @@
2323
import org.eclipse.core.commands.ExecutionException;
2424
import org.eclipse.core.commands.IExecutionListener;
2525
import org.eclipse.core.commands.NotHandledException;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
/**
2929
* Tests some of the API on command manager.
@@ -102,13 +102,13 @@ public final void testExecutionListener() {
102102
exception = e;
103103
}
104104

105-
assertSame("Should have received a pre-execute event for the correct command", commandId,
106-
listener.preExecuteId);
107-
assertSame("Should have received a pre-execute event with the correct event", event, listener.preExecuteEvent);
108-
assertSame("Should have received a not-handled event for the correct command", commandId,
109-
listener.notHandledId);
110-
assertSame("Should have received a not-handled event with the correct exception", exception,
111-
listener.notHandledException);
105+
assertSame(commandId,
106+
listener.preExecuteId, "Should have received a pre-execute event for the correct command");
107+
assertSame(event, listener.preExecuteEvent, "Should have received a pre-execute event with the correct event");
108+
assertSame(commandId,
109+
listener.notHandledId, "Should have received a not-handled event for the correct command");
110+
assertSame(exception,
111+
listener.notHandledException, "Should have received a not-handled event with the correct exception");
112112

113113
}
114114
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java

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

2323
import java.util.concurrent.atomic.AtomicReference;
2424

@@ -34,7 +34,7 @@
3434
import org.eclipse.ui.PlatformUI;
3535
import org.eclipse.ui.commands.ICommandService;
3636
import org.eclipse.ui.handlers.IHandlerService;
37-
import org.junit.Test;
37+
import org.junit.jupiter.api.Test;
3838

3939
public class CommandParameterTypeTest {
4040

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandSerializationTest.java

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

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

2121
import java.util.Map;
2222

@@ -26,7 +26,7 @@
2626
import org.eclipse.core.commands.common.NotDefinedException;
2727
import org.eclipse.ui.PlatformUI;
2828
import org.eclipse.ui.commands.ICommandService;
29-
import org.junit.Test;
29+
import org.junit.jupiter.api.Test;
3030

3131
/**
3232
* Test serialization and deserialization of ParameterizedCommands. See <a

0 commit comments

Comments
 (0)