diff --git a/tests/org.eclipse.ui.tests.forms/META-INF/MANIFEST.MF b/tests/org.eclipse.ui.tests.forms/META-INF/MANIFEST.MF index e677e18550c..6e58cf821b4 100755 --- a/tests/org.eclipse.ui.tests.forms/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.ui.tests.forms/META-INF/MANIFEST.MF @@ -6,10 +6,10 @@ Bundle-Version: 3.10.600.qualifier Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.test.performance, - org.eclipse.ui.forms, - org.junit + org.eclipse.ui.forms Bundle-Vendor: Eclipse.org Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)", + org.junit.jupiter.api.function;version="[5.14.0,6.0.0)", org.junit.platform.suite.api;version="[1.14.0,2.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 Eclipse-BundleShape: dir diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsPerformanceTests.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsPerformanceTests.java index d87c1150dea..5e54f837fc5 100755 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsPerformanceTests.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsPerformanceTests.java @@ -15,10 +15,10 @@ package org.eclipse.ui.tests.forms; import org.eclipse.ui.tests.forms.performance.FormsPerformanceTest; - import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; + /* * Tests forms performance (automated). */ diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsTests.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsTests.java index 27d0d0eec38..1fbd271b2d8 100755 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsTests.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/AllFormsTests.java @@ -20,10 +20,10 @@ import org.eclipse.ui.tests.forms.layout.AllLayoutTests; import org.eclipse.ui.tests.forms.util.AllUtilityTests; import org.eclipse.ui.tests.forms.widgets.AllWidgetsTests; - import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; + /** * Tests all forms functionality (automated). */ diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/AllEventsTests.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/AllEventsTests.java index 81b8b22ac8e..afce700e270 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/AllEventsTests.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/AllEventsTests.java @@ -1,7 +1,7 @@ package org.eclipse.ui.tests.forms.events; -import org.junit.platform.suite.api.Suite; import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; @Suite @SelectClasses({ ExpansionListenerTest.class, // diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/ExpansionListenerTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/ExpansionListenerTest.java index c0d52715cbb..59d82e5047f 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/ExpansionListenerTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/ExpansionListenerTest.java @@ -1,6 +1,8 @@ package org.eclipse.ui.tests.forms.events; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.function.Consumer; @@ -9,10 +11,10 @@ import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.events.IExpansionListener; import org.eclipse.ui.forms.widgets.Section; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ExpansionListenerTest { @@ -22,19 +24,19 @@ public class ExpansionListenerTest { private static Shell shell; private static Section section; - @BeforeClass + @BeforeAll public static void classSetup() { shell = new Shell(); section = new Section(shell, SWT.NONE); } - @Before + @BeforeEach public void setup() { firedEvent = new ExpansionEvent(section, true); expansionEventConsumer = event -> this.catchedEvent = event; } - @AfterClass + @AfterAll public static void classTeardown() { shell.dispose(); } @@ -50,14 +52,13 @@ public void callsExpansionStateChangingConsumer() { IExpansionListener.expansionStateChangingAdapter(expansionEventConsumer).expansionStateChanging(firedEvent); assertEquals(firedEvent, catchedEvent); } - - @Test(expected = NullPointerException.class) - public void throwsNullPointerOnNullStateChangedAdapter() { - IExpansionListener.expansionStateChangedAdapter(null); + @Test + void throwsNullPointerOnNullStateChangedAdapter() { + assertThrows(NullPointerException.class, () -> IExpansionListener.expansionStateChangedAdapter(null)); } - @Test(expected = NullPointerException.class) - public void throwsNullPointerOnNullStateChangingAdapter() { - IExpansionListener.expansionStateChangingAdapter(null); + @Test + void throwsNullPointerOnNullStateChangingAdapter() { + assertThrows(NullPointerException.class, () -> IExpansionListener.expansionStateChangingAdapter(null)); } } \ No newline at end of file diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/HyperLinkListenerTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/HyperLinkListenerTest.java index 6c06163aeab..11c42c298ec 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/HyperLinkListenerTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/events/HyperLinkListenerTest.java @@ -1,6 +1,8 @@ package org.eclipse.ui.tests.forms.events; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.function.Consumer; @@ -9,10 +11,10 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.events.IHyperlinkListener; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class HyperLinkListenerTest { @@ -22,19 +24,19 @@ public class HyperLinkListenerTest { private Consumer linkEventConsumer; private static Link link; - @BeforeClass + @BeforeAll public static void classSetup() { shell = new Shell(); link = new Link(shell, SWT.NONE); } - @Before + @BeforeEach public void setup() { firedEvent = new HyperlinkEvent(link, "uri://test", "link", 0); linkEventConsumer = event -> this.catchedEvent = event; } - @AfterClass + @AfterAll public static void classTeardown() { shell.dispose(); } @@ -57,18 +59,19 @@ public void callsEnteredConsumer() { assertEquals(firedEvent, catchedEvent); } - @Test(expected = NullPointerException.class) + @Test public void throwsNullPointerOnNullActivatedAdapter() { - IHyperlinkListener.linkActivatedAdapter(null); + assertThrows(NullPointerException.class, () -> IHyperlinkListener.linkActivatedAdapter(null)); } - @Test(expected = NullPointerException.class) + @Test public void throwsNullPointerOnNullExitedAdapter() { - IHyperlinkListener.linkExitedAdapter(null); + assertThrows(NullPointerException.class, () -> IHyperlinkListener.linkExitedAdapter(null)); } - @Test(expected = NullPointerException.class) + @Test public void throwsNullPointerOnNullEnteredAdapter() { - IHyperlinkListener.linkEnteredAdapter(null); + assertThrows(NullPointerException.class, () -> IHyperlinkListener.linkEnteredAdapter(null)); } + } \ No newline at end of file diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/AllLayoutTests.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/AllLayoutTests.java index bcff254142c..a3c32ec4fd7 100755 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/AllLayoutTests.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/AllLayoutTests.java @@ -17,10 +17,10 @@ import org.eclipse.ui.tests.forms.widgets.HintAdjustmentTest; import org.eclipse.ui.tests.forms.widgets.SizeCacheTest; - import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; + /** * Test all form layouts */ diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestColumnWrapLayout.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestColumnWrapLayout.java index ba9957a8ba9..032ef41bf2a 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestColumnWrapLayout.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestColumnWrapLayout.java @@ -15,7 +15,8 @@ package org.eclipse.ui.tests.forms.layout; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; @@ -29,9 +30,9 @@ import org.eclipse.ui.forms.widgets.ColumnLayoutData; import org.eclipse.ui.internal.forms.widgets.ColumnLayoutUtils; import org.eclipse.ui.tests.forms.layout.ControlFactory.TestLayout; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class TestColumnWrapLayout { @@ -46,7 +47,7 @@ public class TestColumnWrapLayout { private Composite inner; private ColumnLayout layout; - @Before + @BeforeEach public void setUp() { display = PlatformUI.getWorkbench().getDisplay(); shell = new Shell(display); @@ -62,7 +63,7 @@ public void setUp() { inner.setLayout(layout); } - @After + @AfterEach public void tearDown() { shell.dispose(); } @@ -348,7 +349,7 @@ private void assertAllChildrenHaveWidth(int desiredWidth) { Control next = children[idx]; Rectangle bounds = next.getBounds(); - assertEquals("Child " + idx + " should have the correct width", desiredWidth, bounds.width); + assertEquals(desiredWidth, bounds.width, "Child " + idx + " should have the correct width"); } } } diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestTableWrapLayout.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestTableWrapLayout.java index 0fa13fc0978..bf466498741 100755 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestTableWrapLayout.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/layout/TestTableWrapLayout.java @@ -15,8 +15,9 @@ package org.eclipse.ui.tests.forms.layout; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; @@ -30,9 +31,9 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class TestTableWrapLayout { @@ -47,7 +48,7 @@ private int rightEdge(Control lab) { return r.x + r.width; } - @Before + @BeforeEach public void setUp() { display = PlatformUI.getWorkbench().getDisplay(); shell = new Shell(display); @@ -64,7 +65,7 @@ public void setUp() { inner.setLayout(layout); } - @After + @AfterEach public void tearDown() { shell.dispose(); } @@ -135,8 +136,8 @@ public void testTableWrapLayoutWrappingLabels() { inner.setSize(300, 1000); inner.layout(false); - assertEquals("l1 had the wrong bounds", new Rectangle(0, 0, 300, 10), l1.getBounds()); - assertEquals("l2 had the wrong bounds", new Rectangle(0, 10, 300, 40), l2.getBounds()); + assertEquals(new Rectangle(0, 0, 300, 10), l1.getBounds(), "l1 had the wrong bounds"); + assertEquals(new Rectangle(0, 10, 300, 40), l2.getBounds(), "l2 had the wrong bounds"); } /** diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/performance/FormsPerformanceTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/performance/FormsPerformanceTest.java index a2c3574b5a2..3c923d84a98 100755 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/performance/FormsPerformanceTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/performance/FormsPerformanceTest.java @@ -42,7 +42,7 @@ import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FormsPerformanceTest extends PerformanceTestCase { diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormColorsTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormColorsTest.java index fe7d9e8f22f..6ace809096e 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormColorsTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormColorsTest.java @@ -15,15 +15,16 @@ package org.eclipse.ui.tests.forms.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.forms.FormColors; import org.eclipse.ui.forms.IFormColors; import org.eclipse.ui.forms.widgets.FormToolkit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FormColorsTest { @@ -65,14 +66,14 @@ public void testStandalone() { Color fg = fColors.getForeground(); Color bc = fColors.getBorderColor(); for (int i = 0; i < KEYS_NON_NULL.length; i++) - assertEquals("FormColors did not return the same instance for key: " + KEYS_NON_NULL[i], colors[i], fColors.getColor(KEYS_NON_NULL[i])); + assertEquals(colors[i], fColors.getColor(KEYS_NON_NULL[i]), "FormColors did not return the same instance for key: " + KEYS_NON_NULL[i]); for (int i = 0; i < KEYS_NULL.length; i++) - assertEquals("FormColors did not return the same instance for key: " + KEYS_NULL[i], nullColors[i], fColors.getColor(KEYS_NULL[i])); - assertEquals("FormColors did not return the same instance for getInactiveBackground()", inactiveBg, - fColors.getInactiveBackground()); - assertEquals("FormColors did not return the same instance for getBackground()", bg, fColors.getBackground()); - assertEquals("FormColors did not return the same instance for getForeground()", fg, fColors.getForeground()); - assertEquals("FormColors did not return the same instance for getBorderColor()", bc, fColors.getBorderColor()); + assertEquals(nullColors[i], fColors.getColor(KEYS_NULL[i]), "FormColors did not return the same instance for key: " + KEYS_NULL[i]); + assertEquals(inactiveBg, fColors.getInactiveBackground(), + "FormColors did not return the same instance for getInactiveBackground()"); + assertEquals(bg, fColors.getBackground(), "FormColors did not return the same instance for getBackground()"); + assertEquals(fg, fColors.getForeground(), "FormColors did not return the same instance for getForeground()"); + assertEquals(bc, fColors.getBorderColor(), "FormColors did not return the same instance for getBorderColor()"); fColors.dispose(); } @@ -101,30 +102,26 @@ public void testMultiple() { Color fg2 = fColors2.getForeground(); Color bc2 = fColors2.getBorderColor(); for (int i = 0; i < KEYS_NON_NULL.length; i++) - assertEquals("Different concurrent instances of FormColors did not return the same Color for key: " - + KEYS_NON_NULL[i], colors[i], colors2[i]); + assertEquals(colors[i], colors2[i], "Different concurrent instances of FormColors did not return the same Color for key: " + + KEYS_NON_NULL[i]); for (int i = 0; i < KEYS_NULL.length; i++) - assertEquals("Different concurrent instances of FormColors did not return the same Color for key: " - + KEYS_NULL[i], nullColors[i], nullColors2[i]); - assertEquals( - "Different concurrent instances of FormColors did not return the same Color for getInactiveBackground()", - inactiveBg, inactiveBg2); - assertEquals("Different concurrent instances of FormColors did not return the same Color for getBackground()", - bg, bg2); - assertEquals("Different concurrent instances of FormColors did not return the same Color for getForeground()", - fg, fg2); - assertEquals("Different concurrent instances of FormColors did not return the same Color for getBorderColor()", - bc, bc2); + assertEquals(nullColors[i], nullColors2[i], "Different concurrent instances of FormColors did not return the same Color for key: " + + KEYS_NULL[i]); + assertEquals(inactiveBg, inactiveBg2, + "Different concurrent instances of FormColors did not return the same Color for getInactiveBackground()"); + assertEquals(bg, bg2, "Different concurrent instances of FormColors did not return the same Color for getBackground()"); + assertEquals(fg, fg2, "Different concurrent instances of FormColors did not return the same Color for getForeground()"); + assertEquals(bc, bc2, "Different concurrent instances of FormColors did not return the same Color for getBorderColor()"); fColors2.dispose(); for (int i = 0; i < KEYS_NON_NULL.length; i++) - assertFalse("FormColors disposed different instance's key: " + KEYS_NON_NULL[i], colors[i].isDisposed()); + assertFalse(colors[i].isDisposed(), "FormColors disposed different instance's key: " + KEYS_NON_NULL[i]); for (int i = 0; i < KEYS_NULL.length; i++) - assertFalse("FormColors disposed different instance's key: " + KEYS_NULL[i], - nullColors[i] != null && nullColors[i].isDisposed()); - assertFalse("FormColors disposed different instance's getInactiveBackground()", inactiveBg.isDisposed()); - assertFalse("FormColors disposed different instance's getBackground()", bg.isDisposed()); - assertFalse("FormColors disposed different instance's getForeground()", fg.isDisposed()); - assertFalse("FormColors disposed different instance's getBorderColor()", bc.isDisposed()); + assertFalse(nullColors[i] != null && nullColors[i].isDisposed(), + "FormColors disposed different instance's key: " + KEYS_NULL[i]); + assertFalse(inactiveBg.isDisposed(), "FormColors disposed different instance's getInactiveBackground()"); + assertFalse(bg.isDisposed(), "FormColors disposed different instance's getBackground()"); + assertFalse(fg.isDisposed(), "FormColors disposed different instance's getForeground()"); + assertFalse(bc.isDisposed(), "FormColors disposed different instance's getBorderColor()"); fColors.dispose(); } @@ -153,27 +150,27 @@ public void testShared() { boolean testBorderDispose = !bc.equals(fColors.getColor(IFormColors.BORDER)); tk2.dispose(); for (int i = 0; i < KEYS_NON_NULL.length; i++) - assertFalse("FormToolkit disposed shared FormColor's key: " + KEYS_NON_NULL[i], colors[i].isDisposed()); + assertFalse(colors[i].isDisposed(), "FormToolkit disposed shared FormColor\'s key: " + KEYS_NON_NULL[i]); for (int i = 0; i < KEYS_NULL.length; i++) - assertFalse("FormToolkit disposed shared FormColor's key: " + KEYS_NULL[i], - nullColors[i] != null && nullColors[i].isDisposed()); - assertFalse("FormToolkit disposed shared FormColor's getInactiveBackground()", inactiveBg.isDisposed()); - assertFalse("FormToolkit disposed shared FormColor's getBackground()", bg.isDisposed()); - assertFalse("FormToolkit disposed shared FormColor's getForeground()", fg.isDisposed()); - assertFalse("FormToolkit disposed shared FormColor's getBorderColor()", bc.isDisposed()); + assertFalse(nullColors[i] != null && nullColors[i].isDisposed(), + "FormToolkit disposed shared FormColor\'s key: " + KEYS_NULL[i]); + assertFalse(inactiveBg.isDisposed(), "FormToolkit disposed shared FormColor\'s getInactiveBackground()"); + assertFalse(bg.isDisposed(), "FormToolkit disposed shared FormColor\'s getBackground()"); + assertFalse(fg.isDisposed(), "FormToolkit disposed shared FormColor\'s getForeground()"); + assertFalse(bc.isDisposed(), "FormToolkit disposed shared FormColor\'s getBorderColor()"); tk.dispose(); for (int i = 0; i < KEYS_NON_NULL.length; i++) - assertFalse("Last FormToolkit disposed shared FormColor's key: " + KEYS_NON_NULL[i], - colors[i].isDisposed()); + assertFalse(colors[i].isDisposed(), + "Last FormToolkit disposed shared FormColor\'s key: " + KEYS_NON_NULL[i]); for (int i = 0; i < KEYS_NULL.length; i++) - assertFalse("Last FormToolkit disposed shared FormColor's key: " + KEYS_NULL[i], - nullColors[i] != null && nullColors[i].isDisposed()); - assertFalse("Last FormToolkit disposed shared FormColor's getInactiveBackground()", inactiveBg.isDisposed()); - assertFalse("Last FormToolkit disposed shared FormColor's getBackground()", bg.isDisposed()); - assertFalse("Last FormToolkit disposed shared FormColor's getForeground()", fg.isDisposed()); + assertFalse(nullColors[i] != null && nullColors[i].isDisposed(), + "Last FormToolkit disposed shared FormColor\'s key: " + KEYS_NULL[i]); + assertFalse(inactiveBg.isDisposed(), "Last FormToolkit disposed shared FormColor\'s getInactiveBackground()"); + assertFalse(bg.isDisposed(), "Last FormToolkit disposed shared FormColor\'s getBackground()"); + assertFalse(fg.isDisposed(), "Last FormToolkit disposed shared FormColor\'s getForeground()"); if (testBorderDispose) - assertFalse("Last FormToolkit with shared FormColors disposed getBorderColor() when it shouldn't have", - bc.isDisposed()); + assertFalse(bc.isDisposed(), + "Last FormToolkit with shared FormColors disposed getBorderColor() when it shouldn\'t have"); fColors.dispose(); } @@ -182,8 +179,8 @@ public void testCustom() { FormColors fColors = new FormColors(Display.getCurrent()); Color test1 = fColors.createColor(TEST_KEY_1, 255, 155, 55); Color test2 = fColors.createColor(TEST_KEY_2, 55, 155, 255); - assertEquals("FormColors returned wrong color for an existing key.", fColors.getColor(TEST_KEY_1), test1); - assertEquals("FormColors returned wrong color for an existing key.", fColors.getColor(TEST_KEY_2), test2); + assertEquals(test1, fColors.getColor(TEST_KEY_1), "FormColors returned wrong color for an existing key."); + assertEquals(test2, fColors.getColor(TEST_KEY_2), "FormColors returned wrong color for an existing key."); fColors.dispose(); } } diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormFontsTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormFontsTest.java index 516e12ea1dc..1478e638f7f 100755 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormFontsTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormFontsTest.java @@ -15,15 +15,16 @@ package org.eclipse.ui.tests.forms.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.internal.forms.widgets.FormFonts; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FormFontsTest { @Test @@ -31,13 +32,12 @@ public void testSingleton() { Display display = Display.getCurrent(); FormFonts instance = FormFonts.getInstance(); // ensure the singleton is returning the same instance - assertEquals("getInstance() returned a different FormFonts instance", instance, FormFonts.getInstance()); + assertEquals(instance, FormFonts.getInstance(), "getInstance() returned a different FormFonts instance"); Font boldSystemFont = instance.getBoldFont(display, display.getSystemFont()); instance.markFinished(boldSystemFont, display); // ensure the singleton is returning the same instance after creating and disposing one gradient - assertEquals( - "getInstance() returned a different FormFonts instance after creation and disposal of one bold font", - instance, FormFonts.getInstance()); + assertEquals(instance, FormFonts.getInstance(), + "getInstance() returned a different FormFonts instance after creation and disposal of one bold font"); } @Test @@ -46,8 +46,7 @@ public void testDisposeOne() { Font boldSystemFont = FormFonts.getInstance().getBoldFont(display, display.getSystemFont()); FormFonts.getInstance().markFinished(boldSystemFont, display); // ensure that getting a single gradient and marking it as finished disposed it - assertTrue("markFinished(...) did not dispose a font after a single getBoldFont()", - boldSystemFont.isDisposed()); + assertTrue(boldSystemFont.isDisposed(), "markFinished(...) did not dispose a font after a single getBoldFont()"); } @Test @@ -56,27 +55,27 @@ public void testMultipleInstances() { Font boldSystemFont = FormFonts.getInstance().getBoldFont(display, display.getSystemFont()); int count; // ensure that the same image is returned for many calls with the same parameter - for (count = 1; count < 20; count ++) - assertEquals("getBoldFont(...) returned a different font for the same params on iteration " + count, - boldSystemFont, FormFonts.getInstance().getBoldFont(display, display.getSystemFont())); - for ( ;count > 0; count--) { + for (count = 1; count < 20; count++) + assertEquals(boldSystemFont, FormFonts.getInstance().getBoldFont(display, display.getSystemFont()), + "getBoldFont(...) returned a different font for the same params on iteration " + count); + for (; count > 0; count--) { FormFonts.getInstance().markFinished(boldSystemFont, display); if (count != 1) // ensure that the gradient is not disposed early - assertFalse("markFinished(...) disposed a shared font early on iteration " + count, - boldSystemFont.isDisposed()); + assertFalse(boldSystemFont.isDisposed(), + "markFinished(...) disposed a shared font early on iteration " + count); else // ensure that the gradient is disposed on the last markFinished - assertTrue("markFinished(...) did not dispose a shared font on the last call", - boldSystemFont.isDisposed()); + assertTrue(boldSystemFont.isDisposed(), + "markFinished(...) did not dispose a shared font on the last call"); } } @Test public void testMultipleFonts() { Display display = Display.getCurrent(); - Font veranda = new Font(display, "Veranda",12,SWT.NORMAL); - Font arial = new Font(display, "Arial",12,SWT.NORMAL); + Font veranda = new Font(display, "Veranda", 12, SWT.NORMAL); + Font arial = new Font(display, "Arial", 12, SWT.NORMAL); Font boldVeranda = FormFonts.getInstance().getBoldFont(display, veranda); Font boldArial = FormFonts.getInstance().getBoldFont(display, arial); assertFalse(boldVeranda.equals(boldArial)); @@ -94,6 +93,6 @@ public void testDisposeUnknown() { Display display = Display.getCurrent(); Font system = new Font(display, display.getSystemFont().getFontData()); FormFonts.getInstance().markFinished(system, display); - assertTrue("markFinished(...) did not dispose of an unknown font", system.isDisposed()); + assertTrue(system.isDisposed(), "markFinished(...) did not dispose of an unknown font"); } } diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormImagesTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormImagesTest.java index 0bae04287fe..884d3262602 100755 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormImagesTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormImagesTest.java @@ -15,11 +15,12 @@ package org.eclipse.ui.tests.forms.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -31,21 +32,22 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.internal.forms.widgets.FormImages; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FormImagesTest { private static FormImages instance; + @Test public void testSingleton() throws Exception { Display display = Display.getCurrent(); FormImages instance = FormImages.getInstance(); // ensure the singleton is returning the same instance - assertEquals("getInstance() returned a different FormImages instance", instance, FormImages.getInstance()); + assertEquals(instance, FormImages.getInstance(), "getInstance() returned a different FormImages instance"); Image gradient = instance.getGradient(new Color(display, 1, 1, 1), new Color(display, 7, 7, 7), 21, 21, 0, display); instance.markFinished(gradient, display); // ensure the singleton is returning the same instance after creating and disposing one gradient - assertEquals("getInstance() returned a different FormImages instance after creation and disposal of one image", - instance, FormImages.getInstance()); + assertEquals(instance, FormImages.getInstance(), + "getInstance() returned a different FormImages instance after creation and disposal of one image"); } @Test @@ -55,8 +57,8 @@ public void testDisposeOne() throws Exception { new Color(display, 0, 0, 0), 21, 21, 0, display); getFormImagesInstance().markFinished(gradient, display); // ensure that getting a single gradient and marking it as finished disposed it - assertTrue("markFinished(...) did not dispose an image after a single getGradient()", gradient.isDisposed()); - assertNull("descriptors map", getDescriptors(getFormImagesInstance())); + assertTrue(gradient.isDisposed(), "markFinished(...) did not dispose an image after a single getGradient()"); + assertNull(getDescriptors(getFormImagesInstance()), "descriptors map"); } @Test @@ -66,21 +68,21 @@ public void testMultipleSimpleInstances() throws Exception { new Color(display, 0, 0, 0), 30, 16, 3, display); int count; // ensure that the same image is returned for many calls with the same parameter - for (count = 1; count < 20; count ++) - assertEquals("getGradient(...) returned a different image for the same params on iteration " + count, - gradient, getFormImagesInstance().getGradient(new Color(display, 200, 200, 200), - new Color(display, 0, 0, 0), 30, 16, 3, display)); - for ( ;count > 0; count--) { + for (count = 1; count < 20; count++) + assertEquals(gradient, getFormImagesInstance().getGradient(new Color(display, 200, 200, 200), + new Color(display, 0, 0, 0), 30, 16, 3, display), + "getGradient(...) returned a different image for the same params on iteration " + count); + for (; count > 0; count--) { getFormImagesInstance().markFinished(gradient, display); if (count != 1) // ensure that the gradient is not disposed early - assertFalse("markFinished(...) disposed a shared image early on iteration " + count, - gradient.isDisposed()); + assertFalse(gradient.isDisposed(), + "markFinished(...) disposed a shared image early on iteration " + count); else // ensure that the gradient is disposed on the last markFinished - assertTrue("markFinished(...) did not dispose a shared image on the last call", gradient.isDisposed()); + assertTrue(gradient.isDisposed(), "markFinished(...) did not dispose a shared image on the last call"); } - assertNull("descriptors map", getDescriptors(getFormImagesInstance())); + assertNull(getDescriptors(getFormImagesInstance()), "descriptors map"); } @Test @@ -92,49 +94,48 @@ public void testMultipleSectionGradientInstances() throws Exception { // ensure that the same image is returned for many calls with the same // parameter for (count = 1; count < 20; count++) - assertEquals( - "getSectionGradientImage(...) returned a different image for the same params on iteration " + count, - gradient, getFormImagesInstance().getSectionGradientImage(new Color(display, 200, 200, 200), - new Color(display, 0, 0, 0), 30, 16, 3, display)); + assertEquals(gradient, getFormImagesInstance().getSectionGradientImage(new Color(display, 200, 200, 200), + new Color(display, 0, 0, 0), 30, 16, 3, display), + "getSectionGradientImage(...) returned a different image for the same params on iteration " + + count); for (; count > 0; count--) { getFormImagesInstance().markFinished(gradient, display); if (count != 1) // ensure that the gradient is not disposed early - assertFalse("markFinished(...) disposed a shared image early on iteration " + count, - gradient.isDisposed()); + assertFalse(gradient.isDisposed(), + "markFinished(...) disposed a shared image early on iteration " + count); else // ensure that the gradient is disposed on the last markFinished - assertTrue("markFinished(...) did not dispose a shared image on the last call", - gradient.isDisposed()); + assertTrue(gradient.isDisposed(), "markFinished(...) did not dispose a shared image on the last call"); } - assertNull("descriptors map", getDescriptors(getFormImagesInstance())); + assertNull(getDescriptors(getFormImagesInstance()), "descriptors map"); } @Test public void testMultipleComplexInstances() throws Exception { Display display = Display.getCurrent(); Image gradient = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 200, 200, 200), new Color(display, 0, 0, 0) }, - new int[] {100}, 31, true, null, display); + new Color[] { new Color(display, 200, 200, 200), new Color(display, 0, 0, 0) }, new int[] { 100 }, 31, + true, null, display); int count; // ensure that the same image is returned for many calls with the same parameter - for (count = 1; count < 20; count ++) - assertEquals("getGradient(...) returned a different image for the same params on iteration " + count, - gradient, + for (count = 1; count < 20; count++) + assertEquals(gradient, getFormImagesInstance().getGradient( new Color[] { new Color(display, 200, 200, 200), new Color(display, 0, 0, 0) }, - new int[] {100}, 31, true, null, display)); - for ( ;count > 0; count--) { + new int[] { 100 }, 31, true, null, display), + "getGradient(...) returned a different image for the same params on iteration " + count); + for (; count > 0; count--) { getFormImagesInstance().markFinished(gradient, display); if (count != 1) // ensure that the gradient is not disposed early - assertFalse("markFinished(...) disposed a shared image early on iteration " + count, - gradient.isDisposed()); + assertFalse(gradient.isDisposed(), + "markFinished(...) disposed a shared image early on iteration " + count); else // ensure that the gradient is disposed on the last markFinished - assertTrue("markFinished(...) did not dispose a shared image on the last call", gradient.isDisposed()); + assertTrue(gradient.isDisposed(), "markFinished(...) did not dispose a shared image on the last call"); } - assertNull("descriptors map", getDescriptors(getFormImagesInstance())); + assertNull(getDescriptors(getFormImagesInstance()), "descriptors map"); } @Test @@ -164,85 +165,84 @@ public void testMultipleUniqueInstances() throws Exception { images[10] = getFormImagesInstance().getGradient(new Color[] { new Color(display, 0, 0, 0) }, new int[] {}, 31, true, null, display); images[11] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 1, 1, 1) }, - new int[] {80}, 31, true, new Color(display,255,255,255), display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 1, 1, 1) }, new int[] { 80 }, 31, true, + new Color(display, 255, 255, 255), display); images[12] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 1, 1, 1) }, - new int[] {80}, 31, true, new Color(display,0,0,0), display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 1, 1, 1) }, new int[] { 80 }, 31, true, + new Color(display, 0, 0, 0), display); images[13] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 100) }, - new int[] {100}, 31, true, null, display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 100) }, new int[] { 100 }, 31, + true, null, display); images[14] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 1, 0, 0), new Color(display, 100, 100, 100) }, - new int[] {100}, 31, true, null, display); + new Color[] { new Color(display, 1, 0, 0), new Color(display, 100, 100, 100) }, new int[] { 100 }, 31, + true, null, display); images[15] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 1, 0), new Color(display, 100, 100, 100) }, - new int[] {100}, 31, true, null, display); + new Color[] { new Color(display, 0, 1, 0), new Color(display, 100, 100, 100) }, new int[] { 100 }, 31, + true, null, display); images[16] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 1), new Color(display, 100, 100, 100) }, - new int[] {100}, 31, true, null, display); + new Color[] { new Color(display, 0, 0, 1), new Color(display, 100, 100, 100) }, new int[] { 100 }, 31, + true, null, display); images[17] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 101, 100, 100) }, - new int[] {100}, 31, true, null, display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 101, 100, 100) }, new int[] { 100 }, 31, + true, null, display); images[18] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 101, 100) }, - new int[] {100}, 31, true, null, display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 101, 100) }, new int[] { 100 }, 31, + true, null, display); images[19] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 101) }, - new int[] {100}, 31, true, null, display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 101) }, new int[] { 100 }, 31, + true, null, display); images[20] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 100) }, - new int[] {100}, 20, true, null, display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 100) }, new int[] { 100 }, 20, + true, null, display); images[21] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 100) }, - new int[] {100}, 31, false, null, display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 100) }, new int[] { 100 }, 31, + false, null, display); images[22] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 100) }, - new int[] {50}, 31, true, new Color(display,1,1,1), display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 100, 100, 100) }, new int[] { 50 }, 31, + true, new Color(display, 1, 1, 1), display); images[23] = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 1, 1, 1), new Color(display, 101, 101, 101) }, - new int[] {50}, 20, false, new Color(display,1,1,1), display); + new Color[] { new Color(display, 1, 1, 1), new Color(display, 101, 101, 101) }, new int[] { 50 }, 20, + false, new Color(display, 1, 1, 1), display); // ensure none of the images are the same for (int i = 0; i < images.length - 1; i++) { - for (int j = i+1; j < images.length; j++) { - assertNotSame( - "getGradient(...) returned the same image for different parameters: i = " + i + "; j = " + j, - images[i], images[j]); + for (int j = i + 1; j < images.length; j++) { + assertNotSame(images[i], images[j], + "getGradient(...) returned the same image for different parameters: i = " + i + "; j = " + + j); } } // ensure all of the images are disposed with one call to markFinished for (int i = 0; i < images.length; i++) { getFormImagesInstance().markFinished(images[i], display); - assertTrue("markFinished(...) did not dispose an image that was only requested once: i = " + i, - images[i].isDisposed()); + assertTrue(images[i].isDisposed(), + "markFinished(...) did not dispose an image that was only requested once: i = " + i); } - assertNull("descriptors map", getDescriptors(getFormImagesInstance())); + assertNull(getDescriptors(getFormImagesInstance()), "descriptors map"); } @Test public void testComplexEquality() throws Exception { Display display = Display.getCurrent(); Image image1 = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 255, 255, 255) }, - new int[] {100}, 20, true, new Color(display,100,100,100), display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 255, 255, 255) }, new int[] { 100 }, 20, + true, new Color(display, 100, 100, 100), display); Image image2 = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 255, 255, 255) }, - new int[] {100}, 20, true, new Color(display,0,0,0), display); - assertEquals( - "different images were created with only the background color differing when that difference is irrelevant", - image1, image2); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 255, 255, 255) }, new int[] { 100 }, 20, + true, new Color(display, 0, 0, 0), display); + assertEquals(image1, image2, + "different images were created with only the background color differing when that difference is irrelevant"); getFormImagesInstance().markFinished(image1, display); getFormImagesInstance().markFinished(image2, display); image1 = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 255, 255, 255) }, - new int[] {80}, 20, true, new Color(display,100,100,100), display); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 255, 255, 255) }, new int[] { 80 }, 20, + true, new Color(display, 100, 100, 100), display); image2 = getFormImagesInstance().getGradient( - new Color[] { new Color(display, 0, 0, 0), new Color(display, 255, 255, 255) }, - new int[] {80}, 20, true, new Color(display,0,0,0), display); - assertNotSame("the same image was used when different background colors were specified", image1, image2); + new Color[] { new Color(display, 0, 0, 0), new Color(display, 255, 255, 255) }, new int[] { 80 }, 20, + true, new Color(display, 0, 0, 0), display); + assertNotSame(image1, image2, "the same image was used when different background colors were specified"); getFormImagesInstance().markFinished(image1, display); getFormImagesInstance().markFinished(image2, display); - assertNull("descriptors map", getDescriptors(getFormImagesInstance())); + assertNull(getDescriptors(getFormImagesInstance()), "descriptors map"); } @Test @@ -252,39 +252,40 @@ public void testToolkitColors() throws Exception { Display display = Display.getCurrent(); FormToolkit kit1 = new FormToolkit(display); - kit1.getColors().createColor(blueKey, new RGB(0,0,255)); - kit1.getColors().createColor(redKey, new RGB(255,0,0)); + kit1.getColors().createColor(blueKey, new RGB(0, 0, 255)); + kit1.getColors().createColor(redKey, new RGB(255, 0, 0)); FormToolkit kit2 = new FormToolkit(display); - kit2.getColors().createColor(blueKey, new RGB(0,0,255)); - kit2.getColors().createColor(redKey, new RGB(255,0,0)); + kit2.getColors().createColor(blueKey, new RGB(0, 0, 255)); + kit2.getColors().createColor(redKey, new RGB(255, 0, 0)); Image image1 = getFormImagesInstance().getGradient(kit1.getColors().getColor(blueKey), kit1.getColors().getColor(redKey), 21, 21, 0, display); Image image2 = getFormImagesInstance().getGradient(kit2.getColors().getColor(blueKey), kit2.getColors().getColor(redKey), 21, 21, 0, display); - assertEquals("different images were created for the same RGBs with different Color instances", image1, image2); + assertEquals(image1, image2, "different images were created for the same RGBs with different Color instances"); Image image3 = getFormImagesInstance().getGradient(new Color(display, 0, 0, 255), new Color(display, 255, 0, 0), 21, 21, 0, display); - assertEquals("different images were created for the same RGBs with different Color instances", image1, image3); + assertEquals(image1, image3, "different images were created for the same RGBs with different Color instances"); kit1.dispose(); - assertFalse("image was disposed after toolkits were disposed", image1.isDisposed()); + assertFalse(image1.isDisposed(), "image was disposed after toolkits were disposed"); kit2.dispose(); - assertFalse("image was disposed after toolkits were disposed", image2.isDisposed()); + assertFalse(image2.isDisposed(), "image was disposed after toolkits were disposed"); getFormImagesInstance().markFinished(image1, display); - assertFalse("image was disposed early", image1.isDisposed()); + assertFalse(image1.isDisposed(), "image was disposed early"); getFormImagesInstance().markFinished(image2, display); - assertFalse("image was disposed early", image2.isDisposed()); + assertFalse(image2.isDisposed(), "image was disposed early"); getFormImagesInstance().markFinished(image3, display); - assertTrue("image was not disposed", image3.isDisposed()); - assertNull("descriptors map", getDescriptors(getFormImagesInstance())); + assertTrue(image3.isDisposed(), "image was not disposed"); + assertNull(getDescriptors(getFormImagesInstance()), "descriptors map"); } @Test public void testDisposeUnknown() throws Exception { Display display = Display.getCurrent(); - Image image = new Image(display, (gc, width, height) -> {}, 10, 10); + Image image = new Image(display, (gc, width, height) -> { + }, 10, 10); getFormImagesInstance().markFinished(image, display); - assertTrue("markFinished(...) did not dispose of an unknown image", image.isDisposed()); - assertNull("descriptors map", getDescriptors(getFormImagesInstance())); + assertTrue(image.isDisposed(), "markFinished(...) did not dispose of an unknown image"); + assertNull(getDescriptors(getFormImagesInstance()), "descriptors map"); } private static HashMap getDescriptors(FormImages formImages) throws Exception { diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormToolkitTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormToolkitTest.java index fbc3f26e4c3..c4b4516f8a5 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormToolkitTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormToolkitTest.java @@ -17,7 +17,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.forms.widgets.FormToolkit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FormToolkitTest { diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/ImageHyperlinkTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/ImageHyperlinkTest.java index 94edb60d16f..ca7d0c360b1 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/ImageHyperlinkTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/ImageHyperlinkTest.java @@ -14,11 +14,12 @@ *******************************************************************************/ package org.eclipse.ui.tests.forms.util; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Field; @@ -33,9 +34,9 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.widgets.ImageHyperlink; import org.eclipse.ui.internal.forms.widgets.FormImages; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ImageHyperlinkTest { @@ -44,7 +45,7 @@ public class ImageHyperlinkTest { private GC gc; private TestImageHyperlink imageHyperlink; - @Before + @BeforeEach public void setUp() throws Exception { display = PlatformUI.getWorkbench().getDisplay(); shell = new Shell(display); @@ -56,7 +57,7 @@ public void setUp() throws Exception { gc = new GC(display); } - @After + @AfterEach public void tearDown() throws Exception { shell.dispose(); gc.dispose(); @@ -128,6 +129,7 @@ public void testPaintHyperlinkDoesNotLeakDisabledImage() throws Exception { assertSame(prevDisabledImage, getDisabledImage(imageHyperlink)); } + @Test public void testSetImageNullClearsDisabledImage() throws Exception { Image image = createGradient(); @@ -142,8 +144,8 @@ public void testSetImageNullClearsDisabledImage() throws Exception { } private Image createGradient() { - return FormImages.getInstance().getGradient(new Color(display, 0, 0, 0), new Color(display, 100, 100, 100), 1, - 1, 1, display); + return FormImages.getInstance().getGradient(new Color(display, 0, 0, 0), new Color(display, 100, 100, 100), 1, 1, + 1, display); } private static Image getDisabledImage(ImageHyperlink link) throws Exception { diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java index 27ad1290d8f..62d6e459aef 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java @@ -14,8 +14,9 @@ *******************************************************************************/ package org.eclipse.ui.tests.forms.widgets; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; @@ -36,9 +37,9 @@ import org.eclipse.ui.forms.events.IExpansionListener; import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.eclipse.ui.tests.forms.layout.ControlFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for expandable composite @@ -106,7 +107,7 @@ private Point getTextExtend(String str) { } } - @Before + @BeforeEach public void setUp() throws Exception { font = new Font(display, "Arial", 12, SWT.NORMAL); shell = new Shell(display); @@ -116,7 +117,7 @@ public void setUp() throws Exception { shell.open(); } - @After + @AfterEach public void tearDown() throws Exception { if (humanWatching) dispatch(1000); @@ -478,7 +479,7 @@ public void testLabelLongAndTextClientComp() { Rectangle bounds = update(); - assertEquals("Width", 500, bounds.width); + assertEquals(500, bounds.width, "Width"); assertAround("Text Client width", 500 / 2, client.getBounds().width, 3); assertTextLines(7, bounds); } @@ -493,15 +494,15 @@ public void testLabelShortAndTextClientComp() { Rectangle bounds = update(); - assertEquals("Width", 500, bounds.width); + assertEquals(500, bounds.width, "Width"); int w = getTextExtend(shortText).x; assertAround("Text Client width", 500 - w, client.getBounds().width, 8); assertTextLines(4, bounds); } private void assertAround(String prefix, int len1, int len2, int delta) { - assertTrue(prefix + ": expected around " + len1 + " pixes +/- " + delta + " but was " + len2, - len1 - delta <= len2 && len2 <= len1 + delta); + assertTrue(len1 - delta <= len2 && len2 <= len1 + delta, + prefix + ": expected around " + len1 + " pixes +/- " + delta + " but was " + len2); } @Test diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTest.java index 89a3299f220..3e4ca0c07d5 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTest.java @@ -22,10 +22,10 @@ import org.eclipse.ui.forms.widgets.ILayoutExtension; import org.eclipse.ui.forms.widgets.SizeCache; import org.eclipse.ui.internal.forms.widgets.FormUtil; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class FormTest { private static Display display; @@ -41,12 +41,12 @@ public class FormTest { private Shell shell; - @Before + @BeforeEach public void setUp() throws Exception { shell = new Shell(display); } - @After + @AfterEach public void tearDown() throws Exception { shell.dispose(); } @@ -60,10 +60,10 @@ public void testFormLayoutCanIgnoreBody() { SizeCache bodyCache = new SizeCache(); headCache.setControl(form.getHead()); bodyCache.setControl(form.getBody()); - Assert.assertEquals(Math.max(headCache.computeMinimumWidth(), bodyCache.computeMinimumWidth()), + Assertions.assertEquals(Math.max(headCache.computeMinimumWidth(), bodyCache.computeMinimumWidth()), ((ILayoutExtension) form.getLayout()).computeMinimumWidth(form, true)); form.setData(FormUtil.IGNORE_BODY, Boolean.TRUE); - Assert.assertEquals(Math.max(headCache.computeMinimumWidth(), 0), + Assertions.assertEquals(Math.max(headCache.computeMinimumWidth(), 0), ((ILayoutExtension) form.getLayout()).computeMinimumWidth(form, true)); } } diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTextModelTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTextModelTest.java index 65017a12afd..7f7154d6390 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTextModelTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTextModelTest.java @@ -13,10 +13,11 @@ *******************************************************************************/ package org.eclipse.ui.tests.forms.widgets; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.ui.internal.forms.widgets.FormTextModel; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for FormTextModel @@ -28,8 +29,8 @@ public void testWhitespaceNormalized() { FormTextModel formTextModel = new FormTextModel(); formTextModel.setWhitespaceNormalized(true); formTextModel.parseTaggedText("

line with \r\n whitespace Test

", false); - assertEquals("FormTextModel does not remove whitespace correctly according to the rules", - "line with whitespace Test" + System.lineSeparator(), formTextModel.getAccessibleText()); + assertEquals("line with whitespace Test" + System.lineSeparator(), formTextModel.getAccessibleText(), + "FormTextModel does not remove whitespace correctly according to the rules"); } @Test @@ -37,8 +38,9 @@ public void testWhitespaceNotNormalized() { FormTextModel formTextModel = new FormTextModel(); formTextModel.setWhitespaceNormalized(false); formTextModel.parseTaggedText("

line with whitespace Test

", false); - assertEquals("FormTextModel does not preserve whitespace correctly according to the rules", - " line with whitespace Test " + System.lineSeparator(), formTextModel.getAccessibleText()); + assertEquals(" line with whitespace Test " + System.lineSeparator(), + formTextModel.getAccessibleText(), + "FormTextModel does not preserve whitespace correctly according to the rules"); } @Test diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/HintAdjustmentTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/HintAdjustmentTest.java index 2b0ddd4acee..36fe7ad830a 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/HintAdjustmentTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/HintAdjustmentTest.java @@ -13,7 +13,8 @@ ******************************************************************************/ package org.eclipse.ui.tests.forms.widgets; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; @@ -34,9 +35,9 @@ import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TreeNode; import org.eclipse.ui.forms.widgets.Twistie; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * SWT controls have a complicated contract on @@ -74,12 +75,12 @@ public class HintAdjustmentTest { private Shell shell; - @Before + @BeforeEach public void setUp() throws Exception { shell = new Shell(display); } - @After + @AfterEach public void tearDown() throws Exception { shell.dispose(); } @@ -103,10 +104,10 @@ void verifyComputeSize(Control control) { Point computedSize = control.computeSize(TEST_VALUE, TEST_VALUE); - assertEquals("control is not applying the width adjustment correctly", TEST_VALUE + widthAdjustment, - computedSize.x); - assertEquals("control is not applying the height adjustment correctly", TEST_VALUE + heightAdjustment, - computedSize.y); + assertEquals(TEST_VALUE + widthAdjustment, computedSize.x, + "control is not applying the width adjustment correctly"); + assertEquals(TEST_VALUE + heightAdjustment, computedSize.y, + "control is not applying the height adjustment correctly"); } @Test diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ScrolledFormTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ScrolledFormTest.java index a97e74fb3ea..b86aff2adbe 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ScrolledFormTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ScrolledFormTest.java @@ -13,7 +13,8 @@ ******************************************************************************/ package org.eclipse.ui.tests.forms.widgets; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; @@ -22,9 +23,9 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.tests.forms.layout.ControlFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test cases for {@link ScrolledForm}. @@ -33,13 +34,13 @@ public class ScrolledFormTest { private Shell shell; private Display display; - @Before + @BeforeEach public void setUp() throws Exception { display = Display.getDefault(); shell = new Shell(display); } - @After + @AfterEach public void tearDown() throws Exception { shell.dispose(); } @@ -124,10 +125,10 @@ public static Point computeLayout(Shell shell, ScrollTestData testData) { form.layout(true); while (!shell.isDisposed() && shell.getDisplay().readAndDispatch()) { } - assertEquals("Horizontal scrollbar visibility was wrong for " + testData, testData.expectsHScroll(), - form.getHorizontalBar().getVisible()); - assertEquals("Vertical scrollbar visibility was wrong for " + testData, testData.expectsVScroll(), - form.getVerticalBar().getVisible()); + assertEquals(testData.expectsHScroll(), form.getHorizontalBar().getVisible(), + "Horizontal scrollbar visibility was wrong for " + testData); + assertEquals(testData.expectsVScroll(), + form.getVerticalBar().getVisible(), "Vertical scrollbar visibility was wrong for " + testData); Point result = parent.getSize(); form.dispose(); return result; @@ -141,8 +142,8 @@ private void runTest(ScrollTestData testData, int expectedWidth, int expectedHei boolean heightOkay = (Math.abs(expectedHeight - result.y) <= 1); boolean widthOkay = (expectedWidth == result.x); if (!(heightOkay && widthOkay)) { - assertEquals("Child control had unexpected size for test case " + testData, - new Point(expectedWidth, expectedHeight), result); + assertEquals(new Point(expectedWidth, expectedHeight), result, + "Child control had unexpected size for test case " + testData); } } diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SectionFactoryTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SectionFactoryTest.java index 639f5ac033f..2155fc970db 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SectionFactoryTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SectionFactoryTest.java @@ -11,9 +11,10 @@ *******************************************************************************/ package org.eclipse.ui.tests.forms.widgets; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Control; @@ -25,19 +26,19 @@ import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.SectionFactory; import org.eclipse.ui.forms.widgets.Twistie; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SectionFactoryTest { protected static Shell shell; - @Before + @BeforeEach public void setup() { shell = new Shell(); } - @After + @AfterEach public void tearDown() { shell.dispose(); } @@ -73,7 +74,7 @@ public void addsSectionExpandListeners() { Section section = SectionFactory.newSection(ExpandableComposite.TWISTIE).onExpanded(e -> raisedEvents[0] = e) .create(shell); Control twistie = section.getChildren()[0]; - assertTrue("Expected a twistie", twistie instanceof Twistie); + assertTrue(twistie instanceof Twistie, "Expected a twistie"); click(twistie); assertNotNull(raisedEvents[0]); @@ -85,7 +86,7 @@ public void addsSectionExpandingListener() { Section section = SectionFactory.newSection(ExpandableComposite.TWISTIE).onExpanding(e -> raisedEvents[0] = e) .create(shell); Control twistie = section.getChildren()[0]; - assertTrue("Expected a twistie", twistie instanceof Twistie); + assertTrue(twistie instanceof Twistie, "Expected a twistie"); click(twistie); assertNotNull(raisedEvents[0]); diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SizeCacheTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SizeCacheTest.java index dc1a3108529..de620b7afda 100644 --- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SizeCacheTest.java +++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SizeCacheTest.java @@ -13,7 +13,8 @@ *******************************************************************************/ package org.eclipse.ui.tests.forms.widgets; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; @@ -32,9 +33,9 @@ import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.SizeCache; import org.eclipse.ui.forms.widgets.TableWrapLayout; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SizeCacheTest { private static Display display; @@ -60,7 +61,7 @@ public class SizeCacheTest { } } - @Before + @BeforeEach public void setUp() throws Exception { font = new Font(display, "Arial", 12, SWT.NORMAL); shell = new Shell(display); @@ -70,7 +71,7 @@ public void setUp() throws Exception { shell.open(); } - @After + @AfterEach public void tearDown() throws Exception { if (humanWatching) dispatch(1000);