Skip to content

Commit 15816d8

Browse files
committed
Migrate e4.ui.tests to JUnit 5 (except parameterized tests)
1 parent 4bf1ec5 commit 15816d8

40 files changed

Lines changed: 331 additions & 367 deletions

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/Bug299755Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
******************************************************************************/
1515
package org.eclipse.e4.ui.tests.application;
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 jakarta.inject.Inject;
2121
import jakarta.inject.Named;
@@ -25,7 +25,7 @@
2525
import org.eclipse.e4.core.contexts.IEclipseContext;
2626
import org.eclipse.e4.core.di.annotations.Optional;
2727
import org.eclipse.e4.ui.services.IServiceConstants;
28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

3030
public class Bug299755Test {
3131

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/Bug308220Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
******************************************************************************/
1515
package org.eclipse.e4.ui.tests.application;
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 jakarta.inject.Inject;
2121
import jakarta.inject.Named;
@@ -26,7 +26,7 @@
2626
import org.eclipse.e4.core.contexts.RunAndTrack;
2727
import org.eclipse.e4.core.di.annotations.Optional;
2828
import org.eclipse.e4.ui.services.IServiceConstants;
29-
import org.junit.Test;
29+
import org.junit.jupiter.api.Test;
3030

3131
public class Bug308220Test {
3232

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/Bug320857Test.java

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

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

2020
import jakarta.inject.Inject;
2121
import jakarta.inject.Named;
@@ -33,9 +33,9 @@
3333
import org.eclipse.e4.ui.workbench.IPresentationEngine;
3434
import org.eclipse.e4.ui.workbench.modeling.EModelService;
3535
import org.eclipse.emf.common.notify.Notifier;
36-
import org.junit.After;
37-
import org.junit.Before;
38-
import org.junit.Test;
36+
import org.junit.jupiter.api.AfterEach;
37+
import org.junit.jupiter.api.BeforeEach;
38+
import org.junit.jupiter.api.Test;
3939

4040
public class Bug320857Test {
4141

@@ -45,7 +45,7 @@ public class Bug320857Test {
4545

4646
private EModelService ems;
4747

48-
@Before
48+
@BeforeEach
4949
public void setUp() throws Exception {
5050
applicationContext = E4Application.createDefaultContext();
5151
ems = applicationContext.get(EModelService.class);
@@ -55,7 +55,7 @@ protected String getEngineURI() {
5555
return "bundleclass://org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.application.HeadlessContextPresentationEngine"; //$NON-NLS-1$
5656
}
5757

58-
@After
58+
@AfterEach
5959
public void tearDown() throws Exception {
6060
applicationContext.dispose();
6161
}

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/E4ResourceTest.java

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

1515
package org.eclipse.e4.ui.tests.application;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertNotNull;
19-
import static org.junit.Assert.assertSame;
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.assertSame;
2020

2121
import java.util.Map;
2222
import java.util.Map.Entry;
@@ -27,7 +27,7 @@
2727
import org.eclipse.e4.ui.model.application.ui.basic.MBasicFactory;
2828
import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow;
2929
import org.eclipse.emf.ecore.EObject;
30-
import org.junit.Test;
30+
import org.junit.jupiter.api.Test;
3131

3232
public class E4ResourceTest {
3333
@Test

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/EModelServiceFindTest.java

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

2323
import java.util.ArrayList;
2424
import java.util.List;
@@ -46,22 +46,22 @@
4646
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement;
4747
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
4848
import org.eclipse.e4.ui.workbench.modeling.EModelService;
49-
import org.junit.After;
50-
import org.junit.Before;
51-
import org.junit.Test;
49+
import org.junit.jupiter.api.AfterEach;
50+
import org.junit.jupiter.api.BeforeEach;
51+
import org.junit.jupiter.api.Test;
5252

5353
public class EModelServiceFindTest {
5454

5555
private IEclipseContext applicationContext;
5656

5757
MApplication app = null;
5858

59-
@Before
59+
@BeforeEach
6060
public void setUp() throws Exception {
6161
applicationContext = E4Application.createDefaultContext();
6262
}
6363

64-
@After
64+
@AfterEach
6565
public void tearDown() throws Exception {
6666
applicationContext.dispose();
6767
}

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/EModelServiceInsertTest.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
******************************************************************************/
1414
package org.eclipse.e4.ui.tests.application;
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.e4.core.contexts.IEclipseContext;
2121
import org.eclipse.e4.ui.internal.workbench.swt.E4Application;
@@ -28,9 +28,9 @@
2828
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
2929
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
3030
import org.eclipse.e4.ui.workbench.modeling.EModelService;
31-
import org.junit.After;
32-
import org.junit.Before;
33-
import org.junit.Test;
31+
import org.junit.jupiter.api.AfterEach;
32+
import org.junit.jupiter.api.BeforeEach;
33+
import org.junit.jupiter.api.Test;
3434

3535
public class EModelServiceInsertTest {
3636

@@ -40,13 +40,13 @@ public class EModelServiceInsertTest {
4040

4141
private EModelService ems;
4242

43-
@Before
43+
@BeforeEach
4444
public void setUp() throws Exception {
4545
applicationContext = E4Application.createDefaultContext();
4646
ems = applicationContext.get(EModelService.class);
4747
}
4848

49-
@After
49+
@AfterEach
5050
public void tearDown() throws Exception {
5151
applicationContext.dispose();
5252
}
@@ -113,20 +113,19 @@ private void testInsert(MApplication app, String relToId, int where, float ratio
113113
ratio);
114114

115115
MUIElement newPartParent = newPart.getParent();
116-
assertTrue("parent must be a sash",
117-
(newPartParent instanceof MPartSashContainer));
116+
assertTrue((newPartParent instanceof MPartSashContainer), "parent must be a sash");
118117
MPartSashContainer psc = (MPartSashContainer) newPartParent;
119118

120119
boolean horizontal = where == EModelService.LEFT_OF
121120
|| where == EModelService.RIGHT_OF;
122-
assertEquals("invalid sash orientation", horizontal, psc.isHorizontal());
121+
assertEquals(horizontal, psc.isHorizontal(), "invalid sash orientation");
123122

124123
if (where == EModelService.LEFT_OF || where == EModelService.ABOVE) {
125-
assertEquals("new part should be first", 0, psc.getChildren().indexOf(newPart));
126-
assertEquals("old part should be second", 1, psc.getChildren().indexOf(relTo));
124+
assertEquals(0, psc.getChildren().indexOf(newPart), "new part should be first");
125+
assertEquals(1, psc.getChildren().indexOf(relTo), "old part should be second");
127126
} else {
128-
assertEquals("old part should be first", 0, psc.getChildren().indexOf(relTo));
129-
assertEquals("new part should be second", 1, psc.getChildren().indexOf(newPart));
127+
assertEquals(0, psc.getChildren().indexOf(relTo), "old part should be first");
128+
assertEquals(1, psc.getChildren().indexOf(newPart), "new part should be second");
130129
}
131130
}
132131

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/EModelServiceTest.java

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

16-
import static org.junit.Assert.assertEquals;
17-
import static org.junit.Assert.assertNotNull;
18-
import static org.junit.Assert.assertSame;
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.assertSame;
19+
import static org.junit.jupiter.api.Assertions.assertTrue;
2020

2121
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;
2222
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
@@ -28,7 +28,7 @@
2828
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
2929
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
3030
import org.eclipse.e4.ui.workbench.modeling.EModelService;
31-
import org.junit.Test;
31+
import org.junit.jupiter.api.Test;
3232

3333
public class EModelServiceTest extends UITest {
3434

0 commit comments

Comments
 (0)