Skip to content

Commit 34e3f47

Browse files
vogellaakurtakov
authored andcommitted
Migration of ui.tests.forms from JUnit4 to JUnit5
1 parent e900fff commit 34e3f47

22 files changed

+310
-298
lines changed

tests/org.eclipse.ui.tests.forms/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Bundle-Version: 3.10.600.qualifier
66
Require-Bundle: org.eclipse.ui,
77
org.eclipse.core.runtime,
88
org.eclipse.test.performance,
9-
org.eclipse.ui.forms,
10-
org.junit
9+
org.eclipse.ui.forms
1110
Bundle-Vendor: Eclipse.org
1211
Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
12+
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
1313
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"
1414
Bundle-RequiredExecutionEnvironment: JavaSE-17
1515
Eclipse-BundleShape: dir

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsPerformanceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
package org.eclipse.ui.tests.forms;
1616

1717
import org.eclipse.ui.tests.forms.performance.FormsPerformanceTest;
18-
1918
import org.junit.platform.suite.api.SelectClasses;
2019
import org.junit.platform.suite.api.Suite;
2120

21+
2222
/*
2323
* Tests forms performance (automated).
2424
*/

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
import org.eclipse.ui.tests.forms.layout.AllLayoutTests;
2121
import org.eclipse.ui.tests.forms.util.AllUtilityTests;
2222
import org.eclipse.ui.tests.forms.widgets.AllWidgetsTests;
23-
2423
import org.junit.platform.suite.api.SelectClasses;
2524
import org.junit.platform.suite.api.Suite;
2625

26+
2727
/**
2828
* Tests all forms functionality (automated).
2929
*/

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/AllEventsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.eclipse.ui.tests.forms.events;
22

3-
import org.junit.platform.suite.api.Suite;
43
import org.junit.platform.suite.api.SelectClasses;
4+
import org.junit.platform.suite.api.Suite;
55

66
@Suite
77
@SelectClasses({ ExpansionListenerTest.class, //
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.eclipse.ui.tests.forms.events;
22

3-
import static org.junit.Assert.assertEquals;
3+
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertThrows;
46

57
import java.util.function.Consumer;
68

@@ -9,10 +11,10 @@
911
import org.eclipse.ui.forms.events.ExpansionEvent;
1012
import org.eclipse.ui.forms.events.IExpansionListener;
1113
import org.eclipse.ui.forms.widgets.Section;
12-
import org.junit.AfterClass;
13-
import org.junit.Before;
14-
import org.junit.BeforeClass;
15-
import org.junit.Test;
14+
import org.junit.jupiter.api.AfterAll;
15+
import org.junit.jupiter.api.BeforeAll;
16+
import org.junit.jupiter.api.BeforeEach;
17+
import org.junit.jupiter.api.Test;
1618

1719
public class ExpansionListenerTest {
1820

@@ -22,19 +24,19 @@ public class ExpansionListenerTest {
2224
private static Shell shell;
2325
private static Section section;
2426

25-
@BeforeClass
27+
@BeforeAll
2628
public static void classSetup() {
2729
shell = new Shell();
2830
section = new Section(shell, SWT.NONE);
2931
}
3032

31-
@Before
33+
@BeforeEach
3234
public void setup() {
3335
firedEvent = new ExpansionEvent(section, true);
3436
expansionEventConsumer = event -> this.catchedEvent = event;
3537
}
3638

37-
@AfterClass
39+
@AfterAll
3840
public static void classTeardown() {
3941
shell.dispose();
4042
}
@@ -50,14 +52,13 @@ public void callsExpansionStateChangingConsumer() {
5052
IExpansionListener.expansionStateChangingAdapter(expansionEventConsumer).expansionStateChanging(firedEvent);
5153
assertEquals(firedEvent, catchedEvent);
5254
}
53-
54-
@Test(expected = NullPointerException.class)
55-
public void throwsNullPointerOnNullStateChangedAdapter() {
56-
IExpansionListener.expansionStateChangedAdapter(null);
55+
@Test
56+
void throwsNullPointerOnNullStateChangedAdapter() {
57+
assertThrows(NullPointerException.class, () -> IExpansionListener.expansionStateChangedAdapter(null));
5758
}
5859

59-
@Test(expected = NullPointerException.class)
60-
public void throwsNullPointerOnNullStateChangingAdapter() {
61-
IExpansionListener.expansionStateChangingAdapter(null);
60+
@Test
61+
void throwsNullPointerOnNullStateChangingAdapter() {
62+
assertThrows(NullPointerException.class, () -> IExpansionListener.expansionStateChangingAdapter(null));
6263
}
6364
}

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/HyperLinkListenerTest.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.eclipse.ui.tests.forms.events;
22

3-
import static org.junit.Assert.assertEquals;
3+
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertThrows;
46

57
import java.util.function.Consumer;
68

@@ -9,10 +11,10 @@
911
import org.eclipse.swt.widgets.Shell;
1012
import org.eclipse.ui.forms.events.HyperlinkEvent;
1113
import org.eclipse.ui.forms.events.IHyperlinkListener;
12-
import org.junit.AfterClass;
13-
import org.junit.Before;
14-
import org.junit.BeforeClass;
15-
import org.junit.Test;
14+
import org.junit.jupiter.api.AfterAll;
15+
import org.junit.jupiter.api.BeforeAll;
16+
import org.junit.jupiter.api.BeforeEach;
17+
import org.junit.jupiter.api.Test;
1618

1719
public class HyperLinkListenerTest {
1820

@@ -22,19 +24,19 @@ public class HyperLinkListenerTest {
2224
private Consumer<HyperlinkEvent> linkEventConsumer;
2325
private static Link link;
2426

25-
@BeforeClass
27+
@BeforeAll
2628
public static void classSetup() {
2729
shell = new Shell();
2830
link = new Link(shell, SWT.NONE);
2931
}
3032

31-
@Before
33+
@BeforeEach
3234
public void setup() {
3335
firedEvent = new HyperlinkEvent(link, "uri://test", "link", 0);
3436
linkEventConsumer = event -> this.catchedEvent = event;
3537
}
3638

37-
@AfterClass
39+
@AfterAll
3840
public static void classTeardown() {
3941
shell.dispose();
4042
}
@@ -57,18 +59,19 @@ public void callsEnteredConsumer() {
5759
assertEquals(firedEvent, catchedEvent);
5860
}
5961

60-
@Test(expected = NullPointerException.class)
62+
@Test
6163
public void throwsNullPointerOnNullActivatedAdapter() {
62-
IHyperlinkListener.linkActivatedAdapter(null);
64+
assertThrows(NullPointerException.class, () -> IHyperlinkListener.linkActivatedAdapter(null));
6365
}
6466

65-
@Test(expected = NullPointerException.class)
67+
@Test
6668
public void throwsNullPointerOnNullExitedAdapter() {
67-
IHyperlinkListener.linkExitedAdapter(null);
69+
assertThrows(NullPointerException.class, () -> IHyperlinkListener.linkExitedAdapter(null));
6870
}
6971

70-
@Test(expected = NullPointerException.class)
72+
@Test
7173
public void throwsNullPointerOnNullEnteredAdapter() {
72-
IHyperlinkListener.linkEnteredAdapter(null);
74+
assertThrows(NullPointerException.class, () -> IHyperlinkListener.linkEnteredAdapter(null));
7375
}
76+
7477
}

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/AllLayoutTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import org.eclipse.ui.tests.forms.widgets.HintAdjustmentTest;
1919
import org.eclipse.ui.tests.forms.widgets.SizeCacheTest;
20-
2120
import org.junit.platform.suite.api.SelectClasses;
2221
import org.junit.platform.suite.api.Suite;
2322

23+
2424
/**
2525
* Test all form layouts
2626
*/

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestColumnWrapLayout.java

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

1616
package org.eclipse.ui.tests.forms.layout;
1717

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

2021
import org.eclipse.swt.SWT;
2122
import org.eclipse.swt.graphics.Point;
@@ -29,9 +30,9 @@
2930
import org.eclipse.ui.forms.widgets.ColumnLayoutData;
3031
import org.eclipse.ui.internal.forms.widgets.ColumnLayoutUtils;
3132
import org.eclipse.ui.tests.forms.layout.ControlFactory.TestLayout;
32-
import org.junit.After;
33-
import org.junit.Before;
34-
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;
3536

3637
public class TestColumnWrapLayout {
3738

@@ -46,7 +47,7 @@ public class TestColumnWrapLayout {
4647
private Composite inner;
4748
private ColumnLayout layout;
4849

49-
@Before
50+
@BeforeEach
5051
public void setUp() {
5152
display = PlatformUI.getWorkbench().getDisplay();
5253
shell = new Shell(display);
@@ -62,7 +63,7 @@ public void setUp() {
6263
inner.setLayout(layout);
6364
}
6465

65-
@After
66+
@AfterEach
6667
public void tearDown() {
6768
shell.dispose();
6869
}
@@ -348,7 +349,7 @@ private void assertAllChildrenHaveWidth(int desiredWidth) {
348349
Control next = children[idx];
349350

350351
Rectangle bounds = next.getBounds();
351-
assertEquals("Child " + idx + " should have the correct width", desiredWidth, bounds.width);
352+
assertEquals(desiredWidth, bounds.width, "Child " + idx + " should have the correct width");
352353
}
353354
}
354355
}

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestTableWrapLayout.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
package org.eclipse.ui.tests.forms.layout;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertTrue;
18+
19+
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
2021

2122
import org.eclipse.swt.SWT;
2223
import org.eclipse.swt.graphics.Point;
@@ -30,9 +31,9 @@
3031
import org.eclipse.ui.PlatformUI;
3132
import org.eclipse.ui.forms.widgets.TableWrapData;
3233
import org.eclipse.ui.forms.widgets.TableWrapLayout;
33-
import org.junit.After;
34-
import org.junit.Before;
35-
import org.junit.Test;
34+
import org.junit.jupiter.api.AfterEach;
35+
import org.junit.jupiter.api.BeforeEach;
36+
import org.junit.jupiter.api.Test;
3637

3738
public class TestTableWrapLayout {
3839

@@ -47,7 +48,7 @@ private int rightEdge(Control lab) {
4748
return r.x + r.width;
4849
}
4950

50-
@Before
51+
@BeforeEach
5152
public void setUp() {
5253
display = PlatformUI.getWorkbench().getDisplay();
5354
shell = new Shell(display);
@@ -64,7 +65,7 @@ public void setUp() {
6465
inner.setLayout(layout);
6566
}
6667

67-
@After
68+
@AfterEach
6869
public void tearDown() {
6970
shell.dispose();
7071
}
@@ -135,8 +136,8 @@ public void testTableWrapLayoutWrappingLabels() {
135136
inner.setSize(300, 1000);
136137
inner.layout(false);
137138

138-
assertEquals("l1 had the wrong bounds", new Rectangle(0, 0, 300, 10), l1.getBounds());
139-
assertEquals("l2 had the wrong bounds", new Rectangle(0, 10, 300, 40), l2.getBounds());
139+
assertEquals(new Rectangle(0, 0, 300, 10), l1.getBounds(), "l1 had the wrong bounds");
140+
assertEquals(new Rectangle(0, 10, 300, 40), l2.getBounds(), "l2 had the wrong bounds");
140141
}
141142

142143
/**

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/performance/FormsPerformanceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import org.eclipse.ui.forms.widgets.Section;
4343
import org.eclipse.ui.forms.widgets.TableWrapData;
4444
import org.eclipse.ui.forms.widgets.TableWrapLayout;
45-
import org.junit.Test;
45+
import org.junit.jupiter.api.Test;
4646

4747
public class FormsPerformanceTest extends PerformanceTestCase {
4848

0 commit comments

Comments
 (0)