diff --git a/tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF index fc402aa4f30..02953b95126 100644 --- a/tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF @@ -13,6 +13,7 @@ Require-Bundle: org.junit;bundle-version="4.12.0", org.eclipse.ui.tests.harness Import-Package: org.osgi.framework, 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)" Export-Package: org.eclipse.jface.tests.fieldassist;x-internal:=true, org.eclipse.jface.tests.preferences;x-internal:=true, diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java index 8bd3ceeaeb4..e65bc8d396c 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java @@ -15,12 +15,12 @@ *******************************************************************************/ package org.eclipse.jface.tests.dialogs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.io.StringReader; @@ -29,7 +29,7 @@ import org.eclipse.jface.dialogs.DialogSettings; import org.eclipse.jface.dialogs.IDialogSettings; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DialogSettingsTest { diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/DialogTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/DialogTest.java index c5298f986cf..c8b47776b56 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/DialogTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/DialogTest.java @@ -13,7 +13,7 @@ ******************************************************************************/ package org.eclipse.jface.tests.dialogs; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -22,8 +22,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; public class DialogTest { @@ -32,7 +32,7 @@ public class DialogTest { */ private Dialog dialog; - @After + @AfterEach public void tearDown() throws Exception { if (dialog != null) { // close the dialog @@ -69,9 +69,9 @@ public void testButtonAlignmentBug272583() { int cancelX = cancelBtn.getBounds().x; if (okBtn.getDisplay().getDismissalAlignment() == SWT.LEFT) { - assertTrue("The 'OK' button should be to the left of the 'Cancel' button", okX < cancelX); + assertTrue(okX < cancelX, "The 'OK' button should be to the left of the 'Cancel' button"); } else { - assertTrue("The 'OK' button should be to the right of the 'Cancel' button", cancelX < okX); + assertTrue(cancelX < okX, "The 'OK' button should be to the right of the 'Cancel' button"); } forceLayoutDialog.close(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/InputDialogTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/InputDialogTest.java index 5b1914cf3f8..7e21709ded9 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/InputDialogTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/InputDialogTest.java @@ -14,14 +14,14 @@ package org.eclipse.jface.tests.dialogs; import org.eclipse.jface.dialogs.InputDialog; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; public class InputDialogTest { private InputDialog dialog; - @After + @AfterEach public void tearDown() throws Exception { if (dialog != null) { dialog.close(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/PlainMessageDialogTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/PlainMessageDialogTest.java index 44692dcdb2f..8973416bf78 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/PlainMessageDialogTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/PlainMessageDialogTest.java @@ -12,7 +12,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.dialogs; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; @@ -24,22 +24,22 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; -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 PlainMessageDialogTest { private Builder builder; private PlainMessageDialog dialog; - @Before + @BeforeEach public void setup() { Shell shell = new Shell(Display.getDefault()); builder = PlainMessageDialog.getBuilder(shell, "My Dialog"); } - @After + @AfterEach public void tearDown() { if (dialog != null) { dialog.close(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java index 28344c68ddd..c282b8b20e2 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java @@ -14,7 +14,7 @@ package org.eclipse.jface.tests.dialogs; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.lang.reflect.Field; @@ -22,7 +22,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.widgets.Shell; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test case to assert proper styles have been set for ProgressIndicator. diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/ProgressMonitorDialogTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/ProgressMonitorDialogTest.java index f1d2586f4ec..81ec470edd2 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/ProgressMonitorDialogTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/ProgressMonitorDialogTest.java @@ -16,12 +16,12 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.swt.widgets.Display; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ProgressMonitorDialogTest { - @Before + @BeforeEach public void setUp() throws Exception { // ensure we've initialized a display for this thread Display.getDefault(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/SafeRunnableErrorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/SafeRunnableErrorTest.java index 097d7aaad3b..5c417c20c4a 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/SafeRunnableErrorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/SafeRunnableErrorTest.java @@ -13,11 +13,11 @@ ******************************************************************************/ package org.eclipse.jface.tests.dialogs; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.jface.util.SafeRunnable; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * NOTE - these tests are not really very good, in order to really test this you diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/StatusDialogTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/StatusDialogTest.java index b259fdd052a..59509e1664d 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/StatusDialogTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/StatusDialogTest.java @@ -13,7 +13,7 @@ ******************************************************************************/ package org.eclipse.jface.tests.dialogs; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -22,9 +22,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; -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 StatusDialogTest { @@ -41,12 +41,12 @@ public void testEscapeAmpesandInStatusLabelBug395426() { assertEquals("&&", statusLabel.getText()); } - @Before + @BeforeEach public void setUp() throws Exception { shell = new Shell(); } - @After + @AfterEach public void tearDown() throws Exception { shell.dispose(); } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java index 486e0b7848c..08995a73cf8 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java @@ -18,8 +18,8 @@ import org.eclipse.jface.resource.ResourceLocator; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; public class TitleAreaDialogTest { @@ -28,7 +28,7 @@ public class TitleAreaDialogTest { private TitleAreaDialog dialog; - @After + @AfterEach public void tearDown() throws Exception { if (dialog != null) { dialog.close(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/DecorationOverlayIconTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/DecorationOverlayIconTest.java index 05a53beccd0..dd6545d87be 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/DecorationOverlayIconTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/DecorationOverlayIconTest.java @@ -13,11 +13,11 @@ *******************************************************************************/ package org.eclipse.jface.tests.images; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.resource.ImageDescriptor; @@ -26,8 +26,8 @@ import org.eclipse.jface.viewers.DecorationOverlayIcon; import org.eclipse.jface.viewers.IDecoration; import org.eclipse.swt.graphics.Image; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @since 3.13 @@ -41,7 +41,7 @@ public class DecorationOverlayIconTest { private ImageDescriptor overlayDescriptor1; private ImageDescriptor overlayDescriptor2; - @Before + @BeforeEach public void setUp() { ImageRegistry imageRegistry = JFaceResources.getImageRegistry(); baseImage1 = imageRegistry.get(Dialog.DLG_IMG_HELP); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/DeferredImageDescriptorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/DeferredImageDescriptorTest.java index 52031000bbd..711c797f28a 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/DeferredImageDescriptorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/DeferredImageDescriptorTest.java @@ -15,16 +15,16 @@ package org.eclipse.jface.tests.images; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.net.URL; import org.eclipse.core.runtime.Adapters; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.ImageData; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test loading ImageDescriptors from a URL calculated on demand. @@ -57,15 +57,15 @@ public void testAdaptToURL() { () -> DeferredImageDescriptorTest.class.getResource("anything.gif")); URL url = Adapters.adapt(descriptor, URL.class); - assertNotNull("DeferredImageDescriptor does not adapt to URL", url); + assertNotNull(url, "DeferredImageDescriptor 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); } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/FileImageDescriptorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/FileImageDescriptorTest.java index f189c3f620e..dbc7d722c55 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/FileImageDescriptorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/FileImageDescriptorTest.java @@ -19,11 +19,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.IOException; import java.net.URL; @@ -37,7 +37,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageFileNameProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; @@ -98,7 +98,7 @@ public void testFileImageDescriptorLocal() { ImageDescriptor descriptor = ImageDescriptor.createFromFile(FileImageDescriptorTest.class, "anything.gif"); Image image = descriptor.createImage(); - assertNotNull("Could not find image", image); + assertNotNull(image, "Could not find image"); image.dispose(); } @@ -112,7 +112,7 @@ public void testFileImageDescriptorMissing() { ImageDescriptor descriptor = ImageDescriptor.createFromFile(FileImageDescriptorTest.class, "missing.gif"); Image image = descriptor.createImage(false); - assertNull("Found an image but should be null", image); + assertNull(image, "Found an image but should be null"); } /** @@ -124,7 +124,7 @@ public void testFileImageDescriptorMissingWithDefault() { ImageDescriptor descriptor = ImageDescriptor.createFromFile(FileImageDescriptorTest.class, "missing.gif"); Image image = descriptor.createImage(true); - assertNotNull("Did not find default image", image); + assertNotNull(image, "Did not find default image"); } /** @@ -135,10 +135,10 @@ public void testFileImageDescriptorMissingWithDefault() { public void testDifferentImagesPerFileImageDescriptor() { ImageDescriptor descriptor = ImageDescriptor.createFromFile(FileImageDescriptorTest.class, "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 FileImageDescriptor", image1, image2); + assertNotNull(image2, "Could not find second image"); + assertNotEquals(image1, image2, "Found equal images for FileImageDescriptor"); image1.dispose(); image2.dispose(); } @@ -194,23 +194,23 @@ public void testImageFileNameProviderGetxPath() { ImageDescriptor descriptor = ImageDescriptor.createFromFile(FileImageDescriptorTest.class, "/icons/imagetests/rectangular-57x16.png"); ImageFileNameProvider fileNameProvider = Adapters.adapt(descriptor, ImageFileNameProvider.class); - assertNotNull("FileImageDescriptor does not adapt to ImageFileNameProvider", fileNameProvider); + assertNotNull(fileNameProvider, "FileImageDescriptor 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("FileImageDescriptor does return identical ImageFileNameProvider", fileNameProvider, - fileNameProvider2nd); + assertNotSame(fileNameProvider, + fileNameProvider2nd, "FileImageDescriptor does return identical ImageFileNameProvider"); String imagePath100 = fileNameProvider.getImagePath(100); - assertNotNull("FileImageDescriptor's ImageFileNameProvider does not return the 100% path", imagePath100); + assertNotNull(imagePath100, "FileImageDescriptor's ImageFileNameProvider does not return the 100% path"); assertEquals(IPath.fromOSString(imagePath100).lastSegment(), "rectangular-57x16.png"); String imagePath200 = fileNameProvider.getImagePath(200); - assertNotNull("FileImageDescriptor's ImageFileNameProvider does not return the 200% path", imagePath200); + assertNotNull(imagePath200, "FileImageDescriptor's ImageFileNameProvider does not return the 200% path"); assertEquals(IPath.fromOSString(imagePath200).lastSegment(), "rectangular-114x32.png"); String imagePath150 = fileNameProvider.getImagePath(150); - assertNotNull("FileImageDescriptor's ImageFileNameProvider does not return the 150% path", imagePath150); + assertNotNull(imagePath150, "FileImageDescriptor's ImageFileNameProvider does not return the 150% path"); assertEquals(IPath.fromOSString(imagePath150).lastSegment(), "rectangular-86x24.png"); String imagePath250 = fileNameProvider.getImagePath(250); - assertNull("FileImageDescriptor's ImageFileNameProvider does return a 250% path", imagePath250); + assertNull(imagePath250, "FileImageDescriptor's ImageFileNameProvider does return a 250% path"); } @Test @@ -218,15 +218,15 @@ public void testImageFileNameProviderGetxName() { ImageDescriptor descriptor = ImageDescriptor.createFromFile(FileImageDescriptorTest.class, "/icons/imagetests/zoomIn.png"); ImageFileNameProvider fileNameProvider = Adapters.adapt(descriptor, ImageFileNameProvider.class); - assertNotNull("FileImageDescriptor does not adapt to ImageFileNameProvider", fileNameProvider); + assertNotNull(fileNameProvider, "FileImageDescriptor does not adapt to ImageFileNameProvider"); String imagePath100 = fileNameProvider.getImagePath(100); - assertNotNull("FileImageDescriptor's ImageFileNameProvider does not return the 100% path", imagePath100); + assertNotNull(imagePath100, "FileImageDescriptor's ImageFileNameProvider does not return the 100% path"); assertEquals(IPath.fromOSString(imagePath100).lastSegment(), "zoomIn.png"); String imagePath200 = fileNameProvider.getImagePath(200); - assertNotNull("FileImageDescriptor's ImageFileNameProvider does not return the @2x path", imagePath200); + assertNotNull(imagePath200, "FileImageDescriptor's ImageFileNameProvider does not return the @2x path"); assertEquals(IPath.fromOSString(imagePath200).lastSegment(), "zoomIn@2x.png"); String imagePath150 = fileNameProvider.getImagePath(150); - assertNull("FileImageDescriptor's ImageFileNameProvider does return a @1.5x path", imagePath150); + assertNull(imagePath150, "FileImageDescriptor's ImageFileNameProvider does return a @1.5x path"); } @Test @@ -235,20 +235,20 @@ public void testAdaptToURL() { "/icons/imagetests/rectangular-57x16.png"); URL url = Adapters.adapt(descriptor, URL.class); - assertNotNull("FileImageDescriptor does not adapt to URL", url); + assertNotNull(url, "FileImageDescriptor 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); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/ImageRegistryTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/ImageRegistryTest.java index fb0a2876eba..8b917a38765 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/ImageRegistryTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/ImageRegistryTest.java @@ -14,8 +14,8 @@ *******************************************************************************/ package org.eclipse.jface.tests.images; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IconAndMessageDialog; @@ -24,7 +24,7 @@ import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.window.Window; import org.eclipse.swt.graphics.Image; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @since 3.0 @@ -36,7 +36,7 @@ public void testGetNull() { ImageRegistry reg = JFaceResources.getImageRegistry(); Image result = reg.get((String) null); - assertNull("Registry should handle null", result); + assertNull(result, "Registry should handle null"); } @SuppressWarnings("removal") @@ -56,7 +56,7 @@ public void testGetString() { for (String imageName : imageNames) { Image image1 = reg.get(imageName); - assertNotNull("Returned null image", image1); + assertNotNull(image1, "Returned null image"); } } @@ -77,7 +77,7 @@ public void testGetIconMessageDialogImages() { iconDialog.getQuestionImage(), iconDialog.getWarningImage() }; for (Image image : images) { - assertNotNull("Returned null image", image); + assertNotNull(image, "Returned null image"); } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/LazyResourceManagerTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/LazyResourceManagerTest.java index 5d26a0e932e..d9483e991d9 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/LazyResourceManagerTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/LazyResourceManagerTest.java @@ -14,10 +14,10 @@ *******************************************************************************/ package org.eclipse.jface.tests.images; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +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 static org.junit.jupiter.api.Assertions.assertSame; import java.util.HashMap; import java.util.Map; @@ -32,7 +32,7 @@ import org.eclipse.jface.resource.ResourceManager; import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.Image; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings({ "rawtypes", "unchecked" }) public class LazyResourceManagerTest { diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/ResourceManagerTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/ResourceManagerTest.java index 0f844b7153e..b04b2803801 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/ResourceManagerTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/images/ResourceManagerTest.java @@ -14,10 +14,10 @@ *******************************************************************************/ package org.eclipse.jface.tests.images; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -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.assertTrue; import java.util.Objects; @@ -37,10 +37,10 @@ import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; -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; /** * @since 3.1 @@ -96,7 +96,7 @@ public int hashCode() { } } - @Before + @BeforeEach public void setUp() throws Exception { TestDescriptor.refCount = 0; Display display = Display.getCurrent(); @@ -145,18 +145,18 @@ public void setUp() throws Exception { numDupes = 12; } - @After + @AfterEach public void tearDown() throws Exception { globalResourceManager.dispose(); - Assert.assertEquals("Detected leaks", 0, TestDescriptor.refCount); + Assertions.assertEquals(0, TestDescriptor.refCount, "Detected leaks"); testImage.dispose(); testImage2.dispose(); } protected void validateResource(Object resource) throws Exception { - Assert.assertNotNull("Allocated resource was null", resource); + Assertions.assertNotNull(resource, "Allocated resource was null"); if (resource instanceof Image image) { - assertFalse("Image is disposed", image.isDisposed()); + assertFalse(image.isDisposed(), "Image is disposed"); return; } } @@ -183,8 +183,8 @@ public void testDescriptorAllocations() throws Exception { // Allocating resources without the manager will not reuse duplicates, so we // should get exactly one resource per descriptor. - Assert.assertEquals("Expecting one resource to be allocated per descriptor", descriptors.length, - TestDescriptor.refCount); + Assertions.assertEquals(descriptors.length, + TestDescriptor.refCount, "Expecting one resource to be allocated per descriptor"); // Deallocate resources directly using the descriptors for (int i = 0; i < descriptors.length; i++) { @@ -209,15 +209,14 @@ public void testDeviceManagerAllocations() throws Exception { resources[i] = resource; } - Assert.assertEquals( - "Descriptors created from Images should not reallocate Images when the original can be reused", - testImage, resources[9]); + Assertions.assertEquals(testImage, resources[9], + "Descriptors created from Images should not reallocate Images when the original can be reused"); // Allocating resources without the manager will reuse duplicates, so the number // of resources should equal the number of unique descriptors. - Assert.assertEquals("Duplicate descriptors should be reused", descriptors.length - numDupes, - TestDescriptor.refCount); + Assertions.assertEquals(descriptors.length - numDupes, + TestDescriptor.refCount, "Duplicate descriptors should be reused"); // Deallocate resources directly using the descriptors for (DeviceResourceDescriptor next : descriptors) { @@ -265,13 +264,13 @@ public void testLocalManagerAllocations() throws Exception { // back down to the count we had after we allocated lm1 resources) allocateResources(lm2, lm2Resources); deallocateResources(lm2, lm2Resources); - Assert.assertEquals(lm1Count, TestDescriptor.refCount); + Assertions.assertEquals(TestDescriptor.refCount, lm1Count); // Dispose lm2 (shouldn't do anything since we already deallocated all of its // resources) // Ensure that this doesn't change any refcounts lm2.dispose(); - Assert.assertEquals(lm1Count, TestDescriptor.refCount); + Assertions.assertEquals(TestDescriptor.refCount, lm1Count); // Dispose lm1 without first deallocating its resources. This should correctly // detect @@ -280,7 +279,7 @@ public void testLocalManagerAllocations() throws Exception { // allocating // the global resources. lm1.dispose(); - Assert.assertEquals(initialCount, TestDescriptor.refCount); + Assertions.assertEquals(TestDescriptor.refCount, initialCount); } @@ -293,7 +292,7 @@ public void testImageDataResourceAllocations() throws Exception { // Allocate a bunch of global resources allocateResources(globalResourceManager, gResources); - Assert.assertEquals(2, TestDescriptor.refCount); + Assertions.assertEquals(TestDescriptor.refCount, 2); } /* @@ -303,7 +302,7 @@ public void testImageDataResourceAllocations() throws Exception { public void testResourceManagerFind() throws Exception { DeviceResourceDescriptor descriptor = descriptors[0]; Object resource = globalResourceManager.find(descriptor); - assertNull("Resource should be null since it is not allocated", resource); + assertNull(resource, "Resource should be null since it is not allocated"); resource = globalResourceManager.create(descriptor); // Ensure that the resource was allocated correctly @@ -311,8 +310,8 @@ public void testResourceManagerFind() throws Exception { // Now the resource should be found Object foundResource = globalResourceManager.find(descriptor); - assertNotNull("Found resource should not be null", foundResource); - assertTrue("Found resource should be an image", foundResource instanceof Image); + assertNotNull(foundResource, "Found resource should not be null"); + assertTrue(foundResource instanceof Image, "Found resource should be an image"); // Destroy the resource we created globalResourceManager.destroy(descriptor); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/ColumnLabelProviderLambdaTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/ColumnLabelProviderLambdaTest.java index 65291bf003a..adc2dbcc125 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/ColumnLabelProviderLambdaTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/ColumnLabelProviderLambdaTest.java @@ -1,6 +1,6 @@ package org.eclipse.jface.tests.labelProviders; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.tests.viewers.StructuredViewerTest.TestLabelProvider; @@ -10,7 +10,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ColumnLabelProviderLambdaTest { @@ -24,7 +24,7 @@ public void testCreateTextProvider() { Integer[] model = (Integer[]) columnViewer.getViewer().getInput(); ColumnLabelProvider provider = (ColumnLabelProvider) columnViewer.getViewer().getLabelProvider(0); String firstElementText = provider.getText(model[0]); - assertEquals("same label text", Integer.valueOf(0).toString(), firstElementText); + assertEquals(Integer.valueOf(0).toString(), firstElementText, "same label text"); } @Test @@ -37,7 +37,7 @@ public void testCreateImageProvider() { shell.open(); Integer[] model = (Integer[]) columnViewer.getViewer().getInput(); ColumnLabelProvider provider = (ColumnLabelProvider) columnViewer.getViewer().getLabelProvider(0); - assertEquals("same image", fgImage, provider.getImage(model[0])); + assertEquals(fgImage, provider.getImage(model[0]), "same image"); } @Test @@ -52,8 +52,8 @@ public void testCreateTextImageProvider() { Integer[] model = (Integer[]) columnViewer.getViewer().getInput(); ColumnLabelProvider provider = (ColumnLabelProvider) columnViewer.getViewer().getLabelProvider(0); String firstElementText = provider.getText(model[0]); - assertEquals("same label text", Integer.valueOf(0).toString(), firstElementText); - assertEquals("same image", fgImage, provider.getImage(model[0])); + assertEquals(Integer.valueOf(0).toString(), firstElementText, "same label text"); + assertEquals(fgImage, provider.getImage(model[0]), "same image"); } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/IDecorationContextTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/IDecorationContextTest.java index 3c4705cc13e..ca6142ae796 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/IDecorationContextTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/IDecorationContextTest.java @@ -14,8 +14,8 @@ package org.eclipse.jface.tests.labelProviders; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import org.eclipse.core.runtime.AssertionFailedException; import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider; @@ -26,7 +26,7 @@ import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.StyledString; import org.eclipse.swt.graphics.Image; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Most of the setup has been taken from diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderLambdaTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderLambdaTest.java index 050f94ce1b7..478872f80a1 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderLambdaTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderLambdaTest.java @@ -1,6 +1,6 @@ package org.eclipse.jface.tests.labelProviders; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.tests.viewers.StructuredViewerTest.TestLabelProvider; @@ -13,7 +13,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class LabelProviderLambdaTest { @@ -47,7 +47,7 @@ public void testCreateTextProvider() { shell.open(); Table table = (Table) viewer.getControl(); String firstElementText = table.getItem(0).getText(); - assertEquals("rendered label", Integer.valueOf(0).toString(), firstElementText); + assertEquals(Integer.valueOf(0).toString(), firstElementText, "rendered label"); } @Test @@ -60,8 +60,8 @@ public void testCreateTextImageProvider() { Table table = (Table) viewer.getControl(); String firstElementText = table.getItem(0).getText(); LabelProvider provider = (LabelProvider) viewer.getLabelProvider(); - assertEquals("same label text", Integer.valueOf(0).toString(), firstElementText); - assertEquals("same image", fgImage, provider.getImage(table.getItem(0))); + assertEquals(Integer.valueOf(0).toString(), firstElementText, "same label text"); + assertEquals(fgImage, provider.getImage(table.getItem(0)), "same image"); } @@ -75,8 +75,8 @@ public void testCreateImageProvider() { Table table = (Table) viewer.getControl(); LabelProvider provider = (LabelProvider) viewer.getLabelProvider(); String firstElementText = table.getItem(0).getText(); - assertEquals("same label text", Integer.valueOf(0).toString(), firstElementText); - assertEquals("same image", fgImage, provider.getImage(table.getItem(0))); + assertEquals(Integer.valueOf(0).toString(), firstElementText, "same label text"); + assertEquals(fgImage, provider.getImage(table.getItem(0)), "same image"); } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderTest.java index 49b6ce965b9..842920bfce5 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderTest.java @@ -1,15 +1,16 @@ package org.eclipse.jface.tests.labelProviders; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.function.Function; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; -import org.junit.AfterClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; public class LabelProviderTest { @@ -21,7 +22,7 @@ public class LabelProviderTest { private final Function textFunction = o -> o instanceof Car ? ((Car) o).getMake() : "unknown"; private final Function imageFunction = o -> o instanceof Car ? horchImage : defaultImage; - @AfterClass + @AfterAll public static void classTeardown() { horchImage.dispose(); defaultImage.dispose(); @@ -74,24 +75,32 @@ public void textImageProviderGivesBoth() { assertEquals("unknown", labelProvider.getText(new Object())); } - @Test(expected = NullPointerException.class) + @Test public void throwsExceptionOnNullTextProvider() { - LabelProvider.createTextProvider(null); + assertThrows(NullPointerException.class, () -> { + LabelProvider.createTextProvider(null); + }); } - @Test(expected = NullPointerException.class) + @Test public void throwsExceptionOnNullImageProvider() { - LabelProvider.createImageProvider(null); + assertThrows(NullPointerException.class, () -> { + LabelProvider.createImageProvider(null); + }); } - @Test(expected = NullPointerException.class) + @Test public void throwsExceptionOnNullTextProviderInTextImageProvider() { - LabelProvider.createTextImageProvider(null, imageFunction); + assertThrows(NullPointerException.class, () -> { + LabelProvider.createTextImageProvider(null, imageFunction); + }); } - @Test(expected = NullPointerException.class) + @Test public void throwsExceptionOnNullImageProviderInTextImageProvider() { - LabelProvider.createTextImageProvider(textFunction, null); + assertThrows(NullPointerException.class, () -> { + LabelProvider.createTextImageProvider(textFunction, null); + }); } static class Car { diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/AbstractColumnLayoutTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/AbstractColumnLayoutTest.java index e7c7b3f1e36..3b5d92dfad6 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/AbstractColumnLayoutTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/AbstractColumnLayoutTest.java @@ -15,8 +15,8 @@ package org.eclipse.jface.tests.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.jface.layout.TableColumnLayout; import org.eclipse.jface.viewers.ColumnPixelData; @@ -28,9 +28,9 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; -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; /** * @since 3.4 @@ -39,7 +39,7 @@ public final class AbstractColumnLayoutTest { Display display; Shell shell; - @Before + @BeforeEach public void setUp() throws Exception { display = Display.getCurrent(); if (display == null) { @@ -51,7 +51,7 @@ public void setUp() throws Exception { } - @After + @AfterEach public void tearDown() throws Exception { shell.dispose(); } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GeometryTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GeometryTest.java index 75022f47907..64e05b317fb 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GeometryTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GeometryTest.java @@ -14,11 +14,11 @@ package org.eclipse.jface.tests.layout; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.util.Geometry; import org.eclipse.swt.graphics.Rectangle; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @since 3.3 diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GridDataFactoryTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GridDataFactoryTest.java index 6cd05054db8..b2c43da6e98 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GridDataFactoryTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GridDataFactoryTest.java @@ -13,12 +13,12 @@ ******************************************************************************/ package org.eclipse.jface.tests.layout; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @since 3.5 diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GridLayoutFactoryTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GridLayoutFactoryTest.java index 8ec7b49a7a0..b0e917e61d6 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GridLayoutFactoryTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/GridLayoutFactoryTest.java @@ -13,10 +13,10 @@ ******************************************************************************/ package org.eclipse.jface.tests.layout; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.layout.GridLayoutFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @since 3.3 diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/TreeColumnLayoutTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/TreeColumnLayoutTest.java index a05da0c9fd9..9520dbca77e 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/TreeColumnLayoutTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/layout/TreeColumnLayoutTest.java @@ -13,16 +13,16 @@ ******************************************************************************/ package org.eclipse.jface.tests.layout; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import org.eclipse.jface.layout.TreeColumnLayout; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; -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 TreeColumnLayoutTest { @@ -44,7 +44,7 @@ public void testBug395890LayoutAfterExpandEventWithDisposedTree() throws Excepti } } - @Before + @BeforeEach public void setUp() throws Exception { display = Display.getCurrent(); if (display == null) { @@ -53,7 +53,7 @@ public void setUp() throws Exception { parent = new Shell(display, SWT.NONE); } - @After + @AfterEach public void tearDown() throws Exception { parent.dispose(); } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/BooleanFieldEditorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/BooleanFieldEditorTest.java index 4a696ca41e4..bc10c2558f9 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/BooleanFieldEditorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/BooleanFieldEditorTest.java @@ -16,9 +16,9 @@ package org.eclipse.jface.tests.preferences; -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 java.lang.reflect.Field; @@ -32,8 +32,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class BooleanFieldEditorTest { @@ -44,7 +44,7 @@ public class BooleanFieldEditorTest { private boolean otherThreadEventOccurred = false; private final Object lock = new Object(); - @Before + @BeforeEach public void setUp() throws Exception { shell = new Shell(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/IntegerFieldEditorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/IntegerFieldEditorTest.java index 492d3dc9d43..2231d64e4d9 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/IntegerFieldEditorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/IntegerFieldEditorTest.java @@ -15,23 +15,23 @@ package org.eclipse.jface.tests.preferences; -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.jface.preference.IntegerFieldEditor; import org.eclipse.jface.preference.PreferenceStore; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class IntegerFieldEditorTest { private Shell shell; private IntegerFieldEditor integerFieldEditor; - @Before + @BeforeEach public void setUp() throws Exception { shell = new Shell(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/ScaleFieldEditorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/ScaleFieldEditorTest.java index 44607d49dd2..668c913303a 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/ScaleFieldEditorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/ScaleFieldEditorTest.java @@ -13,16 +13,16 @@ *******************************************************************************/ package org.eclipse.jface.tests.preferences; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.eclipse.jface.preference.PreferenceStore; import org.eclipse.jface.preference.ScaleFieldEditor; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Scale; import org.eclipse.swt.widgets.Shell; -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 ScaleFieldEditorTest { @@ -31,13 +31,13 @@ public class ScaleFieldEditorTest { private Shell shell; private ScaleFieldEditor editor; - @Before + @BeforeEach public void setUp() { shell = new Shell(SWT.NONE); editor = new ScaleFieldEditor(PREFKEY, "Test Scale", shell); } - @After + @AfterEach public void tearDown() { if (shell != null && !shell.isDisposed()) { shell.dispose(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/StringFieldEditorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/StringFieldEditorTest.java index 55776f65df9..bee79181cf5 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/StringFieldEditorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/preferences/StringFieldEditorTest.java @@ -16,23 +16,23 @@ package org.eclipse.jface.tests.preferences; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import org.eclipse.jface.preference.PreferenceStore; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class StringFieldEditorTest { private Shell shell; private StringFieldEditor stringFieldEditor; - @Before + @BeforeEach public void setUp() throws Exception { shell = new Shell(); 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 f7fae9ee6f0..977fe3297eb 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 @@ -13,11 +13,11 @@ *******************************************************************************/ package org.eclipse.jface.tests.resources; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +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 java.time.Duration; @@ -31,7 +31,7 @@ import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.widgets.Display; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FontRegistryTest { @@ -92,7 +92,7 @@ private static Display initializeDisplayInSeparateThread() { private static void waitForDisplayInstantiation(AtomicReference displayReference) { Instant maximumEndTime = Instant.now().plus(Duration.ofSeconds(10)); while (displayReference.get() == null) { - assertFalse("display was not instantiated in time", Instant.now().isAfter(maximumEndTime)); + assertFalse(Instant.now().isAfter(maximumEndTime), "display was not instantiated in time"); Thread.yield(); } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/JFaceResourcesTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/JFaceResourcesTest.java index f730a7e948d..a330ed3e5d8 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/JFaceResourcesTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/JFaceResourcesTest.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.resources; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; @@ -21,7 +21,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JFaceResourcesTest { @@ -32,7 +32,7 @@ public void ensureLocalResourceManagerCanBeCreated() { Composite composite = new Composite(shell, SWT.NONE); LocalResourceManager localResourceManager = JFaceResources.managerFor(composite); - assertNotNull("LocalResourceManager cannot be created via static accessor", localResourceManager); + assertNotNull(localResourceManager, "LocalResourceManager cannot be created via static accessor"); } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java index 4a704f820da..97173aa5027 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java @@ -14,7 +14,7 @@ *******************************************************************************/ package org.eclipse.jface.tests.viewers; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; @@ -26,9 +26,9 @@ import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Shell; -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 Bug205700TreeViewerTest { @@ -44,7 +44,7 @@ public class Bug205700TreeViewerTest { private final TreeNode child10 = new TreeNode("Child10"); - @Before + @BeforeEach public void setUp() throws Exception { shell = new Shell(); @@ -58,7 +58,7 @@ public void setUp() throws Exception { shell.open(); } - @After + @AfterEach public void tearDown() throws Exception { shell.close(); } @@ -88,7 +88,7 @@ private void assertItemNames(String[] names) { } private void assertItemName(int index, String name) { - assertEquals("at " + index, name, viewer.getTree().getItem(index).getText()); + assertEquals(name, viewer.getTree().getItem(index).getText(), "at " + index); } @Test diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug287765Test.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug287765Test.java index 5680e684016..251d43f2d57 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug287765Test.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug287765Test.java @@ -27,9 +27,9 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Shell; -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; /** * @since 3.4 @@ -127,7 +127,7 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } - @Before + @BeforeEach public void setUp() throws Exception { final Shell shell = new Shell(); shell.setLayout(new GridLayout()); @@ -156,7 +156,7 @@ public void setUp() throws Exception { shell.open(); } - @After + @AfterEach public void tearDown() throws Exception { treeViewer.getControl().getShell().dispose(); treeViewer = null; diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug553483ViewerDropAdapterTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug553483ViewerDropAdapterTest.java index 7d55e05f163..f15d1b970d4 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug553483ViewerDropAdapterTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/Bug553483ViewerDropAdapterTest.java @@ -13,8 +13,8 @@ *******************************************************************************/ package org.eclipse.jface.tests.viewers; -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.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.ArrayContentProvider; @@ -34,9 +34,9 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Shell; -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 Bug553483ViewerDropAdapterTest { @@ -48,7 +48,7 @@ public class Bug553483ViewerDropAdapterTest { private Point tgtPos2; private int numberOfDrops; - @Before + @BeforeEach public void setUp() throws Exception { display = new Display(); shell = new Shell(display); @@ -107,7 +107,7 @@ public void setUp() throws Exception { } } - @After + @AfterEach public void tearDown() throws Exception { assertTrue(shell.isDisposed()); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java index 0b1c4cf3ce4..734cd82c69c 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java @@ -13,8 +13,8 @@ *******************************************************************************/ package org.eclipse.jface.tests.viewers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import org.eclipse.jface.util.ILogger; import org.eclipse.jface.util.ISafeRunnableRunner; @@ -30,9 +30,9 @@ import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; -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 ComboViewerComparerTest { @@ -85,7 +85,7 @@ public int hashCode(final Object element) { assertEquals(aElement.getName(), selectedElement.getName()); } - @Before + @BeforeEach public void setUp() { oldLogger = Policy.getLog(); oldRunner = SafeRunnable.getRunner(); @@ -108,7 +108,7 @@ public void setUp() { shell.open(); } - @After + @AfterEach public void tearDown() { Policy.setLog(oldLogger); SafeRunnable.setRunner(oldRunner); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/DrillDownAdapterTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/DrillDownAdapterTest.java index db0d1bc7282..105a4c76eee 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/DrillDownAdapterTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/DrillDownAdapterTest.java @@ -1,6 +1,6 @@ package org.eclipse.jface.tests.viewers; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; import java.util.ArrayList; import java.util.List; @@ -11,21 +11,21 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.part.DrillDownAdapter; -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 DrillDownAdapterTest { private Shell shell; - @Before + @BeforeEach public void setUp() { shell = new Shell(); shell.open(); } - @After + @AfterEach public void tearDown() { shell.close(); } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java index 4b45ced2020..409ac6f70d7 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java @@ -13,18 +13,18 @@ *******************************************************************************/ package org.eclipse.jface.tests.viewers; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.Iterator; import java.util.TreeSet; import org.eclipse.jface.viewers.deferred.LazySortedCollection; -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; /** * @since 3.1 @@ -63,7 +63,7 @@ public static void printArray(Object[] array) { } } - @Before + @BeforeEach public void setUp() throws Exception { comparator = new TestComparator(); collection = new LazySortedCollection(comparator); @@ -76,7 +76,7 @@ public void setUp() throws Exception { addAll(elements); } - @After + @AfterEach public void tearDown() throws Exception { System.out.println("Comparisons required by lazy collection: " + comparator.comparisons); System.out.println("Comparisons required by reference implementation: " + comparisonComparator.comparisons); @@ -148,8 +148,8 @@ private void forceFullSort() { private void assertContentsValid() { queryRange(0, comparisonCollection.size(), false); - Assert.assertEquals(comparisonCollection.size(), collection.size()); - Assert.assertEquals(comparisonCollection.isEmpty(), collection.isEmpty()); + Assertions.assertEquals(comparisonCollection.size(), collection.size()); + Assertions.assertEquals(comparisonCollection.isEmpty(), collection.isEmpty()); } private static void assertIsPermutation(Object[] array1, Object[] array2) { @@ -176,7 +176,7 @@ private Object[] queryRange(int start, int length, boolean sorted) { int returnValue = collection.getRange(result, start, sorted); - Assert.assertEquals(returnValue, length); + Assertions.assertEquals(returnValue, length); Object[] expectedResult = computeExpectedElementsInRange(start, length); @@ -197,12 +197,12 @@ private Object[] queryRange(int start, int length, boolean sorted) { @Test public void testComparisonCount() { - assertEquals("additions should not require any comparisons", 0, comparator.comparisons); + assertEquals(0, comparator.comparisons, "additions should not require any comparisons"); queryRange(0, elements.length, false); - assertEquals("requesting the complete set of unsorted elements should not require any comparisons", 0, - comparator.comparisons); + assertEquals(0, + comparator.comparisons, "requesting the complete set of unsorted elements should not require any comparisons"); } /** @@ -222,8 +222,8 @@ public void testSortAll() { queryRange(elements.length - 10, 10, true); queryRange(0, 10, false); - Assert.assertEquals("Once the lazy collection is fully sorted, it should not require further comparisons", - comparisons, comparator.comparisons); + Assertions.assertEquals(comparisons, comparator.comparisons, + "Once the lazy collection is fully sorted, it should not require further comparisons"); } /** diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java index c03ccd20381..006f8ae148c 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java @@ -15,8 +15,8 @@ *******************************************************************************/ package org.eclipse.jface.tests.viewers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.util.ArrayList; import java.util.List; @@ -31,9 +31,9 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.tests.harness.util.DisplayHelper; -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 ListViewerRefreshTest { /** @@ -49,7 +49,7 @@ public class ListViewerRefreshTest { private ArrayList input = null; - @Before + @BeforeEach public void setUp() throws Exception { shell = new Shell(); shell.setSize(400, 200); @@ -68,7 +68,7 @@ public void setUp() throws Exception { shell.open(); } - @After + @AfterEach public void tearDown() throws Exception { shell.dispose(); shell = null; diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java index 455bf88e844..82f8480a227 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java @@ -14,9 +14,9 @@ *******************************************************************************/ package org.eclipse.jface.tests.viewers; -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 java.util.ArrayList; import java.util.Arrays; @@ -24,7 +24,7 @@ import org.eclipse.jface.viewers.IElementComparer; import org.eclipse.jface.viewers.StructuredSelection; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class StructuredSelectionTest { @@ -226,26 +226,26 @@ static class EqualsHashCodeContractTestHelper { public static void testExpectedEqualsObjects(Object o1, Object o2) { // reflexive - assertTrue(REFLEXIVITY_MSG, o1.equals(o1)); - assertTrue(REFLEXIVITY_MSG, o2.equals(o2)); + assertTrue(o1.equals(o1), REFLEXIVITY_MSG); + assertTrue(o2.equals(o2), REFLEXIVITY_MSG); // symmetric - assertTrue(SYMMETRICITY_MSG, o1.equals(o2)); - assertTrue(SYMMETRICITY_MSG, o2.equals(o1)); + assertTrue(o1.equals(o2), SYMMETRICITY_MSG); + assertTrue(o2.equals(o1), SYMMETRICITY_MSG); // consistent for (int i = 0; i < CONSISTENCY_THRESHOLD; i++) { - assertTrue(EQUALS_CONSITENCY_MSG, o1.equals(o2)); - assertTrue(EQUALS_CONSITENCY_MSG, o2.equals(o1)); + assertTrue(o1.equals(o2), EQUALS_CONSITENCY_MSG); + assertTrue(o2.equals(o1), EQUALS_CONSITENCY_MSG); } // For any non-null reference value x, x.equals(null) should return false. - assertFalse(NOT_EQUALS_NULL_MSG, o1.equals(null)); - assertFalse(NOT_EQUALS_NULL_MSG, o2.equals(null)); + assertFalse(o1.equals(null), NOT_EQUALS_NULL_MSG); + assertFalse(o2.equals(null), NOT_EQUALS_NULL_MSG); // a.equals(b) => a.hashCode() == b.hashCode() - assertEquals(EQUALS_IMPLIES_SAME_HASHCODE_MSG, o1.hashCode(), o2.hashCode()); + assertEquals(o1.hashCode(), o2.hashCode(), EQUALS_IMPLIES_SAME_HASHCODE_MSG); for (int i = 0; i < CONSISTENCY_THRESHOLD; i++) { - assertEquals(HASHCODE_CONSISTENCY_MSG, o1.hashCode(), o1.hashCode()); - assertEquals(HASHCODE_CONSISTENCY_MSG, o2.hashCode(), o2.hashCode()); + assertEquals(o1.hashCode(), o1.hashCode(), HASHCODE_CONSISTENCY_MSG); + assertEquals(o2.hashCode(), o2.hashCode(), HASHCODE_CONSISTENCY_MSG); } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/StyledStringBuilderTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/StyledStringBuilderTest.java index 2ff05186e4e..c647bbfc585 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/StyledStringBuilderTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/StyledStringBuilderTest.java @@ -13,14 +13,14 @@ *******************************************************************************/ package org.eclipse.jface.tests.viewers; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.viewers.StyledString; import org.eclipse.jface.viewers.StyledString.Styler; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.graphics.TextStyle; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class StyledStringBuilderTest { diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TreeSelectionTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TreeSelectionTest.java index 57514962838..43f819fd993 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TreeSelectionTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TreeSelectionTest.java @@ -15,8 +15,8 @@ package org.eclipse.jface.tests.viewers; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.Arrays; @@ -26,7 +26,7 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.TreeSelection; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @since 3.2 diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/ApplicationWindowTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/ApplicationWindowTest.java index bdc079db78a..700073499ac 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/ApplicationWindowTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/ApplicationWindowTest.java @@ -17,14 +17,14 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.window.ApplicationWindow; import org.eclipse.swt.widgets.Shell; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; public class ApplicationWindowTest { private ApplicationWindow window; - @After + @AfterEach public void tearDown() throws Exception { if (window != null) { // close the window diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/WindowTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/WindowTest.java index 4b43461703e..e82e8a0616a 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/WindowTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/window/WindowTest.java @@ -15,7 +15,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class WindowTest { diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/ButtonAlignmentTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/ButtonAlignmentTest.java index b81cb86150e..bb7afd3af5e 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/ButtonAlignmentTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/ButtonAlignmentTest.java @@ -15,29 +15,29 @@ package org.eclipse.jface.tests.wizards; -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.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; -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 ButtonAlignmentTest { private TheTestWizard wizard; private TheTestWizardDialog dialog; - @Before + @BeforeEach public void setUp() throws Exception { // ensure we've initialized a display for this thread Display.getDefault(); } - @After + @AfterEach public void tearDown() throws Exception { if (dialog != null && dialog.getShell() != null && !dialog.getShell().isDisposed()) { @@ -56,8 +56,8 @@ public void testButtonAlignment() { Composite parent = dialog.getFinishedButton().getParent(); Control[] children = parent.getChildren(); assertEquals( - "There should be three children, a composite for back/next buttons, the finish button, and the cancel button", //$NON-NLS-1$ - 3, children.length); + 3, children.length, + "There should be three children, a composite for back/next buttons, the finish button, and the cancel button"); //$NON-NLS-1$ // first children should be the Composite holding the 'Back' and 'Next' // buttons @@ -66,10 +66,10 @@ public void testButtonAlignment() { // retrieve its children and verify its contents Control[] backNextChildren = backNextParent.getChildren(); - assertEquals("Back button should be the first button", dialog //$NON-NLS-1$ - .getBackButton(), backNextChildren[0]); - assertEquals("Next button should be the second button", dialog //$NON-NLS-1$ - .getNextButton(), backNextChildren[1]); + assertEquals(dialog //$NON-NLS-1$ + .getBackButton(), backNextChildren[0], "Back button should be the first button"); + assertEquals(dialog //$NON-NLS-1$ + .getNextButton(), backNextChildren[1], "Next button should be the second button"); // verify button alignment based on the platform's dismissal alignment int finishIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 1 @@ -78,9 +78,9 @@ public void testButtonAlignment() { : 1; assertEquals( - "Finish button's alignment is off", dialog.getFinishedButton(), children[finishIndex]); //$NON-NLS-1$ + dialog.getFinishedButton(), children[finishIndex], "Finish button's alignment is off"); //$NON-NLS-1$ assertEquals( - "Cancel button's alignment is off", dialog.getCancelButton(), children[cancelIndex]); //$NON-NLS-1$ + dialog.getCancelButton(), children[cancelIndex], "Cancel button's alignment is off"); //$NON-NLS-1$ } @Test @@ -100,8 +100,8 @@ public void addPages() { Composite parent = dialog.getFinishedButton().getParent(); Control[] children = parent.getChildren(); assertEquals( - "There should be two children, the finish button, and the cancel button", //$NON-NLS-1$ - 2, children.length); + 2, children.length, + "There should be two children, the finish button, and the cancel button"); //$NON-NLS-1$ // verify button alignment based on the platform's dismissal alignment int finishIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 0 @@ -110,9 +110,9 @@ public void addPages() { : 0; assertEquals( - "Finish button's alignment is off", dialog.getFinishedButton(), children[finishIndex]); //$NON-NLS-1$ + dialog.getFinishedButton(), children[finishIndex], "Finish button's alignment is off"); //$NON-NLS-1$ assertEquals( - "Cancel button's alignment is off", dialog.getCancelButton(), children[cancelIndex]); //$NON-NLS-1$ + dialog.getCancelButton(), children[cancelIndex], "Cancel button's alignment is off"); //$NON-NLS-1$ } @Test @@ -133,8 +133,8 @@ public boolean canFinish() { Composite parent = dialog.getFinishedButton().getParent(); Control[] children = parent.getChildren(); assertEquals( - "There should be three children, a composite for back/next buttons, the finish button, and the cancel button", //$NON-NLS-1$ - 3, children.length); + 3, children.length, + "There should be three children, a composite for back/next buttons, the finish button, and the cancel button"); //$NON-NLS-1$ // first children should be the Composite holding the 'Back' and 'Next' // buttons @@ -143,10 +143,10 @@ public boolean canFinish() { // retrieve its children and verify its contents Control[] backNextChildren = backNextParent.getChildren(); - assertEquals("Back button should be the first button", dialog //$NON-NLS-1$ - .getBackButton(), backNextChildren[0]); - assertEquals("Next button should be the second button", dialog //$NON-NLS-1$ - .getNextButton(), backNextChildren[1]); + assertEquals(dialog //$NON-NLS-1$ + .getBackButton(), backNextChildren[0], "Back button should be the first button"); + assertEquals(dialog //$NON-NLS-1$ + .getNextButton(), backNextChildren[1], "Next button should be the second button"); // verify button alignment based on the platform's dismissal alignment int finishIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 1 @@ -155,9 +155,9 @@ public boolean canFinish() { : 1; assertEquals( - "Finish button's alignment is off", dialog.getFinishedButton(), children[finishIndex]); //$NON-NLS-1$ + dialog.getFinishedButton(), children[finishIndex], "Finish button's alignment is off"); //$NON-NLS-1$ assertEquals( - "Cancel button's alignment is off", dialog.getCancelButton(), children[cancelIndex]); //$NON-NLS-1$ + dialog.getCancelButton(), children[cancelIndex], "Cancel button's alignment is off"); //$NON-NLS-1$ } } diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardProgressMonitorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardProgressMonitorTest.java index 58962b879a9..a4fb1636e21 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardProgressMonitorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardProgressMonitorTest.java @@ -15,8 +15,8 @@ package org.eclipse.jface.tests.wizards; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.IWizard; @@ -26,15 +26,15 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Layout; -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 WizardProgressMonitorTest { private ProgressMonitoringWizardDialog dialog; - @Before + @BeforeEach public void setUp() throws Exception { // initialize a display Display.getDefault(); @@ -42,7 +42,7 @@ public void setUp() throws Exception { dialog.setBlockOnOpen(false); } - @After + @AfterEach public void tearDown() throws Exception { if (dialog != null) { dialog.close(); @@ -84,8 +84,8 @@ public void testProgressLabelsClearedBug271530() throws Exception { protected void performAsserts() { - assertEquals("The progress monitor's label should have been cleared", //$NON-NLS-1$ - "", dialog.getProgressMonitorLabelText()); //$NON-NLS-1$ + assertEquals("", dialog.getProgressMonitorLabelText(), //$NON-NLS-1$ + "The progress monitor's label should have been cleared"); //$NON-NLS-1$ String subTask = dialog.getProgressMonitorSubTaskText(); if (subTask != null && !subTask.isEmpty()) { @@ -97,8 +97,8 @@ protected IRunnableWithProgress getRunnable(final String taskName) { return monitor -> { // check that the label is empty - assertEquals("The progress monitor's label is not initially empty", //$NON-NLS-1$ - "", dialog.getProgressMonitorLabelText()); //$NON-NLS-1$ + assertEquals("", dialog.getProgressMonitorLabelText(), //$NON-NLS-1$ + "The progress monitor's label is not initially empty"); //$NON-NLS-1$ // check the subtask as well String subTask = dialog.getProgressMonitorSubTaskText(); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardTest.java index 463dc78474f..f4e6b9e4871 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/wizards/WizardTest.java @@ -15,10 +15,10 @@ package org.eclipse.jface.tests.wizards; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IPageChangedListener; @@ -28,9 +28,9 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; -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 WizardTest { protected static final int NUM_PAGES = 3; @@ -51,120 +51,120 @@ public class WizardTest { @Test public void testEndingWithFinish() { //test page count - assertEquals("Wizard has wrong number of pages", NUM_PAGES, wizard.getPageCount()); + assertEquals(NUM_PAGES, wizard.getPageCount(), "Wizard has wrong number of pages"); //test page name - assertEquals("WizardPage.getName() returned wrong name", TheTestWizard.page1Name, wizard.page1.getName()); + assertEquals(TheTestWizard.page1Name, wizard.page1.getName(), "WizardPage.getName() returned wrong name"); //test getPage() - assertSame("Wizard.getPage() returned wrong page", wizard.getPage(TheTestWizard.page1Name), wizard.page1); + assertSame(wizard.page1, wizard.getPage(TheTestWizard.page1Name), "Wizard.getPage() returned wrong page"); //test title wizard.setWindowTitle(WIZARD_TITLE); - assertEquals("Wizard has wrong title", wizard.getWindowTitle(), WIZARD_TITLE); + assertEquals(WIZARD_TITLE, wizard.getWindowTitle(), "Wizard has wrong title"); wizard.page1.setTitle(PAGE_TITLE); - assertEquals("Wizard has wrong title", wizard.page1.getTitle(), PAGE_TITLE); + assertEquals(PAGE_TITLE, wizard.page1.getTitle(), "Wizard has wrong title"); //set+test color twice to ensure initial color didn't happen to be color1 wizard.setTitleBarColor(color1); - assertEquals("Wizard has wrong title color", wizard.getTitleBarColor(), color1); + assertEquals(color1, wizard.getTitleBarColor(), "Wizard has wrong title color"); wizard.setTitleBarColor(color2); - assertEquals("Wizard has wrong title color", wizard.getTitleBarColor(), color2); + assertEquals(color2, wizard.getTitleBarColor(), "Wizard has wrong title color"); //test on starting page - assertSame("Wizard has wrong starting page", wizard.page1, wizard.getStartingPage()); - assertSame("Wizard not on starting page", wizard.page1, dialog.getCurrentPage()); + assertSame(wizard.page1, wizard.getStartingPage(), "Wizard has wrong starting page"); + assertSame(wizard.page1, dialog.getCurrentPage(), "Wizard not on starting page"); //test getMessage() - assertSame("WizardPage error message should be null", null, wizard.page1.getErrorMessage()); + assertSame(null, wizard.page1.getErrorMessage(), "WizardPage error message should be null"); wizard.page1.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS); - assertEquals("WizardPage error message set correctly", TheTestWizardPage.BAD_TEXT_FIELD_STATUS, - wizard.page1.getErrorMessage()); + assertEquals(TheTestWizardPage.BAD_TEXT_FIELD_STATUS, + wizard.page1.getErrorMessage(), "WizardPage error message set correctly"); //test page completion wizard.page1.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS); - assertTrue("Page should be completed", wizard.page1.canFlipToNextPage()); + assertTrue(wizard.page1.canFlipToNextPage(), "Page should be completed"); //Setting good value should've cleared the error message - assertSame("WizardPage error message should be null", null, wizard.page1.getErrorMessage()); + assertSame(null, wizard.page1.getErrorMessage(), "WizardPage error message should be null"); //test getNextPage() without page changes - assertSame("WizardPage.getNexPage() wrong page", wizard.page2, wizard.page1.getNextPage()); - assertSame("Wizard.getNexPage() wrong page", wizard.page2, wizard.getNextPage(wizard.page1)); - assertSame("WizardPage.getPreviousPage() wrong page", wizard.page1, wizard.page2.getPreviousPage()); - assertSame("Wizard.getPreviousPage() wrong page", wizard.page1, wizard.getPreviousPage(wizard.page2)); - assertSame("WizardPage.getNexPage() wrong page", wizard.page3, wizard.page2.getNextPage()); - assertSame("Wizard.getPreviousPage() wrong page", wizard.page2, wizard.getPreviousPage(wizard.page3)); + assertSame(wizard.page2, wizard.page1.getNextPage(), "WizardPage.getNexPage() wrong page"); + assertSame(wizard.page2, wizard.getNextPage(wizard.page1), "Wizard.getNexPage() wrong page"); + assertSame(wizard.page1, wizard.page2.getPreviousPage(), "WizardPage.getPreviousPage() wrong page"); + assertSame(wizard.page1, wizard.getPreviousPage(wizard.page2), "Wizard.getPreviousPage() wrong page"); + assertSame(wizard.page3, wizard.page2.getNextPage(), "WizardPage.getNexPage() wrong page"); + assertSame(wizard.page2, wizard.getPreviousPage(wizard.page3), "Wizard.getPreviousPage() wrong page"); //test canFinish() wizard.page2.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS); - assertFalse("Wizard should not be able to finish", wizard.canFinish()); + assertFalse(wizard.canFinish(), "Wizard should not be able to finish"); wizard.page2.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS); - assertTrue("Wizard should be able to finish", wizard.canFinish()); + assertTrue(wizard.canFinish(), "Wizard should be able to finish"); //test simulated Finish button hit //TheTestWizard's performFinish() sets DID_FINISH to true dialog.finishPressed(); - assertTrue("Wizard didn't perform finish", DID_FINISH); + assertTrue(DID_FINISH, "Wizard didn't perform finish"); } @Test public void testEndingWithCancel() { - assertSame("Wizard not on starting page", wizard.page1, dialog.getCurrentPage()); + assertSame(wizard.page1, dialog.getCurrentPage(), "Wizard not on starting page"); //TheTestWizard's performFinish() sets DID_FINISH to true, ensure it was not called wizard.performCancel(); - assertFalse("Wizard finished but should not have", DID_FINISH); + assertFalse(DID_FINISH, "Wizard finished but should not have"); dialog.cancelPressed(); - assertFalse("Wizard performed finished but should not have", DID_FINISH); + assertFalse(DID_FINISH, "Wizard performed finished but should not have"); } @Test public void testPageChanging() { //initially on first page - assertSame("Wizard started on wrong page", wizard.page1, dialog.getCurrentPage()); - assertFalse("Back button should be disabled on first page", dialog.getBackButton().getEnabled()); - assertTrue("Next button should be enabled on first page", dialog.getNextButton().getEnabled()); + assertSame(wizard.page1, dialog.getCurrentPage(), "Wizard started on wrong page"); + assertFalse(dialog.getBackButton().getEnabled(), "Back button should be disabled on first page"); + assertTrue(dialog.getNextButton().getEnabled(), "Next button should be enabled on first page"); //move to middle page 2 dialog.nextPressed(); - assertSame("Wizard.nextPressed() set wrong page", wizard.page2, dialog.getCurrentPage()); - assertTrue("Back button should be enabled on middle page", dialog.getBackButton().getEnabled()); - assertTrue("Next button should be enabled on middle page", dialog.getNextButton().getEnabled()); + assertSame(wizard.page2, dialog.getCurrentPage(), "Wizard.nextPressed() set wrong page"); + assertTrue(dialog.getBackButton().getEnabled(), "Back button should be enabled on middle page"); + assertTrue(dialog.getNextButton().getEnabled(), "Next button should be enabled on middle page"); //test that can't complete by inserting bad value to be validated wizard.page2.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS); - assertFalse("Finish should be disabled when bad field value", dialog.getFinishedButton().getEnabled()); - assertTrue("Cancel should always be enabled", dialog.getCancelButton().getEnabled()); + assertFalse(dialog.getFinishedButton().getEnabled(), "Finish should be disabled when bad field value"); + assertTrue(dialog.getCancelButton().getEnabled(), "Cancel should always be enabled"); //test that can complete by inserting good value to be validated wizard.page2.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS); - assertTrue("Finish should be enabled when good field value", dialog.getFinishedButton().getEnabled()); + assertTrue(dialog.getFinishedButton().getEnabled(), "Finish should be enabled when good field value"); //move to last page 3 dialog.nextPressed(); - assertSame("Wizard.nextPressed() set wrong page", wizard.page3, dialog.getCurrentPage()); - assertTrue("Back button should be enabled on last page", dialog.getBackButton().getEnabled()); - assertFalse("Next button should be disenabled on last page", dialog.getNextButton().getEnabled()); + assertSame(wizard.page3, dialog.getCurrentPage(), "Wizard.nextPressed() set wrong page"); + assertTrue(dialog.getBackButton().getEnabled(), "Back button should be enabled on last page"); + assertFalse(dialog.getNextButton().getEnabled(), "Next button should be disenabled on last page"); //move back to page 2 dialog.backPressed(); - assertSame("Wizard.backPressed() set wrong page", wizard.page2, dialog.getCurrentPage()); - assertTrue("Back button should be enabled on middle page", dialog.getBackButton().getEnabled()); - assertTrue("Next button should be enabled on middle page", dialog.getNextButton().getEnabled()); + assertSame(wizard.page2, dialog.getCurrentPage(), "Wizard.backPressed() set wrong page"); + assertTrue(dialog.getBackButton().getEnabled(), "Back button should be enabled on middle page"); + assertTrue(dialog.getNextButton().getEnabled(), "Next button should be enabled on middle page"); //move back to page 1 dialog.backPressed(); - assertSame("Wizard.backPressed() set wrong page", wizard.page1, dialog.getCurrentPage()); - assertFalse("Back button should be disabled on first page", dialog.getBackButton().getEnabled()); - assertTrue("Next button should be enabled on first page", dialog.getNextButton().getEnabled()); + assertSame(wizard.page1, dialog.getCurrentPage(), "Wizard.backPressed() set wrong page"); + assertFalse(dialog.getBackButton().getEnabled(), "Back button should be disabled on first page"); + assertTrue(dialog.getNextButton().getEnabled(), "Next button should be enabled on first page"); //move Next to page 2 dialog.buttonPressed(IDialogConstants.NEXT_ID); - assertSame("Wizard.backPressed() set wrong page", wizard.page2, dialog.getCurrentPage()); + assertSame(wizard.page2, dialog.getCurrentPage(), "Wizard.backPressed() set wrong page"); //move Back to page 1 dialog.buttonPressed(IDialogConstants.BACK_ID); - assertSame("Wizard.backPressed() set wrong page", wizard.page1, dialog.getCurrentPage()); + assertSame(wizard.page1, dialog.getCurrentPage(), "Wizard.backPressed() set wrong page"); } @Test @@ -172,16 +172,16 @@ public void testShowPage() { //move to page 3 dialog.nextPressed(); dialog.nextPressed(); - assertSame("Wizard.nextPressed() set wrong page", wizard.page3, dialog.getCurrentPage()); + assertSame(wizard.page3, dialog.getCurrentPage(), "Wizard.nextPressed() set wrong page"); //showPage() back to page 1 dialog.showPage(wizard.page1); - assertSame("Wizard.showPage() set wrong page", wizard.page1, dialog.getCurrentPage()); + assertSame(wizard.page1, dialog.getCurrentPage(), "Wizard.showPage() set wrong page"); //TODO Next test fails due to bug #249369 -// assertEquals("Back button should be disabled on first page", false, dialog.getBackButton().getEnabled()); - assertTrue("Next button should be enabled on first page", dialog.getNextButton().getEnabled()); +// assertEquals(false, dialog.getBackButton().getEnabled(), "Back button should be disabled on first page"); + assertTrue(dialog.getNextButton().getEnabled(), "Next button should be enabled on first page"); } @Test @@ -192,18 +192,18 @@ public void testPageChangeListening() { IPageChangedListener changedListener = event -> pageChanged = true; IPageChangingListener changingListener = event -> { - assertFalse("Page should not have changed yet", pageChanged); + assertFalse(pageChanged, "Page should not have changed yet"); pageChangingFired = true; }; //test that listener notifies us of page change dialog.addPageChangedListener(changedListener); dialog.addPageChangingListener(changingListener); //assert is in the listener - assertFalse("Page change notified unintentially", pageChanged); + assertFalse(pageChanged, "Page change notified unintentially"); //change to page 2 dialog.nextPressed(); - assertTrue("Wasn't notified of page change", pageChanged); - assertTrue("Wasn't notified of page changing", pageChangingFired); + assertTrue(pageChanged, "Wasn't notified of page change"); + assertTrue(pageChangingFired, "Wasn't notified of page changing"); dialog.removePageChangingListener(changingListener); //if not removed, its assert will fail on next nextPressed() //change to page 2 @@ -214,7 +214,7 @@ public void testPageChangeListening() { dialog.removePageChangedListener(changedListener); //change to page 3 dialog.nextPressed(); - assertFalse("Page change notified unintentially", pageChanged); + assertFalse(pageChanged, "Page change notified unintentially"); } @Test @@ -255,7 +255,7 @@ public void testWizardPageDispose() { //---------------------------------------------------- - @Before + @BeforeEach public void setUp() throws Exception { DID_FINISH = false; color1 = new RGB(255, 0, 0); @@ -264,7 +264,7 @@ public void setUp() throws Exception { createWizardDialog(); } - @After + @AfterEach public void tearDown() throws Exception { if(dialog.getShell() != null && ! dialog.getShell().isDisposed()) { dialog.close();