diff --git a/features/.project b/features/.project new file mode 100644 index 000000000000..cf8899cb3fa1 --- /dev/null +++ b/features/.project @@ -0,0 +1,11 @@ + + + features + + + + + + + + diff --git a/tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF index 815803d26266..22e2c1d34bb1 100644 --- a/tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF @@ -5,8 +5,7 @@ Bundle-SymbolicName: org.eclipse.jface.tests Bundle-Version: 1.5.0.qualifier Automatic-Module-Name: org.eclipse.jface.tests Bundle-RequiredExecutionEnvironment: JavaSE-21 -Require-Bundle: org.junit;bundle-version="4.12.0", - org.eclipse.jface, +Require-Bundle: org.eclipse.jface, org.eclipse.equinox.registry, org.eclipse.core.runtime, org.eclipse.ui, @@ -14,6 +13,7 @@ Require-Bundle: org.junit;bundle-version="4.12.0", Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)", org.junit.jupiter.api.extension;version="[5.14.0,6.0.0)", org.junit.jupiter.api.function;version="[5.14.0,6.0.0)", + org.junit.jupiter.api.io;version="[5.14.0,6.0.0)", org.junit.platform.commons.function;version="[1.14.0,2.0.0)", org.junit.platform.suite.api;version="[1.14.0,2.0.0)", org.opentest4j;version="1.3.0", diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/action/AllActionTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/action/AllActionTests.java index af6efa208cba..6ca56c5e67c5 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/action/AllActionTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/action/AllActionTests.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.action; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -23,8 +23,6 @@ MenuManagerTest.class }) public class AllActionTests { - public static void main(String[] args) { - JUnitCore.main(AllActionTests.class.getName()); - } + } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/action/JFaceActionRule.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/action/JFaceActionRule.java deleted file mode 100644 index cca0e0444427..000000000000 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/action/JFaceActionRule.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 vogella GmbH and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Lars Vogel - initial API and implementation - *******************************************************************************/ -package org.eclipse.jface.tests.action; - -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * Junit4 rule for all JFace action tests. - * - * @since 3.1 - */ -public class JFaceActionRule implements TestRule { - - private Display display; - private Shell shell; - - @Override - public Statement apply(final Statement base, final Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - display = Display.getCurrent(); - if (display == null) { - display = new Display(); - } - shell = new Shell(display); - shell.setSize(500, 500); - shell.setLayout(new FillLayout()); - shell.open(); - - try { - base.evaluate(); // This will run the test. - } finally { - shell.dispose(); - } - } - }; - } - - protected Shell getShell() { - return shell; - } - -} diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/AllDialogTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/AllDialogTests.java index 89c89fe99d6d..bf2309218e9f 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/AllDialogTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/AllDialogTests.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.dialogs; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -24,7 +24,5 @@ ProgressMonitorDialogTest.class, PlainMessageDialogTest.class }) public class AllDialogTests { - public static void main(String[] args) { - JUnitCore.main(AllDialogTests.class.getName()); - } + } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistTestCase.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistTestCase.java index 116bdd077e5e..122b9e0427ff 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistTestCase.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistTestCase.java @@ -14,9 +14,9 @@ ******************************************************************************/ package org.eclipse.jface.tests.fieldassist; -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.jface.bindings.keys.KeyStroke; import org.eclipse.swt.SWT; @@ -25,15 +25,12 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.tests.harness.util.TestRunLogUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TestWatcher; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; public abstract class AbstractFieldAssistTestCase { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; - + /** * The window that is being tested. */ @@ -49,8 +46,9 @@ public abstract class AbstractFieldAssistTestCase { */ private int originalShellCount; - @Before - public final void setUp() throws Exception { + @BeforeEach + public final void setUp(TestInfo testInfo) throws Exception { + System.out.println(TestRunLogUtil.formatTestStartMessage(testInfo.getTestMethod().get().getName())); Display display = getDisplay(); anotherShell = new Shell(display); new Text(anotherShell, SWT.SINGLE); @@ -61,13 +59,14 @@ public final void setUp() throws Exception { assertNotNull(window); } - @After - public final void tearDown() throws Exception { + @AfterEach + public final void tearDown(TestInfo testInfo) throws Exception { if (window != null) { spinEventLoop(); } closeFieldAssistWindow(); anotherShell.close(); + System.out.println(TestRunLogUtil.formatTestFinishedMessage(testInfo.getTestMethod().get().getName())); } protected Display getDisplay() { @@ -171,7 +170,7 @@ protected void sendKeyDownToControl(char character) { Event event = new Event(); event.type = SWT.KeyDown; event.character = character; - assertTrue("unable to post event to display queue for test case", window.getDisplay().post(event)); + assertTrue(window.getDisplay().post(event), "unable to post event to display queue for test case"); spinEventLoop(); } @@ -186,7 +185,7 @@ protected void sendKeyDownToControl(KeyStroke keystroke) { Event event = new Event(); event.type = SWT.KeyDown; event.keyCode = keystroke.getNaturalKey(); - assertTrue("unable to post event to display queue for test case", window.getDisplay().post(event)); + assertTrue(window.getDisplay().post(event), "unable to post event to display queue for test case"); spinEventLoop(); } @@ -195,8 +194,8 @@ protected void sendKeyDownToControl(KeyStroke keystroke) { */ protected void assertOneShellUp() { spinEventLoop(); - assertEquals("There should only be one shell up, the dialog", originalShellCount + 1, - window.getDisplay().getShells().length); + assertEquals(originalShellCount + 1, + window.getDisplay().getShells().length, "There should only be one shell up, the dialog"); } /** @@ -205,8 +204,8 @@ protected void assertOneShellUp() { */ protected void assertTwoShellsUp() { spinEventLoop(); - assertEquals("There should two shells up, the dialog and the proposals dialog", originalShellCount + 2, - window.getDisplay().getShells().length); + assertEquals(originalShellCount + 2, + window.getDisplay().getShells().length, "There should two shells up, the dialog and the proposals dialog"); } protected void setControlContent(String text) { @@ -219,4 +218,4 @@ protected String getControlContent() { } -} +} \ No newline at end of file diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/ContentProposalAdapterTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/ContentProposalAdapterTest.java index d28a45f7067b..1e72f55d5a74 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/ContentProposalAdapterTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/ContentProposalAdapterTest.java @@ -13,9 +13,9 @@ *******************************************************************************/ package org.eclipse.jface.tests.fieldassist; -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.jface.fieldassist.ContentProposalAdapter; import org.eclipse.jface.fieldassist.IContentProposalProvider; @@ -28,15 +28,12 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.tests.harness.util.TestRunLogUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestWatcher; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; public class ContentProposalAdapterTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; /** * A shell that hosts the decorated text control @@ -121,8 +118,9 @@ public void testBug520372AutoActivationDelayESC() throws Exception { // most of the following code is copied from AbstractFieldAssistTestCase - @Before - public final void setUp() throws Exception { + @BeforeEach + public final void setUp(TestInfo testInfo) throws Exception { + System.out.println(TestRunLogUtil.formatTestStartMessage(testInfo.getTestMethod().get().getName())); Display display = getDisplay(); originalShellCount = display.getShells().length; controlShell = new Shell(display); @@ -133,8 +131,8 @@ public final void setUp() throws Exception { assertNotNull(contentProposalAdapter); } - @After - public final void tearDown() throws Exception { + @AfterEach + public final void tearDown(TestInfo testInfo) throws Exception { if (controlShell != null) { spinEventLoop(); controlShell.close(); @@ -145,6 +143,7 @@ public final void tearDown() throws Exception { } this.display = null; } + System.out.println(TestRunLogUtil.formatTestFinishedMessage(testInfo.getTestMethod().get().getName())); } private Display getDisplay() { @@ -179,7 +178,7 @@ private void sendKeyDownToControl(char character) { Event event = new Event(); event.type = SWT.KeyDown; event.character = character; - assertTrue("unable to post event to display queue for test case", text.getDisplay().post(event)); + assertTrue(text.getDisplay().post(event), "unable to post event to display queue for test case"); spinEventLoop(); } @@ -233,7 +232,7 @@ private void ensurePopupIsUp() { */ private void assertOneShellUp() { spinEventLoop(); - assertEquals("There should only be one shell up, the dialog", originalShellCount + 1, - text.getDisplay().getShells().length); + assertEquals(originalShellCount + 1, + text.getDisplay().getShells().length, "There should only be one shell up, the dialog"); } -} +} \ No newline at end of file diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/ControlDecorationTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/ControlDecorationTests.java index 5890ccfee8bb..66b58ba29c75 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/ControlDecorationTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/ControlDecorationTests.java @@ -13,16 +13,16 @@ ******************************************************************************/ package org.eclipse.jface.tests.fieldassist; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.jface.fieldassist.FieldDecorationRegistry; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ControlDecorationTests extends AbstractFieldAssistTestCase { @@ -37,15 +37,15 @@ public void testDecorationIsVisible() { .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); decoration.setDescriptionText("foo"); window.open(); - assertTrue("1.0", decoration.isVisible()); + assertTrue(decoration.isVisible(), "1.0"); decoration.hide(); - assertFalse("1.1", decoration.isVisible()); + assertFalse(decoration.isVisible(), "1.1"); decoration.show(); - assertTrue("1.2", decoration.isVisible()); + assertTrue(decoration.isVisible(), "1.2"); window.getFieldAssistControl().setVisible(false); - assertFalse("1.3", decoration.isVisible()); + assertFalse(decoration.isVisible(), "1.3"); window.getFieldAssistControl().setVisible(true); - assertTrue("1.4", decoration.isVisible()); + assertTrue(decoration.isVisible(), "1.4"); // focus related tests. Comment out for now. // see bug 275393 @@ -71,7 +71,7 @@ public void testHoverVisibility() { decoration.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); decoration.setDescriptionText("foo"); - assertTrue("1.0", decoration.isVisible()); + assertTrue(decoration.isVisible(), "1.0"); assertOneShellUp(); decoration.hide(); decoration.showHoverText("Show me"); @@ -87,7 +87,7 @@ public void testHoverVisibility() { // focus related tests @Test - @Ignore("Disabled see Bug 418420 and bug 275393") + @Disabled("Disabled see Bug 418420 and bug 275393") public void testBug418420() { AbstractFieldAssistWindow window = getFieldAssistWindow(); window.open(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/FieldAssistAPITests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/FieldAssistAPITests.java index bb2ea58a4035..0d2825941475 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/FieldAssistAPITests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/FieldAssistAPITests.java @@ -14,13 +14,13 @@ ******************************************************************************/ package org.eclipse.jface.tests.fieldassist; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; import org.eclipse.jface.fieldassist.ContentProposal; import org.eclipse.jface.fieldassist.IContentProposal; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FieldAssistAPITests extends AbstractFieldAssistTestCase { @@ -32,37 +32,37 @@ public class FieldAssistAPITests extends AbstractFieldAssistTestCase { @Test public void testSimpleContentProposal() { proposal = new ContentProposal(content); - assertEquals("1.0", content, proposal.getContent()); - assertEquals("1.1", content, proposal.getLabel()); - assertNull("1.2", proposal.getDescription()); - assertEquals("1.3", content.length(), proposal.getCursorPosition()); + assertEquals(content, proposal.getContent(), "1.0"); + assertEquals(content, proposal.getLabel(), "1.1"); + assertNull(proposal.getDescription(), "1.2"); + assertEquals(content.length(), proposal.getCursorPosition(), "1.3"); } @Test public void testContentProposalWithCursor() { proposal = new ContentProposal(content, label, description, 3); - assertEquals("3.0", content, proposal.getContent()); - assertEquals("3.1", label, proposal.getLabel()); - assertEquals("3.2", description, proposal.getDescription()); - assertEquals("3.3", 3, proposal.getCursorPosition()); + assertEquals(content, proposal.getContent(), "3.0"); + assertEquals(label, proposal.getLabel(), "3.1"); + assertEquals(description, proposal.getDescription(), "3.2"); + assertEquals(3, proposal.getCursorPosition(), "3.3"); } @Test public void testContentProposalWithLabel() { proposal = new ContentProposal(content, label, description); - assertEquals("3.0", content, proposal.getContent()); - assertEquals("3.1", label, proposal.getLabel()); - assertEquals("3.2", description, proposal.getDescription()); - assertEquals("3.3", content.length(), proposal.getCursorPosition()); + assertEquals(content, proposal.getContent(), "3.0"); + assertEquals(label, proposal.getLabel(), "3.1"); + assertEquals(description, proposal.getDescription(), "3.2"); + assertEquals(content.length(), proposal.getCursorPosition(), "3.3"); } @Test public void testContentProposalWithDescription() { proposal = new ContentProposal(content, description); - assertEquals("2.0", content, proposal.getContent()); - assertEquals("2.1", content, proposal.getLabel()); - assertEquals("2.2", description, proposal.getDescription()); - assertEquals("2.3", content.length(), proposal.getCursorPosition()); + assertEquals(content, proposal.getContent(), "2.0"); + assertEquals(content, proposal.getLabel(), "2.1"); + assertEquals(description, proposal.getDescription(), "2.2"); + assertEquals(content.length(), proposal.getCursorPosition(), "2.3"); } public void testInitializationWithInvalidCursor() { @@ -70,7 +70,7 @@ public void testInitializationWithInvalidCursor() { proposal = new ContentProposal(content, label, description, 100); fail("4.0"); } catch (IllegalArgumentException e) { - assertNull("It is expected to be null", proposal); + assertNull(proposal, "It is expected to be null"); } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/FieldAssistTestCase.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/FieldAssistTestCase.java index fe259d49eda8..f6862fda4720 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/FieldAssistTestCase.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/fieldassist/FieldAssistTestCase.java @@ -13,9 +13,9 @@ ******************************************************************************/ package org.eclipse.jface.tests.fieldassist; -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.jface.bindings.keys.KeyStroke; import org.eclipse.jface.fieldassist.ContentProposalAdapter; @@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Shell; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * This class contains test cases appropriate for generic field assist @@ -104,7 +104,7 @@ public void testPropagateKeysOff() { ensurePopupIsUp(); assertTwoShellsUp(); sendKeyDownToControl(EXTRA_CHAR); - assertEquals("1.0", SAMPLE_CONTENT + new String(new char [] {ACTIVATE_CHAR}), getControlContent()); + assertEquals(SAMPLE_CONTENT + new String(new char [] {ACTIVATE_CHAR}), getControlContent(), "1.0"); } @Test @@ -118,7 +118,7 @@ public void testPropagateKeysOn() { ensurePopupIsUp(); assertTwoShellsUp(); sendKeyDownToControl(EXTRA_CHAR); - assertEquals("1.0", SAMPLE_CONTENT + new String(new char [] {ACTIVATE_CHAR, EXTRA_CHAR}), getControlContent()); + assertEquals(SAMPLE_CONTENT + new String(new char [] {ACTIVATE_CHAR, EXTRA_CHAR}), getControlContent(), "1.0"); } @Test @@ -169,28 +169,28 @@ public void testDecorationIsVisible() { .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); decoration.setDescriptionText("foo"); spinEventLoop(); - assertTrue("1.0", decoration.isVisible()); + assertTrue(decoration.isVisible(), "1.0"); decoration.hide(); - assertFalse("1.1", decoration.isVisible()); + assertFalse(decoration.isVisible(), "1.1"); decoration.setShowOnlyOnFocus(true); sendFocusElsewhere(); sendFocusInToControl(); spinEventLoop(); - assertFalse("1.2", decoration.isVisible()); + assertFalse(decoration.isVisible(), "1.2"); decoration.show(); - assertTrue("1.3", decoration.isVisible()); + assertTrue(decoration.isVisible(), "1.3"); sendFocusElsewhere(); spinEventLoop(); - assertFalse("1.4", decoration.isVisible()); + assertFalse(decoration.isVisible(), "1.4"); decoration.setShowOnlyOnFocus(false); - assertTrue("1.5", decoration.isVisible()); + assertTrue(decoration.isVisible(), "1.5"); window.getFieldAssistControl().setVisible(false); - assertFalse("1.6", decoration.isVisible()); + assertFalse(decoration.isVisible(), "1.6"); decoration.hide(); window.getFieldAssistControl().setVisible(true); - assertFalse("1.7", decoration.isVisible()); + assertFalse(decoration.isVisible(), "1.7"); decoration.show(); - assertTrue("1.8", decoration.isVisible()); + assertTrue(decoration.isVisible(), "1.8"); } @Test @@ -206,16 +206,16 @@ public void testPopupFocus() { // Send focus to the control (not the popup) window.getFieldAssistControl().setFocus(); spinEventLoop(); - assertFalse("1.0", window.getContentProposalAdapter().hasProposalPopupFocus()); + assertFalse(window.getContentProposalAdapter().hasProposalPopupFocus(), "1.0"); window.getContentProposalAdapter().setProposalPopupFocus(); spinEventLoop(); - assertTrue("1.1", window.getContentProposalAdapter().hasProposalPopupFocus()); + assertTrue(window.getContentProposalAdapter().hasProposalPopupFocus(), "1.1"); // Setting focus to another shell deactivates the popup sendFocusElsewhere(); spinEventLoop(); assertOneShellUp(); - assertFalse("1.2", window.getContentProposalAdapter().hasProposalPopupFocus()); + assertFalse(window.getContentProposalAdapter().hasProposalPopupFocus(), "1.2"); } @Test @@ -226,16 +226,16 @@ public void testPopupIsOpen() { window.setKeyStroke(stroke); window.open(); - assertFalse("1.0", window.getContentProposalAdapter().isProposalPopupOpen()); + assertFalse(window.getContentProposalAdapter().isProposalPopupOpen(), "1.0"); sendKeyDownToControl(stroke); assertTwoShellsUp(); - assertTrue("1.1", window.getContentProposalAdapter().isProposalPopupOpen()); + assertTrue(window.getContentProposalAdapter().isProposalPopupOpen(), "1.1"); // Setting focus to another shell deactivates the popup sendFocusElsewhere(); spinEventLoop(); assertOneShellUp(); - assertFalse("1.2", window.getContentProposalAdapter().isProposalPopupOpen()); + assertFalse(window.getContentProposalAdapter().isProposalPopupOpen(), "1.2"); } /** @@ -264,7 +264,7 @@ public void testBug256651ReplaceMode() { Rectangle popupBounds = popupShell.getBounds(); Rectangle controlBounds = getFieldAssistWindow().getFieldAssistControl().getBounds(); controlBounds = getDisplay().map(getFieldAssistWindow().getFieldAssistControl().getParent(), null, controlBounds); - assertFalse("Popup is blocking the control", popupBounds.intersects(controlBounds)); + assertFalse(popupBounds.intersects(controlBounds), "Popup is blocking the control"); } /** @@ -292,6 +292,6 @@ public void testDefaultPopupPositioningReplaceMode() { Rectangle popupBounds = popupShell.getBounds(); Rectangle controlBounds = getFieldAssistWindow().getFieldAssistControl().getBounds(); controlBounds = getDisplay().map(getFieldAssistWindow().getFieldAssistControl().getParent(), null, controlBounds); - assertFalse("Popup is blocking the control", popupBounds.intersects(controlBounds)); + assertFalse(popupBounds.intersects(controlBounds), "Popup is blocking the control"); } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/AllImagesTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/AllImagesTests.java index 7761d2aa8463..7eae3d22a8d1 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/AllImagesTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/AllImagesTests.java @@ -14,7 +14,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.images; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -24,7 +24,5 @@ UrlImageDescriptorTest.class, DecorationOverlayIconTest.class, DeferredImageDescriptorTest.class }) public class AllImagesTests { - public static void main(String[] args) { - JUnitCore.main(AllImagesTests.class.getName()); - } + } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/UrlImageDescriptorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/UrlImageDescriptorTest.java index ead4939cca00..46263387e08d 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/UrlImageDescriptorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/UrlImageDescriptorTest.java @@ -15,11 +15,11 @@ ******************************************************************************/ package org.eclipse.jface.tests.images; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; import java.io.File; import java.io.IOException; @@ -32,14 +32,13 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageFileNameProvider; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class UrlImageDescriptorTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public File tempFolder; /** * Test that individually created images of a given descriptor are not equal @@ -50,10 +49,10 @@ public void testDifferentImagesPerUrlImageDescriptor() { ImageDescriptor descriptor = ImageDescriptor .createFromURL(FileImageDescriptorTest.class.getResource("/icons/imagetests/anything.gif")); Image image1 = descriptor.createImage(); - assertNotNull("Could not find first image", image1); + assertNotNull(image1, "Could not find first image"); Image image2 = descriptor.createImage(); - assertNotNull("Could not find second image", image2); - assertNotEquals("Found equal images for URLImageDescriptor", image1, image2); + assertNotNull(image2, "Could not find second image"); + assertNotEquals(image1, image2, "Found equal images for URLImageDescriptor"); image1.dispose(); image2.dispose(); } @@ -86,23 +85,22 @@ public void testImageFileNameProviderGetxPath() { .createFromURL(FileImageDescriptorTest.class.getResource("/icons/imagetests/rectangular-57x16.png")); ImageFileNameProvider fileNameProvider = Adapters.adapt(descriptor, ImageFileNameProvider.class); - assertNotNull("URLImageDescriptor does not adapt to ImageFileNameProvider", fileNameProvider); + assertNotNull(fileNameProvider, "URLImageDescriptor does not adapt to ImageFileNameProvider"); ImageFileNameProvider fileNameProvider2nd = Adapters.adapt(descriptor, ImageFileNameProvider.class); // Issue #679: The returned ImageFileNameProvider must be different each time, // because Image#equals depends on this non-uniqueness: - assertNotSame("URLImageDescriptor does return identical ImageFileNameProvider", fileNameProvider, - fileNameProvider2nd); + assertNotSame(fileNameProvider, fileNameProvider2nd, "URLImageDescriptor does return identical ImageFileNameProvider"); String imagePath100 = fileNameProvider.getImagePath(100); - assertNotNull("URLImageDescriptor ImageFileNameProvider does not return the 100% path", imagePath100); + assertNotNull(imagePath100, "URLImageDescriptor ImageFileNameProvider does not return the 100% path"); assertEquals(IPath.fromOSString(imagePath100).lastSegment(), "rectangular-57x16.png"); String imagePath200 = fileNameProvider.getImagePath(200); - assertNotNull("URLImageDescriptor ImageFileNameProvider does not return the 200% path", imagePath200); + assertNotNull(imagePath200, "URLImageDescriptor ImageFileNameProvider does not return the 200% path"); assertEquals(IPath.fromOSString(imagePath200).lastSegment(), "rectangular-114x32.png"); String imagePath150 = fileNameProvider.getImagePath(150); - assertNotNull("URLImageDescriptor ImageFileNameProvider does not return the 150% path", imagePath150); + assertNotNull(imagePath150, "URLImageDescriptor ImageFileNameProvider does not return the 150% path"); assertEquals(IPath.fromOSString(imagePath150).lastSegment(), "rectangular-86x24.png"); String imagePath250 = fileNameProvider.getImagePath(250); - assertNull("URLImageDescriptor's ImageFileNameProvider does return a 250% path", imagePath250); + assertNull(imagePath250, "URLImageDescriptor's ImageFileNameProvider does return a 250% path"); } @Test @@ -111,15 +109,15 @@ public void testImageFileNameProviderGetxName() { .createFromURL(FileImageDescriptorTest.class.getResource("/icons/imagetests/zoomIn.png")); ImageFileNameProvider fileNameProvider = Adapters.adapt(descriptor, ImageFileNameProvider.class); - assertNotNull("URLImageDescriptor does not adapt to ImageFileNameProvider", fileNameProvider); + assertNotNull(fileNameProvider, "URLImageDescriptor does not adapt to ImageFileNameProvider"); String imagePath100 = fileNameProvider.getImagePath(100); - assertNotNull("URLImageDescriptor ImageFileNameProvider does not return the 100% path", imagePath100); + assertNotNull(imagePath100, "URLImageDescriptor ImageFileNameProvider does not return the 100% path"); assertEquals(IPath.fromOSString(imagePath100).lastSegment(), "zoomIn.png"); String imagePath200 = fileNameProvider.getImagePath(200); - assertNotNull("URLImageDescriptor ImageFileNameProvider does not return the @2x path", imagePath200); + assertNotNull(imagePath200, "URLImageDescriptor ImageFileNameProvider does not return the @2x path"); assertEquals(IPath.fromOSString(imagePath200).lastSegment(), "zoomIn@2x.png"); String imagePath150 = fileNameProvider.getImagePath(150); - assertNull("URLImageDescriptor's ImageFileNameProvider does return a @1.5x path", imagePath150); + assertNull(imagePath150, "URLImageDescriptor's ImageFileNameProvider does return a @1.5x path"); } @Test @@ -136,20 +134,22 @@ private void testImageFileNameProviderGetxName_forFileURL(boolean osgiAvailable) boolean oldOsgiAvailable = InternalPolicy.OSGI_AVAILABLE; InternalPolicy.OSGI_AVAILABLE = osgiAvailable; try { - URL imageFileURL = tempFolder.newFile("image.png").toURI().toURL(); - tempFolder.newFile("image@2x.png"); + File file = new File(tempFolder, "image.png"); + file.createNewFile(); + URL imageFileURL = file.toURI().toURL(); + new File(tempFolder, "image@2x.png").createNewFile(); ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageFileURL); ImageFileNameProvider fileNameProvider = Adapters.adapt(descriptor, ImageFileNameProvider.class); - assertNotNull("URLImageDescriptor does not adapt to ImageFileNameProvider", fileNameProvider); + assertNotNull(fileNameProvider, "URLImageDescriptor does not adapt to ImageFileNameProvider"); String imagePath100 = fileNameProvider.getImagePath(100); - assertNotNull("URLImageDescriptor ImageFileNameProvider does not return the 100% path", imagePath100); + assertNotNull(imagePath100, "URLImageDescriptor ImageFileNameProvider does not return the 100% path"); assertEquals(IPath.fromOSString(imagePath100).lastSegment(), "image.png"); String imagePath200 = fileNameProvider.getImagePath(200); - assertNotNull("URLImageDescriptor ImageFileNameProvider does not return the @2x path", imagePath200); + assertNotNull(imagePath200, "URLImageDescriptor ImageFileNameProvider does not return the @2x path"); assertEquals(IPath.fromOSString(imagePath200).lastSegment(), "image@2x.png"); String imagePath150 = fileNameProvider.getImagePath(150); - assertNull("URLImageDescriptor's ImageFileNameProvider does return a @1.5x path", imagePath150); + assertNull(imagePath150, "URLImageDescriptor's ImageFileNameProvider does return a @1.5x path"); } finally { InternalPolicy.OSGI_AVAILABLE = oldOsgiAvailable; } @@ -157,7 +157,8 @@ private void testImageFileNameProviderGetxName_forFileURL(boolean osgiAvailable) @Test public void testImageFileNameProviderGetxName_forFileURL_WhiteSpace() throws IOException { - File imageFolder = tempFolder.newFolder("folder with spaces"); + File imageFolder = new File(tempFolder, "folder with spaces"); + imageFolder.mkdir(); File imageFile = new File(imageFolder, "image with spaces.png"); imageFile.createNewFile(); @@ -166,10 +167,10 @@ public void testImageFileNameProviderGetxName_forFileURL_WhiteSpace() throws IOE ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageFileURL); ImageFileNameProvider fileNameProvider = Adapters.adapt(descriptor, ImageFileNameProvider.class); - assertNotNull("URLImageDescriptor does not adapt to ImageFileNameProvider", fileNameProvider); + assertNotNull(fileNameProvider, "URLImageDescriptor does not adapt to ImageFileNameProvider"); String imagePath100 = fileNameProvider.getImagePath(100); - assertNotNull("URLImageDescriptor ImageFileNameProvider does not return the 100% path", imagePath100); + assertNotNull(imagePath100, "URLImageDescriptor ImageFileNameProvider does not return the 100% path"); } @Test @@ -178,24 +179,24 @@ public void testAdaptToURL() { .createFromURL(FileImageDescriptorTest.class.getResource("/icons/imagetests/rectangular-57x16.png")); URL url = Adapters.adapt(descriptor, URL.class); - assertNotNull("URLImageDescriptor does not adapt to URL", url); + assertNotNull(url, "URLImageDescriptor does not adapt to URL"); ImageDescriptor descriptorFromUrl = ImageDescriptor.createFromURL(url); ImageData imageDataOrig = descriptor.getImageData(100); - assertNotNull("Original URL does not return 100% image data", imageDataOrig); + assertNotNull(imageDataOrig, "Original URL does not return 100% image data"); ImageData imageDataURL = descriptorFromUrl.getImageData(100); - assertNotNull("Adapted URL does not return 100% image data", imageDataURL); + assertNotNull(imageDataURL, "Adapted URL does not return 100% image data"); assertEquals(imageDataOrig.width, imageDataURL.width); assertEquals(imageDataOrig.height, imageDataURL.height); ImageData imageDataOrig200 = descriptor.getImageData(200); - assertNotNull("Original URL does not return 200% image data", imageDataOrig200); + assertNotNull(imageDataOrig200, "Original URL does not return 200% image data"); ImageData imageDataURL200 = descriptorFromUrl.getImageData(200); assertEquals(imageDataOrig200.width, imageDataURL200.width); assertEquals(imageDataOrig200.height, imageDataURL200.height); } -} +} \ No newline at end of file diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/AllLayoutTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/AllLayoutTests.java index d61447c8555b..0b0a510488f1 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/AllLayoutTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/AllLayoutTests.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.layout; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -23,8 +23,6 @@ GridLayoutFactoryTest.class, TreeColumnLayoutTest.class }) public class AllLayoutTests { - public static void main(String[] args) { - JUnitCore.main(AllLayoutTests.class.getName()); - } + } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/AllPrefsTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/AllPrefsTests.java index 18f658a8121e..9c9b1a4a9dbe 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/AllPrefsTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/AllPrefsTests.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.preferences; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -27,7 +27,5 @@ }) public class AllPrefsTests { - public static void main(String[] args) { - JUnitCore.main(AllPrefsTests.class.getName()); - } + } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/AllResourcesTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/AllResourcesTests.java index 9f29e3c86a09..044cb499040a 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/AllResourcesTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/AllResourcesTests.java @@ -14,7 +14,7 @@ package org.eclipse.jface.tests.resources; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -23,7 +23,5 @@ @SelectClasses({ FontRegistryTest.class, JFaceResourcesTest.class }) public class AllResourcesTests { - public static void main(String[] args) { - JUnitCore.main(AllResourcesTests.class.getName()); - } + } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/FontRegistryTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/FontRegistryTest.java index 977fe3297eb7..f817e28c8aba 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/FontRegistryTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/FontRegistryTest.java @@ -18,7 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.time.Duration; import java.time.Instant; @@ -55,7 +55,7 @@ public void testBug544026() { @Test public void multipleDisplayDispose() { - assumeTrue("multiple Display instance only allowed on Windows", OS.isWindows()); + assumeTrue(OS.isWindows(), "multiple Display instance only allowed on Windows"); FontRegistry fontRegistry = new FontRegistry(); Display secondDisplay = initializeDisplayInSeparateThread(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/AllViewersTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/AllViewersTests.java index 5b6d9f7da940..e62843873bdc 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/AllViewersTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/AllViewersTests.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.viewers; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -36,8 +36,6 @@ TableViewerWithLimitCompatibilityTest.class }) public class AllViewersTests { - public static void main(String[] args) { - JUnitCore.main(AllViewersTests.class.getName()); - } + } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java index 9ee269ced360..220867dc0988 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java @@ -18,7 +18,7 @@ import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; -import junit.framework.AssertionFailedError; +import org.opentest4j.AssertionFailedError; /** * The TestLazyModelContentProvider is the lazy version diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TreeViewerWithLimitTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TreeViewerWithLimitTest.java index 15d34fb2b450..9fdd9b96c5c7 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TreeViewerWithLimitTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TreeViewerWithLimitTest.java @@ -14,10 +14,10 @@ package org.eclipse.jface.tests.viewers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; @@ -50,17 +50,17 @@ private void assertSetSelectionExpNode(DataModel invisible) { treeViewer.setSelection(new StructuredSelection(invisible), true); processEvents(); IStructuredSelection selection = treeViewer.getStructuredSelection(); - assertFalse("Selection must not be empty", selection.isEmpty()); + assertFalse(selection.isEmpty(), "Selection must not be empty"); Object firstElement = selection.getFirstElement(); - assertTrue("Selection must be expandable node: " + firstElement, treeViewer.isExpandableNode(firstElement)); + assertTrue(treeViewer.isExpandableNode(firstElement), "Selection must be expandable node: " + firstElement); } private void assertSetSelection(DataModel firstEle) { treeViewer.setSelection(new StructuredSelection(firstEle)); processEvents(); IStructuredSelection selection = treeViewer.getStructuredSelection(); - assertFalse("Selection must not be empty", selection.isEmpty()); - assertEquals("incorrect element is selected", firstEle, selection.getFirstElement()); + assertFalse(selection.isEmpty(), "Selection must not be empty"); + assertEquals(firstEle, selection.getFirstElement(), "incorrect element is selected"); } @Test @@ -85,7 +85,7 @@ public void testReveal() throws Exception { break; } } - assertTrue("item to select must be inside expandable node", found); + assertTrue(found, "item to select must be inside expandable node"); } @Test @@ -100,7 +100,7 @@ public void testCollapseAll() { TreeItem[] items = assertLimitedItems(); for (int i = 0; i < VIEWER_LIMIT; i++) { TreeItem treeItem = items[i]; - assertFalse("expansion must be false", treeItem.getExpanded()); + assertFalse(treeItem.getExpanded(), "expansion must be false"); } } @@ -124,17 +124,17 @@ public void testExpandAll() { private TreeItem[] assertLimitedItems(TreeItem treeItem) { TreeItem[] items = treeItem.getItems(); - assertEquals("There should be only limited items", VIEWER_LIMIT + 1, items.length); + assertEquals(VIEWER_LIMIT + 1, items.length, "There should be only limited items"); Object data = items[VIEWER_LIMIT].getData(); - assertTrue("last item must be expandable node", treeViewer.isExpandableNode(data)); + assertTrue(treeViewer.isExpandableNode(data), "last item must be expandable node"); return items; } private TreeItem[] assertLimitedItems() { TreeItem[] rootLevelItems = treeViewer.getTree().getItems(); - assertEquals("There should be only limited items", VIEWER_LIMIT + 1, rootLevelItems.length); + assertEquals(VIEWER_LIMIT + 1, rootLevelItems.length, "There should be only limited items"); Object data = rootLevelItems[VIEWER_LIMIT].getData(); - assertTrue("last item must be expandable node", treeViewer.isExpandableNode(data)); + assertTrue(treeViewer.isExpandableNode(data), "last item must be expandable node"); return rootLevelItems; } @@ -153,8 +153,8 @@ public void testExpandToLevelInt() { private static void assertDummyItem(TreeItem treeItem) { TreeItem[] items = treeItem.getItems(); - assertEquals("Item must not be expanded", 1, items.length); - assertNull("Dummy tree item data must be null", items[0].getData()); + assertEquals(1, items.length, "Item must not be expanded"); + assertNull(items[0].getData(), "Dummy tree item data must be null"); } @Test @@ -181,12 +181,12 @@ public void testRemoveItemsAtParent() { DataModel firstEle = rootModel.get(0); DataModel thirdOfFirst = firstEle.children.get(2).children.remove(2); TreeItem visItem = treeViewer.getTree().getItem(0).getItem(2).getItem(2); - assertEquals("element contains unexpected data", thirdOfFirst, visItem.getData()); + assertEquals(thirdOfFirst, visItem.getData(), "element contains unexpected data"); treeViewer.remove(firstEle, new Object[] { thirdOfFirst }); processEvents(); thirdOfFirst = firstEle.children.get(2).children.get(2); visItem = treeViewer.getTree().getItem(0).getItem(2).getItem(2); - assertEquals("element contains unexpected data", thirdOfFirst, visItem.getData()); + assertEquals(thirdOfFirst, visItem.getData(), "element contains unexpected data"); } @Test @@ -196,12 +196,12 @@ public void testRemoveItem() { processEvents(); DataModel firstEle = rootModel.remove(0); TreeItem firstItem = treeViewer.getTree().getItem(0); - assertEquals("element contains unexpected data", firstEle, firstItem.getData()); + assertEquals(firstEle, firstItem.getData(), "element contains unexpected data"); treeViewer.remove(firstEle); processEvents(); firstEle = rootModel.get(0); firstItem = treeViewer.getTree().getItem(0); - assertEquals("element contains unexpected data", firstEle, firstItem.getData()); + assertEquals(firstEle, firstItem.getData(), "element contains unexpected data"); } @Test @@ -222,37 +222,37 @@ public void testSetAutoExpandLevel() { @Test public void testInsert() { TreeItem thirdItem = treeViewer.getTree().getItem(2); - assertEquals("unexpected element found at position 2", rootModel.get(2), thirdItem.getData()); + assertEquals(rootModel.get(2), thirdItem.getData(), "unexpected element found at position 2"); DataModel newElement = new DataModel(Integer.valueOf(3)); rootModel.add(newElement); treeViewer.insert(rootModel, newElement, 2); processEvents(); thirdItem = treeViewer.getTree().getItem(2); - assertEquals("unexpected element found at position 2", newElement, thirdItem.getData()); + assertEquals(newElement, thirdItem.getData(), "unexpected element found at position 2"); } @Test public void testRefresh() { DataModel firstEle = rootModel.remove(0); TreeItem firstItem = treeViewer.getTree().getItem(0); - assertEquals("element contains unexpected data", firstEle, firstItem.getData()); + assertEquals(firstEle, firstItem.getData(), "element contains unexpected data"); treeViewer.refresh(); processEvents(); firstEle = rootModel.get(0); firstItem = treeViewer.getTree().getItem(0); - assertEquals("element contains unexpected data", firstEle, firstItem.getData()); + assertEquals(firstEle, firstItem.getData(), "element contains unexpected data"); } @Test public void testSetFilters() { DataModel firstEle = rootModel.get(0); TreeItem firstItem = treeViewer.getTree().getItem(0); - assertEquals("element contains unexpected data", firstEle, firstItem.getData()); + assertEquals(firstEle, firstItem.getData(), "element contains unexpected data"); treeViewer.setFilters(new TestViewerFilter()); processEvents(); firstEle = rootModel.get(6); firstItem = treeViewer.getTree().getItem(0); - assertEquals("element contains unexpected data", firstEle, firstItem.getData()); + assertEquals(firstEle, firstItem.getData(), "element contains unexpected data"); } @Test @@ -262,7 +262,7 @@ public void testSetInput() { rootModel.add(rootLevel); treeViewer.setInput(rootModel); processEvents(); - assertEquals("there must be only one item", 1, treeViewer.getTree().getItems().length); + assertEquals(1, treeViewer.getTree().getItems().length, "there must be only one item"); treeViewer.setInput(createModel(DEFAULT_ELEMENTS_COUNT)); processEvents(); assertLimitedItems(); @@ -271,21 +271,21 @@ public void testSetInput() { @Test public void testContains() { // some random element. - assertFalse("element must not be available on the viewer", treeViewer.contains(fRootElement, "")); + assertFalse(treeViewer.contains(fRootElement, ""), "element must not be available on the viewer"); // first child of root. - assertTrue("element must be available on the viewer", treeViewer.contains(rootModel, rootModel.get(0))); + assertTrue(treeViewer.contains(rootModel, rootModel.get(0)), "element must be available on the viewer"); // last child of the root - assertTrue("element must be available on the viewer", - treeViewer.contains(rootModel, rootModel.get(rootModel.size() - 1))); + assertTrue( + treeViewer.contains(rootModel, rootModel.get(rootModel.size() - 1)), "element must be available on the viewer"); // child of first element is not expanded - assertFalse("element must not be available on the viewer", - treeViewer.contains(rootModel, rootModel.get(0).children.get(0))); + assertFalse( + treeViewer.contains(rootModel, rootModel.get(0).children.get(0)), "element must not be available on the viewer"); treeViewer.expandAll(); // child of first element when expanded. - assertTrue("element must be available on the viewer", - treeViewer.contains(rootModel, rootModel.get(0).children.get(0))); + assertTrue( + treeViewer.contains(rootModel, rootModel.get(0).children.get(0)), "element must be available on the viewer"); } @Override @@ -346,4 +346,4 @@ public TestTreeViewer(Composite parent) { } } -} +} \ No newline at end of file diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/AllWindowTests.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/AllWindowTests.java index 55e74f7b7afc..868c2cbe62e1 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/AllWindowTests.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/AllWindowTests.java @@ -14,7 +14,7 @@ package org.eclipse.jface.tests.window; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -26,7 +26,5 @@ }) public class AllWindowTests { - public static void main(String[] args) { - JUnitCore.main(AllWindowTests.class.getName()); - } + } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardTestSuite.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardTestSuite.java index b8154f28091f..12a3d96d7ed1 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardTestSuite.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardTestSuite.java @@ -14,7 +14,7 @@ package org.eclipse.jface.tests.wizards; -import org.junit.runner.JUnitCore; + import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -23,8 +23,6 @@ @SelectClasses({ ButtonAlignmentTest.class, WizardTest.class, WizardProgressMonitorTest.class }) public class WizardTestSuite { - public static void main(String[] args) { - JUnitCore.main(WizardTestSuite.class.getName()); - } + }