diff --git a/com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF index 32dda27d44..a355289be0 100644 --- a/com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF @@ -5,8 +5,7 @@ Bundle-SymbolicName: com.avaloq.tools.ddk.check.ui.test Bundle-Version: 16.3.0.qualifier Bundle-Vendor: Avaloq Group AG Bundle-RequiredExecutionEnvironment: JavaSE-21 -Require-Bundle: org.junit, - com.avaloq.tools.ddk.check.ui, +Require-Bundle: com.avaloq.tools.ddk.check.ui, com.avaloq.tools.ddk.xtext.test.core, com.avaloq.tools.ddk.test.core, com.avaloq.tools.ddk.test.ui, @@ -23,7 +22,7 @@ Require-Bundle: org.junit, org.objectweb.asm;resolution:=optional, junit-jupiter-api, junit-jupiter-engine, - junit-vintage-engine + junit-platform-suite-api Export-Package: com.avaloq.tools.ddk.check.ui.test, com.avaloq.tools.ddk.check.ui.test.util, com.avaloq.tools.ddk.check diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckCatalogWizardTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckCatalogWizardTest.java index 5f2a92d35a..9afa389fdc 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckCatalogWizardTest.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckCatalogWizardTest.java @@ -11,8 +11,8 @@ package com.avaloq.tools.ddk.check.ui.test; import static com.avaloq.tools.ddk.test.ui.swtbot.util.SwtBotWizardUtil.selectProjectFolder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.lang.reflect.InvocationTargetException; import java.util.Collections; @@ -32,11 +32,14 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.xtext.Grammar; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; import org.eclipse.xtext.ui.util.PluginProjectFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.api.extension.ExtendWith; import com.avaloq.tools.ddk.check.ui.test.internal.CheckWizardUiTestInjectorProvider; import com.avaloq.tools.ddk.check.ui.test.util.CheckWizardTestUtil; @@ -44,7 +47,6 @@ import com.avaloq.tools.ddk.check.ui.wizard.Messages; import com.avaloq.tools.ddk.test.core.BugTest; import com.avaloq.tools.ddk.test.ui.swtbot.SwtWizardBot; -import com.avaloq.tools.ddk.xtext.test.junit.runners.XtextClassRunner; import com.google.inject.Inject; import com.google.inject.Provider; @@ -53,8 +55,9 @@ * The CheckProjectWizardTestBackup tests the Check Project Wizard. */ @InjectWith(CheckWizardUiTestInjectorProvider.class) -@RunWith(XtextClassRunner.class) +@ExtendWith(InjectionExtension.class) @SuppressWarnings("nls") +@TestInstance(Lifecycle.PER_CLASS) public class CheckCatalogWizardTest { /** This is the name of the catalog wizard. It's the name SWTBot uses to look up the wizard. */ @@ -117,7 +120,7 @@ protected void execute(final IProgressMonitor monitor) throws CoreException, Inv * Initializes this test class pre-loading grammar access instances, which might involve bundle activation and class loading. *

*/ - @Before + @BeforeEach public void setUp() { wizard = new SwtWizardBot(); project = createProject(); @@ -142,7 +145,7 @@ public void testPackageSelected() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); initializeWizardBot(); // because the selected item is a package initially, this package is shown in the field. - assertEquals("Initial package is entered", VALID_PACKAGE_NAME, wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText()); + assertEquals(VALID_PACKAGE_NAME, wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText(), "Initial package is entered"); } /** @@ -155,7 +158,7 @@ public void testCheckCatalogWizardIsEnabled() { // that way, the wizard page should be enabled. initializeWizardBot(); - assertEquals("new check catalog page was loaded", Messages.CATALOG_WIZARD_WINDOW_TITLE, wizard.activeShell().getText()); + assertEquals(Messages.CATALOG_WIZARD_WINDOW_TITLE, wizard.activeShell().getText(), "new check catalog page was loaded"); wizard.waitUntil(Conditions.widgetIsEnabled(wizard.textWithLabel(Messages.CATALOG_FIELD_NAME_LABEL)), SwtWizardBot.SWTBOT_TIMEOUT); wizard.waitUntil(Conditions.widgetIsEnabled(wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL)), SwtWizardBot.SWTBOT_TIMEOUT); CheckWizardTestUtil.assertButtonsEnabled(false, true, false, wizard); @@ -170,7 +173,7 @@ public void testInitiallyNoPackageSelected() { initializeWizardBot(); // because the selected item is not a package initially, the field has to be empty. - assertSame("Initially, no package is selected", wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText().length(), 0); + assertSame(wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText().length(), 0, "Initially, no package is selected"); } /** @@ -259,7 +262,7 @@ public void testInitiallyNoGrammarSelected() { * @throws CoreException * if project doesn't exist. */ - @After + @AfterEach public void tearDown() throws CoreException { wizard.closeWizard(); project.delete(true, new NullProgressMonitor()); diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckProjectWizardTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckProjectWizardTest.java index e6c61201b0..4ee768c4ae 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckProjectWizardTest.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckProjectWizardTest.java @@ -10,30 +10,30 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.ui.test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.xtext.testing.InjectWith; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.avaloq.tools.ddk.check.ui.test.internal.CheckWizardUiTestInjectorProvider; import com.avaloq.tools.ddk.check.ui.test.util.CheckWizardTestUtil; import com.avaloq.tools.ddk.check.ui.wizard.Messages; import com.avaloq.tools.ddk.test.core.BugTest; import com.avaloq.tools.ddk.test.ui.swtbot.SwtWizardBot; -import com.avaloq.tools.ddk.xtext.test.junit.runners.XtextClassRunner; /** * The CheckProjectWizardTest tests the Check Project Wizard. */ @InjectWith(CheckWizardUiTestInjectorProvider.class) -@RunWith(XtextClassRunner.class) +@ExtendWith(InjectionExtension.class) @SuppressWarnings("nls") public class CheckProjectWizardTest { @@ -48,7 +48,7 @@ public class CheckProjectWizardTest { /** * Start again the Check project wizard before every test. */ - @Before + @BeforeEach public void setUp() { wizard = new SwtWizardBot(); wizard.openNewWizard(CHECK_PROJECT_WIZARD_NAME); @@ -59,7 +59,7 @@ public void setUp() { */ @Test public void testCheckProjectWizardIsAvailable() { - assertNotNull("the project wizard was found", wizard); + assertNotNull(wizard, "the project wizard was found"); CheckWizardTestUtil.assertButtonsEnabled(false, true, false, wizard); } @@ -101,9 +101,9 @@ public void fieldValuesAfterPageChange() { wizard.writeToTextField(Messages.PROJECT_NAME_LABEL, CORRECT_PROJECT_NAME); wizard.changeToPreviousPage(); wizard.changeToNextPage(); - assertEquals("Project input stays unchanged", CORRECT_PROJECT_NAME, wizard.textWithLabel(Messages.PROJECT_NAME_LABEL).getText()); + assertEquals(CORRECT_PROJECT_NAME, wizard.textWithLabel(Messages.PROJECT_NAME_LABEL).getText(), "Project input stays unchanged"); wizard.changeToNextPage(); - assertEquals("Initially, package name equals to project name", CORRECT_PROJECT_NAME, wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText()); + assertEquals(CORRECT_PROJECT_NAME, wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText(), "Initially, package name equals to project name"); } /** @@ -115,13 +115,13 @@ public void testNextButtonChangesPage() { SWTBotShell projectPage = wizard.shell(Messages.PROJECT_WIZARD_WINDOW_TITLE); wizard.changeToNextPage(); SWTBotShell catalogPage = wizard.shell(Messages.PROJECT_WIZARD_WINDOW_TITLE); - assertNotSame("Next button changed page", projectPage, catalogPage); + assertNotSame(projectPage, catalogPage, "Next button changed page"); } /** * Close the wizard after every test. */ - @After + @AfterEach public void tearDown() { wizard.closeWizard(); } diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckUiTestSuite.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckUiTestSuite.java index ecadabab3f..de6a8964e6 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckUiTestSuite.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/CheckUiTestSuite.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.ui.test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; import com.avaloq.tools.ddk.check.ui.test.builder.CheckContextsExtensionTest; import com.avaloq.tools.ddk.check.ui.test.builder.CheckMarkerHelpExtensionTest; @@ -21,11 +21,11 @@ /** - * Empty class serving only as holder for JUnit4 annotations. + * Empty class serving only as holder for JUnit5 annotations. */ -@RunWith(Suite.class) // @Format-Off -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ CheckQuickfixTest.class, CheckProjectWizardTest.class, CheckCatalogWizardTest.class, diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckContextsExtensionTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckContextsExtensionTest.java index c520123043..7320a12388 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckContextsExtensionTest.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckContextsExtensionTest.java @@ -10,6 +10,10 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.ui.test.builder; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; @@ -19,11 +23,11 @@ import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel; import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.testing.extensions.InjectionExtension; import org.eclipse.xtext.testing.util.ParseHelper; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.avaloq.tools.ddk.check.check.CheckCatalog; import com.avaloq.tools.ddk.check.ui.builder.util.CheckContextsExtensionHelper; @@ -33,16 +37,14 @@ import com.google.common.collect.Lists; import com.google.inject.Inject; -import junit.framework.TestCase; - /** * Tests CheckContextExtensionUtil. */ @SuppressWarnings({"restriction", "nls"}) @InjectWith(CheckWizardUiTestInjectorProvider.class) -@RunWith(XtextRunner.class) -public class CheckContextsExtensionTest extends TestCase { +@ExtendWith(InjectionExtension.class) +public class CheckContextsExtensionTest { private static final String CATALOG_WITH_FIRST_CHECK_LIVE = "package com.test catalog c for grammar g { live error \"First Check\"{ for g { issue }}}"; @@ -56,10 +58,13 @@ public class CheckContextsExtensionTest extends TestCase { @Inject private IWorkspace workspace; - @Override - @Before - public void setUp() throws Exception { - catalog = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE); + @BeforeEach + public void setUp() { + try { + catalog = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE); + } catch (Exception e) { + throw new AssertionError(e); + } IFile pluginxml = workspace.getRoot().getFile(new Path("/test/plugin.xml")); pluginModel = new WorkspacePluginModel(pluginxml, false); } @@ -74,10 +79,10 @@ public void setUp() throws Exception { public void testCreateExtension() throws CoreException { IPluginExtension extension = contextsUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null); // Test if the extension has been created. - assertEquals("Contexts extension has been created.", CheckContextsExtensionHelper.CONTEXTS_EXTENSION_POINT_ID, extension.getPoint()); + assertEquals(CheckContextsExtensionHelper.CONTEXTS_EXTENSION_POINT_ID, extension.getPoint(), "Contexts extension has been created."); // Test if the attributes are set correctly String contextsFileName = ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckContextsExtensionHelper.FILE_ATTRIBUTE_TAG).getValue(); - assertEquals("Contexts File name is set correctly", CheckContextsExtensionHelper.CONTEXTS_FILE_NAME, contextsFileName); + assertEquals(CheckContextsExtensionHelper.CONTEXTS_FILE_NAME, contextsFileName, "Contexts File name is set correctly"); } /** @@ -90,7 +95,7 @@ public void testCreateExtension() throws CoreException { public void testIsExtensionUpdateRequiredTrue() throws CoreException { IPluginExtension extension = createErroneousExtension(); Iterable elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class); - assertTrue("Extension update is required", contextsUtil.isExtensionUpdateRequired(catalog, extension, elements)); + assertTrue(contextsUtil.isExtensionUpdateRequired(catalog, extension, elements), "Extension update is required"); } /** @@ -103,7 +108,7 @@ public void testIsExtensionUpdateRequiredTrue() throws CoreException { public void testIsExtensionUpdateRequiredFalse() throws CoreException { IPluginExtension extension = contextsUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null); Iterable elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class); - assertFalse("No extension update is required ", contextsUtil.isExtensionUpdateRequired(catalog, extension, elements)); + assertFalse(contextsUtil.isExtensionUpdateRequired(catalog, extension, elements), "No extension update is required "); } /** diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckMarkerHelpExtensionTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckMarkerHelpExtensionTest.java index 502fabc2dd..7ca8b94d45 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckMarkerHelpExtensionTest.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckMarkerHelpExtensionTest.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.ui.test.builder; -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 java.util.List; import java.util.Set; @@ -26,10 +26,10 @@ import org.eclipse.pde.core.plugin.IPluginObject; import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel; import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.testing.extensions.InjectionExtension; import org.eclipse.xtext.testing.util.ParseHelper; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.avaloq.tools.ddk.check.check.CheckCatalog; import com.avaloq.tools.ddk.check.check.XIssueExpression; @@ -48,7 +48,7 @@ */ @SuppressWarnings({"restriction", "PMD.SignatureDeclareThrowsException", "nls"}) @InjectWith(CheckWizardUiTestInjectorProvider.class) -@RunWith(XtextRunner.class) +@ExtendWith(InjectionExtension.class) public class CheckMarkerHelpExtensionTest { private static final String SECONDCHECK_CONTEXTID = "null.c_secondcheck"; @@ -83,12 +83,12 @@ public void testCreateExtension() throws Exception { IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE)); // Test if the extension has been created. - assertEquals("Marker help extension has been created.", CheckMarkerHelpExtensionHelper.MARKERHELP_EXTENSION_POINT_ID, extension.getPoint()); + assertEquals(CheckMarkerHelpExtensionHelper.MARKERHELP_EXTENSION_POINT_ID, extension.getPoint(), "Marker help extension has been created."); // Test if the extension contains the marker help element IPluginElement element = (IPluginElement) extension.getChildren()[0]; - assertEquals("The marker help element has the correct context id", FIRSTCHECK_CONTEXID, element.getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue()); - assertEquals("The marker help element has the correct markertype", MARKERTYPE_FAST, element.getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue()); + assertEquals(FIRSTCHECK_CONTEXID, element.getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue(), "The marker help element has the correct context id"); + assertEquals(MARKERTYPE_FAST, element.getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue(), "The marker help element has the correct markertype"); } /** @@ -103,7 +103,7 @@ public void testAddElement() throws Exception { final CheckCatalog catalogWithOneCheck = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE); IPluginExtension extension = createMarkerHelpExtension(catalogWithOneCheck); - assertEquals("Original catalog has one marker help extension", 1, extension.getChildCount()); + assertEquals(1, extension.getChildCount(), "Original catalog has one marker help extension"); CheckCatalog catalogWithTwoChecks = parser.parse(CATALOG_WITH_TWO_CHECKS); markerUtil.updateExtension(catalogWithTwoChecks, extension); @@ -113,8 +113,8 @@ public void testAddElement() throws Exception { for (IPluginObject element : extension.getChildren()) { contextIds.add(((IPluginElement) element).getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue()); } - assertEquals("The extension has two elements", 2, extension.getChildCount()); - assertTrue("Both checks are elements of the extension ", contextIds.containsAll(Sets.newHashSet(FIRSTCHECK_CONTEXID, SECONDCHECK_CONTEXTID))); + assertEquals(2, extension.getChildCount(), "The extension has two elements"); + assertTrue(contextIds.containsAll(Sets.newHashSet(FIRSTCHECK_CONTEXID, SECONDCHECK_CONTEXTID)), "Both checks are elements of the extension "); } /** @@ -128,13 +128,13 @@ public void testRemoveElement() throws Exception { final CheckCatalog catalogWithTwoChecks = parser.parse(CATALOG_WITH_TWO_CHECKS); IPluginExtension extension = createMarkerHelpExtension(catalogWithTwoChecks); - assertEquals("Original catalog has two marker help extensions", 2, extension.getChildCount()); + assertEquals(2, extension.getChildCount(), "Original catalog has two marker help extensions"); CheckCatalog catalogWithOneCheck = parser.parse(CATALOG_WITH_SECOND_CHECK_ONDEMAND); markerUtil.updateExtension(catalogWithOneCheck, extension); - assertEquals("Updated catalog has one marker help extension only", 1, extension.getChildCount()); - assertEquals("The element for the removed check has been deleted.", SECONDCHECK_CONTEXTID, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue()); + assertEquals(1, extension.getChildCount(), "Updated catalog has one marker help extension only"); + assertEquals(SECONDCHECK_CONTEXTID, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue(), "The element for the removed check has been deleted."); } /** @@ -147,12 +147,12 @@ public void testRemoveElement() throws Exception { public void testMarkerTypeUpdate() throws Exception { IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE)); - assertEquals("Before update: Markertype is fast.", MARKERTYPE_FAST, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue()); + assertEquals(MARKERTYPE_FAST, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue(), "Before update: Markertype is fast."); CheckCatalog updateMarkertype = parser.parse(CATALOG_WITH_FIRST_CHECK_ONDEMAND); markerUtil.updateExtension(updateMarkertype, extension); - assertEquals("After update: Markertype is expensive.", MARKERTYPE_EXPENSIVE, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue()); + assertEquals(MARKERTYPE_EXPENSIVE, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue(), "After update: Markertype is expensive."); } @Inject @@ -181,8 +181,8 @@ public void testCheckHasTwoIssueCodes() throws Exception { issueCodesInExtension.add(((IPluginElement) element).getAttribute(CheckMarkerHelpExtensionHelper.ATTRIBUTE_VALUE_TAG).getValue()); } } - assertTrue("A marker help element for both issueCodes has been created.", Iterables.elementsEqual(issueCodesInExtension, issueCodesOfCheck)); - assertEquals("extension has two marker help elements", 2, issueCodesInExtension.size()); + assertTrue(Iterables.elementsEqual(issueCodesInExtension, issueCodesOfCheck), "A marker help element for both issueCodes has been created."); + assertEquals(2, issueCodesInExtension.size(), "extension has two marker help elements"); } /** diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckTocExtensionTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckTocExtensionTest.java index 62108eeed2..8a865abb13 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckTocExtensionTest.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckTocExtensionTest.java @@ -10,6 +10,11 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.ui.test.builder; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; @@ -19,11 +24,11 @@ import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel; import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.testing.extensions.InjectionExtension; import org.eclipse.xtext.testing.util.ParseHelper; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.avaloq.tools.ddk.check.check.CheckCatalog; import com.avaloq.tools.ddk.check.ui.builder.util.CheckTocExtensionHelper; @@ -33,16 +38,14 @@ import com.google.common.collect.Lists; import com.google.inject.Inject; -import junit.framework.TestCase; - /** * Tests the CheckTocExtensionUtil class. */ @SuppressWarnings({"restriction", "PMD.SignatureDeclareThrowsException", "nls"}) @InjectWith(CheckWizardUiTestInjectorProvider.class) -@RunWith(XtextRunner.class) -public class CheckTocExtensionTest extends TestCase { +@ExtendWith(InjectionExtension.class) +public class CheckTocExtensionTest { @Inject private ParseHelper parser; @@ -58,8 +61,7 @@ public class CheckTocExtensionTest extends TestCase { private CheckCatalog catalog; private IPluginModelBase pluginModel; - @Before - @Override + @BeforeEach public void setUp() throws Exception { catalog = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE); IFile pluginxml = workspace.getRoot().getFile(new Path("/test/plugin.xml")); @@ -76,10 +78,10 @@ public void setUp() throws Exception { @Test public void testCreateExtension() throws CoreException { IPluginExtension extension = tocUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null); - assertEquals("Toc extension has been created", CheckTocExtensionHelper.TOC_EXTENSION_POINT_ID, extension.getPoint()); - assertEquals("Toc extension name is correct", tocUtil.getExtensionPointName(catalog), extension.getName()); - assertEquals("Extension has exactly one element", 1, extension.getChildCount()); - assertEquals("toc.xml file location is correctly set", CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue()); + assertEquals(CheckTocExtensionHelper.TOC_EXTENSION_POINT_ID, extension.getPoint(), "Toc extension has been created"); + assertEquals(tocUtil.getExtensionPointName(catalog), extension.getName(), "Toc extension name is correct"); + assertEquals(1, extension.getChildCount(), "Extension has exactly one element"); + assertEquals(CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue(), "toc.xml file location is correctly set"); } /** @@ -93,7 +95,7 @@ public void testIsExtensionUpdateRequiredTrue() throws CoreException { IPluginExtension extension = createErroneousTocExtension(); Iterable elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class); - assertTrue("Toc extension update is required", tocUtil.isExtensionUpdateRequired(catalog, extension, elements)); + assertTrue(tocUtil.isExtensionUpdateRequired(catalog, extension, elements), "Toc extension update is required"); } /** @@ -125,7 +127,7 @@ public void testUpdateTocExtension() throws CoreException { IPluginExtension extension = createErroneousTocExtension(); assertNotSame("File location is not as expected", CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue()); tocUtil.updateExtension(catalog, extension); - assertEquals("Toc file location is now set correctly", CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue()); + assertEquals(CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue(), "Toc file location is now set correctly"); } /** @@ -138,6 +140,6 @@ public void testUpdateTocExtension() throws CoreException { public void testIsExtensionUpdateRequiredFalse() throws CoreException { IPluginExtension extension = tocUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null); Iterable elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class); - assertFalse("No toc extension update is required", tocUtil.isExtensionUpdateRequired(catalog, extension, elements)); + assertFalse(tocUtil.isExtensionUpdateRequired(catalog, extension, elements), "No toc extension update is required"); } } diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/AbstractCheckContentAssistBugTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/AbstractCheckContentAssistBugTest.java index 10b0719128..c495b3c921 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/AbstractCheckContentAssistBugTest.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/AbstractCheckContentAssistBugTest.java @@ -11,7 +11,7 @@ package com.avaloq.tools.ddk.check.ui.test.contentassist; import static org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.findJavaProject; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.InputStream; diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/BugAig931Test.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/BugAig931Test.java index f045ef73cd..459c7a8e93 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/BugAig931Test.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/BugAig931Test.java @@ -10,6 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.ui.test.contentassist; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import java.util.List; @@ -20,8 +22,7 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.ui.progress.UIJob; import org.eclipse.xtext.common.types.access.jdt.IJavaProjectProvider; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.google.common.base.Function; import com.google.common.collect.Iterables; @@ -51,7 +52,7 @@ public String apply(final ICompletionProposal input) { } })); for (String string : expected) { - Assert.assertTrue(NLS.bind("Expected {0} but found {1}", Arrays.toString(expected), actual), actual.contains(string)); + assertTrue(actual.contains(string), NLS.bind("Expected {0} but found {1}", Arrays.toString(expected), actual)); } } diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/quickfix/AbstractCheckQuickfixTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/quickfix/AbstractCheckQuickfixTest.java index f1f0d26c66..ef55d7d63f 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/quickfix/AbstractCheckQuickfixTest.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/quickfix/AbstractCheckQuickfixTest.java @@ -11,8 +11,8 @@ package com.avaloq.tools.ddk.check.ui.test.quickfix; import com.avaloq.tools.ddk.check.ui.test.util.CheckXtextTestUtil; -import com.avaloq.tools.ddk.xtext.test.AbstractXtextTestUtil; -import com.avaloq.tools.ddk.xtext.test.ui.quickfix.AbstractQuickFixTest; +import com.avaloq.tools.ddk.xtext.test.jupiter.AbstractQuickFixTest; +import com.avaloq.tools.ddk.xtext.test.jupiter.AbstractXtextTestUtil; /** diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/quickfix/CheckQuickfixTest.xtend b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/quickfix/CheckQuickfixTest.xtend index 00bbade639..08bb518d40 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/quickfix/CheckQuickfixTest.xtend +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/quickfix/CheckQuickfixTest.xtend @@ -19,10 +19,9 @@ import com.avaloq.tools.ddk.test.ui.swtbot.condition.WaitForEquals import com.avaloq.tools.ddk.test.ui.swtbot.util.ProblemsViewTestUtil import org.eclipse.swtbot.swt.finder.widgets.TimeoutException import org.eclipse.xtext.diagnostics.Diagnostic -import org.junit.Assert -import org.junit.Test - -import static org.junit.Assert.fail +import org.junit.jupiter.api.Test +import static org.junit.jupiter.api.Assertions.assertTrue +import static org.junit.jupiter.api.Assertions.fail /** * Test quickfixes for Check files. @@ -95,7 +94,7 @@ class CheckQuickfixTest extends AbstractCheckQuickfixTest { assertHasQuickFix(Diagnostic::LINKING_DIAGNOSTIC, quickfixLabel); assertQuickFixSuccessful(Diagnostic::LINKING_DIAGNOSTIC, quickfixLabel); val afterIssues = getXtextTestUtil().getIssues(getDocument()); - Assert.assertTrue(afterIssues.size < beforeIssues.size); + assertTrue(afterIssues.size < beforeIssues.size); } /** diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/util/CheckWizardTestUtil.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/util/CheckWizardTestUtil.java index aaf746eee6..e98cb010b0 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/util/CheckWizardTestUtil.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/util/CheckWizardTestUtil.java @@ -14,8 +14,8 @@ import static com.avaloq.tools.ddk.test.ui.swtbot.SwtWizardBot.FINISH; import static com.avaloq.tools.ddk.test.ui.swtbot.SwtWizardBot.NEXT; import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swtbot.eclipse.finder.waits.Conditions; @@ -65,19 +65,19 @@ private CheckWizardTestUtil() { */ public static void assertButtonsEnabled(final boolean nextIsEnabled, final boolean backIsEnabled, final boolean finishIsEnabled, final SwtWizardBot swtWizardBot) { if (nextIsEnabled) { - assertTrue("Next button is enabled", swtWizardBot.button(NEXT).isEnabled()); + assertTrue(swtWizardBot.button(NEXT).isEnabled(), "Next button is enabled"); } else { - assertFalse("Next button is disabled", swtWizardBot.button(NEXT).isEnabled()); + assertFalse(swtWizardBot.button(NEXT).isEnabled(), "Next button is disabled"); } if (backIsEnabled) { - assertTrue("Back button is enabled", swtWizardBot.button(BACK).isEnabled()); + assertTrue(swtWizardBot.button(BACK).isEnabled(), "Back button is enabled"); } else { - assertFalse("Back button is disabled", swtWizardBot.button(BACK).isEnabled()); + assertFalse(swtWizardBot.button(BACK).isEnabled(), "Back button is disabled"); } if (finishIsEnabled) { - assertTrue("Finish button is enabled", swtWizardBot.button(FINISH).isEnabled()); + assertTrue(swtWizardBot.button(FINISH).isEnabled(), "Finish button is enabled"); } else { - assertFalse("Finish button is disabled", swtWizardBot.button(FINISH).isEnabled()); + assertFalse(swtWizardBot.button(FINISH).isEnabled(), "Finish button is disabled"); } } @@ -184,7 +184,7 @@ public Boolean run() { return wizardShell.widget.getData() instanceof WizardDialog; } }); - assertTrue("Wizard is active before waiting on grammar field", wizardIsActive); + assertTrue(wizardIsActive, "Wizard is active before waiting on grammar field"); wizard.waitUntil(Conditions.widgetIsEnabled(wizard.comboBoxWithLabel(Messages.GRAMMAR_FIELD_NAME_LABEL)), 2 * SwtWizardBot.SWTBOT_TIMEOUT); } diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/util/CheckXtextTestUtil.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/util/CheckXtextTestUtil.java index 3959a35fd8..7cd624770c 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/util/CheckXtextTestUtil.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/util/CheckXtextTestUtil.java @@ -10,11 +10,11 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.ui.test.util; -import com.avaloq.tools.ddk.xtext.test.AbstractXtextTestUtil; -import com.avaloq.tools.ddk.xtext.test.ITestProjectManager; -import com.avaloq.tools.ddk.xtext.test.PluginTestProjectManager; import com.avaloq.tools.ddk.check.CheckConstants; import com.avaloq.tools.ddk.check.ui.internal.CheckActivator; +import com.avaloq.tools.ddk.xtext.test.ITestProjectManager; +import com.avaloq.tools.ddk.xtext.test.PluginTestProjectManager; +import com.avaloq.tools.ddk.xtext.test.jupiter.AbstractXtextTestUtil; import com.google.inject.Injector; @@ -34,7 +34,7 @@ private static final class InstanceHolder { private static final CheckXtextTestUtil INSTANCE = new CheckXtextTestUtil(); public static CheckXtextTestUtil get() { - return INSTANCE; + return INSTANCE; } } diff --git a/com.avaloq.tools.ddk.checkcfg.ui.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.checkcfg.ui.test/META-INF/MANIFEST.MF index cd9212e747..e82d168969 100644 --- a/com.avaloq.tools.ddk.checkcfg.ui.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.checkcfg.ui.test/META-INF/MANIFEST.MF @@ -6,8 +6,7 @@ Bundle-Version: 16.3.0.qualifier Bundle-Vendor: Avaloq Group AG Bundle-RequiredExecutionEnvironment: JavaSE-21 Export-Package: com.avaloq.tools.ddk.checkcfg.ui.test -Require-Bundle: org.junit, - junit-jupiter-api, +Require-Bundle: junit-jupiter-api, junit-jupiter-engine, - junit-vintage-engine + junit-platform-suite-api Automatic-Module-Name: com.avaloq.tools.ddk.checkcfg.ui.test diff --git a/com.avaloq.tools.ddk.checkcfg.ui.test/src/com/avaloq/tools/ddk/checkcfg/ui/test/CheckCfgUiTestSuite.java b/com.avaloq.tools.ddk.checkcfg.ui.test/src/com/avaloq/tools/ddk/checkcfg/ui/test/CheckCfgUiTestSuite.java index dc801dc5bc..60866c7ab5 100644 --- a/com.avaloq.tools.ddk.checkcfg.ui.test/src/com/avaloq/tools/ddk/checkcfg/ui/test/CheckCfgUiTestSuite.java +++ b/com.avaloq.tools.ddk.checkcfg.ui.test/src/com/avaloq/tools/ddk/checkcfg/ui/test/CheckCfgUiTestSuite.java @@ -10,17 +10,10 @@ *******************************************************************************/ package com.avaloq.tools.ddk.checkcfg.ui.test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - - /** - * Empty class serving only as holder for JUnit4 annotations. + * Empty class serving only as holder for JUnit5 annotations. */ -@RunWith(Suite.class) // @Format-Off -@Suite.SuiteClasses({ -}) // @Format-On public class CheckCfgUiTestSuite { } diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/jupiter/AbstractQuickFixTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/jupiter/AbstractQuickFixTest.java index a082548ee8..ee5891b2a5 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/jupiter/AbstractQuickFixTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/jupiter/AbstractQuickFixTest.java @@ -386,7 +386,7 @@ private void assertQuickFixProducesExpectedOutput(final String expectedContent, if (ignoreFormatting) { MatcherAssert.assertThat(message, actual, IsEqualCompressingWhiteSpace.equalToCompressingWhiteSpace(expected)); } else { - assertEquals(message, expected, actual); + assertEquals(expected, actual, message); } }