diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/generator/IssueCodeValueTest.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/generator/IssueCodeValueTest.xtend index 26ad426597..55b67b4f4f 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/generator/IssueCodeValueTest.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/generator/IssueCodeValueTest.xtend @@ -16,7 +16,7 @@ import org.junit.runner.RunWith import com.avaloq.tools.ddk.check.CheckInjectorProvider import org.eclipse.xtext.testing.XtextRunner import com.avaloq.tools.ddk.check.core.test.AbstractCheckGenerationTestCase -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.List import org.eclipse.xtext.xbase.testing.JavaSource import java.io.ByteArrayInputStream diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/AbstractCheckTestCase.java b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/AbstractCheckTestCase.java index 877f97296a..93f9a05073 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/AbstractCheckTestCase.java +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/AbstractCheckTestCase.java @@ -11,6 +11,9 @@ package com.avaloq.tools.ddk.check.core.test; import static com.google.common.collect.Sets.newHashSet; +import org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.io.InputStream; @@ -38,9 +41,9 @@ import org.eclipse.xtext.resource.XtextResourceSet; import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil; import org.eclipse.xtext.util.StringInputStream; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import com.avaloq.tools.ddk.check.CheckConstants; import com.avaloq.tools.ddk.check.ui.internal.CheckActivator; @@ -54,14 +57,12 @@ import com.google.inject.Injector; import com.google.inject.Provider; -import junit.framework.TestCase; - /** * An abstract test class for tests on Check models. Allows creating a project and adding files. */ @SuppressWarnings({"PMD.SignatureDeclareThrowsException", "restriction"}) -public abstract class AbstractCheckTestCase extends TestCase { +public abstract class AbstractCheckTestCase { private static final int TWO_KILO_BYTES = 2048; protected static final Logger LOGGER = LogManager.getLogger(AbstractCheckTestCase.class); private static final PluginTestProjectManager PROJECT_MANAGER = new PluginTestProjectManager(CheckActivator.getInstance().getInjector(CheckConstants.GRAMMAR)); @@ -72,7 +73,7 @@ public abstract class AbstractCheckTestCase extends TestCase { private Provider resourceSetProvider; @Override - @Before + @BeforeEach public void setUp() throws Exception { getInjector().injectMembers(this); } @@ -83,7 +84,7 @@ public void setUp() throws Exception { * @throws Exception * the exception */ - @BeforeClass + @BeforeAll public static void prepareWorkspace() throws Exception { PROJECT_MANAGER.setup(ImmutableList. of()); } @@ -117,7 +118,7 @@ public T get(final Class clazz) { /** * Clean up after all tests have terminated. */ - @AfterClass + @AfterAll public static void cleanUp() { PROJECT_MANAGER.teardown(); } diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BasicModelTest.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BasicModelTest.xtend index 1f0d2ade7f..7fec83879d 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BasicModelTest.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BasicModelTest.xtend @@ -21,11 +21,11 @@ import org.eclipse.xtext.resource.XtextResource import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.util.ParseHelper -import org.junit.Ignore -import org.junit.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test import org.junit.runner.RunWith -import static org.junit.Assert.* +import static org.junit.jupiter.api.Assertions.* @InjectWith(typeof(CheckUiInjectorProvider)) @RunWith(typeof(XtextRunner)) @@ -73,8 +73,8 @@ class BasicModelTest { } /* Tests that Checks documented with ML_COMMENTs have an inferred description field. */ + @Disabled("Fails because DocumentedImplCustom uses the null resource description provider to get the document provider") @Test - @Ignore("Fails because DocumentedImplCustom uses the null resource description provider to get the document provider") def void testInferingOfDescription() { val check = util.getFirstInstanceOf(parser.parse(modelUtil.modelWithCheck), typeof(Check)) assertEquals("No documentation.", check.description) diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugAig830.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugAig830.xtend index e5c57fde49..a9d187313e 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugAig830.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugAig830.xtend @@ -19,8 +19,8 @@ import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.util.ParseHelper import org.eclipse.xtext.xbase.XbasePackage -import org.junit.Assert -import org.junit.Test +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test import org.junit.runner.RunWith @InjectWith(typeof(CheckUiInjectorProvider)) diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugDsl27.java b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugDsl27.java index fc357d6b2d..bd18084dbd 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugDsl27.java +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugDsl27.java @@ -15,7 +15,7 @@ import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.XtextRunner; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.check.CheckInjectorProvider; @@ -31,8 +31,8 @@ public class BugDsl27 extends AbstractCheckGenerationTestCase { /** * Tests that our test source compiles fine. */ - @Test - public void testGeneratedCodeHasNoErrors() { + @org.junit.jupiter.api.Test + void testGeneratedCodeHasNoErrors() { try (InputStream sourceStream = BugDsl27.class.getResourceAsStream("bugdsl27/BugDsl27")) { generateAndCompile(sourceStream); } catch (IOException exception) { diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/CheckScopingTest.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/CheckScopingTest.xtend index 7433dd6418..bab88e16cf 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/CheckScopingTest.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/CheckScopingTest.xtend @@ -22,7 +22,7 @@ import java.util.List import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith @InjectWith(typeof(CheckUiInjectorProvider)) diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/IssueCodeToLabelMapGenerationTest.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/IssueCodeToLabelMapGenerationTest.xtend index c5b381b555..57ba171a85 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/IssueCodeToLabelMapGenerationTest.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/IssueCodeToLabelMapGenerationTest.xtend @@ -15,7 +15,7 @@ import com.avaloq.tools.ddk.check.CheckInjectorProvider import java.io.ByteArrayInputStream import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith import java.util.List import org.eclipse.xtext.xbase.testing.JavaSource diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/ProjectBasedTests.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/ProjectBasedTests.xtend index 10d3b47e0e..a822bfdcad 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/ProjectBasedTests.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/ProjectBasedTests.xtend @@ -20,7 +20,7 @@ import org.eclipse.core.resources.IProject import org.eclipse.core.resources.IResource import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/formatting/CheckFormattingTest.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/formatting/CheckFormattingTest.xtend index 4b7f8c0677..247a07477c 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/formatting/CheckFormattingTest.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/formatting/CheckFormattingTest.xtend @@ -18,7 +18,7 @@ import org.eclipse.xtext.preferences.MapBasedPreferenceValues import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.formatter.FormatterTestHelper -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith @InjectWith(typeof(CheckUiInjectorProvider)) diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckApiAccessValidationsTest.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckApiAccessValidationsTest.xtend index 37f141b582..ca4b53ffe0 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckApiAccessValidationsTest.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckApiAccessValidationsTest.xtend @@ -13,7 +13,7 @@ import org.eclipse.xtext.testing.InjectWith import org.junit.runner.RunWith import org.eclipse.xtext.testing.XtextRunner import com.avaloq.tools.ddk.check.CheckUiInjectorProvider -import org.junit.Test +import org.junit.jupiter.api.Test import com.google.inject.Inject import org.eclipse.xtext.testing.util.ParseHelper import com.avaloq.tools.ddk.check.check.CheckCatalog diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckJavaValidatorUtilTest.java b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckJavaValidatorUtilTest.java index af865e5af6..bc7159d806 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckJavaValidatorUtilTest.java +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckJavaValidatorUtilTest.java @@ -10,17 +10,17 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.validation; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.core.runtime.IStatus; import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.XtextRunner; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.check.CheckUiInjectorProvider; import com.google.inject.Inject; -import junit.framework.TestCase; - /** * Tests for com.avaloq.tools.ddk.check.validation.CheckJavaValidatorUtil. @@ -28,7 +28,7 @@ @InjectWith(CheckUiInjectorProvider.class) @RunWith(XtextRunner.class) -public class CheckJavaValidatorUtilTest extends TestCase { +public class CheckJavaValidatorUtilTest { // assertion messages. private static final String STARTS_WITH_LOWER_CASE = "starts with lower case"; @@ -64,7 +64,7 @@ public class CheckJavaValidatorUtilTest extends TestCase { * Tests checkProjectName. The given values are valid. */ @Test - public void projectNameIsValid() { + void projectNameIsValid() { assertTrue(QUALIFIED_NAME, util.checkProjectName("project.name").isOK()); assertTrue(NON_QUALIFIED_NAME, util.checkProjectName("projectname").isOK()); } @@ -73,7 +73,7 @@ public void projectNameIsValid() { * Tests checkProjectName. The given values are invalid. */ @Test - public void projectNameIsInvalid() { + void projectNameIsInvalid() { assertTrue(NAME_IS_EMPTY, util.checkProjectName(EMPTY_STRING).matches(IStatus.ERROR)); assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkProjectName("Project.name").matches(IStatus.ERROR)); assertTrue(STARTS_WITH_ILLEGAL_CHARACTER_DOT, util.checkProjectName(".projectname").matches(IStatus.ERROR)); @@ -88,7 +88,7 @@ public void projectNameIsInvalid() { */ @Test - public void packageNameIsValid() { + void packageNameIsValid() { assertTrue(QUALIFIED_NAME, util.checkPackageName("package.name").isOK()); assertTrue(NON_QUALIFIED_NAME, util.checkPackageName("packagename").isOK()); } @@ -98,7 +98,7 @@ public void packageNameIsValid() { */ @Test - public void packageNameIsInvalid() { + void packageNameIsInvalid() { assertTrue(NAME_IS_EMPTY, util.checkPackageName(EMPTY_STRING).matches(IStatus.ERROR)); assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkPackageName("Package.name").matches(IStatus.ERROR)); assertTrue(STARTS_WITH_ILLEGAL_CHARACTER_DOT, util.checkPackageName(".packagename").matches(IStatus.ERROR)); @@ -112,7 +112,7 @@ public void packageNameIsInvalid() { * Tests checkCatalogName. The given values are valid. */ @Test - public void catalogNameIsValid() { + void catalogNameIsValid() { assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCatalogName("Catalogname").isOK()); assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCatalogName("CatalogName").isOK()); } @@ -121,7 +121,7 @@ public void catalogNameIsValid() { * Tests checkCatalogName. The given values are invalid. */ @Test - public void catalogNameIsInvalid() { + void catalogNameIsInvalid() { assertTrue(NAME_IS_EMPTY, util.checkCatalogName(EMPTY_STRING).matches(IStatus.ERROR)); assertTrue(QUALIFIED_NAME, util.checkCatalogName("Catalog.Name").matches(IStatus.ERROR)); assertTrue(CONTAINS_ILLEGAL_CHARACTER, util.checkCatalogName(",Catalogname").matches(IStatus.ERROR)); @@ -132,7 +132,7 @@ public void catalogNameIsInvalid() { * Tests checkCatalogName. The given values are discouraged. */ @Test - public void catalogNameIsDiscouraged() { + void catalogNameIsDiscouraged() { assertTrue(STARTS_WITH_LOWER_CASE, util.checkCatalogName("catalogname").matches(IStatus.WARNING)); assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCatalogName("catalogName").matches(IStatus.WARNING)); } @@ -141,7 +141,7 @@ public void catalogNameIsDiscouraged() { * Tests checkCheckName. The given values are valid. */ @Test - public void checkNameIsValid() { + void checkNameIsValid() { assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCheckName("Checkname").isOK()); assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCheckName("CheckName").isOK()); } @@ -150,7 +150,7 @@ public void checkNameIsValid() { * Tests checkCheckName. The given values are invalid. */ @Test - public void checkNameIsInvalid() { + void checkNameIsInvalid() { assertTrue(NAME_IS_EMPTY, util.checkCheckName(EMPTY_STRING).matches(IStatus.ERROR)); assertTrue(QUALIFIED_NAME, util.checkCheckName("Check.name").matches(IStatus.ERROR)); assertTrue(CONTAINS_ILLEGAL_CHARACTER, util.checkCheckName(",checkname").matches(IStatus.ERROR)); @@ -161,7 +161,7 @@ public void checkNameIsInvalid() { * Tests checkCheckName. The given values are discouraged. */ @Test - public void checkNameIsDiscouraged() { + void checkNameIsDiscouraged() { assertTrue(STARTS_WITH_LOWER_CASE, util.checkCheckName("checkname").matches(IStatus.WARNING)); assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCheckName("checkName").matches(IStatus.WARNING)); @@ -171,7 +171,7 @@ public void checkNameIsDiscouraged() { * Tests checkCategoryName. The given values are valid. */ @Test - public void categoryNameIsValid() { + void categoryNameIsValid() { assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCategoryName("Categoryname").isOK()); assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCategoryName("CategoryName").isOK()); } @@ -180,7 +180,7 @@ public void categoryNameIsValid() { * Tests checkCategoryName. The given values are invalid. */ @Test - public void categoryNameIsInvalid() { + void categoryNameIsInvalid() { assertTrue(NAME_IS_EMPTY, util.checkCategoryName(EMPTY_STRING).matches(IStatus.ERROR)); assertTrue(QUALIFIED_NAME, util.checkCategoryName("Category.name").matches(IStatus.ERROR)); assertTrue(CONTAINS_ILLEGAL_CHARACTER, util.checkCategoryName("%categoryname").matches(IStatus.ERROR)); @@ -191,7 +191,7 @@ public void categoryNameIsInvalid() { * Tests checkCategoryName. The given values are discouraged. */ @Test - public void categoryNameIsDiscouraged() { + void categoryNameIsDiscouraged() { assertTrue(STARTS_WITH_LOWER_CASE, util.checkCategoryName("categoryname").matches(IStatus.WARNING)); assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCategoryName("categoryName").matches(IStatus.WARNING)); } diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckValidationTest.xtend b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckValidationTest.xtend index 340eb56c36..1599d26f59 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckValidationTest.xtend +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckValidationTest.xtend @@ -20,8 +20,8 @@ import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.util.ParseHelper import org.eclipse.xtext.testing.validation.ValidationTestHelper import org.eclipse.xtext.xbase.XbasePackage$Literals -import org.junit.Ignore -import org.junit.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test import org.junit.runner.RunWith import com.avaloq.tools.ddk.check.validation.IssueCodes import com.avaloq.tools.ddk.check.check.CheckPackage @@ -96,8 +96,8 @@ class CheckValidationTest { } /* Tests checkContextTypeIsUnique(Check) */ + @Disabled("Tests do not work because of scoping issues at run-time") @Test - @Ignore("Tests do not work because of scoping issues at run-time") def void testContextTypeIsUnique() { // should fail var contexts = Lists::newArrayList("for C c {issue}", "for C d {issue}") diff --git a/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/context/CheckContextTest.java b/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/context/CheckContextTest.java index a63a7ea41e..2da2358404 100644 --- a/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/context/CheckContextTest.java +++ b/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/context/CheckContextTest.java @@ -11,16 +11,14 @@ package com.avaloq.tools.ddk.check.runtime.context; import org.eclipse.emf.ecore.EObject; -import org.junit.Assert; -import org.junit.Test; - -import junit.framework.TestCase; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Provides some tests of the reflective {@link AbstractCheckContext} framework. */ -public class CheckContextTest extends TestCase { +public class CheckContextTest { public static final String ENABLED_ISSUE_CODE = "Enabled.Issue.Code"; public static final String DISABLED_ISSUE_CODE = "Disabled.Issue.Code"; @@ -33,13 +31,13 @@ public class CheckContextTest extends TestCase { * Tests that the {@link DummyCheckContext} properly marks issue codes as enabled and disabled. */ @Test - public void testIssuesEnabledDisabled() { + void testIssuesEnabledDisabled() { ICheckContext checkContext = new DummyCheckContext(); - Assert.assertTrue("Check an issue code in annotations but enabled is still enabled", checkContext.isCheckValid(DUMMY_CONTEXT, ENABLED_ISSUE_CODE)); - Assert.assertTrue("Check an issue code not in any annotations is still enabled", checkContext.isCheckValid(DUMMY_CONTEXT, NOT_MENTIONED_ISSUE_CODE)); - Assert.assertFalse("Check an issue code in annotations is disabled", checkContext.isCheckValid(DUMMY_CONTEXT, DISABLED_ISSUE_CODE)); - Assert.assertFalse("Check disabling has priority over enabling", checkContext.isCheckValid(DUMMY_CONTEXT, DISABLED_AND_ENABLED_ISSUE_CODE)); - Assert.assertFalse("Check disabling has priority over enabling, using different order", checkContext.isCheckValid(DUMMY_CONTEXT, ENABLED_AND_DISABLED_ISSUE_CODE)); + Assertions.assertTrue("Check an issue code in annotations but enabled is still enabled", checkContext.isCheckValid(DUMMY_CONTEXT, ENABLED_ISSUE_CODE)); + Assertions.assertTrue("Check an issue code not in any annotations is still enabled", checkContext.isCheckValid(DUMMY_CONTEXT, NOT_MENTIONED_ISSUE_CODE)); + Assertions.assertFalse("Check an issue code in annotations is disabled", checkContext.isCheckValid(DUMMY_CONTEXT, DISABLED_ISSUE_CODE)); + Assertions.assertFalse("Check disabling has priority over enabling", checkContext.isCheckValid(DUMMY_CONTEXT, DISABLED_AND_ENABLED_ISSUE_CODE)); + Assertions.assertFalse("Check disabling has priority over enabling, using different order", checkContext.isCheckValid(DUMMY_CONTEXT, ENABLED_AND_DISABLED_ISSUE_CODE)); } } diff --git a/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/core/registry/CheckExtensionPointTests.java b/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/core/registry/CheckExtensionPointTests.java index 8d01a80d39..e937a5a63f 100644 --- a/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/core/registry/CheckExtensionPointTests.java +++ b/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/core/registry/CheckExtensionPointTests.java @@ -10,24 +10,26 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.runtime.core.registry; +import org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.Assertions.assertNull; +import org.junit.jupiter.api.Assertions.fail; + import java.util.List; import java.util.NoSuchElementException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import junit.framework.TestCase; - /** * Provides some test cases for the Check extension point. */ -public class CheckExtensionPointTests extends TestCase { +public class CheckExtensionPointTests { private static final String DUMMY_EXTENSION_ID = "com.avaloq.tools.ddk.check.runtime.core.test"; private static final String CHECK_EXTENSION_ID = "com.avaloq.tools.ddk.check.runtime.core"; @@ -85,7 +87,7 @@ private IConfigurationElement findConfigurationElement(final IConfigurationEleme * @see Platform#getExtensionRegistry() */ @Test - public void testExtensionPointIsRegistered() { + void testExtensionPointIsRegistered() { try { findCheckExtensionPoint(findExtensionPoints()); } catch (NoSuchElementException e) { @@ -98,7 +100,7 @@ public void testExtensionPointIsRegistered() { * point. */ @Test - public void testDummyClientRegistered() { + void testDummyClientRegistered() { assertNotNull("Test plugin successfully registered to the check extension point", findCheckExtensionPoint(findExtensionPoints()).getExtension(DUMMY_EXTENSION_ID)); } @@ -106,16 +108,16 @@ public void testDummyClientRegistered() { * Tests that a non-existing client is not registered with the extension * point registry. */ - @Test - public void testInvalidClientNotRegistered() { + @org.junit.jupiter.api.Test + void testInvalidClientNotRegistered() { assertNull("Non-existing client not registered to the check extension point", findCheckExtensionPoint(findExtensionPoints()).getExtension("a.b.c")); } /** * Tests that the check extension point has an attribute {@value #TARGET_CLASS_ATTRIBUTE}. */ - @Test - public void testTargetClassAttributeFound() { + @org.junit.jupiter.api.Test + void testTargetClassAttributeFound() { IExtensionPoint point = findCheckExtensionPoint(findExtensionPoints()); assertNotNull("Found a configuration element with attribute \"targetClass\"", findConfigurationElement(point.getConfigurationElements(), TARGET_CLASS_ATTRIBUTE)); } @@ -123,8 +125,8 @@ public void testTargetClassAttributeFound() { /** * Tests that the check extension point has an attribute {@value #LANGUAGE_ATTRIBUTE}. */ - @Test - public void testLanguageAttributeFound() { + @org.junit.jupiter.api.Test + void testLanguageAttributeFound() { IExtensionPoint point = findCheckExtensionPoint(findExtensionPoints()); assertNotNull("Found a configuration element with attribute \"language\"", findConfigurationElement(point.getConfigurationElements(), LANGUAGE_ATTRIBUTE)); } diff --git a/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/core/validation/CheckValidatorTest.java b/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/core/validation/CheckValidatorTest.java index a91a3de534..6ed9bf1d23 100644 --- a/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/core/validation/CheckValidatorTest.java +++ b/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/core/validation/CheckValidatorTest.java @@ -10,9 +10,9 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.runtime.core.validation; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.check.runtime.issue.ICheckValidatorImpl; import com.avaloq.tools.ddk.check.runtime.validation.AbstractCheckValidator; @@ -44,8 +44,8 @@ protected String getHostLanguage() { * * @see {@link com.avaloq.tools.ddk.check.extensionpoint.test.validation.DummyValidator} */ - @Test - public void testAtLeastOneValidatorFound() { + @org.junit.jupiter.api.Test + void testAtLeastOneValidatorFound() { ICheckValidatorImpl dummyValidator = Iterables.getOnlyElement(getValidators(Maps.newHashMap(), null)); assertEquals("Dummy validator found", "DummyValidator", dummyValidator.getClass().getSimpleName()); } diff --git a/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/label/CheckRuleLabelProviderTest.java b/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/label/CheckRuleLabelProviderTest.java index 290ad8d6d3..2bae132c7a 100644 --- a/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/label/CheckRuleLabelProviderTest.java +++ b/com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/label/CheckRuleLabelProviderTest.java @@ -10,9 +10,9 @@ package com.avaloq.tools.ddk.check.runtime.label; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -23,9 +23,9 @@ import java.util.Collections; import java.util.List; -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; import com.avaloq.tools.ddk.check.runtime.issue.ICheckValidatorImpl; import com.avaloq.tools.ddk.check.runtime.registry.ICheckValidatorRegistry; @@ -72,7 +72,7 @@ public class CheckRuleLabelProviderTest { /** * Setup done before each test. */ - @Before + @BeforeEach public void setUp() { // Create mocks @@ -97,7 +97,7 @@ protected void configure() { /** * Teardown done after each test. */ - @After + @AfterEach public void tearDown() { mockCheckValidatorRegistry = null; @@ -127,7 +127,7 @@ private void mockValidatorsWithChecks() { * Test the default binding. */ @Test - public void testBinding() { + void testBinding() { // ASSERT assertSame("Binding of label provider incorrect.", CheckRuleLabelProvider.class, checkRuleLabelProvider.getClass()); } @@ -135,8 +135,8 @@ public void testBinding() { /** * Test successfully getting a check label. */ - @Test - public void testSuccess() { + @org.junit.jupiter.api.Test + void testSuccess() { // ARRANGE mockValidatorsWithChecks(); @@ -164,8 +164,8 @@ public void testWhenIssueCodeNotPresent() { /** * Test trying to get the check label for a null issue code. */ - @Test - public void testWithNullID() { + @org.junit.jupiter.api.Test + void testWithNullID() { // ARRANGE mockValidatorsWithChecks(); @@ -180,7 +180,7 @@ public void testWithNullID() { * Test trying to get a check label when there are no validators. */ @Test - public void testWithNoValidators() { + void testWithNoValidators() { // ARRANGE when(mockCheckValidatorRegistry.getValidators()).thenReturn(Collections.emptyList()); @@ -194,8 +194,8 @@ public void testWithNoValidators() { /** * Test trying to get a check label when there are no checks registered. */ - @Test - public void testWithNoChecks() { + @org.junit.jupiter.api.Test + void testWithNoChecks() { // ARRANGE when(mockCheckValidatorRegistry.getValidators()).thenReturn(mockValidators); for (ICheckValidatorImpl mockValidator : mockValidators) { @@ -212,8 +212,8 @@ public void testWithNoChecks() { /** * Test trying to get the check label for an issue code which is not a check issue code. */ - @Test - public void testWhenIssueCodeIsNotACheckIssueCode() { + @org.junit.jupiter.api.Test + void testWhenIssueCodeIsNotACheckIssueCode() { // ARRANGE final String notACheckIssueCode = "package.name.SomeOtherClass.issue.code"; @@ -232,8 +232,8 @@ public void testWhenIssueCodeIsNotACheckIssueCode() { /** * Test that check labels are cached. */ - @Test - public void testCaching() { + @org.junit.jupiter.api.Test + void testCaching() { // ARRANGE mockValidatorsWithChecks(); @@ -266,8 +266,8 @@ public void publicInvalidateCache() { /** * Test that the cache can be invalidated by subclasses. */ - @Test - public void testInvalidatingCache() { + @org.junit.jupiter.api.Test + void testInvalidatingCache() { // ARRANGE final CheckRuleLabelProviderWithInvalidateCacheExposed checkRuleLabelProviderWithInvalidateCacheExposed = injector.getInstance(CheckRuleLabelProviderWithInvalidateCacheExposed.class); @@ -290,8 +290,8 @@ public void testInvalidatingCache() { /** * Test that the class is bound as a singleton. */ - @Test - public void testClassIsSingleton() { + @org.junit.jupiter.api.Test + void testClassIsSingleton() { // ACT final ICheckRuleLabelProvider otherCheckRuleLabelProvider = injector.getInstance(CheckRuleLabelProvider.class); diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.xtend b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.xtend index 5e7b6983e4..48ecfad6a4 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.xtend +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.xtend @@ -23,7 +23,7 @@ import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.validation.ValidationTestHelper import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith @InjectWith(typeof(TestLanguageUiInjectorProvider)) diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.xtend b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.xtend index 97ee56ff3e..2afef11d83 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.xtend +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.xtend @@ -22,7 +22,7 @@ import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.util.ParseHelper import org.eclipse.xtext.testing.validation.ValidationTestHelper -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith @InjectWith(typeof(TestLanguageUiInjectorProvider)) diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.xtend b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.xtend index 8d485dff38..7071adcfc7 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.xtend +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.xtend @@ -15,10 +15,10 @@ import com.avaloq.tools.ddk.check.runtime.label.ICheckRuleLabelProvider import com.avaloq.tools.ddk.check.validation.LibraryChecksIssueCodes import com.google.inject.AbstractModule import com.google.inject.Guice -import org.junit.Test +import org.junit.jupiter.api.Test -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertNotNull +import static org.junit.jupiter.api.Assertions.assertEquals +import static org.junit.jupiter.api.Assertions.assertNotNull /** * End-to-end test for getting Check labels. 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 c60f5d4225..694611276b 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,7 +5,7 @@ Bundle-SymbolicName: com.avaloq.tools.ddk.check.ui.test Bundle-Version: 16.2.0.qualifier Bundle-Vendor: Avaloq Group AG Bundle-RequiredExecutionEnvironment: JavaSE-21 -Require-Bundle: org.junit, +Require-Bundle: org.junit.jupiter.api, com.avaloq.tools.ddk.check.ui, com.avaloq.tools.ddk.xtext.test.core, com.avaloq.tools.ddk.test.core, @@ -20,7 +20,9 @@ Require-Bundle: org.junit, org.eclipse.xtext.xbase.lib, org.eclipse.core.runtime, org.eclipse.ui.workbench;resolution:=optional, - org.objectweb.asm;resolution:=optional + org.objectweb.asm;resolution:=optional, + junit-jupiter-api, + org.junit 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 06fef0015c..8ac55d3bbe 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; @@ -33,9 +33,9 @@ import org.eclipse.xtext.Grammar; import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.ui.util.PluginProjectFactory; -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; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.check.ui.test.internal.CheckWizardUiTestInjectorProvider; @@ -116,7 +116,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(); @@ -137,7 +137,7 @@ private void initializeWizardBot() { * Test if the package field contains the selected package. */ @Test - public void testPackageSelected() { + void testPackageSelected() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); initializeWizardBot(); // because the selected item is a package initially, this package is shown in the field. @@ -148,7 +148,7 @@ public void testPackageSelected() { * Test if catalog wizard is enabled if a project folder is selected. */ @Test - public void testCheckCatalogWizardIsEnabled() { + void testCheckCatalogWizardIsEnabled() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); // open the check catalog wizard after having selected the project source folder. // that way, the wizard page should be enabled. @@ -164,7 +164,7 @@ public void testCheckCatalogWizardIsEnabled() { * Test if the package field is empty, if the selected item is no package. */ @Test - public void testInitiallyNoPackageSelected() { + void testInitiallyNoPackageSelected() { selectProjectFolder(wizard, SRC_FOLDER); initializeWizardBot(); @@ -176,7 +176,7 @@ public void testInitiallyNoPackageSelected() { * Test if the next and finish button are disabled if the package name is invalid. */ @Test - public void testPackageNameInvalid() { + void testPackageNameInvalid() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); // open the check catalog wizard after having selected the project source folder. initializeWizardBot(); @@ -192,7 +192,7 @@ public void testPackageNameInvalid() { * Test if the finish button is enabled if the package name is valid. */ @Test - public void testPackageNameValid() { + void testPackageNameValid() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); // open the check catalog wizard after having selected the project source folder. initializeWizardBot(); @@ -205,7 +205,7 @@ public void testPackageNameValid() { * Test if the next and finish button are disabled if the catalog name is invalid. */ @Test - public void testCatalogNameInvalid() { + void testCatalogNameInvalid() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); // open the check catalog wizard after having selected the project source folder. initializeWizardBot(); @@ -219,7 +219,7 @@ public void testCatalogNameInvalid() { * Tests that discouraged catalog names are accepted. */ @Test - public void testCatalogNameDiscouraged() { + void testCatalogNameDiscouraged() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); initializeWizardBot(); @@ -232,7 +232,7 @@ public void testCatalogNameDiscouraged() { * Tests valid catalog names. */ @Test - public void testCatalogName() { + void testCatalogName() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); initializeWizardBot(); @@ -258,7 +258,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 5261a85cc2..c93965205d 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,15 +10,16 @@ *******************************************************************************/ 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.jupiter.api.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.check.ui.test.internal.CheckWizardUiTestInjectorProvider; @@ -47,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); @@ -57,7 +58,7 @@ public void setUp() { * Check if the project wizard is available. */ @Test - public void testCheckProjectWizardIsAvailable() { + void testCheckProjectWizardIsAvailable() { assertNotNull("the project wizard was found", wizard); CheckWizardTestUtil.assertButtonsEnabled(false, true, false, wizard); } @@ -65,8 +66,8 @@ public void testCheckProjectWizardIsAvailable() { /** * Test if the buttons 'next', 'back' and 'finish' are correctly enabled/disabled. */ - @Test - public void testProjectNameInvalid() { + @org.junit.jupiter.api.Test + void testProjectNameInvalid() { CheckWizardTestUtil.projectName(wizard, "", CheckWizardTestUtil.NEXT_DISABLED); CheckWizardTestUtil.projectName(wizard, ".project.name", CheckWizardTestUtil.NEXT_DISABLED); CheckWizardTestUtil.projectName(wizard, "Project.name", CheckWizardTestUtil.NEXT_DISABLED); @@ -87,7 +88,7 @@ public void testFinishButtonDisabledInProjectPage() { * Test if the buttons 'next', 'back' and 'finish' are correctly enabled/disabled. */ @Test - public void testProjectNameValid() { + void testProjectNameValid() { CheckWizardTestUtil.projectName(wizard, "project.name", CheckWizardTestUtil.NEXT_ENABLED); CheckWizardTestUtil.projectName(wizard, "projectname", CheckWizardTestUtil.NEXT_ENABLED); } @@ -96,7 +97,7 @@ public void testProjectNameValid() { * Test if the buttons 'next', 'back' and 'finish' are correctly enabled/disabled. */ @Test - public void fieldValuesAfterPageChange() { + void fieldValuesAfterPageChange() { wizard.writeToTextField(Messages.PROJECT_NAME_LABEL, CORRECT_PROJECT_NAME); wizard.changeToPreviousPage(); wizard.changeToNextPage(); @@ -120,7 +121,7 @@ public void testNextButtonChangesPage() { /** * 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/builder/CheckContextsExtensionTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/builder/CheckContextsExtensionTest.java index e46b2b9f1d..4ec0e2ceb8 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 org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Assertions.assertFalse; +import org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; @@ -18,11 +22,11 @@ import org.eclipse.pde.core.plugin.IPluginExtension; 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.util.ParseHelper; -import org.eclipse.xtext.testing.InjectWith; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.check.check.CheckCatalog; @@ -33,8 +37,6 @@ import com.google.common.collect.Lists; import com.google.inject.Inject; -import junit.framework.TestCase; - /** * Tests CheckContextExtensionUtil. @@ -42,7 +44,7 @@ @SuppressWarnings("restriction") @InjectWith(CheckWizardUiTestInjectorProvider.class) @RunWith(XtextRunner.class) -public class CheckContextsExtensionTest extends TestCase { +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 }}}"; @@ -57,7 +59,7 @@ public class CheckContextsExtensionTest extends TestCase { private IWorkspace workspace; @Override - @Before + @BeforeEach public void setUp() throws Exception { catalog = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE); IFile pluginxml = workspace.getRoot().getFile(new Path("/test/plugin.xml")); @@ -71,7 +73,7 @@ public void setUp() throws Exception { * core exception */ @Test - public void testCreateExtension() throws CoreException { + 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()); @@ -87,7 +89,7 @@ public void testCreateExtension() throws CoreException { * the core exception */ @Test - public void testIsExtensionUpdateRequiredTrue() throws CoreException { + 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)); @@ -100,7 +102,7 @@ public void testIsExtensionUpdateRequiredTrue() throws CoreException { * the core exception */ @Test - public void testIsExtensionUpdateRequiredFalse() throws CoreException { + 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)); 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 cdf20f180b..5811eedcfa 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; @@ -28,7 +28,7 @@ import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.testing.util.ParseHelper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.check.check.CheckCatalog; @@ -78,8 +78,8 @@ public class CheckMarkerHelpExtensionTest { * @throws Exception * the exception */ - @Test - public void testCreateExtension() throws Exception { + @org.junit.jupiter.api.Test + void testCreateExtension() throws Exception { IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE)); // Test if the extension has been created. @@ -98,8 +98,8 @@ public void testCreateExtension() throws Exception { * @throws Exception * the exception */ - @Test - public void testAddElement() throws Exception { + @org.junit.jupiter.api.Test + void testAddElement() throws Exception { final CheckCatalog catalogWithOneCheck = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE); IPluginExtension extension = createMarkerHelpExtension(catalogWithOneCheck); @@ -123,8 +123,8 @@ public void testAddElement() throws Exception { * @throws Exception * the exception */ - @Test - public void testRemoveElement() throws Exception { + @org.junit.jupiter.api.Test + void testRemoveElement() throws Exception { final CheckCatalog catalogWithTwoChecks = parser.parse(CATALOG_WITH_TWO_CHECKS); IPluginExtension extension = createMarkerHelpExtension(catalogWithTwoChecks); @@ -143,8 +143,8 @@ public void testRemoveElement() throws Exception { * @throws Exception * the exception */ - @Test - public void testMarkerTypeUpdate() throws Exception { + @org.junit.jupiter.api.Test + 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()); @@ -164,8 +164,8 @@ public void testMarkerTypeUpdate() throws Exception { * @throws Exception * the exception */ - @Test - public void testCheckHasTwoIssueCodes() throws Exception { + @org.junit.jupiter.api.Test + void testCheckHasTwoIssueCodes() throws Exception { IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE)); CheckCatalog twoIssueCodes = parser.parse(CATALOG_CHECK_HAS_TWO_ISSUECODES); 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 13fb54b31a..76943c16ac 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,7 +10,10 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.ui.test.builder; -import junit.framework.TestCase; +import org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Assertions.assertFalse; +import org.junit.jupiter.api.Assertions.assertNotSame; +import org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspace; @@ -23,8 +26,8 @@ import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.testing.util.ParseHelper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.check.check.CheckCatalog; @@ -42,7 +45,7 @@ @SuppressWarnings({"restriction", "PMD.SignatureDeclareThrowsException"}) @InjectWith(CheckWizardUiTestInjectorProvider.class) @RunWith(XtextRunner.class) -public class CheckTocExtensionTest extends TestCase { +public class CheckTocExtensionTest { @Inject private ParseHelper parser; @@ -58,7 +61,7 @@ public class CheckTocExtensionTest extends TestCase { private CheckCatalog catalog; private IPluginModelBase pluginModel; - @Before + @BeforeEach @Override public void setUp() throws Exception { catalog = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE); @@ -69,12 +72,12 @@ public void setUp() throws Exception { /** * Tests if the toc extension is correctly created. - * + * * @throws CoreException * the core exception */ - @Test - public void testCreateExtension() throws CoreException { + @org.junit.jupiter.api.Test + 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()); @@ -84,12 +87,12 @@ public void testCreateExtension() throws CoreException { /** * Tests if isExtensionUpdateRequired returns true if only an erroneous extension exists for the check catalog. - * + * * @throws CoreException * the core exception */ - @Test - public void testIsExtensionUpdateRequiredTrue() throws CoreException { + @org.junit.jupiter.api.Test + void testIsExtensionUpdateRequiredTrue() throws CoreException { IPluginExtension extension = createErroneousTocExtension(); Iterable elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class); @@ -98,7 +101,7 @@ public void testIsExtensionUpdateRequiredTrue() throws CoreException { /** * Creates an erroneous toc extension. - * + * * @return the plugin extension * @throws CoreException * the core exception @@ -116,12 +119,12 @@ private IPluginExtension createErroneousTocExtension() throws CoreException { /** * Tests if an update of a toc extension is correctly done. - * + * * @throws CoreException * the core exception */ @Test - public void testUpdateTocExtension() throws CoreException { + 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); @@ -130,12 +133,12 @@ public void testUpdateTocExtension() throws CoreException { /** * Tests if isExtensionUpdateRequires returns false if a correct extension already exists. - * + * * @throws CoreException * the core exception */ @Test - public void testIsExtensionUpdateRequiredFalse() throws CoreException { + 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)); 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 85dce9ec8b..38549a6965 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 @@ -20,8 +20,8 @@ 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.Assertions; +import org.junit.jupiter.api.Test; import com.google.common.base.Function; import com.google.common.collect.Iterables; @@ -51,7 +51,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)); + Assertions.assertTrue(NLS.bind("Expected {0} but found {1}", Arrays.toString(expected), actual), actual.contains(string)); } } @@ -62,7 +62,7 @@ public String apply(final ICompletionProposal input) { * the exception */ @Test - public void testBugAig931() throws Exception { + void testBugAig931() throws Exception { final String partialModel = "package p catalog T for grammar com.avaloq.tools.ddk.check.Check { error \"X\" for "; final String[] expectedContextTypeProposals = {"EObject - org.eclipse.emf.ecore", "JvmType - org.eclipse.xtext.common.types"}; new UIJob("compute completion proposals") { 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..16b1081bc6 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,10 @@ 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 org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test -import static org.junit.Assert.fail +import static org.junit.jupiter.api.Assertions.fail /** * Test quickfixes for Check files. @@ -95,7 +95,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); + Assertions.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 e13c185389..fa35472acd 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; diff --git a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/contentassist/CheckCfgContentAssistTest.xtend b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/contentassist/CheckCfgContentAssistTest.xtend index e9985f811a..fb2d9f7aa4 100644 --- a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/contentassist/CheckCfgContentAssistTest.xtend +++ b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/contentassist/CheckCfgContentAssistTest.xtend @@ -16,7 +16,7 @@ import com.avaloq.tools.ddk.test.checkcfg.TestPropertySpecificationWithExpectedV import com.avaloq.tools.ddk.test.checkcfg.TestPropertySpecificationWithOutExpectedValues import com.avaloq.tools.ddk.xtext.test.contentassist.AbstractAcfContentAssistTest import com.google.common.collect.Lists -import org.junit.Test +import org.junit.jupiter.api.Test import static com.avaloq.tools.ddk.checkcfg.CheckCfgConstants.PROPERTY_EXECUTABLE_EXTENSION_ATTRIBUTE import static com.avaloq.tools.ddk.checkcfg.CheckCfgConstants.PROPERTY_EXTENSION_POINT diff --git a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/scoping/CheckCfgScopeProviderTest.xtend b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/scoping/CheckCfgScopeProviderTest.xtend index dd8e62f977..06e5dd3ab1 100644 --- a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/scoping/CheckCfgScopeProviderTest.xtend +++ b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/scoping/CheckCfgScopeProviderTest.xtend @@ -16,7 +16,7 @@ import com.avaloq.tools.ddk.checkcfg.checkcfg.CheckcfgPackage import com.avaloq.tools.ddk.checkcfg.util.CheckCfgTestUtil import com.avaloq.tools.ddk.xtext.test.scoping.AbstractScopingTest -import static org.junit.Assert.assertArrayEquals +import static org.junit.jupiter.api.Assertions.assertArrayEquals final class CheckCfgScopeProviderTest extends AbstractScopingTest { diff --git a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/syntax/CheckCfgSyntaxTest.xtend b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/syntax/CheckCfgSyntaxTest.xtend index 978c127b60..58c9640403 100644 --- a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/syntax/CheckCfgSyntaxTest.xtend +++ b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/syntax/CheckCfgSyntaxTest.xtend @@ -15,7 +15,7 @@ import com.avaloq.tools.ddk.checkcfg.util.CheckCfgTestUtil import com.avaloq.tools.ddk.xtext.test.validation.AbstractValidationTest import java.util.LinkedList import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil -import org.junit.Test +import org.junit.jupiter.api.Test class CheckCfgSyntaxTest extends AbstractValidationTest { diff --git a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgConfiguredParameterValidationsTest.xtend b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgConfiguredParameterValidationsTest.xtend index 015a28f1c4..652212cd12 100644 --- a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgConfiguredParameterValidationsTest.xtend +++ b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgConfiguredParameterValidationsTest.xtend @@ -16,7 +16,7 @@ import com.avaloq.tools.ddk.test.checkcfg.TestPropertySpecificationWithExpectedV import com.avaloq.tools.ddk.test.checkcfg.TestPropertySpecificationWithOutExpectedValues import com.avaloq.tools.ddk.xtext.test.validation.AbstractValidationTest import com.google.common.collect.Lists -import org.junit.Test +import org.junit.jupiter.api.Test import static com.avaloq.tools.ddk.checkcfg.CheckCfgConstants.PROPERTY_EXECUTABLE_EXTENSION_ATTRIBUTE import static com.avaloq.tools.ddk.checkcfg.CheckCfgConstants.PROPERTY_EXTENSION_POINT diff --git a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgTest.xtend b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgTest.xtend index b3e3b4ca3d..e2091d231a 100644 --- a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgTest.xtend +++ b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgTest.xtend @@ -10,21 +10,20 @@ *******************************************************************************/ package com.avaloq.tools.ddk.checkcfg.validation +import com.avaloq.tools.ddk.checkcfg.CheckCfgUiInjectorProvider import com.avaloq.tools.ddk.checkcfg.checkcfg.CheckConfiguration import com.avaloq.tools.ddk.checkcfg.checkcfg.CheckcfgPackage import com.google.inject.Inject -import junit.framework.TestCase +import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.util.ParseHelper import org.eclipse.xtext.testing.validation.ValidationTestHelper -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith -import org.eclipse.xtext.testing.InjectWith -import com.avaloq.tools.ddk.checkcfg.CheckCfgUiInjectorProvider @InjectWith(typeof(CheckCfgUiInjectorProvider)) @RunWith(XtextRunner) -class CheckCfgTest extends TestCase { +class CheckCfgTest { @Inject diff --git a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgValidationTest.java b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgValidationTest.java index 9098f1a1b4..1ee103114f 100644 --- a/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgValidationTest.java +++ b/com.avaloq.tools.ddk.checkcfg.core.test/src/com/avaloq/tools/ddk/checkcfg/validation/CheckCfgValidationTest.java @@ -14,7 +14,6 @@ import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.testing.util.ParseHelper; import org.eclipse.xtext.testing.validation.ValidationTestHelper; -import org.junit.Test; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.checkcfg.CheckCfgUiInjectorProvider; @@ -23,15 +22,13 @@ import com.avaloq.tools.ddk.checkcfg.util.CheckCfgModelUtil; import com.google.inject.Inject; -import junit.framework.TestCase; - /** * Performs validations on Check Configuration models. */ @InjectWith(CheckCfgUiInjectorProvider.class) @RunWith(XtextRunner.class) -public class CheckCfgValidationTest extends TestCase { +public class CheckCfgValidationTest { @Inject private ValidationTestHelper helper; @@ -51,8 +48,8 @@ public class CheckCfgValidationTest extends TestCase { * @throws Exception * if a problem occurred parsing the test model */ - @Test - public void testDisabledCheckIsNotConfigured() throws Exception { // NOPMD + @org.junit.jupiter.api.Test + void testDisabledCheckIsNotConfigured() throws Exception { // NOPMD CheckConfiguration model = parser.parse(modelUtil.basicModelWithDisabledTest() + " (val = 0)"); helper.assertWarning(model, CheckcfgPackage.Literals.CONFIGURED_CHECK, IssueCodes.DISABLED_CHECK_NOT_CONFIGURED); } diff --git a/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/check/CheckConfigurationIsAppliedTest.xtend b/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/check/CheckConfigurationIsAppliedTest.xtend index 7a4f8e9b6b..d0efb358cd 100644 --- a/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/check/CheckConfigurationIsAppliedTest.xtend +++ b/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/check/CheckConfigurationIsAppliedTest.xtend @@ -18,7 +18,7 @@ import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.validation.ValidationTestHelper import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith import com.avaloq.tools.ddk.sample.helloworld.helloWorld.Model import com.avaloq.tools.ddk.sample.helloworld.ui.internal.HelloworldActivator diff --git a/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/check/CheckExecutionEnvironmentProjectTest.xtend b/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/check/CheckExecutionEnvironmentProjectTest.xtend index 6ee7691b4f..bb49723ffd 100644 --- a/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/check/CheckExecutionEnvironmentProjectTest.xtend +++ b/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/check/CheckExecutionEnvironmentProjectTest.xtend @@ -16,7 +16,7 @@ import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.util.ParseHelper import org.eclipse.xtext.testing.validation.ValidationTestHelper -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith import com.avaloq.tools.ddk.sample.helloworld.ui.internal.HelloworldActivator import com.avaloq.tools.ddk.sample.helloworld.helloWorld.Model diff --git a/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/label/IssueLabelTest.xtend b/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/label/IssueLabelTest.xtend index 52f52a928a..2d1fdaf531 100644 --- a/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/label/IssueLabelTest.xtend +++ b/com.avaloq.tools.ddk.sample.helloworld.ui.test/src/com/avaloq/tools/ddk/sample/helloworld/label/IssueLabelTest.xtend @@ -12,10 +12,10 @@ package com.avaloq.tools.ddk.sample.helloworld.label import com.google.inject.AbstractModule import com.google.inject.Guice -import org.junit.Test +import org.junit.jupiter.api.Test -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertNotNull +import static org.junit.jupiter.api.Assertions.assertEquals +import static org.junit.jupiter.api.Assertions.assertNotNull import com.avaloq.tools.ddk.sample.helloworld.validation.LibraryChecksIssueCodes import com.avaloq.tools.ddk.check.runtime.label.ICheckRuleLabelProvider diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/AbstractSystemTest.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/AbstractSystemTest.java index cf2ab9a09d..78ee5283ed 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/AbstractSystemTest.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/AbstractSystemTest.java @@ -15,8 +15,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.Rule; import org.junit.internal.AssumptionViolatedException; import org.junit.rules.TestWatcher; @@ -127,7 +127,7 @@ public void finished(final Description description) { * Setup of the system test. * Implementations need to specify the setup steps in this method and also provide the @Before annotation. */ - @Before + @BeforeEach public void setUp() { AbstractTestStep.registerTestStepListener(this); } @@ -209,7 +209,7 @@ protected final void executeSystemTestPlan() { * Note: Undoes all test and setup steps in the correct order, if the test is not marked as a System Test. *

*/ - @After + @AfterEach public void tearDown() { try { AbstractTestStep.setCheckPreconditions(true); diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/BugTestAwareRule.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/BugTestAwareRule.java index fc61f2b065..469b1efb28 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/BugTestAwareRule.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/BugTestAwareRule.java @@ -37,7 +37,7 @@ * @org.junit.Test * @com.avaloq.tools.ddk.test.core.BugTest(value = "BUG-42", unresolved = true) * public void testMethod() { - * org.junit.Assert.fail(); + * org.junit.Assertions.fail(); * } * } * diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/CompoundStep.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/CompoundStep.java index b82ee7384a..9eadac7e9f 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/CompoundStep.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/CompoundStep.java @@ -13,9 +13,9 @@ import java.util.List; import java.util.ListIterator; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.eclipse.core.runtime.Assert; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Assertions; import com.google.common.collect.Lists; @@ -130,9 +130,9 @@ public void undo() { * the {@link Throwable} of the problem(s) encountered, must not be {@code null} */ private void addUndoProblem(final MultipleTestProblems multipleTestProblems, final AbstractStep step, final Throwable throwable) { - Assert.isNotNull(multipleTestProblems, "multipleTestProblems"); - Assert.isNotNull(step, ARGUMENT_STEP); - Assert.isNotNull(throwable, ARGUMENT_THROWABLE); + Assertions.isNotNull(multipleTestProblems, "multipleTestProblems"); + Assertions.isNotNull(step, ARGUMENT_STEP); + Assertions.isNotNull(throwable, ARGUMENT_THROWABLE); if (throwable instanceof MultipleTestProblems) { MultipleTestProblems caughtMultipleTestProblems = (MultipleTestProblems) throwable; for (Throwable problem : caughtMultipleTestProblems.getProblems()) { @@ -157,8 +157,8 @@ private void addUndoProblem(final MultipleTestProblems multipleTestProblems, fin * the problem occurred, never {@code null} */ private void logError(final AbstractStep step, final Throwable throwable) { - Assert.isNotNull(step, ARGUMENT_STEP); - Assert.isNotNull(throwable, ARGUMENT_THROWABLE); + Assertions.isNotNull(step, ARGUMENT_STEP); + Assertions.isNotNull(throwable, ARGUMENT_THROWABLE); logger.error("Error in " + step.getName() + ": " + throwable.getLocalizedMessage()); } @@ -172,7 +172,7 @@ private void logError(final AbstractStep step, final Throwable throwable) { * @return the newly added {@link AbstractStep}, never {@code null} */ public T addStep(final T step) { - Assert.isNotNull(step, ARGUMENT_STEP); + Assertions.isNotNull(step, ARGUMENT_STEP); plannedSteps.add(step); return step; } @@ -184,7 +184,7 @@ public T addStep(final T step) { * the steps to add, must not be {@code null} */ public void addSteps(final List steps) { - Assert.isNotNull(steps, ARGUMENT_STEPS); + Assertions.isNotNull(steps, ARGUMENT_STEPS); for (final AbstractStep step : steps) { if (step != null) { addStep(step); diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/IssueAwareRule.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/IssueAwareRule.java index 40413f0ce5..cde0592fcb 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/IssueAwareRule.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/IssueAwareRule.java @@ -37,7 +37,7 @@ * @org.junit.Test * @com.avaloq.tools.ddk.test.core.Issue(value = "ISSUE-42", fixed = false) * public void testMethod() { - * org.junit.Assert.fail(); + * org.junit.Assertions.fail(); * } * } * diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/StepResult.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/StepResult.java index 6d3bb54a81..4d60a13b5b 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/StepResult.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/StepResult.java @@ -51,7 +51,7 @@ public T getValue() { void setValue(final T value) { // currently we set the result multiple time until the postconditions succeed. Hence we cannot enforce this anymore. // XXX : think about refactoring so that we can check the following assertion again, or decide to remove it for good. - // Assert.assertFalse("Step result value must not have been set yet.", valueSet); + // Assertions.assertFalse("Step result value must not have been set yet.", valueSet); this.value = value; valueSet = true; } diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/TestEntityAction.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/TestEntityAction.java index 5730732382..a7d6d0a013 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/TestEntityAction.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/TestEntityAction.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.test.core; -import org.eclipse.core.runtime.Assert; +import org.junit.jupiter.api.Assertions; /** @@ -34,8 +34,8 @@ public class TestEntityAction { * the entity action, must not be {@code null} */ public TestEntityAction(final ITestEntity testEntity, final TestEntityOperation entityAction) { - Assert.isNotNull(testEntity, TEST_ENTITY_ARGUMENT); - Assert.isNotNull(entityAction, ENTITY_ACTION_ARGUMENT); + Assertions.isNotNull(testEntity, TEST_ENTITY_ARGUMENT); + Assertions.isNotNull(entityAction, ENTITY_ACTION_ARGUMENT); if (entityAction.equals(TestEntityOperation.DISPOSE)) { testEntity.dispose(); } diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/TestPlan.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/TestPlan.java index 0d1427d31a..2028945c00 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/TestPlan.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/TestPlan.java @@ -18,7 +18,7 @@ import java.util.ListIterator; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; @@ -73,7 +73,7 @@ public static TestPlan create() { * @return the newly added {@link AbstractStep}, never {@code null} */ public T addSetupStep(final T setupStep) { - Assert.assertTrue("Must not add a setup step after adding a test step.", getCompoundTestStep().getSteps().isEmpty()); + Assertions.assertTrue("Must not add a setup step after adding a test step.", getCompoundTestStep().getSteps().isEmpty()); getCompoundSetupStep().addStep(setupStep); return setupStep; } diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/junit/runners/ClassRunner.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/junit/runners/ClassRunner.java index 60074e5ac4..b8acd32230 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/junit/runners/ClassRunner.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/junit/runners/ClassRunner.java @@ -19,9 +19,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.junit.internal.AssumptionViolatedException; import org.junit.internal.runners.model.EachTestNotifier; import org.junit.internal.runners.statements.RunAfters; @@ -140,7 +140,7 @@ private void ensureInitialized() { expectedMethods = ImmutableList.copyOf(Iterables.filter(testMethods, new Predicate() { @Override public boolean apply(final FrameworkMethod input) { - return input.getAnnotation(Ignore.class) == null; + return input.getAnnotation(Disabled.class) == null; } })); currentMethodIndex = 0; @@ -184,9 +184,9 @@ public void filter(final Filter filter) throws NoTestsRemainException { @Override protected void runChild(final FrameworkMethod method, final RunNotifier notifier) { ensureInitialized(); - final boolean ignored = method.getAnnotation(Ignore.class) != null; + final boolean ignored = method.getAnnotation(Disabled.class) != null; if (!ignored) { - Assert.assertEquals("Method " + method.getName() + " not equal", expectedMethods.get(currentMethodIndex++), method); //$NON-NLS-1$//$NON-NLS-2$ + Assertions.assertEquals("Method " + method.getName() + " not equal", expectedMethods.get(currentMethodIndex++), method); //$NON-NLS-1$//$NON-NLS-2$ } if (ignored || testRuns == 1 && testRetries == 0 && method.getAnnotation(Retry.class) == null) { super.runChild(method, notifier); diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/mock/ExtensionRegistryMock.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/mock/ExtensionRegistryMock.java index a8eb2d4878..6a880e7ad0 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/mock/ExtensionRegistryMock.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/mock/ExtensionRegistryMock.java @@ -25,7 +25,7 @@ import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.RegistryFactory; import org.eclipse.emf.common.util.WrappedException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.mockito.stubbing.Answer; import com.google.common.collect.LinkedHashMultimap; @@ -172,7 +172,7 @@ public static void assertUnMocked() { if (registrySpy != null) { try { String extensionPointId = configurationElements.keySet().iterator().next(); - Assert.fail("Extension point " + extensionPointId + " still has mocked configuration elements."); //$NON-NLS-1$ //$NON-NLS-2$ + Assertions.fail("Extension point " + extensionPointId + " still has mocked configuration elements."); //$NON-NLS-1$ //$NON-NLS-2$ } catch (NoSuchElementException e) { // shouldn't happen throw new IllegalStateException("The extension registry mock is in an unexpected state.", e); //$NON-NLS-1$ } diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/mock/ServiceMock.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/mock/ServiceMock.java index aa8988e369..f5c9cff818 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/mock/ServiceMock.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/mock/ServiceMock.java @@ -11,10 +11,9 @@ package com.avaloq.tools.ddk.test.core.mock; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** @@ -46,10 +45,8 @@ public static boolean isMocked(final Class classToCheck) { */ public static void assertAllMocksRemoved() { if (!originalServices.keySet().isEmpty()) { - Iterator> iterator = originalServices.keySet().iterator(); - while (iterator.hasNext()) { - Class clazz = iterator.next(); - Assert.fail("Service " + clazz.getName() + " is still mocked."); //$NON-NLS-1$//$NON-NLS-2$ + for (Class clazz : originalServices.keySet()) { + Assertions.fail("Service " + clazz.getName() + " is still mocked."); //$NON-NLS-1$//$NON-NLS-2$ } } } diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/CoreUtilTools.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/CoreUtilTools.java index 1635b29ad3..bb3928d58e 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/CoreUtilTools.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/CoreUtilTools.java @@ -15,7 +15,7 @@ import java.util.Locale; import org.apache.commons.lang.RandomStringUtils; -import org.eclipse.core.runtime.Assert; +import org.junit.jupiter.api.Assertions; /** @@ -77,7 +77,7 @@ public static String randomAlphanumericString(final int count) { } String string = stringBuilder.toString(); - Assert.isNotNull(string, "string"); //$NON-NLS-1$ + Assertions.isNotNull(string, "string"); //$NON-NLS-1$ return string.toUpperCase(Locale.ENGLISH); } diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/JobChangeListener.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/JobChangeListener.java index 306baee5b0..bc957aaf82 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/JobChangeListener.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/JobChangeListener.java @@ -14,11 +14,11 @@ import java.util.Map; import java.util.Set; -import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.junit.jupiter.api.Assertions; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -124,7 +124,7 @@ public synchronized void scheduled(final IJobChangeEvent event) { * @return {@code true} if such a job was found, {@code false} otherwise */ public synchronized boolean hasJob(final String name) { - Assert.isNotNull(name, "name"); + Assertions.isNotNull(name, "name"); if (jobNames.contains(name)) { return true; } diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/JobMatcher.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/JobMatcher.java index bc23749ad3..6cee166918 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/JobMatcher.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/JobMatcher.java @@ -19,7 +19,7 @@ import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; @@ -213,7 +213,7 @@ public final void deregister() { * the expected number of jobs */ public final void assertNumberOfNewJobs(final int expected) { - Assert.assertEquals("Wrong number of jobs were scheduled", expected, newJobs.size()); + Assertions.assertEquals("Wrong number of jobs were scheduled", expected, newJobs.size()); } /** @@ -226,13 +226,13 @@ public final void assertNumberOfNewJobs(final int expected) { public final void assertNewJobsFinished() { try { List expectedJobs = Lists.newArrayList(newJobs); - Assert.assertFalse("No matching new jobs were scheduled: " + finder, expectedJobs.isEmpty()); + Assertions.assertFalse("No matching new jobs were scheduled: " + finder, expectedJobs.isEmpty()); expectedJobs.removeAll(finishedJobs); while (!expectedJobs.isEmpty()) { try { Job job = getNextJob(); if (job == null) { - Assert.fail("Expected new jobs did not finish after " + waitTimeout + " milliseconds: " + expectedJobs); + Assertions.fail("Expected new jobs did not finish after " + waitTimeout + " milliseconds: " + expectedJobs); } expectedJobs.remove(job); } catch (InterruptedException e) { @@ -260,7 +260,7 @@ public final void waitForExistingJobs() { try { Job job = getNextJob(); if (job == null) { - Assert.fail("Existing jobs did not finish after " + waitTimeout + " milliseconds: " + expectedJobs); + Assertions.fail("Existing jobs did not finish after " + waitTimeout + " milliseconds: " + expectedJobs); } expectedJobs.remove(job); } catch (InterruptedException e) { diff --git a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/SimpleProgressMonitor.java b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/SimpleProgressMonitor.java index a2ced2e21d..e5fde6e4ca 100644 --- a/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/SimpleProgressMonitor.java +++ b/com.avaloq.tools.ddk.test.core/src/com/avaloq/tools/ddk/test/core/util/SimpleProgressMonitor.java @@ -11,7 +11,7 @@ package com.avaloq.tools.ddk.test.core.util; import org.eclipse.core.runtime.IProgressMonitor; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** @@ -169,7 +169,7 @@ public void waitForTermination() { final long timeStarted = System.currentTimeMillis(); while (!isTerminated()) { long remainingWaitTime = TIMEOUT + timeStarted - System.currentTimeMillis(); - Assert.assertFalse("Progress monitor did not get done signal", remainingWaitTime <= 0); + Assertions.assertFalse("Progress monitor did not get done signal", remainingWaitTime <= 0); try { this.wait(remainingWaitTime); } catch (InterruptedException e) /* CHECKSTYLE:OFF */ { diff --git a/com.avaloq.tools.ddk.test.ui.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.test.ui.test/META-INF/MANIFEST.MF index dd61b9dc3d..43474a5db6 100644 --- a/com.avaloq.tools.ddk.test.ui.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.test.ui.test/META-INF/MANIFEST.MF @@ -6,7 +6,7 @@ Bundle-Version: 16.2.0.qualifier Bundle-ActivationPolicy: lazy Bundle-Vendor: Avaloq Group AG Bundle-RequiredExecutionEnvironment: JavaSE-21 -Require-Bundle: org.junit, +Require-Bundle: org.junit.jupiter.api, org.eclipse.swtbot.eclipse.finder, org.eclipse.swt, com.avaloq.tools.ddk.test.core, diff --git a/com.avaloq.tools.ddk.test.ui.test/src/com/avaloq/tools/ddk/test/ui/test/swtbot/DeChKeyboardLayoutTest.java b/com.avaloq.tools.ddk.test.ui.test/src/com/avaloq/tools/ddk/test/ui/test/swtbot/DeChKeyboardLayoutTest.java index fd895d38e7..9cd7e8d822 100644 --- a/com.avaloq.tools.ddk.test.ui.test/src/com/avaloq/tools/ddk/test/ui/test/swtbot/DeChKeyboardLayoutTest.java +++ b/com.avaloq.tools.ddk.test.ui.test/src/com/avaloq/tools/ddk/test/ui/test/swtbot/DeChKeyboardLayoutTest.java @@ -10,11 +10,11 @@ *******************************************************************************/ package com.avaloq.tools.ddk.test.ui.test.swtbot; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor; import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.test.ui.swtbot.SwtWorkbenchBot; @@ -29,7 +29,7 @@ public class DeChKeyboardLayoutTest { * Tests com.avaloq.test.swtbot.DE_CH. */ @Test - public void testDeChKeyboardLayout() { + void testDeChKeyboardLayout() { SWTBotPreferences.KEYBOARD_LAYOUT = "com.avaloq.test.swtbot.DE_CH"; SWTBotPreferences.KEYBOARD_STRATEGY = "org.eclipse.swtbot.swt.finder.keyboard.MockKeyboardStrategy"; SwtWorkbenchBot bot = new SwtWorkbenchBot(); diff --git a/com.avaloq.tools.ddk.test.ui.test/src/com/avaloq/tools/ddk/test/ui/test/swtbot/SwtBotRadioTest.java b/com.avaloq.tools.ddk.test.ui.test/src/com/avaloq/tools/ddk/test/ui/test/swtbot/SwtBotRadioTest.java index 0d51f80dba..1e94821eeb 100644 --- a/com.avaloq.tools.ddk.test.ui.test/src/com/avaloq/tools/ddk/test/ui/test/swtbot/SwtBotRadioTest.java +++ b/com.avaloq.tools.ddk.test.ui.test/src/com/avaloq/tools/ddk/test/ui/test/swtbot/SwtBotRadioTest.java @@ -10,12 +10,12 @@ *******************************************************************************/ package com.avaloq.tools.ddk.test.ui.test.swtbot; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.test.core.Issue; import com.avaloq.tools.ddk.test.core.IssueAwareRule; @@ -57,8 +57,8 @@ public String getText() { /** * Test if the method {@link com.avaloq.tools.ddk.test.ui.swtbot.SwtBotRadio#click()} works correctly. */ - @Test - public void testSwtRadioButtonClick() { + @org.junit.jupiter.api.Test + void testSwtRadioButtonClick() { SwtWorkbenchBot bot = new SwtWorkbenchBot(); bot.resetWorkbench(); testRadioButtonClick(bot); diff --git a/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/CoreSwtbotTools.java b/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/CoreSwtbotTools.java index 17375e0547..d256ee8511 100644 --- a/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/CoreSwtbotTools.java +++ b/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/CoreSwtbotTools.java @@ -11,7 +11,7 @@ package com.avaloq.tools.ddk.test.ui.swtbot; import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.awt.AWTException; import java.awt.Robot; @@ -19,7 +19,6 @@ import java.util.Arrays; import java.util.List; -import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.AssertionFailedException; import org.eclipse.emf.common.util.WrappedException; import org.eclipse.osgi.util.NLS; @@ -48,6 +47,7 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.WorkbenchException; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.test.core.util.Reflect; import com.avaloq.tools.ddk.test.ui.swtbot.condition.WaitForTable; @@ -141,7 +141,7 @@ public static WorkbenchFocusPolicy getWorkbenchFocusPolicy() { * the {@link SwtWorkbenchBot} for which to check the focus, must not be {@code null} */ public static void enforceWorkbenchFocusPolicy(final SwtWorkbenchBot bot) { - Assert.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(bot, ARGUMENT_BOT); if (bot.getFocusedWidget() == null) { if (WorkbenchFocusPolicy.WAIT == getWorkbenchFocusPolicy()) { bot.waitUntilFocused(); @@ -167,7 +167,7 @@ public void run() { * to work with, must not be {@code null} */ public static void initializeWorkbench(final SwtWorkbenchBot bot) { - Assert.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(bot, ARGUMENT_BOT); // Move mouse outside client area (to prevent problems with context menus) PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override @@ -196,7 +196,7 @@ public void run() { * if {@code true}, append the name of the calling method to the prefix */ public static void captureScreenshot(final SWTBot bot, final String prefix, final boolean useCaller) { - Assert.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(bot, ARGUMENT_BOT); if (prefix == null && !useCaller) { throw new IllegalArgumentException(); } @@ -221,8 +221,8 @@ public static void captureScreenshot(final SWTBot bot, final String prefix, fina * @return {@code true} if a window was found, {@code false} otherwise */ public static boolean checkOpenWindow(final SWTWorkbenchBot bot, final String windowName) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(windowName, "windowName"); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(windowName, "windowName"); try { final SWTBotShell shell = bot.shell(windowName); shell.isActive(); @@ -241,8 +241,8 @@ public static boolean checkOpenWindow(final SWTWorkbenchBot bot, final String wi * the new perspective to open, must not be {@code null} */ public static void switchPerspective(final SWTWorkbenchBot bot, final String perspective) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(perspective, "perspective"); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(perspective, "perspective"); // Change the perspective via the Open Perspective dialog bot.menu("Window").menu("Open Perspective").menu("Other...").click(); final SWTBotShell shell = bot.shell("Open Perspective"); @@ -291,8 +291,8 @@ public void run() { * to look for items in, must not be {@code null} */ public static void waitForTreeItem(final SWTWorkbenchBot bot, final SWTBotTree tree) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(tree, ARGUMENT_TREE); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(tree, ARGUMENT_TREE); bot.waitUntilWidgetAppears(new WaitForTree(tree.widget)); } @@ -305,8 +305,8 @@ public static void waitForTreeItem(final SWTWorkbenchBot bot, final SWTBotTree t * the {@link SWTBotTable}, must not be {@code null} */ public static void waitForTableItem(final SWTWorkbenchBot bot, final SWTBotTable table) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(table, ARGUMENT_TABLE); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(table, ARGUMENT_TABLE); bot.waitUntilWidgetAppears(new WaitForTable(table.widget)); } @@ -320,8 +320,8 @@ public static void waitForTableItem(final SWTWorkbenchBot bot, final SWTBotTable * @return list of tree items, never {@code null} */ public static List treeItems(final SWTWorkbenchBot bot, final SWTBotTree tree) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(tree, ARGUMENT_TREE); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(tree, ARGUMENT_TREE); waitForTreeItem(bot, tree); return new ArrayList(Arrays.asList(tree.getAllItems())); } @@ -336,8 +336,8 @@ public static List treeItems(final SWTWorkbenchBot bot, final SW * @return list of table items, never {@code null} */ public static List tableItems(final SWTWorkbenchBot bot, final SWTBotTable table) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(table, ARGUMENT_TABLE); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(table, ARGUMENT_TABLE); waitForTableItem(bot, table); List items = null; for (int i = 0; i < table.rowCount(); i++) { @@ -354,7 +354,7 @@ public static List tableItems(final SWTWorkbenchBot bot, final * @return clipboard text content, or {@code null} if no text data is available */ public static String getClipboardContent(final SWTWorkbenchBot bot) { - Assert.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(bot, ARGUMENT_BOT); return UIThreadRunnable.syncExec(new Result() { @Override public String run() { @@ -374,8 +374,8 @@ public String run() { * @return {@code true} if expanded, {@code false} otherwise */ public static boolean waitForItem(final SWTWorkbenchBot bot, final SWTBotTreeItem item) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(item, ARGUMENT_ITEM); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(item, ARGUMENT_ITEM); item.select(); safeBlockingExpand(bot, item); if (item.getItems().length == 0) { @@ -394,8 +394,8 @@ public static boolean waitForItem(final SWTWorkbenchBot bot, final SWTBotTreeIte * the name of the view, must not be {@code null} */ public static void openView(final SWTWorkbenchBot bot, final String view) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(view, ARGUMENT_VIEW); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(view, ARGUMENT_VIEW); openView(bot, "Avaloq", view); } @@ -406,7 +406,7 @@ public static void openView(final SWTWorkbenchBot bot, final String view) { * the view id, must not be {@code null} */ public static void openView(final String id) { - Assert.isNotNull(id, "id"); + Assertions.isNotNull(id, "id"); PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override @@ -431,9 +431,9 @@ public void run() { * the name of the view, must not be {@code null} */ public static void openView(final SWTWorkbenchBot bot, final String category, final String view) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(category, "category"); - Assert.isNotNull(view, ARGUMENT_VIEW); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(category, "category"); + Assertions.isNotNull(view, ARGUMENT_VIEW); bot.menu("Window").menu("Show View").menu("Other...").click(); bot.shell("Show View").activate(); final SWTBotTree tree = bot.tree(); @@ -469,9 +469,9 @@ public static void openView(final SWTWorkbenchBot bot, final String category, fi * @return the {@link SWTBotTreeItem}, never {@code null} */ public static SWTBotTreeItem findTreeItem(final SWTWorkbenchBot bot, final SWTBotTree tree, final String item) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(tree, "tree"); - Assert.isNotNull(item, ARGUMENT_ITEM); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(tree, "tree"); + Assertions.isNotNull(item, ARGUMENT_ITEM); int itemCount = 0; boolean itemFound = false; SWTBotTreeItem botTreeItem = null; @@ -508,8 +508,8 @@ public static SWTBotTreeItem findTreeItem(final SWTWorkbenchBot bot, final SWTBo * the name of the desired page (e.g. 'Database'), must not be {@code null} */ public static void openAvaloqPreferencesSection(final SWTWorkbenchBot bot, final String section) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(section, "section"); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(section, "section"); bot.menu("Window").menu("Preferences").click(); final SWTBotShell shell = bot.shell("Preferences"); shell.activate(); @@ -531,8 +531,8 @@ public static void openAvaloqPreferencesSection(final SWTWorkbenchBot bot, final * @return the full name of the item as string, never {@code null} */ public static String getCcomboItemText(final SWTBotCCombo ccombo, final String prefix) { - Assert.isNotNull(ccombo, "ccombo"); - Assert.isNotNull(prefix, "prefix"); + Assertions.isNotNull(ccombo, "ccombo"); + Assertions.isNotNull(prefix, "prefix"); for (String ccomboItem : ccombo.items()) { if (ccomboItem.startsWith(prefix)) { return ccomboItem; @@ -550,8 +550,8 @@ public static String getCcomboItemText(final SWTBotCCombo ccombo, final String p * node to wait for, must not be {@code null} */ public static void safeBlockingCollapse(final SWTWorkbenchBot bot, final SWTBotTreeItem node) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(node, ARGUMENT_NODE); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(node, ARGUMENT_NODE); if (node.isExpanded()) { node.collapse(); try { @@ -584,8 +584,8 @@ public String getFailureMessage() { * node to wait for, must not be {@code null} */ public static void safeBlockingExpand(final SWTWorkbenchBot bot, final SWTBotTreeItem node) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(node, ARGUMENT_NODE); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(node, ARGUMENT_NODE); if (!node.isExpanded()) { node.expand(); try { @@ -621,8 +621,8 @@ public String getFailureMessage() { * @return the last tree item that was expanded, or {@code null} if no item was found */ public static SWTBotTreeItem expandNode(final SWTBotTree bot, final String... nodes) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(nodes, ARGUMENT_NODES); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(nodes, ARGUMENT_NODES); assertArgumentIsNotEmpty(nodes, ARGUMENT_NODES); new SWTBot().waitUntil(widgetIsEnabled(bot)); SWTBotTreeItem item = bot.getTreeItem(nodes[0]); @@ -650,8 +650,8 @@ public static SWTBotTreeItem expandNode(final SWTBotTree bot, final String... no * @return the last tree node that was expanded, never {@code null} */ public static SWTBotTreeItem expandNode(final SWTBotTreeItem bot, final String... nodes) { - Assert.isNotNull(bot, ARGUMENT_BOT); - Assert.isNotNull(nodes, ARGUMENT_NODES); + Assertions.isNotNull(bot, ARGUMENT_BOT); + Assertions.isNotNull(nodes, ARGUMENT_NODES); assertArgumentIsNotEmpty(nodes, ARGUMENT_NODES); SWTBotTreeItem item = bot; for (String node : nodes) { @@ -677,7 +677,7 @@ public static SWTBotTreeItem expandNode(final SWTBotTreeItem bot, final String.. * one array element is null. */ private static void assertArgumentIsNotEmpty(final Object[] array, final String name) { - Assert.isNotNull(array, name); + Assertions.isNotNull(array, name); if (array.length == 0) { throw new IllegalArgumentException("Contract for argument '" + name + "' failed: Array parameter must not be empty."); //$NON-NLS-1$ } else { diff --git a/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/SwtWizardBot.java b/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/SwtWizardBot.java index 058fc83743..83a7342542 100644 --- a/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/SwtWizardBot.java +++ b/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/SwtWizardBot.java @@ -12,7 +12,7 @@ import static com.avaloq.tools.ddk.test.ui.swtbot.util.SwtBotWizardUtil.selectItem; import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; diff --git a/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/util/SwtBotToolbarButtonUtil.java b/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/util/SwtBotToolbarButtonUtil.java index 9ae4c9134a..79e64e547a 100644 --- a/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/util/SwtBotToolbarButtonUtil.java +++ b/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/util/SwtBotToolbarButtonUtil.java @@ -10,10 +10,10 @@ *******************************************************************************/ package com.avaloq.tools.ddk.test.ui.swtbot.util; -import org.eclipse.core.runtime.Assert; import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; import org.eclipse.swtbot.swt.finder.results.BoolResult; import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; +import org.junit.jupiter.api.Assertions; /** @@ -29,7 +29,7 @@ public final class SwtBotToolbarButtonUtil { * @return {@code true} if the toolbar button is selected, {@code false} otherwise */ public static boolean isSelected(final SWTBotToolbarButton toolbarButton) { - Assert.isNotNull(toolbarButton, "toolbarButton"); + Assertions.isNotNull(toolbarButton, "toolbarButton"); return UIThreadRunnable.syncExec(toolbarButton.display, new BoolResult() { @Override public Boolean run() { diff --git a/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/util/SwtBotWizardUtil.java b/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/util/SwtBotWizardUtil.java index e0e11cdf21..8a44834193 100644 --- a/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/util/SwtBotWizardUtil.java +++ b/com.avaloq.tools.ddk.test.ui/src/com/avaloq/tools/ddk/test/ui/swtbot/util/SwtBotWizardUtil.java @@ -18,7 +18,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.eclipse.ui.PlatformUI; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.test.ui.swtbot.SwtWorkbenchBot; @@ -47,7 +47,7 @@ public static void selectProjectFolder(final SwtWorkbenchBot bot, final String f final Tree tree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), comp); PlatformUI.getWorkbench().getDisplay().syncExec(() -> { SWTBotTree botTree = new SWTBotTree(tree); - Assert.assertTrue("folder was not found", selectItem(botTree, folderName)); + Assertions.assertTrue("folder was not found", selectItem(botTree, folderName)); }); } diff --git a/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/AbstractTypeProviderTest.java b/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/AbstractTypeProviderTest.java index 83bc6e7f42..7a33deee2c 100644 --- a/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/AbstractTypeProviderTest.java +++ b/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/AbstractTypeProviderTest.java @@ -10,9 +10,9 @@ *******************************************************************************/ package com.avaloq.tools.ddk.typesystem; -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.util.Arrays; @@ -23,8 +23,8 @@ import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.typesystem.typemodel.IExpression; import com.avaloq.tools.ddk.typesystem.typemodel.INamedElement; @@ -70,7 +70,7 @@ private EClass createEClass(final String name, final EClass... superTypes) { return clazz; } - @Before + @BeforeEach public void init() { EcoreFactory modelFactory = EcoreFactory.eINSTANCE; testModelPackage = modelFactory.createEPackage(); @@ -109,13 +109,13 @@ private void testPlainProvider(final ITypeProvider plainProvider) { } @Test - public void testTypeProviderPlain() { + void testTypeProviderPlain() { ITypeProvider provider = new PlainTypeProvider(); testPlainProvider(provider); } @Test - public void testTypeProviderCyclicDefault() { + void testTypeProviderCyclicDefault() { ITypeProvider provider = new CyclicDefaultTypeProvider(); assertNull("cylic type for expression1 not null", provider.getType(expression1)); assertNull("cylic type for expression2 not null", provider.getType(expression2)); @@ -125,8 +125,8 @@ public void testTypeProviderCyclicDefault() { assertNull("cyclic type for namedElement2 not null", provider.getTypeForNamedElement(namedElement2)); } - @Test - public void testTypeProviderCyclicOverride() { + @org.junit.jupiter.api.Test + void testTypeProviderCyclicOverride() { ITypeProvider provider = new CyclicOverrideTypeProvider(); assertEquals("cyclic override type for expression1 not type1", type1, provider.getType(expression1)); assertEquals("cyclic override type for expression2 not type1", type1, provider.getType(expression2)); @@ -136,8 +136,8 @@ public void testTypeProviderCyclicOverride() { assertEquals("cyclic override type for namedElement2 not type3", type3, provider.getTypeForNamedElement(namedElement2)); } - @Test - public void testTypeProviderCyclicOverrideMixed() { + @org.junit.jupiter.api.Test + void testTypeProviderCyclicOverrideMixed() { ITypeProvider provider = new CyclicOverrideMixedTypeProvider(); assertEquals("cyclic mixed type for expression1 not type1", type1, provider.getType(expression1)); assertEquals("cyclic mixed type for expression2 not type1", type1, provider.getType(expression2)); @@ -148,13 +148,13 @@ public void testTypeProviderCyclicOverrideMixed() { } @Test - public void testDelegatingTypeProvider() { + void testDelegatingTypeProvider() { delegateProvider = new PlainTypeProvider(); testPlainProvider(new DelegatingTypeProvider()); } @Test - public void testDoNothingTypeProvider() { + void testDoNothingTypeProvider() { // we are mainly testing that the AbstractTypeProvider does not crash when the subclass does nothing ITypeProvider provider = new DoNothingTypeProvider(); assertNull("did something for type of expression1", provider.getType(expression1)); diff --git a/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/BuiltInTypeModelAccessTest.java b/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/BuiltInTypeModelAccessTest.java index 401681d46d..92ed94a197 100644 --- a/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/BuiltInTypeModelAccessTest.java +++ b/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/BuiltInTypeModelAccessTest.java @@ -10,18 +10,18 @@ *******************************************************************************/ package com.avaloq.tools.ddk.typesystem; -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.assertSame; +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.assertSame; import org.eclipse.emf.common.util.EList; -import org.junit.Test; import com.avaloq.tools.ddk.typesystem.builtintypemodel.BuiltInTypeModel; import com.avaloq.tools.ddk.typesystem.builtintypemodel.InternalType; import com.avaloq.tools.ddk.typesystem.typemodel.INamedType; +import org.junit.jupiter.api.Test; /** @@ -30,8 +30,8 @@ @SuppressWarnings("nls") public class BuiltInTypeModelAccessTest { - @Test - public void testLoadModel() { + @org.junit.jupiter.api.Test + void testLoadModel() { BuiltInTypeModelAccess typeModelInstance = BuiltInTypeModelAccess.getInstance(); BuiltInTypeModel model = typeModelInstance.getModel(); assertNotNull("Model was created", model); @@ -49,8 +49,8 @@ private void assertPresence(final String name) { assertEquals("Actual type name matches", name, t.getName()); } - @Test - public void testHasInternalTypes() { + @org.junit.jupiter.api.Test + void testHasInternalTypes() { assertPresence(BuiltInTypeModelAccess.ANY_TYPE_NAME); assertPresence(BuiltInTypeModelAccess.ERROR_TYPE_NAME); assertPresence(BuiltInTypeModelAccess.UNDETERMINED_TYPE_NAME); @@ -58,14 +58,14 @@ public void testHasInternalTypes() { } @Test - public void testInvalidInternalTypeNames() { + void testInvalidInternalTypeNames() { assertNull("Null name returns null", BuiltInTypeModelAccess.getInstance().getInternalType(null)); assertNull("Empty name returns null", BuiltInTypeModelAccess.getInstance().getInternalType("")); assertNull("Non-existant name returns null", BuiltInTypeModelAccess.getInstance().getInternalType("xyz!!")); } - @Test - public void testUniqueInternalTypes() { + @org.junit.jupiter.api.Test + void testUniqueInternalTypes() { assertUnique(BuiltInTypeModelAccess.ANY_TYPE_NAME); assertUnique(BuiltInTypeModelAccess.ERROR_TYPE_NAME); assertUnique(BuiltInTypeModelAccess.UNDETERMINED_TYPE_NAME); diff --git a/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/ParameterListMatcherTest.java b/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/ParameterListMatcherTest.java index efb8ed0873..b35d6e25df 100644 --- a/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/ParameterListMatcherTest.java +++ b/com.avaloq.tools.ddk.typesystem.test/src/com/avaloq/tools/ddk/typesystem/ParameterListMatcherTest.java @@ -10,9 +10,9 @@ *******************************************************************************/ package com.avaloq.tools.ddk.typesystem; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; import java.util.ArrayList; import java.util.List; @@ -20,7 +20,6 @@ import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.junit.Test; import com.avaloq.tools.ddk.typesystem.IParameterMatchChecker.IMatchResult; import com.avaloq.tools.ddk.typesystem.ParameterListMatcher.ParameterListMatchResult; @@ -33,6 +32,7 @@ import com.avaloq.tools.ddk.typesystem.typemodel.INamedFormalParameter; import com.avaloq.tools.ddk.typesystem.typemodel.IType; import com.avaloq.tools.ddk.typesystem.typemodel.impl.NamedTypeImpl; +import org.junit.jupiter.api.Test; // You can't have too many tests @@ -210,13 +210,13 @@ private void checkParameterMatch(final IParameterMatchChecker.MatchStatus status } @Test - public void testNoneAgainstNone() { + void testNoneAgainstNone() { ParameterListMatchResult matchResult = parameterListMatcher.match(new ArrayList(), new ArrayList(), parameterMatcher, CASE_INSENSITIVE); checkParameterListResult(ParameterListMatchStatus.MATCH_SUCCESSFUL, 0, 0, matchResult); } @Test - public void testOneUnnamedAgainstOne() { + void testOneUnnamedAgainstOne() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); List actuals = new ArrayList(); @@ -227,8 +227,8 @@ public void testOneUnnamedAgainstOne() { checkParameterMatch(IParameterMatchChecker.MatchStatus.MATCH, actuals.get(0), formals.get(0), matches.get(0)); } - @Test - public void testOneNamedAgainstOne() { + @org.junit.jupiter.api.Test + void testOneNamedAgainstOne() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); List actuals = new ArrayList(); @@ -239,8 +239,8 @@ public void testOneNamedAgainstOne() { checkParameterMatch(IParameterMatchChecker.MatchStatus.MATCH, actuals.get(0), formals.get(0), matches.get(0)); } - @Test - public void testOneNamedAgainstOneCaseSensitive() { + @org.junit.jupiter.api.Test + void testOneNamedAgainstOneCaseSensitive() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1.toUpperCase(Locale.getDefault()), intType)); List actuals = new ArrayList(); @@ -260,8 +260,8 @@ public void testOneNamedAgainstOneCaseSensitive() { checkParameterMatch(IParameterMatchChecker.MatchStatus.NO_MATCH_FOR_NAMED_ACTUAL, actuals.get(0), null, matches.get(0)); } - @Test - public void testOneUnnamedAgainstNone() { + @org.junit.jupiter.api.Test + void testOneUnnamedAgainstNone() { List formals = new ArrayList(); List actuals = new ArrayList(); actuals.add(new ActualParameter(intType)); @@ -272,7 +272,7 @@ public void testOneUnnamedAgainstNone() { } @Test - public void testOneNamedAgainstNone() { + void testOneNamedAgainstNone() { List formals = new ArrayList(); List actuals = new ArrayList(); actuals.add(new NamedActualParameter(NAME_1, intType)); @@ -283,7 +283,7 @@ public void testOneNamedAgainstNone() { } @Test - public void testNoneAgainstOne() { + void testNoneAgainstOne() { List formals = new ArrayList(); NamedFormalParameter mandatoryParam = new NamedFormalParameter(NAME_1, intType); formals.add(mandatoryParam); @@ -295,7 +295,7 @@ public void testNoneAgainstOne() { } @Test - public void testNoneAgainstTwoMandatory() { + void testNoneAgainstTwoMandatory() { // one mandatory and one not mandatory List formals = new ArrayList(); NamedFormalParameter mandatoryParam1 = new NamedFormalParameter(NAME_1, intType); @@ -310,8 +310,8 @@ public void testNoneAgainstTwoMandatory() { assertSame(INCORRECT_UNMATCHED_MANDATORY_FORMAL, mandatoryParam2, matchResult.getUnmatchedMandatoryFormalParameters().get(1)); } - @Test - public void testNoneAgainstTwoMixed() { + @org.junit.jupiter.api.Test + void testNoneAgainstTwoMixed() { // one mandatory and one not mandatory List formals = new ArrayList(); NamedFormalParameter mandatoryParam = new NamedFormalParameter(NAME_1, intType); @@ -325,7 +325,7 @@ public void testNoneAgainstTwoMixed() { } @Test - public void testThreeUnnamedWithOneTypeError() { + void testThreeUnnamedWithOneTypeError() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -343,7 +343,7 @@ public void testThreeUnnamedWithOneTypeError() { } @Test - public void testThreeNamedWithOneTypeError() { + void testThreeNamedWithOneTypeError() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -361,7 +361,7 @@ public void testThreeNamedWithOneTypeError() { } @Test - public void testThreeMixedAgainstThreeMandatory() { + void testThreeMixedAgainstThreeMandatory() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -379,7 +379,7 @@ public void testThreeMixedAgainstThreeMandatory() { } @Test - public void testTwoMixedAgainstThreeMandatory() { + void testTwoMixedAgainstThreeMandatory() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -395,7 +395,7 @@ public void testTwoMixedAgainstThreeMandatory() { } @Test - public void testTwoMixedAgainstThreeWithOptional() { + void testTwoMixedAgainstThreeWithOptional() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType, IS_OPTIONAL, !IS_MULTI)); @@ -411,7 +411,7 @@ public void testTwoMixedAgainstThreeWithOptional() { } @Test - public void testTwoUnnamedAgainstThreeWithOptional() { + void testTwoUnnamedAgainstThreeWithOptional() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -423,7 +423,7 @@ public void testTwoUnnamedAgainstThreeWithOptional() { } @Test - public void testUnnamedTooManyActuals() { + void testUnnamedTooManyActuals() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -442,7 +442,7 @@ public void testUnnamedTooManyActuals() { } @Test - public void testFourUnnamedAgainstTwoWithMulti() { + void testFourUnnamedAgainstTwoWithMulti() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType, IS_MANDATORY, IS_MULTI)); @@ -455,7 +455,7 @@ public void testFourUnnamedAgainstTwoWithMulti() { } @Test - public void testFourNamedAgainstTwoWithMulti() { + void testFourNamedAgainstTwoWithMulti() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType, IS_MANDATORY, IS_MULTI)); @@ -474,7 +474,7 @@ public void testFourNamedAgainstTwoWithMulti() { } @Test - public void testTwoUnNamedAgainstTwoPositional() { + void testTwoUnNamedAgainstTwoPositional() { List formals = new ArrayList(); formals.add(new FormalParameter(intType)); formals.add(new FormalParameter(textType)); @@ -493,7 +493,7 @@ private void check2Successful(final List formals, final List formals = new ArrayList(); formals.add(new FormalParameter(intType)); formals.add(new FormalParameter(textType, IS_MANDATORY, IS_MULTI)); @@ -516,7 +516,7 @@ private void check4Successful(final List formals, final List formals = new ArrayList(); formals.add(new FormalParameter(intType)); formals.add(new FormalParameter(textType, IS_MANDATORY, IS_MULTI)); @@ -535,7 +535,7 @@ public void testFourUnNamedAgainstTwoPositionalwithMultiAndTypeError() { } @Test - public void testNamedAgainstPositional() { + void testNamedAgainstPositional() { List formals = new ArrayList(); formals.add(new FormalParameter(intType)); formals.add(new FormalParameter(textType)); @@ -550,7 +550,7 @@ public void testNamedAgainstPositional() { } @Test - public void testMissingMandatoryAgainstPositional() { + void testMissingMandatoryAgainstPositional() { List formals = new ArrayList(); formals.add(new FormalParameter(intType)); formals.add(new FormalParameter(textType)); @@ -562,8 +562,8 @@ public void testMissingMandatoryAgainstPositional() { checkParameterMatch(IParameterMatchChecker.MatchStatus.MATCH, actuals.get(0), formals.get(0), matches.get(0)); } - @Test - public void testInvalidActualNull() { + @org.junit.jupiter.api.Test + void testInvalidActualNull() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, textType)); @@ -581,7 +581,7 @@ public void testInvalidActualNull() { } @Test - public void testInvalidActualNullWithMulti() { + void testInvalidActualNullWithMulti() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, textType, IS_MANDATORY, IS_MULTI)); @@ -598,7 +598,7 @@ public void testInvalidActualNullWithMulti() { } @Test - public void testInvalidNamedActualNullName() { + void testInvalidNamedActualNullName() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, textType, IS_OPTIONAL, !IS_MULTI)); @@ -609,7 +609,7 @@ public void testInvalidNamedActualNullName() { } @Test - public void testInvalidNamedActualBlankName() { + void testInvalidNamedActualBlankName() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, textType, IS_OPTIONAL, !IS_MULTI)); @@ -627,8 +627,8 @@ private void check2WithNullFormal1(final List formals, fin checkParameterMatch(IParameterMatchChecker.MatchStatus.INVALID_ACTUAL, actuals.get(1), null, matches.get(1)); } - @Test - public void testInvalidFormalNull() { + @org.junit.jupiter.api.Test + void testInvalidFormalNull() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(null); @@ -646,7 +646,7 @@ public void testInvalidFormalNull() { } @Test - public void testInvalidFormalNullName() { + void testInvalidFormalNullName() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(null, intType)); @@ -664,7 +664,7 @@ public void testInvalidFormalNullName() { } @Test - public void testInvalidActualNullNameInvalidFormalNullName() { + void testInvalidActualNullNameInvalidFormalNullName() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(null, intType)); @@ -681,8 +681,8 @@ public void testInvalidActualNullNameInvalidFormalNullName() { checkParameterMatch(IParameterMatchChecker.MatchStatus.INVALID_ACTUAL, actuals.get(2), null, matches.get(2)); } - @Test - public void testDuplicateFormalName() { + @org.junit.jupiter.api.Test + void testDuplicateFormalName() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_1, intType, IS_OPTIONAL, !IS_MULTI)); @@ -699,7 +699,7 @@ public void testDuplicateFormalName() { } @Test - public void testDuplicateNamedActual() { + void testDuplicateNamedActual() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -716,8 +716,8 @@ public void testDuplicateNamedActual() { checkParameterMatch(IParameterMatchChecker.MatchStatus.DUPLICATE_NAMED_ACTUAL, actuals.get(2), formals.get(1), matches.get(2)); } - @Test - public void testPositionalAfterNamed1() { + @org.junit.jupiter.api.Test + void testPositionalAfterNamed1() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -734,8 +734,8 @@ public void testPositionalAfterNamed1() { checkParameterMatch(IParameterMatchChecker.MatchStatus.POSITIONAL_AFTER_NAMED, actuals.get(2), null, matches.get(2)); } - @Test - public void testPositionalAfterNamed2() { + @org.junit.jupiter.api.Test + void testPositionalAfterNamed2() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, textType)); @@ -758,8 +758,8 @@ public void testPositionalAfterNamed2() { } - @Test - public void testNamedMatchesPositional() { + @org.junit.jupiter.api.Test + void testNamedMatchesPositional() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -777,7 +777,7 @@ public void testNamedMatchesPositional() { } @Test - public void testNamedFormalAfterUnnamed1() { + void testNamedFormalAfterUnnamed1() { // these are allowed, match named by position. List formals = new ArrayList(); formals.add(new FormalParameter(intType)); @@ -788,8 +788,8 @@ public void testNamedFormalAfterUnnamed1() { check2Successful(formals, actuals); } - @Test - public void testNamedFormalAfterUnnamed2() { + @org.junit.jupiter.api.Test + void testNamedFormalAfterUnnamed2() { // these are allowed, match named by name. List formals = new ArrayList(); formals.add(new FormalParameter(intType)); @@ -800,8 +800,8 @@ public void testNamedFormalAfterUnnamed2() { check2Successful(formals, actuals); } - @Test - public void testNamedFormalAfterUnnamed3() { + @org.junit.jupiter.api.Test + void testNamedFormalAfterUnnamed3() { // these are allowed, match named by name, unnamed and named optional List formals = new ArrayList(); formals.add(new FormalParameter(intType, !IS_MANDATORY, !IS_MULTI)); @@ -824,7 +824,7 @@ private void verifyOneUnnamedFormalAfterNamed(final List formal } @Test - public void testUnnamedFormalAfterNamed1() { + void testUnnamedFormalAfterNamed1() { // unnamed is matched by position List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); @@ -846,7 +846,7 @@ public void testUnnamedFormalAfterNamed1() { } @Test - public void testUnnamedFormalAfterNamed2() { + void testUnnamedFormalAfterNamed2() { // unnamed is optional, at end and not matched because fewer formal parameters List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); @@ -858,7 +858,7 @@ public void testUnnamedFormalAfterNamed2() { } @Test - public void testUnnamedFormalAfterNamed3() { + void testUnnamedFormalAfterNamed3() { // unnamed is mandatory, at end and not matched because fewer formal parameters List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); @@ -870,7 +870,7 @@ public void testUnnamedFormalAfterNamed3() { } @Test - public void testUnnamedFormalAfterNamed4() { + void testUnnamedFormalAfterNamed4() { // two unnamed formals after named List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -890,7 +890,7 @@ public void testUnnamedFormalAfterNamed4() { } @Test - public void testForceMatchByPosition1() { + void testForceMatchByPosition1() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -907,8 +907,8 @@ public void testForceMatchByPosition1() { checkParameterMatch(IParameterMatchChecker.MatchStatus.MATCH, actuals.get(2), formals.get(2), matches.get(2)); } - @Test - public void testForceMatchByPosition2() { + @org.junit.jupiter.api.Test + void testForceMatchByPosition2() { List formals = new ArrayList(); formals.add(new NamedFormalParameter(NAME_1, intType)); formals.add(new NamedFormalParameter(NAME_2, intType)); @@ -925,8 +925,8 @@ public void testForceMatchByPosition2() { checkParameterMatch(IParameterMatchChecker.MatchStatus.MATCH, actuals.get(2), formals.get(2), matches.get(2)); } - @Test - public void testForceMatchByPosition3() { + @org.junit.jupiter.api.Test + void testForceMatchByPosition3() { List formals = new ArrayList(); formals.add(new FormalParameter(intType)); formals.add(new FormalParameter(intType)); diff --git a/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/exporting/ExportExportingTest.java b/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/exporting/ExportExportingTest.java index b76a3504e1..6a6d0ae3cc 100644 --- a/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/exporting/ExportExportingTest.java +++ b/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/exporting/ExportExportingTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.export.exporting; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.test.AbstractXtextTest; import com.avaloq.tools.ddk.xtext.test.export.util.ExportTestUtil; @@ -28,7 +28,7 @@ protected ExportTestUtil getXtextTestUtil() { } @Test - public final void testExport() { + final void testExport() { // TODO - what should we test? } diff --git a/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/scoping/ExportScopingTest.java b/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/scoping/ExportScopingTest.java index f8034d1f7d..059baa20d4 100644 --- a/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/scoping/ExportScopingTest.java +++ b/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/scoping/ExportScopingTest.java @@ -10,14 +10,14 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.export.scoping; -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 java.io.IOException; import org.eclipse.xtext.naming.QualifiedName; import org.eclipse.xtext.scoping.IScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.export.export.ExportModel; import com.avaloq.tools.ddk.xtext.export.export.ExportPackage; @@ -42,7 +42,7 @@ protected ExportTestUtil getXtextTestUtil() { } @Test - public void testImportPackageScope() throws IOException { + void testImportPackageScope() throws IOException { ExportModel model = (ExportModel) getTestSource().getModel(); IScope scope = scopeProvider.scope_Import_package(model.getImports().get(0), ExportPackage.Literals.IMPORT__PACKAGE); assertNotNull("Could not locate Import.", scope.getSingleElement(QualifiedName.create("http://www.avaloq.com/tools/ddk/xtext/export/Export"))); @@ -50,7 +50,7 @@ public void testImportPackageScope() throws IOException { } @Test - public void testEclassScope() throws IOException { + void testEclassScope() throws IOException { ExportModel model = (ExportModel) getTestSource().getModel(); IScope scope = scopeProvider.scope_EClass(model, null); assertNotNull("Could not locate EClass.", scope.getSingleElement(QualifiedName.create("InterfaceExpression"))); @@ -58,7 +58,7 @@ public void testEclassScope() throws IOException { } @Test - public void testEStructuralFeatureScope() throws IOException { + void testEStructuralFeatureScope() throws IOException { ExportModel model = (ExportModel) getTestSource().getModel(); IScope scope = scopeProvider.scope_EStructuralFeature(model.getInterfaces().get(0), null); // CHECKSTYLE:OFF (DuplicateString) @@ -68,7 +68,7 @@ public void testEStructuralFeatureScope() throws IOException { } @Test - public void testEAttributeScope() throws IOException { + void testEAttributeScope() throws IOException { ExportModel model = (ExportModel) getTestSource().getModel(); IScope scope = scopeProvider.scope_EAttribute(model.getInterfaces().get(0), null); // CHECKSTYLE:OFF (DuplicateString) @@ -78,7 +78,7 @@ public void testEAttributeScope() throws IOException { } @Test - public void testInterfaceNavigationRefScope() throws IOException { + void testInterfaceNavigationRefScope() throws IOException { ExportModel model = (ExportModel) getTestSource().getModel(); IScope scope = scopeProvider.scope_InterfaceNavigation_ref(model.getInterfaces().get(0), null); // CHECKSTYLE:OFF (DuplicateString) diff --git a/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/validation/ExportValidationOkTest.java b/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/validation/ExportValidationOkTest.java index 68a802d179..e6b06b6f37 100644 --- a/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/validation/ExportValidationOkTest.java +++ b/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/validation/ExportValidationOkTest.java @@ -10,10 +10,9 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.export.validation; -import org.junit.Test; - import com.avaloq.tools.ddk.xtext.test.export.util.ExportTestUtil; import com.avaloq.tools.ddk.xtext.test.validation.AbstractValidationTest; +import org.junit.jupiter.api.Test; /** @@ -26,8 +25,8 @@ protected ExportTestUtil getXtextTestUtil() { return ExportTestUtil.getInstance(); } - @Test - public final void testCheckAll() { + @org.junit.jupiter.api.Test + final void testCheckAll() { assertNoDiagnostics(); } diff --git a/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/validation/ExportValidationTest.java b/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/validation/ExportValidationTest.java index c961919772..8a61f39e9f 100644 --- a/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/validation/ExportValidationTest.java +++ b/com.avaloq.tools.ddk.xtext.export.test/src/com/avaloq/tools/ddk/xtext/export/validation/ExportValidationTest.java @@ -10,10 +10,9 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.export.validation; -import org.junit.Test; - import com.avaloq.tools.ddk.xtext.test.export.util.ExportTestUtil; import com.avaloq.tools.ddk.xtext.test.validation.AbstractValidationTest; +import org.junit.jupiter.api.Test; /** @@ -26,29 +25,29 @@ protected ExportTestUtil getXtextTestUtil() { return ExportTestUtil.getInstance(); } - @Test - public final void testCheckExtensions() { + @org.junit.jupiter.api.Test + final void testCheckExtensions() { // TODO cannot test as unable to load resource in test environment assertDiagnosticMessage("Extension 'XYZ' not found"); } - @Test - public final void testCheckInterfaceAndExportUniqueness() { + @org.junit.jupiter.api.Test + final void testCheckInterfaceAndExportUniqueness() { assertDiagnosticMessage("declaration duplicate found: ecore::EClass"); } @Test - public final void testCheckExportFieldUniqueness() { + final void testCheckExportFieldUniqueness() { assertDiagnosticMessage("duplicate found: instanceClassName"); } - @Test - public final void testCheckUserDataNameAsFeature() { + @org.junit.jupiter.api.Test + final void testCheckUserDataNameAsFeature() { assertDiagnosticMessage("instanceClassName is already defined as field"); // TODO assertDiagnosticMessage("xxx has the same name as an existing feature"); } @Test - public final void testCheckOverlap() { + final void testCheckOverlap() { // TODO assertDiagnosticMessage(""); } diff --git a/com.avaloq.tools.ddk.xtext.format.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtext.format.test/META-INF/MANIFEST.MF index e42ef04c91..503c40e7e4 100644 --- a/com.avaloq.tools.ddk.xtext.format.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.xtext.format.test/META-INF/MANIFEST.MF @@ -10,7 +10,7 @@ Fragment-Host: com.avaloq.tools.ddk.xtext.format.ui Require-Bundle: com.avaloq.tools.ddk.xtext.format, com.google.inject, com.avaloq.tools.ddk.xtext.test.core, - org.junit, + org.junit.jupiter.api, org.mockito, org.eclipse.xtext.xbase.lib, org.eclipse.xtext.xbase.testing, diff --git a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/FormatParsingTest.xtend b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/FormatParsingTest.xtend index a196c100c7..21631106d8 100644 --- a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/FormatParsingTest.xtend +++ b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/FormatParsingTest.xtend @@ -8,8 +8,8 @@ import com.google.inject.Inject import org.eclipse.xtext.testing.InjectWith import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.util.ParseHelper -import org.junit.Assert -import org.junit.Test +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test import org.junit.runner.RunWith @RunWith(XtextRunner) @@ -23,8 +23,8 @@ class FormatParsingTest { val result = parseHelper.parse(''' Hello Xtext! ''') - Assert.assertNotNull(result) + Assertions.assertNotNull(result) val errors = result.eResource.errors - Assert.assertTrue('''Unexpected errors: «errors.join(", ")»''', errors.isEmpty) + Assertions.assertTrue('''Unexpected errors: «errors.join(", ")»''', errors.isEmpty) } } diff --git a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/builder/FormatBuilderParticipantTest.java b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/builder/FormatBuilderParticipantTest.java index ed47fca61d..2800f6d1cb 100644 --- a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/builder/FormatBuilderParticipantTest.java +++ b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/builder/FormatBuilderParticipantTest.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.format.builder; -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 static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -21,7 +21,7 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.xtext.resource.IResourceDescription.Delta; import org.eclipse.xtext.resource.IResourceServiceProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatcher; import com.avaloq.tools.ddk.xtext.test.AbstractXtextTest; @@ -66,8 +66,8 @@ protected void beforeAllTests() { /** * Tests whether a {@link Delta} resource has a correct extension to be used by org.eclipse.xtext.builder.BuilderParticipant. */ - @Test - public void hasCorrectExtensionTest() { + @org.junit.jupiter.api.Test + void hasCorrectExtensionTest() { IResourceServiceProvider resourceServiceProvider = mock(IResourceServiceProvider.class); when(resourceServiceProvider.canHandle(argThat(new IsUri()))).thenReturn(true, false); assertTrue("Check if the delta resource has correct extension", participant.hasCorrectExtension(delta, resourceServiceProvider)); @@ -78,7 +78,7 @@ public void hasCorrectExtensionTest() { * Tests whether a {@link Delta} resource comes form the right (SRC) directory to be used by org.eclipse.xtext.builder.BuilderParticipant. */ @Test - public void isSourceOriginatedTest() { + void isSourceOriginatedTest() { when(uriCorrect.segments()).thenReturn(CORRECT_URI_SEGMENTS); assertTrue("Check if the delta resource has correct URI and comes from SRC directory", participant.isSourceOriginated(delta)); when(uriCorrect.segments()).thenReturn(BIN_URI_SEGMENTS); diff --git a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/scoping/FormatScopingTest.java b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/scoping/FormatScopingTest.java index 8762e63501..b242bb8d10 100644 --- a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/scoping/FormatScopingTest.java +++ b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/scoping/FormatScopingTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.format.scoping; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.util.List; import java.util.Set; @@ -27,7 +27,7 @@ import org.eclipse.xtext.nodemodel.ICompositeNode; import org.eclipse.xtext.nodemodel.ILeafNode; import org.eclipse.xtext.nodemodel.util.NodeModelUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.format.format.FormatConfiguration; import com.avaloq.tools.ddk.xtext.format.format.FormatPackage; @@ -101,14 +101,14 @@ protected void beforeEachTest() { * Bug AIG-718. * Tests that all grammars' rules are scoped. */ - @Test - public void allGrammarsScoped() { + @org.junit.jupiter.api.Test + void allGrammarsScoped() { Set expectedURIs = Sets.newHashSet(EcoreUtil.getURI(grammarC.getRules().get(0)), EcoreUtil.getURI(grammarB.getRules().get(0)), EcoreUtil.getURI(grammarA.getRules().get(0)), EcoreUtil.getURI(grammarA.getRules().get(1))); assertScope(formatC, FormatPackage.Literals.GRAMMAR_RULE__TARGET_RULE, expectedURIs); } - @Test - public void keywordScoped() { + @org.junit.jupiter.api.Test + void keywordScoped() { AbstractRule parserRuleA = grammarA.getRules().get(0); Set keywordURIs = Sets.newHashSet(Iterables.transform(GrammarUtil.containedKeywords(parserRuleA), TO_URI)); assertFalse("No keywords found", keywordURIs.isEmpty()); @@ -124,7 +124,7 @@ public void keywordScoped() { * Verify assignemnts (=a, =b ...) are scoped. */ @Test - public void assignmentScoped() { + void assignmentScoped() { AbstractRule parserRuleA = grammarA.getRules().get(0); Set assignmentURIs = Sets.newHashSet(Iterables.transform(GrammarUtil.containedAssignments(parserRuleA), TO_URI)); assertFalse("No assignments found", assignmentURIs.isEmpty()); @@ -136,7 +136,7 @@ public void assignmentScoped() { * Verify Rule { @Rule : ...}. */ @Test - public void ruleCallScoped() { + void ruleCallScoped() { AbstractRule parserRuleAA = grammarA.getRules().get(1); Set ruleCallURIs = Sets.newHashSet(Iterables.transform(GrammarUtil.containedRuleCalls(parserRuleAA), TO_URI)); assertScope(formatA.getRules().get(1), FormatPackage.Literals.GRAMMAR_ELEMENT_REFERENCE__RULE_CALL, ruleCallURIs); @@ -147,13 +147,13 @@ public void ruleCallScoped() { * Verify Rule { rule : ...}. */ @Test - public void ruleSelfScoped() { + void ruleSelfScoped() { AbstractRule parserRuleA = grammarA.getRules().get(0); assertScope(formatC.getRules().get(0), FormatPackage.Literals.GRAMMAR_ELEMENT_REFERENCE__SELF, TO_URI.apply(parserRuleA)); } - @Test - public void groupScoped() { + @org.junit.jupiter.api.Test + void groupScoped() { ParserRule parserRuleA = (ParserRule) grammarA.getRules().get(0); CompoundElement group1 = findSemanticElementByString("(", CompoundElement.class, parserRuleA); // ('-' b=STRING | ('-'c=ID ('-'d=INT | '-'e=STRING)))? diff --git a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/validation/FormatValidationTest.java b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/validation/FormatValidationTest.java index 1e3919b307..54c485b8b6 100644 --- a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/validation/FormatValidationTest.java +++ b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/format/validation/FormatValidationTest.java @@ -10,12 +10,12 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.format.validation; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.format.format.FormatConfiguration; import com.avaloq.tools.ddk.xtext.test.format.util.FormatTestUtil; @@ -102,8 +102,8 @@ private FormatConfiguration createModel(final String formatName, final String ex /** * Tests that non-'rule' directives are invalid in a terminal rule context. */ - @Test - public void testNegativeACF1000() { + @org.junit.jupiter.api.Test + void testNegativeACF1000() { setFormattingRules(new String[0], "INT_EXP { \"e\" : no_space around;}"); assertDiagnostic(parentFormat, FormatValidator.ILLEGAL_DIRECTIVE_CODE); } @@ -111,8 +111,8 @@ public void testNegativeACF1000() { /** * Tests that 'rule' directives are valid in a terminal rule context. */ - @Test - public void testPositiveACF1000() { + @org.junit.jupiter.api.Test + void testPositiveACF1000() { setFormattingRules(new String[0], "INT_EXP { rule : no_space around;}"); assertNoDiagnostic(parentFormat, FormatValidator.ILLEGAL_DIRECTIVE_CODE); } @@ -120,8 +120,8 @@ public void testPositiveACF1000() { /** * Verify that IllegalOverride validation issues error for WildcardRules. */ - @Test - public void illegalWildcardRuleOverride() { + @org.junit.jupiter.api.Test + void illegalWildcardRuleOverride() { setFormattingRules(new String[] {OVERRIDE_WILDCARD_RULE}); assertDiagnostic(extendingFormat, FormatValidator.OVERRIDE_ILLEGAL_CODE); } @@ -130,7 +130,7 @@ public void illegalWildcardRuleOverride() { * Verify that IllegalOverride validation issues error for GrammarRules. */ @Test - public void illegalGrammarRuleOverride() { + void illegalGrammarRuleOverride() { setFormattingRules(new String[] {OVERRIDE_INT_EXP_RULE}); assertDiagnostic(extendingFormat, FormatValidator.OVERRIDE_ILLEGAL_CODE); } @@ -138,8 +138,8 @@ public void illegalGrammarRuleOverride() { /** * Verify that OverrideMissing validation issues error for WildcardRules. */ - @Test - public void missingWildcardRuleOverride() { + @org.junit.jupiter.api.Test + void missingWildcardRuleOverride() { setFormattingRules(new String[] {WILDCARD_RULE}, WILDCARD_RULE); assertDiagnostic(extendingFormat, FormatValidator.OVERRIDE_MISSING_CODE); @@ -149,7 +149,7 @@ public void missingWildcardRuleOverride() { * Verify that OverrideMissing validation issues error for GrammarRules. */ @Test - public void missingGrammarRuleOverride() { + void missingGrammarRuleOverride() { setFormattingRules(new String[] {INT_EXP_RULE}, INT_EXP_RULE); assertDiagnostic(extendingFormat, FormatValidator.OVERRIDE_MISSING_CODE); } @@ -157,8 +157,8 @@ public void missingGrammarRuleOverride() { /** * Verify that OverrideMissing nor IllegalOverride validations issue no error. */ - @Test - public void wildcardRuleOverrideOK() { + @org.junit.jupiter.api.Test + void wildcardRuleOverrideOK() { setFormattingRules(new String[] {OVERRIDE_WILDCARD_RULE}, WILDCARD_RULE); assertNoDiagnostic(extendingFormat, FormatValidator.OVERRIDE_MISSING_CODE); assertNoDiagnostic(extendingFormat, FormatValidator.OVERRIDE_ILLEGAL_CODE); @@ -167,8 +167,8 @@ public void wildcardRuleOverrideOK() { /** * Verify that OverrideMissing nor IllegalOverride validations issue no error. */ - @Test - public void grammarRuleOverrideOK() { + @org.junit.jupiter.api.Test + void grammarRuleOverrideOK() { setFormattingRules(new String[] {OVERRIDE_INT_EXP_RULE}, INT_EXP_RULE); assertNoDiagnostic(extendingFormat, FormatValidator.OVERRIDE_MISSING_CODE); assertNoDiagnostic(extendingFormat, FormatValidator.OVERRIDE_ILLEGAL_CODE); @@ -177,8 +177,8 @@ public void grammarRuleOverrideOK() { /** * Verify that ExtendedGrammarCompatible validation issues error when grammars of the Format models are incompatible. */ - @Test - public void extendedGrammarCompatible() { + @org.junit.jupiter.api.Test + void extendedGrammarCompatible() { try { getXtextTestUtil().getModel("MyDsl.xtext", "grammar com.avaloq.tools.ddk.xtext.format.validation.MyDsl\nimport \"http://www.eclipse.org/emf/2002/Ecore\" as ecore\nRule: 'rule';"); } catch (IOException e) { @@ -191,8 +191,8 @@ public void extendedGrammarCompatible() { /** * Verify that ExtendedGrammarCompatible validation issues no error. */ - @Test - public void extendedGrammarCompatibleOK() { + @org.junit.jupiter.api.Test + void extendedGrammarCompatibleOK() { createModel(PARENT_MODEL_NAME, null); FormatConfiguration extendModel = createModel(EXTENDING_MODEL_NAME, PARENT_MODEL_NAME); assertNoDiagnostic(extendModel, FormatValidator.EXTENDED_GRAMMAR_INCOMPATIBLE_CODE); @@ -203,7 +203,7 @@ public void extendedGrammarCompatibleOK() { * formatting rule must be defined in the extending configuration if it is defined in the parent. */ @Test - public void requiredRulesImplemented() { + void requiredRulesImplemented() { setFormattingRules(new String[0], "Rule {}"); assertDiagnostic(extendingFormat, FormatValidator.GRAMMAR_RULE_MISSING_CODE); } diff --git a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/test/format/util/FormatTestUtil.java b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/test/format/util/FormatTestUtil.java index 289ccd3ec5..f72244c23d 100644 --- a/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/test/format/util/FormatTestUtil.java +++ b/com.avaloq.tools.ddk.xtext.format.test/src/com/avaloq/tools/ddk/xtext/test/format/util/FormatTestUtil.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.format.util; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; diff --git a/com.avaloq.tools.ddk.xtext.generator.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtext.generator.test/META-INF/MANIFEST.MF index 772aa65ef4..1db3d2fc54 100644 --- a/com.avaloq.tools.ddk.xtext.generator.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.xtext.generator.test/META-INF/MANIFEST.MF @@ -13,7 +13,7 @@ Require-Bundle: com.avaloq.tools.ddk.test.core, org.eclipse.xtend, org.eclipse.xtend.typesystem.emf, org.eclipse.xtext, - org.junit, + org.junit.jupiter.api, org.mockito, com.avaloq.tools.ddk.xtext.ui, org.eclipse.xtext.xtext.generator diff --git a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CodeGenerationXTest.java b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CodeGenerationXTest.java index 2d0e111353..6f42b65c82 100644 --- a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CodeGenerationXTest.java +++ b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CodeGenerationXTest.java @@ -10,14 +10,14 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.generator.expression; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import org.eclipse.xtend.expression.ExecutionContextImpl; import org.eclipse.xtend.type.impl.java.JavaBeansMetaModel; import org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.expression.expression.Expression; import com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext; @@ -60,7 +60,7 @@ protected String getTestSourceFileName() { } @Test - public void testliterals() throws Exception { + void testliterals() throws Exception { // CHECKSTYLE:CONSTANTS-OFF assertEquals("42", compile("42")); // NOPMD assertEquals("4.2", compile("4.2")); // NOPMD @@ -71,20 +71,20 @@ public void testliterals() throws Exception { // CHECKSTYLE:CONSTANTS-ON } - @Test - public void testListLiterals() throws Exception { + @org.junit.jupiter.api.Test + void testListLiterals() throws Exception { assertEquals("java.util.Collections. emptyList()", compile("{}")); // NOPMD assertEquals("java.util.Collections.singletonList(1)", compile("{1}")); // NOPMD assertEquals("com.google.common.collect.Lists.newArrayList(1, 2, 3)", compile("{1,2,3}")); // NOPMD } - @Test - public void testIdentifiers() throws Exception { + @org.junit.jupiter.api.Test + void testIdentifiers() throws Exception { assertEquals("obj.getTrue()", compile("^true")); // NOPMD } - @Test - public void testBracketing() throws Exception { + @org.junit.jupiter.api.Test + void testBracketing() throws Exception { // CHECKSTYLE:CONSTANTS-OFF assertEquals("(4 + 2) * 3", compile("(4 + 2) * 3")); // NOPMD assertEquals("(4 + 2) * 3 * 4", compile("(4 + 2) * 3 * 4")); // NOPMD @@ -96,7 +96,7 @@ public void testBracketing() throws Exception { } @Test - public void testBooleanLogic() throws Exception { + void testBooleanLogic() throws Exception { // CHECKSTYLE:CONSTANTS-OFF assertEquals("true", compile("true")); // NOPMD assertEquals("false", compile("false")); // NOPMD @@ -114,8 +114,8 @@ public void testBooleanLogic() throws Exception { // CHECKSTYLE:CONSTANTS-ON } - @Test - public void testArithmetics() throws Exception { + @org.junit.jupiter.api.Test + void testArithmetics() throws Exception { // CHECKSTYLE:CONSTANTS-OFF assertEquals("4 + 2", compile("4 + 2")); // NOPMD assertEquals("4 - 2", compile("4 - 2")); // NOPMD @@ -125,8 +125,8 @@ public void testArithmetics() throws Exception { // CHECKSTYLE:CONSTANTS-ON } - @Test - public void testPrefixExpressions() throws Exception { + @org.junit.jupiter.api.Test + void testPrefixExpressions() throws Exception { // CHECKSTYLE:CONSTANTS-OFF assertEquals("-(4 * 2)", compile("-(4 * 2)")); // NOPMD assertEquals("-(-42)", compile("-(-42)")); // NOPMD @@ -140,7 +140,7 @@ public void testPrefixExpressions() throws Exception { } @Test - public void testInfixExpressions() throws Exception { + void testInfixExpressions() throws Exception { // CHECKSTYLE:CONSTANTS-OFF assertEquals("(true ? 1 : 2) + 3", compile("(true ? 1 : 2) + 3")); // NOPMD assertEquals("!(true ? true : false)", compile("!(true ? true : false)")); // NOPMD @@ -148,37 +148,37 @@ public void testInfixExpressions() throws Exception { // CHECKSTYLE:CONSTANTS-ON } - @Test - public void testImplicitVariable() throws Exception { + @org.junit.jupiter.api.Test + void testImplicitVariable() throws Exception { assertEquals("obj", compile("this")); // NOPMD } @Test - public void testCasting() throws Exception { + void testCasting() throws Exception { assertEquals("((org.eclipse.emf.ecore.EObject) obj)", compile("(ecore::EObject) this")); // NOPMD } - @Test - public void testTypes() throws Exception { + @org.junit.jupiter.api.Test + void testTypes() throws Exception { assertEquals("org.eclipse.emf.ecore.EObject", compile("ecore::EObject")); // NOPMD assertEquals("String", compile("java::lang::String")); // NOPMD } - @Test - public void testIsInstance() throws Exception { + @org.junit.jupiter.api.Test + void testIsInstance() throws Exception { assertEquals("obj instanceof org.eclipse.emf.ecore.EObject", compile("ecore::EObject.isInstance(this)")); // NOPMD } @Test - public void testEContainerNavigation() throws Exception { + void testEContainerNavigation() throws Exception { // CHECKSTYLE:CONSTANTS-OFF assertEquals("obj.eContainer()", compile("this.eContainer")); // NOPMD assertEquals("obj.eContainer()", compile("this.eContainer()")); // NOPMD // CHECKSTYLE:CONSTANTS-ON } - @Test - public void testTypeSelect() throws Exception { + @org.junit.jupiter.api.Test + void testTypeSelect() throws Exception { assertEquals(// NOPMD "com.google.common.collect.Iterables.filter(obj.getFoos(), org.eclipse.emf.ecore.EObject.class)", compile("this.foos.typeSelect(ecore::EObject)")); assertEquals(// NOPMD @@ -186,13 +186,13 @@ public void testTypeSelect() throws Exception { } @Test - public void testCollectionExpression() throws Exception { + void testCollectionExpression() throws Exception { assertEquals(// NOPMD "com.google.common.collect.Iterables.filter(java.util.Collections.singletonList(obj), new com.google.common.base.Predicate() { public boolean apply(Object e) {return true;} })", compile("{this}.select(e|true)")); } @Test - public void testMultipleNavigations() throws Exception { + void testMultipleNavigations() throws Exception { assertEquals(// NOPMD "/* NOT COMPILABLE: Complex expressions like \"this.eContainer.eContainer\" cannot be translated to Java. Consider rewriting the expression or using a JAVA extension. */", compile("this.eContainer.eContainer")); assertEquals(// NOPMD diff --git a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CompilationContextTest.java b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CompilationContextTest.java index 321a9d684c..2f4bb412ff 100644 --- a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CompilationContextTest.java +++ b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CompilationContextTest.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.generator.expression; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; @@ -21,7 +21,7 @@ import org.eclipse.xtend.expression.ExecutionContextImpl; import org.eclipse.xtend.type.impl.java.JavaBeansMetaModel; import org.eclipse.xtend.typesystem.Type; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext; @@ -29,7 +29,7 @@ public class CompilationContextTest { @Test - public void isExtension() { + void isExtension() { ExecutionContextImpl executionContext = new ExecutionContextImpl(); executionContext.registerMetaModel(new JavaBeansMetaModel()); ExtensionFile extensionFile = ParseFacade.file(new InputStreamReader(getClass().getResourceAsStream("/com/avaloq/tools/ddk/xtext/generator/expression/TestExtensions.ext"), StandardCharsets.UTF_8), "TestExtensions.ext"); @@ -40,7 +40,7 @@ public void isExtension() { } @Test - public void analyze() { + void analyze() { ExecutionContextImpl executionContext = new ExecutionContextImpl(); executionContext.registerMetaModel(new JavaBeansMetaModel()); final CompilationContext context = new CompilationContext(executionContext, null); diff --git a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/ExpressionsExtentionsTest.java b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/ExpressionsExtentionsTest.java index c55344fafd..2687e99d65 100644 --- a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/ExpressionsExtentionsTest.java +++ b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/ExpressionsExtentionsTest.java @@ -10,11 +10,11 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.generator.expression; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.expression.expression.Expression; import com.avaloq.tools.ddk.xtext.expression.generator.ExpressionExtensions; @@ -38,7 +38,7 @@ protected String getTestSourceFileName() { } @Test - public final void serialize() throws IOException { + final void serialize() throws IOException { Expression e = (Expression) getXtextTestUtil().getModel("test.expression." + getXtextTestUtil().getFileExtension(), "let x = 1 : 0"); assertEquals("Simple serialization works", "let x = 1 : 0", ExpressionExtensions.serialize(e)); } diff --git a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/test/util/EClassComparatorTest.java b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/test/util/EClassComparatorTest.java index 36e0c08de5..838e88d79c 100644 --- a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/test/util/EClassComparatorTest.java +++ b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/test/util/EClassComparatorTest.java @@ -15,7 +15,7 @@ import static org.eclipse.emf.ecore.EcorePackage.Literals.EDATA_TYPE; import static org.eclipse.emf.ecore.EcorePackage.Literals.EOBJECT; import static org.eclipse.emf.ecore.EcorePackage.Literals.EPACKAGE; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; @@ -23,13 +23,13 @@ import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.xtext.XtextPackage; -import org.junit.Test; import com.avaloq.tools.ddk.xtext.expression.generator.EClassComparator; import com.google.common.base.Function; import com.google.common.base.Functions; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; +import org.junit.jupiter.api.Test; @SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage") @@ -37,8 +37,8 @@ public class EClassComparatorTest { private final Function mapping = Functions. identity(); - @Test - public void testSorting() { + @org.junit.jupiter.api.Test + void testSorting() { List sorted = EClassComparator.sortedGroups(Lists.newArrayList(ECLASS, EDATA_TYPE, EPACKAGE, ECLASSIFIER), mapping); assertEquals(Lists.newArrayList(ECLASS, EDATA_TYPE, EPACKAGE, ECLASSIFIER), sorted); @@ -53,7 +53,7 @@ public void testSorting() { } @Test - public void testSortingWithEObject() { + void testSortingWithEObject() { List sorted = EClassComparator.sortedGroups(Lists.newArrayList(EOBJECT, ECLASS), mapping); assertEquals(Lists.newArrayList(ECLASS, EOBJECT), sorted); @@ -62,7 +62,7 @@ public void testSortingWithEObject() { } @Test - public void testSortingByEPackage() { + void testSortingByEPackage() { ListMultimap sorted = EClassComparator.sortedEPackageGroups(Lists.newArrayList(EOBJECT, ECLASS), mapping); assertEquals(2, sorted.size()); assertEquals(1, sorted.keySet().size()); diff --git a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/test/util/GraphTest.java b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/test/util/GraphTest.java index a822ee5125..11099aaf8d 100644 --- a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/test/util/GraphTest.java +++ b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/test/util/GraphTest.java @@ -10,13 +10,13 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.generator.test.util; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.expression.generator.Graph; import com.google.common.collect.HashMultimap; @@ -29,7 +29,7 @@ public class GraphTest { // CHECKSTYLE:CONSTANTS-OFF @Test - public void testTopologicalSorting() { + void testTopologicalSorting() { Multimap graph = HashMultimap.create(); graph.put("7", "11"); graph.put("7", "8"); @@ -47,7 +47,7 @@ public void testTopologicalSorting() { } @Test - public void testDependencyCycle() { + void testDependencyCycle() { Multimap graph = ImmutableMultimap.of("1", "2", "2", "3", "3", "1"); try { diff --git a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/xbase/test/XbaseGeneratorFragmentTest.xtend b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/xbase/test/XbaseGeneratorFragmentTest.xtend index abdec160f9..f20910b22e 100644 --- a/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/xbase/test/XbaseGeneratorFragmentTest.xtend +++ b/com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/xbase/test/XbaseGeneratorFragmentTest.xtend @@ -12,7 +12,6 @@ package com.avaloq.tools.ddk.xtext.generator.xbase.test import com.avaloq.tools.ddk.test.core.BugTest -import junit.framework.TestCase import org.eclipse.emf.common.util.BasicEList import org.eclipse.emf.ecore.EPackage import org.eclipse.xtext.AbstractElement @@ -26,7 +25,7 @@ import org.eclipse.xtext.RuleCall import org.eclipse.xtext.TypeRef import org.eclipse.xtext.XtextPackage import org.eclipse.xtext.testing.XtextRunner -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith import static org.mockito.Mockito.mock @@ -37,7 +36,7 @@ import org.eclipse.xtext.xtext.generator.xbase.XbaseUsageDetector * Tests for {@link XbaseUsageDetector}. */ @RunWith(XtextRunner) -class XbaseGeneratorFragmentTest extends TestCase { +class XbaseGeneratorFragmentTest { val thisPackageName = "thisPackage" val xtypePackageName = "xtype" diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractTest.java index cc8f7dfccc..8268ef2e3a 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractTest.java @@ -1,461 +1,463 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtext.test; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.common.util.WrappedException; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.runner.RunWith; - -import com.avaloq.tools.ddk.test.core.AfterAll; -import com.avaloq.tools.ddk.test.core.BeforeAll; -import com.avaloq.tools.ddk.test.core.BugTestAwareRule; -import com.avaloq.tools.ddk.test.core.IssueAwareRule; -import com.avaloq.tools.ddk.test.core.LoggingRule; -import com.avaloq.tools.ddk.test.core.mock.ExtensionRegistryMock; -import com.avaloq.tools.ddk.test.core.mock.ServiceMock; -import com.avaloq.tools.ddk.xtext.test.junit.runners.XtextClassRunner; -import com.google.common.collect.ImmutableList; - - -/** - * Provides a test class specific custom test framework for tests that run in the ACF environment. - * All exceptions are wrapped and handed over to the JUnit framework. - */ -@RunWith(XtextClassRunner.class) -public abstract class AbstractTest { - - /** - * Prefix for customer sources. - * Consider also: com.avaloq.tools.asmd.testbase.TestUtil.CUSTR_PREFIX - * The duplicated definition of the prefix must be harmonized based on harmonization of test plugins. - */ - protected static final String CUSTOMER_SOURCE_PREFIX = "custr_"; - - protected static final String PROJECT_NAME = "SDK"; - - private static final String HIGH_LATENCY_PROPERTY = "com.avaloq.tools.hl.supported"; - - private static final String LANGUAGE_VERSION_CACHING_PROPERTY = "com.avaloq.tools.LanguageConfigCaching"; - - private static Map, TestInformation> testInformationMap = new HashMap, TestInformation>(); - - @Rule - // CHECKSTYLE:CHECK-OFF Visibility MethodRules cannot be private - public final LoggingRule watchman = LoggingRule.getInstance(); - // CHECKSTYLE:CHECK-ON Visibility - - /** - * Enables support for unresolved bug tests. - */ - @Rule - // CHECKSTYLE:CHECK-OFF Visibility MethodRules cannot be private - public BugTestAwareRule bugTestRule = BugTestAwareRule.getInstance(); - // CHECKSTYLE:CHECK-ON Visibility - - @Rule - // CHECKSTYLE:CHECK-OFF VisibilityModifier - public final IssueAwareRule issueRule = IssueAwareRule.getInstance(); - - // CHECKSTYLE:CHECK-ON VisibilityModifier - - protected ITestProjectManager getTestProjectManager() { - return getTestUtil().getTestProjectManager(); - } - - /** - * Returns the URI for the given target source file. - * - * @param fullSourceName - * full source name - * @return URI of source - */ - public URI getTargetSourceUri(final String fullSourceName) { - return getTestProjectManager().createTestSourceUri(fullSourceName); - } - - /** - * Returns a list of all kernel source file names that this test will require. - * This can be overridden to extend or replace the returned list. - * - * @return list of all required kernel source file names - */ - protected List getRequiredSourceFileNames() { - List requiredSources = new LinkedList(); - String testSourceFileName = getTestSourceFileName(); - if (testSourceFileName != null && testSourceFileName.length() > 0) { - requiredSources.add(testSourceFileName); - } - return requiredSources; - } - - /** - * Registers all required sources for this test. - * This method can be overridden to register other required source files. - */ - protected void registerRequiredSources() { - addSourcesToWorkspace(getRequiredSourceFileNames()); - } - - /** - * Non-static instance set up before all tests. - */ - @BeforeAll - public final void setUp() { - synchronized (testInformationMap) { - if (!testInformationMap.containsKey(this.getClass())) { - testInformationMap.put(this.getClass(), new TestInformation()); - beforeAllTests(); - } - } - } - - /** - * Non-static instance tear down after all tests. - */ - @AfterAll - public final void tearDown() { - synchronized (testInformationMap) { - afterAllTests(); - ExtensionRegistryMock.assertUnMocked(); - ServiceMock.assertAllMocksRemoved(); - testInformationMap.remove(this.getClass()); - } - } - - /** - * This method prepares the test environment for a test. It is called by the JUnit framework before each test. - * If it is run the first time, it calls the beforeClass method first. Do not call this method manually! - * All exceptions are wrapped and handed over to the JUnit framework. - */ - @Before - public final void before() { - beforeEachTest(); - } - - /** - * This method cleans up the test environment after a test. It is called by the JUnit framework after each test. - * If no more tests are to be run, it calls the afterClass method. Do not call this method manually! - * All exceptions are wrapped and handed over to the JUnit framework. - */ - @After - public final void after() { - afterEachTest(); - } - - /** - * Prepares the test class after the test class has been instantiated. This method can be used to setup the test class before any test is run. - * Do not use JUnit annotation. - * Exceptions are wrapped and handed over to the JUnit framework. - */ - protected void beforeAllTests() { - // check method annotations to ensure test framework policies - System.setProperty(HIGH_LATENCY_PROPERTY, Boolean.FALSE.toString()); - System.setProperty(LANGUAGE_VERSION_CACHING_PROPERTY, Boolean.FALSE.toString()); - enforceAnnotationPolicies(); - getTestProjectManager().setup(ImmutableList. of()); - registerRequiredSources(); - getTestProjectManager().build(); - } - - /** - * After the last task has run but before the test class instance has been garbage collected, this method is called to clean up the test environment. - * Do not use JUnit annotation. - * All exceptions are wrapped and handed over to the JUnit framework. - */ - protected void afterAllTests() { - getTestProjectManager().teardown(); - System.clearProperty(LANGUAGE_VERSION_CACHING_PROPERTY); - System.setProperty(HIGH_LATENCY_PROPERTY, Boolean.TRUE.toString()); - } - - /** - * Prepares for the next test. This method can be used to (re-)initialize the test environment before a (next) test is run. Resource allocations must be dealt - * with in {@link afterEachTest}. - * Do not use JUnit annotation. - * All exceptions are wrapped and handed over to the JUnit framework. - */ - @SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract") - protected void beforeEachTest() { - // empty - } - - /** - * Called after each test to clean up initializations done in {@link beforeEachTest}. - * Do not use JUnit annotation. - * All exceptions are wrapped and handed over to the JUnit framework. - */ - @SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract") - protected void afterEachTest() { - // empty - } - - /** - * Registers a source that is required by the test class. - * The source will be removed from the system when {@link afterAllTests} is called. - * All exceptions are wrapped and handed over to the JUnit framework. - * - * @param sourceFileName - * the name of the file where the source is located, and where the content of the source shall be written to. This is the source name available - * during the test. - */ - protected void addSourceToWorkspace(final String sourceFileName) { - addSourceToWorkspace(sourceFileName, getResourceContent(sourceFileName)); - } - - /** - * Registers a kernel source that is required by the test class. - * The source will be removed from the system when {@link afterAllTests} is called. - * All exceptions are wrapped and handed over to the JUnit framework. - * - * @param sourceFileName - * the name of the file where the content of the source shall be written to. This is the source name available - * during the test. - * @param sourceContent - * the content of the source that shall be written to the file in workspace. - */ - protected void addKernelSourceToWorkspace(final String sourceFileName, final CharSequence sourceContent) { - addSourceToWorkspace(sourceFileName, sourceContent.toString()); - } - - /** - * Registers a customer source that is required by the test class. - * The source will be removed from the system when {@link afterAllTests} is called. - * All exceptions are wrapped and handed over to the JUnit framework. - * - * @param sourceFileName - * the name of the file where the content of the source shall be written to. This is the source name available - * during the test. - * @param sourceContent - * the content of the source that shall be written to the file in workspace. - */ - protected void addCustomerSourceToWorkspace(final String sourceFileName, final CharSequence sourceContent) { - addSourceToWorkspace(CUSTOMER_SOURCE_PREFIX.concat(sourceFileName), sourceContent.toString()); - } - - /** - * Registers a source that is required by the test class. - * The source will be removed from the system when {@link afterAllTests} is called. - * All exceptions are wrapped and handed over to the JUnit framework. - * - * @param sourceFileName - * the name of the file where the content of the source shall be written to. This is the source name available - * during the test. - * @param sourceContent - * the content of the source that shall be written to the file in workspace. - */ - private void addSourceToWorkspace(final String sourceFileName, final String sourceContent) { - createTestSource(sourceFileName, sourceContent); - } - - /** - * Returns the string contents of the loaded resource with the given name. - * - * @param sourceFileName - * the file name - * @return the string contents of the loaded resource - */ - protected String getResourceContent(final String sourceFileName) { - return TestSource.getResourceContent(this.getClass(), sourceFileName); - } - - /** - * Registers a set of sources that is required by the test class. - * The sources will be removed from the system when {@link afterAllTests} is called. - * All exceptions are wrapped and handed over to the JUnit framework. - * - * @param sourceFileNames - * the names of the files where the sources are located, and where the content of the sources shall be written to. - */ - private void addSourcesToWorkspace(final List sourceFileNames) { - try { - new WorkspaceModifyOperation() { - @Override - protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - for (String sourceFileName : sourceFileNames) { - addSourceToWorkspace(sourceFileName); - } - } - }.run(new NullProgressMonitor()); - } catch (InvocationTargetException e) { - throw new WrappedException("failed adding sources to workspace", e); - } catch (InterruptedException e) { - throw new WrappedException("adding sources to workspace interrupted", e); - } - } - - protected Collection getTestSources() { - return getTestProjectManager().getTestSources(); - } - - /** - * Returns the kernel {@link TestSource} for the given sourceFileName. - * - * @param sourceFileName - * the file name of the {@link TestSource} - * @return the {@link TestSource} for the given sourceFileName - */ - protected XtextTestSource getTestSource(final String sourceFileName) { - return (XtextTestSource) getTestProjectManager().getTestSource(sourceFileName); - } - - /** - * Returns the kernel {@link TestSource} for this test class. - * - * @return the {@link TestSource} for this test class - */ - protected TestSource getTestSource() { - return getTestProjectManager().getTestSource(getTestSourceFileName()); - } - - /** - * Get the name of the main test source file. - * - * @return the file name of the main test source file - */ - protected abstract String getTestSourceFileName(); - - /** - * The default implementation returns the name of the test class for the model name of the test source. - * A test class needs to override this, if the name of the main test source model differs from the default. - * - * @return the name of the main test source model - */ - protected String getTestSourceModelName() { - return this.getClass().getSimpleName(); - } - - /** - * Goes through all methods of this object and checks the annotations. - *

- * Methods with a {@link @BeforeClass} or {@link @AfterClass} annotation will cause an exception to be thrown. For that purpose, use the {@link - * beforeAllTests()} and {@link afterAllTests()} methods only. - *

- */ - private void enforceAnnotationPolicies() { - for (Method method : this.getClass().getMethods()) { - // use this policy to not allow BeforeClass or AfterClass annotations. - if (method.isAnnotationPresent(BeforeClass.class) || method.isAnnotationPresent(AfterClass.class)) { - throw new IllegalJUnitAnnotation(); - } - // use this policy to not allow Before or After annotations in subclasses. - // if (!method.getDeclaringClass().equals(AbstractXtextTest.class) && (method.isAnnotationPresent(Before.class) || - // method.isAnnotationPresent(After.class))) { - // throw new - // IllegalJUnitAnnotation("Invalid annotation found. Before and After annotations are not permitted when using the AbstractXtextTest framework. Override - // the methods 'before' and 'after' instead."); - // } - } - } - - /** - * Wait for validation jobs to finish. - */ - protected void waitForValidation() { - waitForJobsOfFamily(org.eclipse.xtext.ui.editor.validation.ValidationJob.XTEXT_VALIDATION_FAMILY); - } - - /** - * Wait for jobs of a given family to finish. - * - * @param family - * to wait for. - */ - protected void waitForJobsOfFamily(final Object family) { - getTestUtil().waitForJobsOfFamily(family); - } - - /** - * Wait for synchronization jobs on opening/closing the editor. - * - * @param editor - * editor part - */ - protected void waitForEditorJobs(final IEditorPart editor) { - getTestUtil().waitForEditorJobs(editor); - } - - /** - * Wait for jobs of a given family to appear. A {@code null} family will - * cause this to wait for any job. - * - * @param family - * to wait for, may be {@code null} - * @param timeout - * ms to wait for. - */ - protected void waitForJobOfFamilyToAppear(final Object family, final long timeout) { - final long timeLimit = System.currentTimeMillis() + timeout; - do { - if (Job.getJobManager().find(family).length > 0) { - return; - } - } while (System.currentTimeMillis() < timeLimit); - } - - /** - * Returns the test information for the current test class. - * - * @return information for the current test class - */ - protected TestInformation getTestInformation() { - synchronized (testInformationMap) { - return testInformationMap.get(this.getClass()); - } - } - - /** - * Create a test source for testing from an existing file. - * - * @param sourceFileName - * file name for source - * @param content - * content of source - * @return a new {@link TestSource} with the given parameters - */ - - protected TestSource createTestSource(final String sourceFileName, final String content) { - TestSource testSource = new TestSource(sourceFileName, content); - getTestProjectManager().addSourceToProject(testSource); - return testSource; - } - - /** - * Get the test class utility for this test. The minimum functionality is given by - * AbstractTestUtil, which does not require that any methods be overridden. Tests - * that require more than this minimal functionality must override this method. - *

- * This method is expected to always return the same instance, even when invoked on different instances of the test class. This is because the associated - * {@link ITestProjectManager} is stateful and required by {@link #beforeAllTests()}, {@link #afterAllTests()}, and {@link #getTestSources()}. - * - * @return the test class utility for this test. - */ - protected abstract AbstractTestUtil getTestUtil(); - -} +/******************************************************************************* + * Copyright (c) 2016 Avaloq Group AG and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Avaloq Group AG - initial API and implementation + *******************************************************************************/ +package com.avaloq.tools.ddk.xtext.test; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.common.util.WrappedException; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.Rule; +import org.junit.runner.RunWith; + +import com.avaloq.tools.ddk.test.core.AfterAll; +import com.avaloq.tools.ddk.test.core.BeforeAll; +import com.avaloq.tools.ddk.test.core.BugTestAwareRule; +import com.avaloq.tools.ddk.test.core.IssueAwareRule; +import com.avaloq.tools.ddk.test.core.LoggingRule; +import com.avaloq.tools.ddk.test.core.mock.ExtensionRegistryMock; +import com.avaloq.tools.ddk.test.core.mock.ServiceMock; +import com.avaloq.tools.ddk.xtext.test.junit.runners.XtextClassRunner; +import com.google.common.collect.ImmutableList; + + +/** + * Provides a test class specific custom test framework for tests that run in the ACF environment. + * All exceptions are wrapped and handed over to the JUnit framework. + */ +@RunWith(XtextClassRunner.class) +public abstract class AbstractTest { + + /** + * Prefix for customer sources. + * Consider also: com.avaloq.tools.asmd.testbase.TestUtil.CUSTR_PREFIX + * The duplicated definition of the prefix must be harmonized based on harmonization of test plugins. + */ + protected static final String CUSTOMER_SOURCE_PREFIX = "custr_"; + + protected static final String PROJECT_NAME = "SDK"; + + private static final String HIGH_LATENCY_PROPERTY = "com.avaloq.tools.hl.supported"; + + private static final String LANGUAGE_VERSION_CACHING_PROPERTY = "com.avaloq.tools.LanguageConfigCaching"; + + private static Map, TestInformation> testInformationMap = new HashMap, TestInformation>(); + + @Rule + // CHECKSTYLE:CHECK-OFF Visibility MethodRules cannot be private + public final LoggingRule watchman = LoggingRule.getInstance(); + // CHECKSTYLE:CHECK-ON Visibility + + /** + * Enables support for unresolved bug tests. + */ + @Rule + // CHECKSTYLE:CHECK-OFF Visibility MethodRules cannot be private + public BugTestAwareRule bugTestRule = BugTestAwareRule.getInstance(); + // CHECKSTYLE:CHECK-ON Visibility + + @Rule + // CHECKSTYLE:CHECK-OFF VisibilityModifier + public final IssueAwareRule issueRule = IssueAwareRule.getInstance(); + + // CHECKSTYLE:CHECK-ON VisibilityModifier + + protected ITestProjectManager getTestProjectManager() { + return getTestUtil().getTestProjectManager(); + } + + /** + * Returns the URI for the given target source file. + * + * @param fullSourceName + * full source name + * @return URI of source + */ + public URI getTargetSourceUri(final String fullSourceName) { + return getTestProjectManager().createTestSourceUri(fullSourceName); + } + + /** + * Returns a list of all kernel source file names that this test will require. + * This can be overridden to extend or replace the returned list. + * + * @return list of all required kernel source file names + */ + protected List getRequiredSourceFileNames() { + List requiredSources = new LinkedList(); + String testSourceFileName = getTestSourceFileName(); + if (testSourceFileName != null && testSourceFileName.length() > 0) { + requiredSources.add(testSourceFileName); + } + return requiredSources; + } + + /** + * Registers all required sources for this test. + * This method can be overridden to register other required source files. + */ + protected void registerRequiredSources() { + addSourcesToWorkspace(getRequiredSourceFileNames()); + } + + /** + * Non-static instance set up before all tests. + */ + @BeforeAll + public final void setUp() { + synchronized (testInformationMap) { + if (!testInformationMap.containsKey(this.getClass())) { + testInformationMap.put(this.getClass(), new TestInformation()); + beforeAllTests(); + } + } + } + + /** + * Non-static instance tear down after all tests. + */ + @AfterAll + public final void tearDown() { + synchronized (testInformationMap) { + afterAllTests(); + ExtensionRegistryMock.assertUnMocked(); + ServiceMock.assertAllMocksRemoved(); + testInformationMap.remove(this.getClass()); + } + } + + /** + * This method prepares the test environment for a test. It is called by the JUnit framework before each test. + * If it is run the first time, it calls the beforeClass method first. Do not call this method manually! + * All exceptions are wrapped and handed over to the JUnit framework. + */ + @BeforeEach + public final void before() { + beforeEachTest(); + } + + /** + * This method cleans up the test environment after a test. It is called by the JUnit framework after each test. + * If no more tests are to be run, it calls the afterClass method. Do not call this method manually! + * All exceptions are wrapped and handed over to the JUnit framework. + */ + @AfterEach + public final void after() { + afterEachTest(); + } + + /** + * Prepares the test class after the test class has been instantiated. This method can be used to setup the test class before any test is run. + * Do not use JUnit annotation. + * Exceptions are wrapped and handed over to the JUnit framework. + */ + protected void beforeAllTests() { + // check method annotations to ensure test framework policies + System.setProperty(HIGH_LATENCY_PROPERTY, Boolean.FALSE.toString()); + System.setProperty(LANGUAGE_VERSION_CACHING_PROPERTY, Boolean.FALSE.toString()); + enforceAnnotationPolicies(); + getTestProjectManager().setup(ImmutableList. of()); + registerRequiredSources(); + getTestProjectManager().build(); + } + + /** + * After the last task has run but before the test class instance has been garbage collected, this method is called to clean up the test environment. + * Do not use JUnit annotation. + * All exceptions are wrapped and handed over to the JUnit framework. + */ + protected void afterAllTests() { + getTestProjectManager().teardown(); + System.clearProperty(LANGUAGE_VERSION_CACHING_PROPERTY); + System.setProperty(HIGH_LATENCY_PROPERTY, Boolean.TRUE.toString()); + } + + /** + * Prepares for the next test. This method can be used to (re-)initialize the test environment before a (next) test is run. Resource allocations must be dealt + * with in {@link afterEachTest}. + * Do not use JUnit annotation. + * All exceptions are wrapped and handed over to the JUnit framework. + */ + @SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract") + protected void beforeEachTest() { + // empty + } + + /** + * Called after each test to clean up initializations done in {@link beforeEachTest}. + * Do not use JUnit annotation. + * All exceptions are wrapped and handed over to the JUnit framework. + */ + @SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract") + protected void afterEachTest() { + // empty + } + + /** + * Registers a source that is required by the test class. + * The source will be removed from the system when {@link afterAllTests} is called. + * All exceptions are wrapped and handed over to the JUnit framework. + * + * @param sourceFileName + * the name of the file where the source is located, and where the content of the source shall be written to. This is the source name available + * during the test. + */ + protected void addSourceToWorkspace(final String sourceFileName) { + addSourceToWorkspace(sourceFileName, getResourceContent(sourceFileName)); + } + + /** + * Registers a kernel source that is required by the test class. + * The source will be removed from the system when {@link afterAllTests} is called. + * All exceptions are wrapped and handed over to the JUnit framework. + * + * @param sourceFileName + * the name of the file where the content of the source shall be written to. This is the source name available + * during the test. + * @param sourceContent + * the content of the source that shall be written to the file in workspace. + */ + protected void addKernelSourceToWorkspace(final String sourceFileName, final CharSequence sourceContent) { + addSourceToWorkspace(sourceFileName, sourceContent.toString()); + } + + /** + * Registers a customer source that is required by the test class. + * The source will be removed from the system when {@link afterAllTests} is called. + * All exceptions are wrapped and handed over to the JUnit framework. + * + * @param sourceFileName + * the name of the file where the content of the source shall be written to. This is the source name available + * during the test. + * @param sourceContent + * the content of the source that shall be written to the file in workspace. + */ + protected void addCustomerSourceToWorkspace(final String sourceFileName, final CharSequence sourceContent) { + addSourceToWorkspace(CUSTOMER_SOURCE_PREFIX.concat(sourceFileName), sourceContent.toString()); + } + + /** + * Registers a source that is required by the test class. + * The source will be removed from the system when {@link afterAllTests} is called. + * All exceptions are wrapped and handed over to the JUnit framework. + * + * @param sourceFileName + * the name of the file where the content of the source shall be written to. This is the source name available + * during the test. + * @param sourceContent + * the content of the source that shall be written to the file in workspace. + */ + private void addSourceToWorkspace(final String sourceFileName, final String sourceContent) { + createTestSource(sourceFileName, sourceContent); + } + + /** + * Returns the string contents of the loaded resource with the given name. + * + * @param sourceFileName + * the file name + * @return the string contents of the loaded resource + */ + protected String getResourceContent(final String sourceFileName) { + return TestSource.getResourceContent(this.getClass(), sourceFileName); + } + + /** + * Registers a set of sources that is required by the test class. + * The sources will be removed from the system when {@link afterAllTests} is called. + * All exceptions are wrapped and handed over to the JUnit framework. + * + * @param sourceFileNames + * the names of the files where the sources are located, and where the content of the sources shall be written to. + */ + private void addSourcesToWorkspace(final List sourceFileNames) { + try { + new WorkspaceModifyOperation() { + @Override + protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { + for (String sourceFileName : sourceFileNames) { + addSourceToWorkspace(sourceFileName); + } + } + }.run(new NullProgressMonitor()); + } catch (InvocationTargetException e) { + throw new WrappedException("failed adding sources to workspace", e); + } catch (InterruptedException e) { + throw new WrappedException("adding sources to workspace interrupted", e); + } + } + + protected Collection getTestSources() { + return getTestProjectManager().getTestSources(); + } + + /** + * Returns the kernel {@link TestSource} for the given sourceFileName. + * + * @param sourceFileName + * the file name of the {@link TestSource} + * @return the {@link TestSource} for the given sourceFileName + */ + protected XtextTestSource getTestSource(final String sourceFileName) { + return (XtextTestSource) getTestProjectManager().getTestSource(sourceFileName); + } + + /** + * Returns the kernel {@link TestSource} for this test class. + * + * @return the {@link TestSource} for this test class + */ + protected TestSource getTestSource() { + TestSource testSource = getTestProjectManager().getTestSource(getTestSourceFileName()); + // Assertions.assertNotNull("TestSource for this test class can be found: " + getTestSourceFileName(), testSource); + return testSource; + } + + /** + * Get the name of the main test source file. + * + * @return the file name of the main test source file + */ + protected abstract String getTestSourceFileName(); + + /** + * The default implementation returns the name of the test class for the model name of the test source. + * A test class needs to override this, if the name of the main test source model differs from the default. + * + * @return the name of the main test source model + */ + protected String getTestSourceModelName() { + return this.getClass().getSimpleName(); + } + + /** + * Goes through all methods of this object and checks the annotations. + *

+ * Methods with a {@link @BeforeClass} or {@link @AfterClass} annotation will cause an exception to be thrown. For that purpose, use the {@link + * beforeAllTests()} and {@link afterAllTests()} methods only. + *

+ */ + private void enforceAnnotationPolicies() { + for (Method method : this.getClass().getMethods()) { + // use this policy to not allow BeforeClass or AfterClass annotations. + if (method.isAnnotationPresent(BeforeAll.class) || method.isAnnotationPresent(AfterAll.class)) { + throw new IllegalJUnitAnnotation(); + } + // use this policy to not allow Before or After annotations in subclasses. + // if (!method.getDeclaringClass().equals(AbstractXtextTest.class) && (method.isAnnotationPresent(Before.class) || + // method.isAnnotationPresent(After.class))) { + // throw new + // IllegalJUnitAnnotation("Invalid annotation found. Before and After annotations are not permitted when using the AbstractXtextTest framework. Override + // the methods 'before' and 'after' instead."); + // } + } + } + + /** + * Wait for validation jobs to finish. + */ + protected void waitForValidation() { + waitForJobsOfFamily(org.eclipse.xtext.ui.editor.validation.ValidationJob.XTEXT_VALIDATION_FAMILY); + } + + /** + * Wait for jobs of a given family to finish. + * + * @param family + * to wait for. + */ + protected void waitForJobsOfFamily(final Object family) { + getTestUtil().waitForJobsOfFamily(family); + } + + /** + * Wait for synchronization jobs on opening/closing the editor. + * + * @param editor + * editor part + */ + protected void waitForEditorJobs(final IEditorPart editor) { + getTestUtil().waitForEditorJobs(editor); + } + + /** + * Wait for jobs of a given family to appear. A {@code null} family will + * cause this to wait for any job. + * + * @param family + * to wait for, may be {@code null} + * @param timeout + * ms to wait for. + */ + protected void waitForJobOfFamilyToAppear(final Object family, final long timeout) { + final long timeLimit = System.currentTimeMillis() + timeout; + do { + if (Job.getJobManager().find(family).length > 0) { + return; + } + } while (System.currentTimeMillis() < timeLimit); + } + + /** + * Returns the test information for the current test class. + * + * @return information for the current test class + */ + protected TestInformation getTestInformation() { + synchronized (testInformationMap) { + return testInformationMap.get(this.getClass()); + } + } + + /** + * Create a test source for testing from an existing file. + * + * @param sourceFileName + * file name for source + * @param content + * content of source + * @return a new {@link TestSource} with the given parameters + */ + + protected TestSource createTestSource(final String sourceFileName, final String content) { + TestSource testSource = new TestSource(sourceFileName, content); + getTestProjectManager().addSourceToProject(testSource); + return testSource; + } + + /** + * Get the test class utility for this test. The minimum functionality is given by + * AbstractTestUtil, which does not require that any methods be overridden. Tests + * that require more than this minimal functionality must override this method. + *

+ * This method is expected to always return the same instance, even when invoked on different instances of the test class. This is because the associated + * {@link ITestProjectManager} is stateful and required by {@link #beforeAllTests()}, {@link #afterAllTests()}, and {@link #getTestSources()}. + * + * @return the test class utility for this test. + */ + protected abstract AbstractTestUtil getTestUtil(); + +} diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractXtextMarkerBasedTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractXtextMarkerBasedTest.java index 9032a4011f..619ccd8a53 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractXtextMarkerBasedTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractXtextMarkerBasedTest.java @@ -10,10 +10,10 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.Collections; @@ -30,7 +30,7 @@ import org.eclipse.xtext.nodemodel.INode; import org.eclipse.xtext.nodemodel.util.NodeModelUtils; import org.eclipse.xtext.xbase.lib.Procedures; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Lists; @@ -98,7 +98,7 @@ protected void afterEachTest() { protected void beforeEachTest() { localMarkerIdCounter = 0; super.beforeEachTest(); - Assert.assertFalse(INVALID_TEST_CONFIGURATION, getMarkerTagsInfo().isInvalidTestClass()); + Assertions.assertFalse(INVALID_TEST_CONFIGURATION, getMarkerTagsInfo().isInvalidTestClass()); } // -------------------------------------------------------------------------- @@ -269,7 +269,7 @@ protected String addAssertion(final AbstractModelAssertion assertion) { * @return Mark text to be inserted in the source file, never {@code null} */ protected String mark(final int id) { - Assert.assertFalse("Tag with " + id + " used to mark more than one location.", usedTags.contains(id)); //$NON-NLS-1$ //$NON-NLS-2$ + Assertions.assertFalse("Tag with " + id + " used to mark more than one location.", usedTags.contains(id)); //$NON-NLS-1$ //$NON-NLS-2$ usedTags.add(id); if (id < 1) { getMarkerTagsInfo().setTestClassInvalid(); diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractXtextTestUtil.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractXtextTestUtil.java index b56948946a..65334ad5fe 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractXtextTestUtil.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AbstractXtextTestUtil.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test; //NOPMD -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 java.io.IOException; import java.io.InputStream; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AcfContentAssistProcessorTestBuilder.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AcfContentAssistProcessorTestBuilder.java index 8415facde0..9f17a572cf 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AcfContentAssistProcessorTestBuilder.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/AcfContentAssistProcessorTestBuilder.java @@ -11,7 +11,7 @@ package com.avaloq.tools.ddk.xtext.test; // CHECKSTYLE:OFF -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.text.MessageFormat; @@ -33,7 +33,7 @@ import org.eclipse.xtext.util.Pair; import org.eclipse.xtext.util.StringInputStream; import org.eclipse.xtext.util.Tuples; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.xtext.ui.util.Function; import com.avaloq.tools.ddk.xtext.ui.util.UiThreadDispatcher; @@ -183,11 +183,11 @@ public BadLocationException run() { ContentAssistContext.Factory factory = get(ContentAssistContext.Factory.class); ContentAssistContext[] contexts = factory.create(sourceViewer, currentModelToParse.length(), xtextResource); for (ContentAssistContext context : contexts) { - Assert.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'", "".equals(context.getPrefix()) + Assertions.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'", "".equals(context.getPrefix()) || matchString.equals(context.getPrefix())); } } else { - Assert.fail("No content assistant for content type " + contentType); + Assertions.fail("No content assistant for content type " + contentType); } } catch (BadLocationException e) { return e; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/contentassist/AbstractAcfContentAssistTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/contentassist/AbstractAcfContentAssistTest.java index 569fc457e7..04121d71c1 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/contentassist/AbstractAcfContentAssistTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/contentassist/AbstractAcfContentAssistTest.java @@ -10,9 +10,9 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.contentassist; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.text.MessageFormat; import java.util.Arrays; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/conversion/AbstractValueConverterServiceTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/conversion/AbstractValueConverterServiceTest.java index 1a877b1ea9..0bcf9d031b 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/conversion/AbstractValueConverterServiceTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/conversion/AbstractValueConverterServiceTest.java @@ -10,9 +10,9 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.conversion; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Collection; import java.util.List; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/formatting/AbstractFormattingTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/formatting/AbstractFormattingTest.java index 561c3aff58..5852144e67 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/formatting/AbstractFormattingTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/formatting/AbstractFormattingTest.java @@ -18,8 +18,8 @@ import org.eclipse.xtext.nodemodel.ICompositeNode; import org.eclipse.xtext.nodemodel.util.NodeModelUtils; import org.eclipse.xtext.resource.SaveOptions; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.test.AbstractXtextTest; @@ -68,7 +68,7 @@ protected String getExpectedTestSourceFileName() { * Test formatting based on the NodeModel. */ @Test - public void formattedNodeModel() { + void formattedNodeModel() { assertFormattedNodeModel(); } @@ -89,8 +89,8 @@ public void preservedParseTreeConstructor() { /** * Test preservation of formatting using NodeModelFormatter. */ - @Test - public void preservedNodeModel() { + @org.junit.jupiter.api.Test + void preservedNodeModel() { assertPreservedNodeModel(); } @@ -145,7 +145,7 @@ protected final void assertPreservedParseTreeConstructor() { */ private void assertFormattedParseTreeConstructor(final EObject model, final String expected) { String actual = getXtextTestUtil().getSerializer().serialize(model, SaveOptions.newBuilder().format().getOptions()); - Assert.assertEquals("Formatted ParseTree", expected.replaceAll(CR_LF, LF), actual.replaceAll(CR_LF, LF)); + Assertions.assertEquals("Formatted ParseTree", expected.replaceAll(CR_LF, LF), actual.replaceAll(CR_LF, LF)); } /** @@ -166,7 +166,7 @@ private void assertFormattedNodeModel(final EObject model, final String input, f ICompositeNode node = NodeModelUtils.getNode(model).getRootNode(); IFormattedRegion region = getXtextTestUtil().get(INodeModelFormatter.class).format(node, offset, length); String actual = input.substring(0, offset) + region.getFormattedText() + input.substring(length + offset); - Assert.assertEquals("Formatted NodeModel", expected.replaceAll(CR_LF, LF), actual.replaceAll(CR_LF, LF)); + Assertions.assertEquals("Formatted NodeModel", expected.replaceAll(CR_LF, LF), actual.replaceAll(CR_LF, LF)); } } diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/generator/AbstractGeneratorTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/generator/AbstractGeneratorTest.java index 9e36e07819..b5d2422a3c 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/generator/AbstractGeneratorTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/generator/AbstractGeneratorTest.java @@ -44,8 +44,8 @@ import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil; import org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil; import org.eclipse.xtext.ui.util.PluginProjectFactory; -import org.junit.AfterClass; -import org.junit.Assert; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; import com.google.common.base.Functions; import com.google.common.base.Predicate; @@ -92,7 +92,7 @@ public abstract class AbstractGeneratorTest { /** * Clean up after all tests have terminated. */ - @AfterClass + @AfterAll public static void cleanUp() { try { IResourcesSetupUtil.cleanWorkspace(); @@ -321,15 +321,15 @@ protected void execute(final IProgressMonitor monitor) throws CoreException, Inv IResourcesSetupUtil.createFile(resourceURI.toPlatformString(true), contents); } catch (IOException e) { LOGGER.error("failed adding file to workspace: " + outputFileName, e); //$NON-NLS-1$ - Assert.fail("Error adding file " + outputFileName + " to workspace: " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ + Assertions.fail("Error adding file " + outputFileName + " to workspace: " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } } } }.run(new NullProgressMonitor()); } catch (InvocationTargetException e) { - Assert.fail("Error adding files to workspace: " + e.getMessage()); //$NON-NLS-1$ + Assertions.fail("Error adding files to workspace: " + e.getMessage()); //$NON-NLS-1$ } catch (InterruptedException e) { - Assert.fail("Error adding files to workspace: " + e.getMessage()); //$NON-NLS-1$ + Assertions.fail("Error adding files to workspace: " + e.getMessage()); //$NON-NLS-1$ } } @@ -404,10 +404,10 @@ public String getContents(final String resourceName) throws IOException { */ public void assertFileGenerated(final String projectName, final String fileName, final String expectedGeneratedContent) throws IOException, CoreException { IFile generatedFile = getFileFromProject(projectName, fileName); - Assert.assertTrue(MessageFormat.format(MESSAGE_GENERATED_FILE_MUST_EXIST, generatedFile.toString()), generatedFile.exists()); + Assertions.assertTrue(MessageFormat.format(MESSAGE_GENERATED_FILE_MUST_EXIST, generatedFile.toString()), generatedFile.exists()); String actualGeneratedContent = getContents(generatedFile); - Assert.assertEquals(MessageFormat.format(MESSAGE_GENERATED_CODE_MUST_BE_CORRECT, generatedFile.toString()), expectedGeneratedContent, actualGeneratedContent); + Assertions.assertEquals(MessageFormat.format(MESSAGE_GENERATED_CODE_MUST_BE_CORRECT, generatedFile.toString()), expectedGeneratedContent, actualGeneratedContent); } /** diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/junit/runners/XtextClassRunner.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/junit/runners/XtextClassRunner.java index b616167c5c..2618b3a96d 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/junit/runners/XtextClassRunner.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/junit/runners/XtextClassRunner.java @@ -20,13 +20,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.eclipse.xtext.testing.XtextRunner; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; import org.junit.internal.AssumptionViolatedException; import org.junit.internal.runners.model.EachTestNotifier; import org.junit.internal.runners.statements.RunAfters; import org.junit.internal.runners.statements.RunBefores; +import org.junit.jupiter.api.Test; import org.junit.runner.Description; import org.junit.runner.manipulation.Filter; import org.junit.runner.manipulation.NoTestsRemainException; @@ -61,7 +61,7 @@ *

*

Test Methods

Considered are all those methods of the test class that are annotated with one (or more) of the following test annotations: *
    - *
  • {@link Test} + *
  • {@link org.junit.jupiter.api.Test} *
  • {@link UnitTest} *
  • {@link ModuleTest} *
  • {@link IntegrationTest} @@ -102,7 +102,7 @@ public class XtextClassRunner extends XtextRunner { /** Class-wide logger. */ private static final Logger LOGGER = LogManager.getLogger(XtextClassRunner.class); @SuppressWarnings("unchecked") - private static final List> TEST_ANNOTATIONS = Lists.newArrayList(Test.class, UnitTest.class, ModuleTest.class, IntegrationTest.class, SystemTest.class, PerformanceTest.class, BugTest.class); + private static final List> TEST_ANNOTATIONS = Lists.newArrayList(org.junit.jupiter.api.Test.class, UnitTest.class, ModuleTest.class, IntegrationTest.class, SystemTest.class, PerformanceTest.class, BugTest.class); private List expectedMethods; private int currentMethodIndex; private final int testRuns; @@ -141,7 +141,7 @@ private void ensureInitialized() { expectedMethods = ImmutableList.copyOf(Iterables.filter(testMethods, new Predicate() { @Override public boolean apply(final FrameworkMethod input) { - return input.getAnnotation(Ignore.class) == null; + return input.getAnnotation(Disabled.class) == null; } })); currentMethodIndex = 0; @@ -185,9 +185,9 @@ public void filter(final Filter filter) throws NoTestsRemainException { @Override protected void runChild(final FrameworkMethod method, final RunNotifier notifier) { ensureInitialized(); - final boolean ignored = method.getAnnotation(Ignore.class) != null; + final boolean ignored = method.getAnnotation(Disabled.class) != null; if (!ignored) { - Assert.assertEquals("Method " + method.getName() + " not equal", expectedMethods.get(currentMethodIndex++), method); //$NON-NLS-1$//$NON-NLS-2$ + Assertions.assertEquals("Method " + method.getName() + " not equal", expectedMethods.get(currentMethodIndex++), method); //$NON-NLS-1$//$NON-NLS-2$ } if (ignored || testRuns == 1 && testRetries == 0 && method.getAnnotation(Retry.class) == null) { super.runChild(method, notifier); diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/linking/AbstractLinkingTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/linking/AbstractLinkingTest.java index 14e5266204..c57fc21ea2 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/linking/AbstractLinkingTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/linking/AbstractLinkingTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.linking; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/model/ModelUtil.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/model/ModelUtil.java index 38153b6509..121b96949c 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/model/ModelUtil.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/model/ModelUtil.java @@ -14,7 +14,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; @@ -84,7 +84,7 @@ public Iterable getAllInstancesOf(final EObject context, // CHECKSTYLE:ON return Iterables.filter(getAllInstancesOf(context, type), input -> { if (input.eClass().getEStructuralFeature(feature.getFeatureID()) != feature) { - Assert.fail("Feature " + feature + " is not a feature of " + input.eClass()); + Assertions.fail("Feature " + feature + " is not a feature of " + input.eClass()); } final Object valueOfFeature = input.eGet(feature); return valueOfFeature != null && valueOfFeature.equals(value); diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/modelinference/AbstractModelInferrerTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/modelinference/AbstractModelInferrerTest.java index 4d4245bb64..e293e34ffc 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/modelinference/AbstractModelInferrerTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/modelinference/AbstractModelInferrerTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.modelinference; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; import java.util.Set; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/resource/AbstractResourceDescriptionManagerTest.xtend b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/resource/AbstractResourceDescriptionManagerTest.xtend index f8b03f2670..7988271470 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/resource/AbstractResourceDescriptionManagerTest.xtend +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/resource/AbstractResourceDescriptionManagerTest.xtend @@ -18,7 +18,7 @@ import org.eclipse.emf.common.util.URI import java.util.Collection import org.eclipse.xtext.resource.IResourceDescription.Delta import com.google.common.collect.HashMultiset -import org.junit.Assert +import org.junit.jupiter.api.Assertions import com.google.common.collect.Sets import com.avaloq.tools.ddk.xtext.test.TestSource @@ -193,6 +193,6 @@ abstract class AbstractResourceDescriptionManagerTest extends AbstractXtextTest */ def assertDeltaAffectedResources(Collection deltas, Collection candidates, Collection expectedUris) { val result = getResourceDescriptionManager().getAffectedResources(deltas, candidates, getResourceDescriptions()); - Assert.assertEquals("Affected URIs must be correct.", HashMultiset.create(expectedUris), HashMultiset.create(result)); + Assertions.assertEquals("Affected URIs must be correct.", HashMultiset.create(expectedUris), HashMultiset.create(result)); } } diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/scoping/AbstractScopingTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/scoping/AbstractScopingTest.java index ad5df858a6..b57637671c 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/scoping/AbstractScopingTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/scoping/AbstractScopingTest.java @@ -17,11 +17,11 @@ import static com.avaloq.tools.ddk.xtext.resource.AbstractSelectorFragmentProvider.SELECTOR_START; import static com.avaloq.tools.ddk.xtext.resource.AbstractSelectorFragmentProvider.UNIQUE; import static com.avaloq.tools.ddk.xtext.resource.AbstractSelectorFragmentProvider.VALUE_SEP; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.ArrayList; import java.util.Collection; @@ -32,7 +32,6 @@ import java.util.function.Supplier; import java.util.regex.Pattern; -import org.eclipse.core.runtime.Assert; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EClass; @@ -55,6 +54,7 @@ import org.eclipse.xtext.scoping.IScopeProvider; import org.eclipse.xtext.util.Triple; import org.eclipse.xtext.xbase.lib.Pair; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.caching.Regexps; import com.avaloq.tools.ddk.xtext.linking.AbstractFragmentProvider; @@ -240,7 +240,7 @@ protected void assertScope(final EObject context, final EReference reference, fi * for given scope, must not be {@code null} */ protected void assertScopedObjects(final EObject context, final EReference reference, final EObject... expectedObjects) { - Assert.isNotNull(expectedObjects, PARAMETER_EXPECTED_OBJECTS); + Assertions.isNotNull(expectedObjects, PARAMETER_EXPECTED_OBJECTS); assertScopedObjects(context, reference, Lists.newArrayList(expectedObjects)); } @@ -258,8 +258,8 @@ protected void assertScopedObjects(final EObject context, final EReference refer */ @SuppressWarnings("unchecked") protected void assertScopedObjects(final EObject context, final EReference reference, final Collection firstExpectedObjectCollection, final Collection... furtherExpectedObjectCollections) { - Assert.isNotNull(firstExpectedObjectCollection, "firstExpectedObjectCollection"); - Assert.isNotNull(furtherExpectedObjectCollections, "furtherExpectedObjectCollections"); + Assertions.isNotNull(firstExpectedObjectCollection, "firstExpectedObjectCollection"); + Assertions.isNotNull(furtherExpectedObjectCollections, "furtherExpectedObjectCollections"); Collection consolidatedList = Lists.newArrayList(firstExpectedObjectCollection); for (Collection expectedObjects : furtherExpectedObjectCollections) { consolidatedList.addAll(expectedObjects); @@ -281,10 +281,10 @@ protected void assertScopedObjects(final EObject context, final EReference refer * the objects expected in the scope, must not be {@code null} */ protected void assertScopedObjects(final EObject context, final EReference reference, final Collection expectedObjects) { - Assert.isNotNull(context, PARAMETER_CONTEXT); - Assert.isNotNull(reference, PARAMETER_REFERENCE); - Assert.isNotNull(expectedObjects, PARAMETER_EXPECTED_OBJECTS); - Assert.isTrue(context.eClass().getEAllReferences().contains(reference), String.format("Contract for argument '%s' failed: Parameter is not within specified range (Expected: %s, Actual: %s).", PARAMETER_CONTEXT, "The context object must contain the given reference.", "Reference not contained by the context object!")); + Assertions.isNotNull(context, PARAMETER_CONTEXT); + Assertions.isNotNull(reference, PARAMETER_REFERENCE); + Assertions.isNotNull(expectedObjects, PARAMETER_EXPECTED_OBJECTS); + Assertions.isTrue(context.eClass().getEAllReferences().contains(reference), String.format("Contract for argument '%s' failed: Parameter is not within specified range (Expected: %s, Actual: %s).", PARAMETER_CONTEXT, "The context object must contain the given reference.", "Reference not contained by the context object!")); Set expectedUriSet = Sets.newHashSet(); for (EObject object : expectedObjects) { expectedUriSet.add(EcoreUtil.getURI(object)); diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractUiTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractUiTest.java index 43683ac964..255dd1063a 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractUiTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractUiTest.java @@ -114,7 +114,7 @@ public SwtWorkbenchBot getBot() { * @return the editor part or null */ protected IEditorPart openEditor(final IFile file, final String editorId, final boolean activate) { - UiAssert.isNotUiThread(); + UiAssertions.isNotUiThread(); IEditorPart editor = UIThreadRunnable.syncExec(getBot().getDisplay(), new Result() { @Override public IEditorPart run() { @@ -149,7 +149,7 @@ public IEditorPart run() { * true if should save before close, false otherwise */ protected void closeEditor(final IEditorPart editor, final boolean save) { - UiAssert.isNotUiThread(); + UiAssertions.isNotUiThread(); Object editorJobs = getTestUtil().getEditorJobFamily(editor); UIThreadRunnable.syncExec(getBot().getDisplay(), new VoidResult() { @Override diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractXtextEditorTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractXtextEditorTest.java index c0f4e81eb2..9f5b237079 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractXtextEditorTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractXtextEditorTest.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.ui; -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 org.eclipse.emf.common.util.WrappedException; import org.eclipse.jface.text.BadLocationException; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractXtextUiTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractXtextUiTest.java index 5c5e92d2f5..ba214a4603 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractXtextUiTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/AbstractXtextUiTest.java @@ -88,7 +88,7 @@ protected void afterAllTests() { * @return {@link IEditorPart} created */ private IEditorPart openEditor(final org.eclipse.emf.common.util.URI uri, final boolean activate) { - UiAssert.isNotUiThread(); + UiAssertions.isNotUiThread(); final IEditorPart editorPart = UIThreadRunnable.syncExec(getBot().getDisplay(), new Result() { @Override public IEditorPart run() { diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/contentassist/AbstractContentAssistUiTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/contentassist/AbstractContentAssistUiTest.java index 8e8086edeb..90eadb96c1 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/contentassist/AbstractContentAssistUiTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/contentassist/AbstractContentAssistUiTest.java @@ -25,7 +25,7 @@ import org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration; import org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer; import org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.State; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.xtext.common.ui.contentassist.TemplatesFirstCompletionProposalComparator; import com.avaloq.tools.ddk.xtext.resource.Messages; @@ -112,9 +112,9 @@ public String apply(final ICompletionProposal from) { protected void assertContentAssist(final List contentassistProposals, final int offset) { evaluateCompletionProposals(offset); Arrays.sort(getCompletionProposals(), new TemplatesFirstCompletionProposalComparator()); - Assert.assertEquals("Same length", contentassistProposals.size(), getCompletionProposals().length); + Assertions.assertEquals("Same length", contentassistProposals.size(), getCompletionProposals().length); for (int i = 0; i < contentassistProposals.size(); i++) { - Assert.assertEquals("Same displayed string", contentassistProposals.get(i), getCompletionProposals()[i].getDisplayString()); + Assertions.assertEquals("Same displayed string", contentassistProposals.get(i), getCompletionProposals()[i].getDisplayString()); } } @@ -152,7 +152,7 @@ protected void assertTemplateProposalExistsAndSuccessful(final String sourceFile @SuppressWarnings("PMD.UseObjectForClearerAPI") protected void assertTemplateProposalExistsAndSuccessful(final String sourceFileName, final String sourceContent, final String contentassistProposal, final String expectedContent, final int offset) { if (sourceContent == null) { - Assert.assertNotNull(String.format("There must be an existing test source with the file name '%s'.", sourceFileName), getTestSource(sourceFileName)); + Assertions.assertNotNull(String.format("There must be an existing test source with the file name '%s'.", sourceFileName), getTestSource(sourceFileName)); } else { createTestSource(sourceFileName, sourceContent); } @@ -169,10 +169,10 @@ protected void assertTemplateProposalExistsAndSuccessful(final String sourceFile } } - Assert.assertNotNull(String.format("Template proposal '%s' must be found.", contentassistProposal), templateProposal); + Assertions.assertNotNull(String.format("Template proposal '%s' must be found.", contentassistProposal), templateProposal); String actualContent = applyTemplateProposal(templateProposal, offset); - Assert.assertEquals("Editor content must match expected result.", expectedContent.replaceAll(CR_LF, LF), actualContent.replaceAll(CR_LF, LF)); + Assertions.assertEquals("Editor content must match expected result.", expectedContent.replaceAll(CR_LF, LF), actualContent.replaceAll(CR_LF, LF)); closeEditor(getEditor(), false); } @@ -190,7 +190,7 @@ private String applyTemplateProposal(final TemplateProposal templateProposal, fi UiThreadDispatcher.dispatchAndWait(new Runnable() { @Override public void run() { - Assert.assertNotNull(EDITOR_HAS_NO_VIEWER, getViewer()); + Assertions.assertNotNull(EDITOR_HAS_NO_VIEWER, getViewer()); templateProposal.apply(getViewer(), ' ', 0, offset); } }); @@ -211,7 +211,7 @@ protected void assertProposalsAtOffsetExist(final int offset, final String... pr evaluateCompletionProposals(offset); final List result = getCompletionProposalDisplayStrings(getCompletionProposals()); for (final String s : proposals) { - Assert.assertTrue(Messages.bind("Expected proposal \"{0}\" but found \"{1}\"", s, result), result.contains(s)); + Assertions.assertTrue(Messages.bind("Expected proposal \"{0}\" but found \"{1}\"", s, result), result.contains(s)); } } diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/folding/AbstractFoldingTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/folding/AbstractFoldingTest.java index ed168df674..7eaff403ba 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/folding/AbstractFoldingTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/folding/AbstractFoldingTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.ui.folding; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Collection; import java.util.Collections; @@ -23,7 +23,7 @@ import org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition; import org.eclipse.xtext.ui.editor.folding.FoldedPosition; import org.eclipse.xtext.ui.editor.folding.IFoldingRegionProvider; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.test.core.BugTest; import com.avaloq.tools.ddk.xtext.test.ui.AbstractXtextEditorTest; @@ -83,7 +83,7 @@ public boolean apply(final Position p) { // CHECKSTYLE:ON message.append("Unmatched Expected Positions:").append(unmatchedExpectedPositions).append('\n'); message.append("Unmatched Actual Positions:").append(unmatchedActualPositions); - Assert.assertTrue(message.toString(), unmatchedExpectedPositions.isEmpty()); + Assertions.assertTrue(message.toString(), unmatchedExpectedPositions.isEmpty()); } } @@ -96,7 +96,7 @@ public void testFoldedPositions() { Collection foldingRegions = getXtextTestUtil().get(IFoldingRegionProvider.class).getFoldingRegions(getDocument()); for (DefaultFoldedPosition foldedPosition : Iterables.filter(foldingRegions, DefaultFoldedPosition.class)) { try { - Assert.assertFalse("Illegal significant region for FoldedPosition " + foldedPosition, foldedPosition.computeCaptionOffset(getDocument()) < 0); + Assertions.assertFalse("Illegal significant region for FoldedPosition " + foldedPosition, foldedPosition.computeCaptionOffset(getDocument()) < 0); /* If the above assertion fails that is probably due to an ITextRegion.EMPTY_REGION being provided for the object's significant text region. */ } catch (BadLocationException e) { fail("Bad location for FoldedPosition: " + e.getMessage()); diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/hover/AbstractHoverTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/hover/AbstractHoverTest.java index 27405f08c7..f2f98dc32a 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/hover/AbstractHoverTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/hover/AbstractHoverTest.java @@ -24,7 +24,7 @@ import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.xtext.test.AbstractXtextTest; @@ -153,7 +153,7 @@ private EList getFeatureValues(final EObject model, final EStructuralFe */ protected void assertHover(final ENamedElement element, final String firstLine) { assertElementExistInHoverMap(element); - Assert.assertTrue("Element '" + element.toString() + "' must have first line of hover '" + firstLine + "'. " + "\n\nHoverMap contains:\n" + Assertions.assertTrue("Element '" + element.toString() + "' must have first line of hover '" + firstLine + "'. " + "\n\nHoverMap contains:\n" + getHoverMap().get(element), hasTextOnFirstLine(getHoverMap().get(element), firstLine)); } @@ -167,7 +167,7 @@ protected void assertHover(final ENamedElement element, final String firstLine) */ protected void assertHoverDoesNotContainText(final ENamedElement element, final String text) { assertElementExistInHoverMap(element); - Assert.assertFalse("Element '" + element.toString() + "' first line of hover must not have '" + text + "'. " + "\n\nHoverMap contains:\n" + Assertions.assertFalse("Element '" + element.toString() + "' first line of hover must not have '" + text + "'. " + "\n\nHoverMap contains:\n" + getHoverMap().get(element), hasTextOnFirstLine(getHoverMap().get(element), text)); } @@ -178,7 +178,7 @@ protected void assertHoverDoesNotContainText(final ENamedElement element, final * element of the model with hover, must not be {@code null} */ private void assertElementExistInHoverMap(final ENamedElement element) { - Assert.assertTrue("Element '" + element.toString() + "' must exist.", getHoverMap().containsKey(element)); + Assertions.assertTrue("Element '" + element.toString() + "' must exist.", getHoverMap().containsKey(element)); } /** diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/hyperlinking/AbstractHyperlinkHelperTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/hyperlinking/AbstractHyperlinkHelperTest.java index d1821ecec7..bf31d50719 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/hyperlinking/AbstractHyperlinkHelperTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/hyperlinking/AbstractHyperlinkHelperTest.java @@ -28,7 +28,7 @@ import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.xtext.test.ui.AbstractXtextEditorTest; import com.google.common.base.Predicate; @@ -53,7 +53,7 @@ public abstract class AbstractHyperlinkHelperTest extends AbstractXtextEditorTes * the position at which to look for a hyperlink */ protected void assertOffsetHasHyperlink(final int offset) { - Assert.assertEquals(OFFSET_MUST_BE_EQUAL, 1, getOffsetHyperlinks(offset).size()); + Assertions.assertEquals(OFFSET_MUST_BE_EQUAL, 1, getOffsetHyperlinks(offset).size()); } /** @@ -63,7 +63,7 @@ protected void assertOffsetHasHyperlink(final int offset) { * the position at which to look for hyperlinks */ protected void assertOffsetHasNoHyperlink(final int offset) { - Assert.assertEquals(OFFSET_MUST_BE_EQUAL, 0, getOffsetHyperlinks(offset).size()); + Assertions.assertEquals(OFFSET_MUST_BE_EQUAL, 0, getOffsetHyperlinks(offset).size()); } /** @@ -95,7 +95,7 @@ protected void assertNoHyperlink(final int tag) { * number of expected hyperlinks */ protected void assertHasHyperlinks(final int tag, final int numberOfHyperlinks) { - Assert.assertEquals(NUMBER_OF_HYPERLINKS_MUST_BE_EQUAL, numberOfHyperlinks, getHyperlinks(tag).size()); + Assertions.assertEquals(NUMBER_OF_HYPERLINKS_MUST_BE_EQUAL, numberOfHyperlinks, getHyperlinks(tag).size()); } /** @@ -113,7 +113,7 @@ protected void assertHasHyperlinks(final int tag, final URI target) { actualTargets.add(((XtextHyperlink) hyperlink).getURI()); } } - MatcherAssert.assertThat("The target must have items", actualTargets, CoreMatchers.hasItem(target)); + MatcherAssertions.assertThat("The target must have items", actualTargets, CoreMatchers.hasItem(target)); } /** @@ -127,7 +127,7 @@ protected void assertHasHyperlinks(final int tag, final URI target) { * number of expected hyperlinks */ protected void assertHasHyperlinks(final XtextResource resource, final int tag, final int numberOfHyperlinks) { - Assert.assertEquals(NUMBER_OF_HYPERLINKS_MUST_BE_EQUAL, numberOfHyperlinks, getHyperlinks(resource, tag).size()); + Assertions.assertEquals(NUMBER_OF_HYPERLINKS_MUST_BE_EQUAL, numberOfHyperlinks, getHyperlinks(resource, tag).size()); } /** diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/labeling/AbstractLabelingTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/labeling/AbstractLabelingTest.java index c1ced92448..40d0f24756 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/labeling/AbstractLabelingTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/labeling/AbstractLabelingTest.java @@ -25,10 +25,10 @@ import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.xtext.util.Pair; import org.eclipse.xtext.util.Tuples; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.xtext.test.AbstractXtextTest; +import org.junit.jupiter.api.Test; /** @@ -49,8 +49,8 @@ protected List> getExpectedElementLabels() { /** * Tests that the expected elements and their labels are exactly identical to all elements of the default test resource. */ - @Test - public void testLabels() { + @org.junit.jupiter.api.Test + void testLabels() { if (getExpectedElementLabels() == null) { return; // TODO: remove this check once all tests have been refactored } @@ -106,8 +106,8 @@ private Map> getLabelMap() { // NOPMD LooseCoupling * the expected label */ protected void assertHasLabel(final Object element, final String label) { - Assert.assertTrue("Element '" + element.toString() + "' must exist.", getLabelMap().containsKey(element)); - Assert.assertTrue("Element '" + element.toString() + "' must have label '" + label + "'. LabelMap contains: " + Assertions.assertTrue("Element '" + element.toString() + "' must exist.", getLabelMap().containsKey(element)); + Assertions.assertTrue("Element '" + element.toString() + "' must have label '" + label + "'. LabelMap contains: " + getLabelMap().get(element), getLabelMap().get(element).contains(label)); } diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/occurrences/AbstractOccurrencesTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/occurrences/AbstractOccurrencesTest.java index 097bf90297..c640c9888b 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/occurrences/AbstractOccurrencesTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/occurrences/AbstractOccurrencesTest.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.ui.occurrences; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; import java.util.Set; @@ -28,12 +28,12 @@ import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.xtext.ui.editor.occurrences.Messages; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; import com.avaloq.tools.ddk.test.core.util.JobChangeListener; import com.avaloq.tools.ddk.xtext.test.ui.AbstractXtextUiTest; import com.google.common.collect.Sets; +import org.junit.jupiter.api.BeforeEach; /** @@ -157,7 +157,7 @@ protected void addKernelSourceToWorkspace(final String sourceFileName, final Cha /** * Sets up the {@link JobChangeListener}. */ - @Before + @BeforeEach public void setUpJobListener() { Job.getJobManager().addJobChangeListener(jobChangeListener); } @@ -165,7 +165,7 @@ public void setUpJobListener() { /** * Tears down the {@link JobChangeListener}. */ - @After + @AfterEach public void tearDownJobListener() { Job.getJobManager().removeJobChangeListener(jobChangeListener); jobChangeListener.reset(); diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/outline/AbstractOutlineTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/outline/AbstractOutlineTest.java index b95f2a98a5..cdd906aa96 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/outline/AbstractOutlineTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/outline/AbstractOutlineTest.java @@ -27,8 +27,8 @@ import org.eclipse.xtext.ui.editor.outline.impl.EObjectNode; import org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode; import org.eclipse.xtext.util.concurrent.IUnitOfWork; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.test.ui.AbstractXtextEditorTest; import com.google.common.base.Predicate; @@ -54,7 +54,7 @@ protected List getExpectedElements() { * Tests that the outline of the default test resource contains exactly the expected elements. */ @Test - public void testOutline() { + void testOutline() { if (getExpectedElements() == null) { return; // TODO: remove this once all tests have been refactored } @@ -101,8 +101,8 @@ protected void assertHasOutlineNode(final Object object) { if (object instanceof EClass) { key = ((EClass) object).getInstanceClass(); } - Assert.assertTrue("Outline must contain element '" + object.toString() + "'.", getOutlineMap().containsKey(key)); - Assert.assertFalse("Outline must contain element '" + object.toString() + "'.", getOutlineMap().get(key).isEmpty()); + Assertions.assertTrue("Outline must contain element '" + object.toString() + "'.", getOutlineMap().containsKey(key)); + Assertions.assertFalse("Outline must contain element '" + object.toString() + "'.", getOutlineMap().get(key).isEmpty()); } /** @@ -128,7 +128,7 @@ protected IOutlineNode assertHasOutlineNode(final String nodeName) { protected IOutlineNode assertHasOutlineNode(final String nodeName, final String nodeType) { IOutlineTreeProvider provider = getXtextTestUtil().get(IOutlineTreeProvider.class); IOutlineNode field = findNode(provider.createRoot(getDocument()), nodeName, nodeType); - Assert.assertNotNull("Outline must contain element '" + nodeName + "'.", field); + Assertions.assertNotNull("Outline must contain element '" + nodeName + "'.", field); return field; } @@ -145,7 +145,7 @@ protected IOutlineNode assertHasOutlineNode(final String nodeName, final String protected void assertHasOutlineNode(final String nodeName, final String nodeType, final String parentName) { IOutlineNode field = assertHasOutlineNode(nodeName, nodeType); IOutlineNode parent = field.getParent(); - Assert.assertEquals("The element '" + nodeName + "' doesn't belong to the '" + parentName + "' group.", parentName, parent.getText().toString()); + Assertions.assertEquals("The element '" + nodeName + "' doesn't belong to the '" + parentName + "' group.", parentName, parent.getText().toString()); } /** @@ -201,9 +201,9 @@ public T exec(final EObject state) throws Exception { // NOPMD })); } try { - Assert.assertNotNull(NLS.bind("At least one outline node represents an object of type \"{0}\"", clazz.getName()), Iterables.find(result, predicate)); + Assertions.assertNotNull(NLS.bind("At least one outline node represents an object of type \"{0}\"", clazz.getName()), Iterables.find(result, predicate)); } catch (NoSuchElementException e) { - Assert.fail(NLS.bind("Could not find an object of type \"{0}\" in outline", clazz.getName())); + Assertions.fail(NLS.bind("Could not find an object of type \"{0}\" in outline", clazz.getName())); } } @@ -218,7 +218,7 @@ protected void assertOutlineNodeTreeConsistsOf(final Object... classes) { outlineMapKeySet.removeAll(Arrays.asList(classes)); // assert that only EStructuralFeatures remain for (Object object : outlineMapKeySet) { - Assert.assertTrue("All remaining objects in outlineMap must be of type EStructuralFeature. Found: " + object, object instanceof EStructuralFeature); + Assertions.assertTrue("All remaining objects in outlineMap must be of type EStructuralFeature. Found: " + object, object instanceof EStructuralFeature); } } diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/outline/AbstractOutlineViewTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/outline/AbstractOutlineViewTest.java index 8988450110..01c02bbe74 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/outline/AbstractOutlineViewTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/outline/AbstractOutlineViewTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.ui.outline; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/quickfix/AbstractQuickFixTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/quickfix/AbstractQuickFixTest.java index 67c11897d1..7ab261a36c 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/quickfix/AbstractQuickFixTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/ui/quickfix/AbstractQuickFixTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.ui.quickfix; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; @@ -23,7 +23,7 @@ import org.eclipse.xtext.validation.Issue; import org.hamcrest.MatcherAssert; import org.hamcrest.text.IsEqualCompressingWhiteSpace; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.check.runtime.quickfix.ICoreModificationContext; import com.avaloq.tools.ddk.check.runtime.ui.quickfix.CoreIssueModificationContext; @@ -89,7 +89,7 @@ protected void afterEachTest() { * the code of the expected issue, may be {@code null} */ protected void assertHasIssue(final String issueCode) { - Assert.assertFalse("Issue " + issueCode + " is empty", issuesWith(issueCode).isEmpty()); + Assertions.assertFalse("Issue " + issueCode + " is empty", issuesWith(issueCode).isEmpty()); } /** @@ -99,7 +99,7 @@ protected void assertHasIssue(final String issueCode) { * the code of the issue for which a quickfix is expected to exist, may be {@code null} */ protected void assertHasQuickFix(final String issueCode) { - Assert.assertFalse("No resolutions found for issue " + issueCode, resolutionsFor(issueCode).isEmpty()); + Assertions.assertFalse("No resolutions found for issue " + issueCode, resolutionsFor(issueCode).isEmpty()); } /** @@ -111,7 +111,7 @@ protected void assertHasQuickFix(final String issueCode) { * the label of the quickfix, may be {@code null} */ protected void assertHasQuickFix(final String issueCode, final String quickfixLabel) { - Assert.assertFalse("No resolutions found for issue " + issueCode, resolutionsFor(issueCode, quickfixLabel).isEmpty()); + Assertions.assertFalse("No resolutions found for issue " + issueCode, resolutionsFor(issueCode, quickfixLabel).isEmpty()); } /** @@ -125,7 +125,7 @@ protected void assertHasQuickFix(final String issueCode, final String quickfixLa * the number of expected quickfix proposal, must not be {@code null} */ protected void assertHasQuickFix(final String issueCode, final String quickfixLabel, final int numberOfQuickfixProposal) { - Assert.assertEquals("Number of resolutions found for issue " + issueCode + Assertions.assertEquals("Number of resolutions found for issue " + issueCode + " does not match the expected number of quickfix proposal", resolutionsFor(issueCode, quickfixLabel).size(), numberOfQuickfixProposal); } @@ -159,7 +159,7 @@ protected void assertNoQuickFix(final String sourceFileName, final String source createTestSource(sourceFileName, sourceFileContent); openEditor(sourceFileName); try { - Assert.assertTrue("No resolutions expected for issue " + issueCode + " on source " + sourceFileName, resolutionsFor(issueCode, quickfixLabel).isEmpty()); + Assertions.assertTrue("No resolutions expected for issue " + issueCode + " on source " + sourceFileName, resolutionsFor(issueCode, quickfixLabel).isEmpty()); } finally { closeEditor(getEditor(), false); } @@ -193,7 +193,7 @@ public void run() { }); } waitForValidation(); - Assert.assertTrue("Resolutions for issue " + issueCode + " with quickfix " + quickfixLabel + Assertions.assertTrue("Resolutions for issue " + issueCode + " with quickfix " + quickfixLabel + "are not empty", resolutionsFor(issueCode, quickfixLabel).isEmpty()); } @@ -234,7 +234,7 @@ public Integer apply(final IssueResolution from) { * Assert that the test source has no syntax error. */ protected void assertNoSyntaxError() { - Assert.assertFalse("The source has syntax errors", Iterables.any(getTestSource().getXtextResource().getErrors(), Predicates.instanceOf(XtextSyntaxDiagnostic.class))); + Assertions.assertFalse("The source has syntax errors", Iterables.any(getTestSource().getXtextResource().getErrors(), Predicates.instanceOf(XtextSyntaxDiagnostic.class))); } /** @@ -353,7 +353,7 @@ private void assertQuickFixExistsAndSuccessful(final String issueCode, final Str private void assertQuickFixExistsAndSuccessful(final String issueCode, final String quickfixLabel, final String expectedContent, final boolean ignoreFormatting) { // Assert amount of quickfixes int resolutionCount = resolutionsFor(issueCode, quickfixLabel).size(); - Assert.assertEquals(String.format("There must be exactly one quickfix with label '%s' for issue '%s', but found '%d'.", quickfixLabel, issueCode, resolutionCount), resolutionCount, 1); + Assertions.assertEquals(String.format("There must be exactly one quickfix with label '%s' for issue '%s', but found '%d'.", quickfixLabel, issueCode, resolutionCount), resolutionCount, 1); // Apply quickfix UiThreadDispatcher.dispatchAndWait(new Runnable() { @Override @@ -365,7 +365,7 @@ public void run() { } }); waitForValidation(); - Assert.assertTrue("Resolutions for issue " + issueCode + " with quickfix " + quickfixLabel + Assertions.assertTrue("Resolutions for issue " + issueCode + " with quickfix " + quickfixLabel + "are not empty", resolutionsFor(issueCode, quickfixLabel).isEmpty()); String actualContent = getDocument().get(); assertQuickFixProducesExpectedOutput(expectedContent, actualContent, ignoreFormatting); @@ -386,7 +386,7 @@ private void assertQuickFixProducesExpectedOutput(final String expectedContent, String expected = expectedContent.replaceAll(CR_LF, LF); String actual = actualContent.replaceAll(CR_LF, LF); if (ignoreFormatting) { - MatcherAssert.assertThat(message, actual, IsEqualCompressingWhiteSpace.equalToCompressingWhiteSpace(expected)); + MatcherAssertions.assertThat(message, actual, IsEqualCompressingWhiteSpace.equalToCompressingWhiteSpace(expected)); } else { assertEquals(message, expected, actual); } diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidValidationTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidValidationTest.java index ffddb3abbb..a49f460fab 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidValidationTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidValidationTest.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.test.validation; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.testing.validation.AssertableDiagnostics.Pred; diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidationTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidationTest.java index abb767b6eb..ca885c1afb 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidationTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidationTest.java @@ -11,11 +11,11 @@ package com.avaloq.tools.ddk.xtext.test.validation; import static org.eclipse.xtext.validation.ValidationMessageAcceptor.INSIGNIFICANT_INDEX; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Arrays; import java.util.List; diff --git a/com.avaloq.tools.ddk.xtext.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtext.test/META-INF/MANIFEST.MF index 7b181c4202..9d50880fd7 100644 --- a/com.avaloq.tools.ddk.xtext.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.xtext.test/META-INF/MANIFEST.MF @@ -19,7 +19,7 @@ Require-Bundle: com.avaloq.tools.ddk.xtext, org.eclipse.emf.ecore, org.eclipse.emf.common, org.antlr.runtime, - org.junit, + org.junit.jupiter.api, com.avaloq.tools.ddk.xtext.builder, org.eclipse.xtext.builder, org.mockito, diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/builder/XtextBuildTriggerTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/builder/XtextBuildTriggerTest.java index 21f8b1f119..3ceab654bb 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/builder/XtextBuildTriggerTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/builder/XtextBuildTriggerTest.java @@ -25,8 +25,8 @@ import org.eclipse.xtext.builder.impl.BuildScheduler; import org.eclipse.xtext.builder.impl.IBuildFlag; import org.eclipse.xtext.testing.AbstractXtextTests; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import com.avaloq.tools.ddk.xtext.builder.layered.XtextBuildTrigger; @@ -40,7 +40,7 @@ public class XtextBuildTriggerTest extends AbstractXtextTests { private BuildScheduler scheduler; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); workspace = mock(IWorkspace.class); @@ -55,7 +55,7 @@ protected void configure() { } @Test - public void testTriggerRespectsAutoBuilding() { + void testTriggerRespectsAutoBuilding() { XtextBuildTrigger buildTrigger = get(XtextBuildTrigger.class); // auto-build disabled diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/formatter/AbstractFormatterTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/formatter/AbstractFormatterTest.java index 39407153a2..689ff5f5ba 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/formatter/AbstractFormatterTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/formatter/AbstractFormatterTest.java @@ -19,7 +19,7 @@ import org.eclipse.xtext.nodemodel.util.NodeModelUtils; import org.eclipse.xtext.resource.SaveOptions; import org.eclipse.xtext.serializer.ISerializer; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import com.avaloq.tools.ddk.xtext.test.AbstractXtextTest; @@ -54,13 +54,13 @@ protected ISerializer getSerializer() { protected void assertFormattedPTC(final String expected, final String model) throws IOException { EObject m = getModel(model); String res = getSerializer().serialize(m, SaveOptions.newBuilder().format().getOptions()); - Assert.assertEquals("Serialization not equal", expected, res); + Assertions.assertEquals("Serialization not equal", expected, res); } protected void assertPreserved(final String model) throws IOException { EObject m = getModel(model); String res = getSerializer().serialize(m, SaveOptions.newBuilder().getOptions()); - Assert.assertEquals("Preserved node model", model, res); + Assertions.assertEquals("Preserved node model", model, res); } // test formatting based on the NodeModel @@ -68,7 +68,7 @@ protected void assertFormattedNM(final String expected, final String model, fina ICompositeNode node = NodeModelUtils.getNode(getModel(model)).getRootNode(); IFormattedRegion r = getXtextTestUtil().get(INodeModelFormatter.class).format(node, offset, length); String actual = model.substring(0, r.getOffset()) + r.getFormattedText() + model.substring(r.getLength() + r.getOffset()); - Assert.assertEquals("Formatting based on the NodeModel", expected, actual); + Assertions.assertEquals("Formatting based on the NodeModel", expected, actual); } } diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/formatter/FormatterTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/formatter/FormatterTest.java index 473afeeb74..eec24d6115 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/formatter/FormatterTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/formatter/FormatterTest.java @@ -13,9 +13,9 @@ import java.io.IOException; import org.eclipse.xtext.resource.SaveOptions; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.formatter.formatterTestLanguage.Decl; import com.avaloq.tools.ddk.xtext.formatter.formatterTestLanguage.FormatterTestLanguageFactory; @@ -47,8 +47,8 @@ protected String getTestSourceFileName() { * * @throws IOException */ - @Test - public void linewrap() throws IOException { + @org.junit.jupiter.api.Test + void linewrap() throws IOException { String model = "test linewrap float val; int x; double y;"; String expected = "test linewrap\nfloat val;\nint x;\ndouble y;"; assertFormattedPTC(expected, model); @@ -62,8 +62,8 @@ public void linewrap() throws IOException { * * @throws IOException */ - @Test - public void keepComments() throws IOException { + @org.junit.jupiter.api.Test + void keepComments() throws IOException { // String model = "test linewrap float val; int x; double y;"; String model = "// begincomment \ntest linewrap// comment1\n" + "float val;//comment2\n" + "int x;" + "double y; //yoyoyo!\n// endcomment."; final String exp = "// begincomment \ntest linewrap// comment1\n" + "float val;//comment2\n" + "int x;\n" + "double y; //yoyoyo!\n// endcomment."; @@ -77,8 +77,8 @@ public void keepComments() throws IOException { * * @throws IOException */ - @Test - public void column() throws IOException { + @org.junit.jupiter.api.Test + void column() throws IOException { String model = "test column item int x;"; String expected = "test\n column\n\titem int x;"; assertFormattedPTC(expected, model); @@ -93,7 +93,7 @@ public void column() throws IOException { * @throws IOException */ @Test - public void columnMinimumPadding() throws IOException { + void columnMinimumPadding() throws IOException { String model = " test column name item int x;"; String expected = "test\n column name\n\n\titem int x;"; assertFormattedPTC(expected, model); @@ -107,7 +107,7 @@ public void columnMinimumPadding() throws IOException { * @throws IOException */ @Test - public void offset() throws IOException { + void offset() throws IOException { String model = "test offset value v pair p1 p2"; String expected = "test\noffset\n\tvalue v\n\t\tpair p1 p2"; assertFormattedPTC(expected, model); @@ -121,7 +121,7 @@ public void offset() throws IOException { * @throws IOException */ @Test - public void rightPadding() throws IOException { + void rightPadding() throws IOException { String model = "test padding long_name n2;"; String expected = "test\npadding long_name n2 ;"; assertFormattedPTC(expected, model); @@ -135,8 +135,8 @@ public void rightPadding() throws IOException { * * @throws IOException */ - @Test - public void indentation() throws IOException { + @org.junit.jupiter.api.Test + void indentation() throws IOException { String model = "test indentation { float val; double y; indentation { int x; } }"; String expected = "test indentation {\n float val;\n double y;\n indentation {\n int x;\n }\n}"; assertFormattedPTC(expected, model); @@ -150,8 +150,8 @@ public void indentation() throws IOException { * * @throws IOException */ - @Test - public void association() throws IOException { + @org.junit.jupiter.api.Test + void association() throws IOException { String model = "test indentation { var = [0,1,2,3,4]; }"; String expected = "test indentation {\n var=[ 0, 1, 2, 3, 4 ];\n}"; assertFormattedPTC(expected, model); @@ -166,7 +166,7 @@ public void association() throws IOException { * @throws IOException */ @Test - public void indentationAndComments() throws IOException { + void indentationAndComments() throws IOException { String model = "test /* xxx */ indentation { float val; // some float\n double /* oo */ y; indentation { // some block\n int x; // xxx\n } } // final comment"; String expected = "test /* xxx */ indentation {\n float val; // some float\n double /* oo */ y;\n indentation { // some block\n int x; // xxx\n }\n} // final comment"; assertFormattedPTC(expected, model); @@ -182,7 +182,7 @@ public void indentationAndComments() throws IOException { * @throws IOException */ @Test - public void indentationAndLineWrap() throws IOException { + void indentationAndLineWrap() throws IOException { String model = "test indentation { void func(x:int,y:int,s:javalangString, foo:javasqlDate, blupp:mylongtype, msads:adshdjkhsakdasdkslajdlsask, x:x, a:b, c:d ); }"; String expected = "test indentation {\n void func(x:int,y:int,\n\t\ts:javalangString,\n\t\tfoo:javasqlDate,\n\t\tblupp:mylongtype,\n\t\tmsads:adshdjkhsakdasdkslajdlsask,\n\t\tx:x,a:b,c:d);\n}"; assertFormattedPTC(expected, model); @@ -196,8 +196,8 @@ public void indentationAndLineWrap() throws IOException { * * @throws IOException */ - @Test - public void between1() throws IOException { + @org.junit.jupiter.api.Test + void between1() throws IOException { String model = "test indentation { indentation { x x; }; }"; String expected = "test indentation {\n indentation {\n x x;\n };\n}"; assertFormattedPTC(expected, model); @@ -212,7 +212,7 @@ public void between1() throws IOException { * @throws IOException */ @Test - public void between2() throws IOException { + void between2() throws IOException { String model = "test indentation { indentation { x x; } }"; String expected = "test indentation {\n indentation {\n x x;\n }\n}"; assertFormattedPTC(expected, model); @@ -226,8 +226,8 @@ public void between2() throws IOException { * * @throws IOException */ - @Test - public void linewrapDatatypeRule() throws IOException { + @org.junit.jupiter.api.Test + void linewrapDatatypeRule() throws IOException { String model = "test linewrap fqn ab; fqn xx.yy.zz;"; String expected = "test linewrap\nfqn\nab;\nfqn\nxx.yy.zz;"; assertFormattedPTC(expected, model); @@ -241,8 +241,8 @@ public void linewrapDatatypeRule() throws IOException { * * @throws IOException */ - @Test - public void linewrapDatatypeRulePartial1() throws IOException { + @org.junit.jupiter.api.Test + void linewrapDatatypeRulePartial1() throws IOException { String model = "test linewrap fqn ab . xx .yy .zz;"; String expected = "test linewrap fqn ab.xx.yy.zz;"; assertFormattedNM(expected, model, 22, 2); @@ -254,8 +254,8 @@ public void linewrapDatatypeRulePartial1() throws IOException { * * @throws IOException */ - @Test - public void linewrapDatatypeRulePartial2() throws IOException { + @org.junit.jupiter.api.Test + void linewrapDatatypeRulePartial2() throws IOException { String model = "test linewrap fqn ab . xx .yy .zz;fqn xxx;"; String expected = "test linewrap fqn\nab.xx.yy.zz;fqn xxx;"; assertFormattedNM(expected, model, 15, 10); @@ -267,8 +267,8 @@ public void linewrapDatatypeRulePartial2() throws IOException { * * @throws IOException */ - @Test - public void linewrapDatatypeRulePartial3() throws IOException { + @org.junit.jupiter.api.Test + void linewrapDatatypeRulePartial3() throws IOException { String model = "test linewrap fqn ab . xx .yy .zz;fqn xxx;"; String expected = "test linewrap fqn ab.xx.yy.zz;\nfqn xxx;"; assertFormattedNM(expected, model, 25, 12); @@ -281,7 +281,7 @@ public void linewrapDatatypeRulePartial3() throws IOException { * @throws IOException */ @Test - public void formatSegment1() throws IOException { + void formatSegment1() throws IOException { String model = "test\nindentation {\n indentation { x x ; } }"; String expected = "test\nindentation {\n indentation {\n x x;\n } }"; assertFormattedNM(expected, model, 30, 18); @@ -294,7 +294,7 @@ public void formatSegment1() throws IOException { * @throws IOException */ @Test - public void formatSegment2() throws IOException { + void formatSegment2() throws IOException { String model = "test indentation {\n indentation { x x ; } }"; // String expected = // "test\nindentation {\n indentation {\n x x;\n } }"; @@ -308,7 +308,7 @@ public void formatSegment2() throws IOException { * @throws IOException */ @Test - public void formatSegment3() throws IOException { + void formatSegment3() throws IOException { String model = " test indentation {\n indentation { x x ; } }"; String expected = "test indentation {\n indentation {\n x x;\n }\n}"; assertFormattedNM(expected, model, 0, model.length()); @@ -320,8 +320,8 @@ public void formatSegment3() throws IOException { * * @throws IOException */ - @Test - public void linewrapDatatypeRuleRef1() throws IOException { + @org.junit.jupiter.api.Test + void linewrapDatatypeRuleRef1() throws IOException { String model = "test linewrap fqn ab .cd .ef; fqnref ab. cd. ef;"; String expected = "test linewrap\nfqn\nab.cd.ef;\nfqnref\nab.cd.ef;"; // assertFormattedPTC(expected, model); @@ -335,7 +335,7 @@ public void linewrapDatatypeRuleRef1() throws IOException { * @throws IOException */ @Test - public void linewrapDatatypeRuleRef2() throws IOException { + void linewrapDatatypeRuleRef2() throws IOException { String model = "test linewrap fqn ab.cd.ef; fqnref ab.cd.ef;"; String expected = "test linewrap\nfqn\nab.cd.ef;\nfqnref\nab.cd.ef;"; assertFormattedPTC(expected, model); @@ -350,8 +350,8 @@ public void linewrapDatatypeRuleRef2() throws IOException { * * @throws IOException */ - @Test - public void linewrapDatatypeRuleComments() throws IOException { + @org.junit.jupiter.api.Test + void linewrapDatatypeRuleComments() throws IOException { String model = "test linewrap/* 1 */fqn/* 2 */ab.cd.ef/* 3 */;/* 4 */fqnref/* 5 */ab.cd.ef/* 6 */;/* 7 */"; // The expected model string differs from Xtext's - // Xtext does not expect a line wrap after the keyword "linewrap" @@ -370,7 +370,7 @@ public void linewrapDatatypeRuleComments() throws IOException { * @throws IOException */ @Test - public void enumeration() throws IOException { + void enumeration() throws IOException { String model = "test linewrap enum lit1,lit2,lit3,lit1;"; String expected = "test linewrap\nenum lit1 ,\nlit2,\nlit3,\nlit1;"; assertFormattedPTC(expected, model); @@ -386,7 +386,7 @@ public void enumeration() throws IOException { */ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=312559 @Test - public void suppressedWhitespace() throws IOException { + void suppressedWhitespace() throws IOException { String model = "test linewrap `f%%a` post;"; String expected = "test linewrap\n`f%< b >%a` post;"; assertFormattedPTC(expected, model); @@ -402,7 +402,7 @@ public void suppressedWhitespace() throws IOException { */ // TODO: investigate whether to include test or not - currently this test // would fail - @Ignore + @Disabled public void suppressedLinewrap() throws IOException { String model = "test linewrap\n`foo%abcd%foo%< b\n>%abcd%foo%abcd%foo%abcd%" + "foo%abcd%foo%abcd%foo%abcd%foo%abcd%foo%abcd%foo%xx%foo%abcd%foo%abcd%" + "foo%abcd%foo%<\nb >%foo%abcd` post;"; @@ -417,8 +417,8 @@ public void suppressedLinewrap() throws IOException { * * @throws IOException */ - @Test - public void linewrapMin() throws IOException { + @org.junit.jupiter.api.Test + void linewrapMin() throws IOException { String model = "test wrapminmax foo bar;"; String expected = "test wrapminmax\n\nfoo bar;"; assertFormattedPTC(expected, model); @@ -433,7 +433,7 @@ public void linewrapMin() throws IOException { * @throws IOException */ @Test - public void linewrapMax() throws IOException { + void linewrapMax() throws IOException { String model = "test wrapminmax\n\n\n\n\n\n\n\n\n\n\n\n\nfoo bar;"; String expected = "test wrapminmax\n\n\n\n\nfoo bar;"; assertFormattedPTC(expected, model); @@ -447,8 +447,8 @@ public void linewrapMax() throws IOException { * * @throws IOException */ - @Test - public void linewrapKeep() throws IOException { + @org.junit.jupiter.api.Test + void linewrapKeep() throws IOException { String model = "test wrapminmax\n\n\n\nfoo bar;"; assertFormattedPTC(model, model); assertFormattedNM(model, model, 0, model.length()); @@ -461,8 +461,8 @@ public void linewrapKeep() throws IOException { * * @throws IOException */ - @Test - public void linewrapDefault() { + @org.junit.jupiter.api.Test + void linewrapDefault() { FormatterTestLanguageFactory f = FormatterTestLanguageFactory.eINSTANCE; TestLinewrapMinMax m = f.createTestLinewrapMinMax(); Decl d = f.createDecl(); @@ -471,7 +471,7 @@ public void linewrapDefault() { m.getItems().add(d); String actual = getSerializer().serialize(m, SaveOptions.newBuilder().format().getOptions()); String expected = "test wrapminmax\n\n\nxxx yyy;"; - Assert.assertEquals("Default Linewrap", expected, actual); + Assertions.assertEquals("Default Linewrap", expected, actual); } /** @@ -480,8 +480,8 @@ public void linewrapDefault() { * * @throws IOException */ - @Test - public void space() throws IOException { + @org.junit.jupiter.api.Test + void space() throws IOException { String model = "test linewrap space foo;"; String expected = "test linewrap\nspace foo;"; assertFormattedPTC(expected, model); @@ -496,7 +496,7 @@ public void space() throws IOException { * @throws IOException */ @Test - public void datatypeRules() throws IOException { + void datatypeRules() throws IOException { String model = "test linewrap datatypes abc kw1 bcd def kw3;"; String expected = "test linewrap\ndatatypes abc\nkw1\nbcd\ndef\nkw3;"; assertFormattedPTC(expected, model); diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/linking/AbstractFragmentProviderTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/linking/AbstractFragmentProviderTest.java index 80d605e0f4..cca1883d4f 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/linking/AbstractFragmentProviderTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/linking/AbstractFragmentProviderTest.java @@ -11,8 +11,8 @@ package com.avaloq.tools.ddk.xtext.linking; import org.eclipse.emf.ecore.EObject; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** @@ -52,23 +52,23 @@ public String unescape(final String text) { private final TestAbstractFragmentProvider fragmentProvider = new TestAbstractFragmentProvider(); @Test - public void testEscape() { + void testEscape() { StringBuilder builder = new StringBuilder(); fragmentProvider.appendEscaped("foo/bar#\\", builder); - Assert.assertEquals("Fragment not properly scaped", builder.toString(), "foo\\/bar#\\\\"); + Assertions.assertEquals("Fragment not properly scaped", builder.toString(), "foo\\/bar#\\\\"); } @Test - public void testUnescape() { - Assert.assertEquals("Fragment not properly unscaped", "foo//bar##\\", fragmentProvider.unescape("foo\\/\\/bar##\\\\")); + void testUnescape() { + Assertions.assertEquals("Fragment not properly unscaped", "foo//bar##\\", fragmentProvider.unescape("foo\\/\\/bar##\\\\")); } - @Test - public void testUnescapeEscape() { + @org.junit.jupiter.api.Test + void testUnescapeEscape() { for (String text : SPECIAL_ESCAPE_CASES) { StringBuilder builder = new StringBuilder(); fragmentProvider.appendEscaped(text, builder); - Assert.assertEquals("Escaped Characters must be equal", text, fragmentProvider.unescape(builder.toString())); + Assertions.assertEquals("Escaped Characters must be equal", text, fragmentProvider.unescape(builder.toString())); } } diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/linking/ShortFragmentProviderTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/linking/ShortFragmentProviderTest.java index b6fa899231..af23d76231 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/linking/ShortFragmentProviderTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/linking/ShortFragmentProviderTest.java @@ -18,14 +18,15 @@ import org.eclipse.emf.ecore.resource.impl.ResourceImpl; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.xtext.resource.IFragmentProvider; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.test.core.BugTest; import com.avaloq.tools.ddk.xtext.test.AbstractTest; import com.avaloq.tools.ddk.xtext.test.AbstractTestUtil; +import org.junit.jupiter.api.BeforeEach; /** @@ -58,7 +59,7 @@ public EObject getEObject(final String fragment) { private EReference testReference; private EReference testReference2; - @Before + @BeforeEach public void initialize() { EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE; @@ -80,7 +81,7 @@ public void initialize() { EPackage.Registry.INSTANCE.put(testPackage.getNsURI(), testPackage); } - @After + @AfterEach public void cleanup() { EPackage.Registry.INSTANCE.remove(testPackage.getNsURI()); } @@ -100,13 +101,13 @@ public void testLongFragment() { resource.getContents().add(root); String fragment = fragmentProvider.getFragment(parent, fragmentFallback); - Assert.assertEquals(FRAGMENT_MUST_BE_EQUAL, "/0*" + (reps + 1), fragment); + Assertions.assertEquals(FRAGMENT_MUST_BE_EQUAL, "/0*" + (reps + 1), fragment); - Assert.assertEquals(FRAGMENT_MUST_BE_EQUAL, parent, fragmentProvider.getEObject(resource, fragment, fragmentFallback)); + Assertions.assertEquals(FRAGMENT_MUST_BE_EQUAL, parent, fragmentProvider.getEObject(resource, fragment, fragmentFallback)); } - @Test - public void testLongFragment2() { + @org.junit.jupiter.api.Test + void testLongFragment2() { int reps = 10; EObject root = EcoreUtil.create(testClass); EObject parent = root; @@ -124,9 +125,9 @@ public void testLongFragment2() { resource.getContents().add(root); String fragment = fragmentProvider.getFragment(parent, fragmentFallback); - Assert.assertEquals(FRAGMENT_MUST_BE_EQUAL, "/0*" + (reps + 1) + "/1", fragment); + Assertions.assertEquals(FRAGMENT_MUST_BE_EQUAL, "/0*" + (reps + 1) + "/1", fragment); - Assert.assertEquals(FRAGMENT_MUST_BE_EQUAL, parent, fragmentProvider.getEObject(resource, fragment, fragmentFallback)); + Assertions.assertEquals(FRAGMENT_MUST_BE_EQUAL, parent, fragmentProvider.getEObject(resource, fragment, fragmentFallback)); } @Override diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/naming/QualifiedNamePatternTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/naming/QualifiedNamePatternTest.java index 365a3b6d02..6e03406d8a 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/naming/QualifiedNamePatternTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/naming/QualifiedNamePatternTest.java @@ -10,14 +10,14 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.naming; -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.Comparator; import org.eclipse.xtext.naming.QualifiedName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.test.core.BugTest; @@ -30,7 +30,7 @@ public class QualifiedNamePatternTest { @Test - public void testSimpleQualifiedNamePattern() { + void testSimpleQualifiedNamePattern() { QualifiedNamePattern pattern = QualifiedNamePattern.create("foo*"); assertEquals(QualifiedName.create("foo"), pattern.lowerInclusive()); assertEquals(QualifiedName.create("fop"), pattern.upperExclusive()); @@ -39,8 +39,8 @@ public void testSimpleQualifiedNamePattern() { assertNoMatch(pattern, "foo", "bar"); } - @Test - public void testQualifiedPrefixNamePattern() { + @org.junit.jupiter.api.Test + void testQualifiedPrefixNamePattern() { QualifiedNamePattern pattern = QualifiedNamePattern.create("foo", "*"); assertEquals(QualifiedName.create("foo", ""), pattern.lowerInclusive()); assertEquals(QualifiedName.create("foo!"), pattern.upperExclusive()); @@ -53,8 +53,8 @@ public void testQualifiedPrefixNamePattern() { assertEquals(QualifiedName.create("foo", "bas"), pattern.upperExclusive()); } - @Test - public void testRecursiveWildcardPattern() { + @org.junit.jupiter.api.Test + void testRecursiveWildcardPattern() { QualifiedNamePattern pattern = QualifiedNamePattern.create("foo", "**"); assertEquals(QualifiedName.create("foo", ""), pattern.lowerInclusive()); assertEquals(QualifiedName.create("foo!"), pattern.upperExclusive()); @@ -63,8 +63,8 @@ public void testRecursiveWildcardPattern() { assertNoMatch(pattern, "foo2", "bar"); } - @Test - public void testRecursiveWildcardPatternWithPrefix() { + @org.junit.jupiter.api.Test + void testRecursiveWildcardPatternWithPrefix() { QualifiedNamePattern pattern = QualifiedNamePattern.create("foo", "b**"); assertEquals(QualifiedName.create("foo", "b"), pattern.lowerInclusive()); assertEquals(QualifiedName.create("foo", "c"), pattern.upperExclusive()); @@ -78,32 +78,32 @@ public void testRecursiveWildcardPatternError() { QualifiedNamePattern.create("foo", "bar**baz"); } - @Test(expected = IllegalArgumentException.class) + @org.junit.jupiter.api.Test(expected = IllegalArgumentException.class) public void testRecursiveWildcardPatternError2() { QualifiedNamePattern.create("foo", "**", "bar"); } - @Test(expected = IllegalArgumentException.class) + @org.junit.jupiter.api.Test(expected = IllegalArgumentException.class) public void testRecursiveWildcardPatternError3() { QualifiedNamePattern.create("foo*bar"); } - @Test - public void testAllPattern() { + @org.junit.jupiter.api.Test + void testAllPattern() { QualifiedNamePattern pattern = QualifiedNamePattern.create("*"); assertEquals(QualifiedName.create(""), pattern.lowerInclusive()); assertEquals(QualifiedName.create("!"), pattern.upperExclusive()); } - @Test - public void testPatternWithoutWildcard() { + @org.junit.jupiter.api.Test + void testPatternWithoutWildcard() { QualifiedNamePattern pattern = QualifiedNamePattern.create("foo"); assertEquals(QualifiedName.create("foo"), pattern.lowerInclusive()); assertEquals(QualifiedName.create("foo!"), pattern.upperExclusive()); } @Test - public void testRegexpPatterns() { + void testRegexpPatterns() { QualifiedNamePattern pattern = QualifiedNamePattern.createFromGlobs("*"); assertEquals(QualifiedName.create(""), pattern.lowerInclusive()); assertEquals(QualifiedName.create("!"), pattern.upperExclusive()); diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/naming/QualifiedNameSegmentTreeLookupTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/naming/QualifiedNameSegmentTreeLookupTest.java index 05968c87f8..dc8f6158e5 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/naming/QualifiedNameSegmentTreeLookupTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/naming/QualifiedNameSegmentTreeLookupTest.java @@ -10,17 +10,17 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.naming; -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 java.util.Collection; import java.util.Collections; import org.eclipse.emf.common.util.URI; import org.eclipse.xtext.naming.QualifiedName; -import org.junit.Test; import com.google.common.collect.ImmutableSet; +import org.junit.jupiter.api.Test; @SuppressWarnings({"nls", "unused", "PMD.JUnitAssertionsShouldIncludeMessage"}) @@ -30,12 +30,12 @@ public class QualifiedNameSegmentTreeLookupTest { private final QualifiedNameSegmentTreeLookup lookup = new QualifiedNameSegmentTreeLookup(URI.class, true); @Test - public void testEmpty() { + void testEmpty() { assertNull(lookup.get(QualifiedName.EMPTY)); } - @Test - public void testExact() { + @org.junit.jupiter.api.Test + void testExact() { QualifiedName name = name("foo"); Collection values = Collections.singletonList(uri(name)); lookup.putAll(name, values); @@ -53,7 +53,7 @@ public void testExact() { } @Test - public void testTopLevelPatternWithoutWildcard() { + void testTopLevelPatternWithoutWildcard() { URI value1 = put("foo"); URI value2 = put("bar"); URI value3 = put("foo2"); @@ -63,8 +63,8 @@ public void testTopLevelPatternWithoutWildcard() { assertContentEquals(ImmutableSet.of(value3), lookup.get(pattern("foo2"), false)); } - @Test - public void testTopLevelPatternWithWildcard() { + @org.junit.jupiter.api.Test + void testTopLevelPatternWithWildcard() { URI value1 = put("foo"); URI value2 = put("foo2"); URI value3 = put("bar"); @@ -74,8 +74,8 @@ public void testTopLevelPatternWithWildcard() { assertContentEquals(ImmutableSet.of(value3), lookup.get(pattern("b*"), true)); } - @Test - public void testNestedPatternMatchesWithoutWildcard() { + @org.junit.jupiter.api.Test + void testNestedPatternMatchesWithoutWildcard() { URI value1 = put("foo"); URI value2 = put("foo.bar"); URI value3 = put("foo2"); @@ -85,8 +85,8 @@ public void testNestedPatternMatchesWithoutWildcard() { assertContentEquals(ImmutableSet.of(value3), lookup.get(pattern("foo2"), true)); } - @Test - public void testNestedPatternMatchesWithWildcard() { + @org.junit.jupiter.api.Test + void testNestedPatternMatchesWithWildcard() { URI value1 = put("foo"); URI value2 = put("foo.bar"); URI value3 = put("foo.baz"); @@ -99,8 +99,8 @@ public void testNestedPatternMatchesWithWildcard() { assertContentEquals(ImmutableSet.of(value2), lookup.get(pattern("foo.bar*"), true)); } - @Test - public void testNestedPatternMatchesWithRecursiveWildcard() { + @org.junit.jupiter.api.Test + void testNestedPatternMatchesWithRecursiveWildcard() { URI value1 = put("foo"); URI value2 = put("foo.bar"); URI value3 = put("foo.bar.baz"); @@ -112,8 +112,8 @@ public void testNestedPatternMatchesWithRecursiveWildcard() { assertContentEquals(ImmutableSet.of(value2, value3, value4), lookup.get(pattern("foo.b**"), true)); } - @Test - public void testUnmatchedNestedPattern() { + @org.junit.jupiter.api.Test + void testUnmatchedNestedPattern() { URI value1 = put("foo"); URI value2 = put("foo.bar"); URI value3 = put("foo.bar.baz"); @@ -131,8 +131,8 @@ public void testUnmatchedNestedPattern() { assertContentEquals(ImmutableSet.of(), lookup.get(pattern("foo.bar.bazz*"), true)); } - @Test - public void testOutOfOrderInsertion() { + @org.junit.jupiter.api.Test + void testOutOfOrderInsertion() { QualifiedName name1 = name("foo.bar"); Collection value1 = Collections.singletonList(uri(name1)); lookup.putAll(name1, value1); diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/AbstractSelectorFragmentProviderTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/AbstractSelectorFragmentProviderTest.java index 1ac4353de4..6a0bbb4f1e 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/AbstractSelectorFragmentProviderTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/AbstractSelectorFragmentProviderTest.java @@ -24,8 +24,8 @@ import org.eclipse.xtext.testing.AbstractXtextTests; import org.eclipse.xtext.resource.IFragmentProvider; import org.eclipse.xtext.util.Modules2; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.google.inject.AbstractModule; @@ -38,7 +38,7 @@ public class AbstractSelectorFragmentProviderTest extends AbstractXtextTests { // CHECKSTYLE:ON - @Before + @BeforeEach @Override public void setUp() throws Exception { super.setUp(); @@ -50,26 +50,26 @@ protected void configure() { })); } - @Test - public void testTopLevelObject() throws Exception { + @org.junit.jupiter.api.Test + void testTopLevelObject() throws Exception { Grammar grammar = (Grammar) getModel("grammar foo.Foo\n" + "generate foo 'http://www.foo.com/foo'\n" + "Foo: 'foo';"); assertFragmentMatchesAndResolves(grammar.eResource(), "/0", grammar); } @Test - public void testMultiValuedContainment() throws Exception { + void testMultiValuedContainment() throws Exception { Grammar grammar = (Grammar) getModel("grammar foo.Foo\n" + "generate foo 'http://www.foo.com/foo'\n" + "Foo: 'foo';"); assertFragmentMatchesAndResolves(grammar.eResource(), "/0/5(0='Foo')#0", grammar.getRules().get(0)); } - @Test - public void testSingleValuedContainment() throws Exception { + @org.junit.jupiter.api.Test + void testSingleValuedContainment() throws Exception { Grammar grammar = (Grammar) getModel("grammar foo.Foo\n" + "generate foo 'http://www.foo.com/foo'\n" + "Foo: 'foo'+;"); assertFragmentMatchesAndResolves(grammar.eResource(), "/0/5(0='Foo')#0/2(3='foo')", grammar.getRules().get(0).getAlternatives()); } - @Test - public void testNullSelectorValue() throws Exception { + @org.junit.jupiter.api.Test + void testNullSelectorValue() throws Exception { Grammar grammar = (Grammar) getModel("grammar foo.Foo\n" + "generate foo 'http://www.foo.com/foo'\n" + "Foo: 'selectCardinality';"); assertFragmentMatchesAndResolves(grammar.eResource(), "/0/5(0='Foo')#0/2(0=null)", grammar.getRules().get(0).getAlternatives()); @@ -78,7 +78,7 @@ public void testNullSelectorValue() throws Exception { } @Test - public void testEscapedSelectorValue() throws Exception { + void testEscapedSelectorValue() throws Exception { Grammar grammar = (Grammar) getModel("grammar foo.Foo\n" + "generate foo 'http://www.foo.com/foo'\n" + "Foo: 'foo.bar#';"); assertFragmentMatchesAndResolves(grammar.eResource(), "/0/5(0='Foo')#0/2(3='foo.bar#')", grammar.getRules().get(0).getAlternatives()); } diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/BugAig1084.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/BugAig1084.java index ec472473e8..b72d549755 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/BugAig1084.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/BugAig1084.java @@ -19,7 +19,7 @@ import org.eclipse.xtext.resource.IEObjectDescription; import org.eclipse.xtext.util.IResourceScopeCache; import org.eclipse.xtext.util.OnChangeEvictingCache; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.google.common.collect.Lists; @@ -31,7 +31,7 @@ public class BugAig1084 { * stack-overflow. */ @Test - public void recursiveLookUp() { + void recursiveLookUp() { Resource resource = org.mockito.Mockito.mock(Resource.class); EList emptyEList = new BasicEList(); org.mockito.Mockito.when(resource.eAdapters()).thenReturn(emptyEList); diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/ResourceDescriptionDeltaTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/ResourceDescriptionDeltaTest.java index d0a53e225f..990416a288 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/ResourceDescriptionDeltaTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/ResourceDescriptionDeltaTest.java @@ -10,10 +10,10 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.resource; -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 java.util.List; @@ -26,18 +26,18 @@ import org.eclipse.xtext.resource.IReferenceDescription; import org.eclipse.xtext.resource.IResourceDescription; import org.eclipse.xtext.resource.impl.AbstractResourceDescription; -import org.junit.Test; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import org.junit.jupiter.api.Test; @SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage") public class ResourceDescriptionDeltaTest { - @Test - public void testGetAddedAndDeletedObjects() { + @org.junit.jupiter.api.Test + void testGetAddedAndDeletedObjects() { ResourceDescriptionDelta delta = new ResourceDescriptionDelta(createDescription("a"), createDescription("a"), null); assertDeltaEquals(0, 0, 0, delta); @@ -58,7 +58,7 @@ public void testGetAddedAndDeletedObjects() { } @Test - public void testGetChangedObjects() { + void testGetChangedObjects() { ResourceDescriptionDelta delta = new ResourceDescriptionDelta(createDescription("a:a"), createDescription("a:a1"), null); assertDeltaEquals(0, 1, 0, delta); @@ -70,19 +70,19 @@ public void testGetChangedObjects() { } @Test - public void testDeltaForNewResource() { + void testDeltaForNewResource() { ResourceDescriptionDelta delta = new ResourceDescriptionDelta(null, createDescription("a"), null); assertDeltaEquals(1, 0, 0, delta); } - @Test - public void testDeltaForDeletedResource() { + @org.junit.jupiter.api.Test + void testDeltaForDeletedResource() { ResourceDescriptionDelta delta = new ResourceDescriptionDelta(createDescription("a"), null, null); assertDeltaEquals(0, 0, 1, delta); } @Test - public void testOldReconstruction() { + void testOldReconstruction() { IResourceDescription oldRes = createDescription("a"); ResourceDescriptionDelta delta = new ResourceDescriptionDelta(oldRes, createDescription("a"), null); diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/util/RuntimeProjectUtilTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/util/RuntimeProjectUtilTest.java index 48a565d55c..9f1a0d4dab 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/util/RuntimeProjectUtilTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/util/RuntimeProjectUtilTest.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.util; -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.Assume.assumeNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -26,7 +26,7 @@ import org.eclipse.xtext.ui.resource.IStorage2UriMapper; import org.eclipse.xtext.ui.resource.Storage2UriMapperImpl; import org.eclipse.xtext.util.Pair; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.avaloq.tools.ddk.xtext.test.AbstractUtilTest; import com.avaloq.tools.ddk.xtext.test.AbstractXtextTestUtil; @@ -83,7 +83,7 @@ protected void beforeAllTests() { * Tests extracting project path from a {@link Resource}. */ @Test - public void getPathProjectTest() { + void getPathProjectTest() { assertEquals("Check if the correct project path has been returned", WORKSPACE_PATH + "/" + TEST_PROJECT_NAME, RuntimeProjectUtil.getPathProject(resource, mapperCorrect)); } @@ -92,7 +92,7 @@ public void getPathProjectTest() { * Tests extracting project name from a {@link URI}. */ @Test - public void getProjectCorrectTest() { + void getProjectCorrectTest() { super.addSourceToWorkspace(SOURCE_NAMES.get(0)); IProject iproject = RuntimeProjectUtil.getProject(uriCorrect, mapperCorrect); assumeNotNull(iproject); @@ -103,7 +103,7 @@ public void getProjectCorrectTest() { * Checks when passed {@link IStorage2UriMapper} is broken then null instead of project name expected. */ @Test - public void getProjectInCorrectTest() { + void getProjectInCorrectTest() { super.addSourceToWorkspace(SOURCE_NAMES.get(0)); IProject iproject = RuntimeProjectUtil.getProject(uriCorrect, mapperInCorrect); assertNull("When passed IStorage2UriMapper is broken then null instead of project name expected", iproject); @@ -114,7 +114,7 @@ public void getProjectInCorrectTest() { * Tests correct delegation of responsibility to the {@link IStorage2UriMapper}. */ @Test - public void findFileStorageCorrectTest() { + void findFileStorageCorrectTest() { super.addSourceToWorkspace(SOURCE_NAMES.get(0)); assertEquals("Check if the correct file has been returned", RuntimeProjectUtil.findFileStorage(uriCorrect, mapperCorrect), file); } @@ -123,7 +123,7 @@ public void findFileStorageCorrectTest() { * Checks when passed {@link IStorage2UriMapper} is broken then no file expected. */ @Test - public void findFileStorageInCorrectTest() { + void findFileStorageInCorrectTest() { assertNull("When passed IStorage2UriMapper is broken then no file expected", RuntimeProjectUtil.findFileStorage(uriInCorrect, mapperInCorrect)); } diff --git a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/quickfix/WorkbenchResolutionAdaptorRunTest.java b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/quickfix/WorkbenchResolutionAdaptorRunTest.java index 96536c2d70..ae00ab5360 100644 --- a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/quickfix/WorkbenchResolutionAdaptorRunTest.java +++ b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/quickfix/WorkbenchResolutionAdaptorRunTest.java @@ -43,8 +43,8 @@ import org.eclipse.xtext.util.Pair; import org.eclipse.xtext.util.Tuples; import org.eclipse.xtext.validation.Issue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import com.avaloq.tools.ddk.check.runtime.ui.quickfix.IModificationContextRegistry; @@ -95,7 +95,7 @@ protected void configure() { private final WorkbenchMarkerResolutionGenerator wmrg = injector.getInstance(WorkbenchMarkerResolutionGenerator.class); - @Before + @BeforeEach public void setUp() throws Exception { wmrg.setIssueUtil(new IssueUtil()); @@ -128,7 +128,7 @@ private void mockMarkerResource(final URI uri) throws CoreException { } @Test - public void testRun() throws CoreException { + void testRun() throws CoreException { WorkbenchResolutionAdapter adapter = wmrg.new WorkbenchResolutionAdapter(mockIssueResolution, mockMarker); when(mockMarkerHelpRegistry.getResolutions(mockMarker)).thenReturn(mockMarkerResolutions); @@ -142,7 +142,7 @@ public void testRun() throws CoreException { } @Test - public void testSingleRun() throws CoreException { + void testSingleRun() throws CoreException { WorkbenchResolutionAdapter adapter = wmrg.new WorkbenchResolutionAdapter(mockIssueResolution, mockMarker); when(mockMarkerHelpRegistry.getResolutions(mockMarker)).thenReturn(mockMarkerResolutions); diff --git a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/quickfix/WorkbenchResolutionAdaptorTest.java b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/quickfix/WorkbenchResolutionAdaptorTest.java index 4f30b927c7..fa7efcc978 100644 --- a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/quickfix/WorkbenchResolutionAdaptorTest.java +++ b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/quickfix/WorkbenchResolutionAdaptorTest.java @@ -11,8 +11,8 @@ package com.avaloq.tools.ddk.xtext.ui.quickfix; -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 static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -21,10 +21,10 @@ import org.eclipse.xtext.ui.editor.quickfix.IssueResolution; import org.eclipse.xtext.ui.util.IssueUtil; import org.eclipse.xtext.validation.Issue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; import com.avaloq.tools.ddk.xtext.ui.quickfix.WorkbenchMarkerResolutionGenerator.WorkbenchResolutionAdapter; +import org.junit.jupiter.api.Test; public class WorkbenchResolutionAdaptorTest { @@ -37,13 +37,13 @@ public class WorkbenchResolutionAdaptorTest { private final WorkbenchMarkerResolutionGenerator mockWmrg = mock(WorkbenchMarkerResolutionGenerator.class); - @Before + @BeforeEach public void setUp() throws Exception { when(mockWmrg.getIssueUtil()).thenReturn(new IssueUtil()); } - @Test - public void testGetLabel() { + @org.junit.jupiter.api.Test + void testGetLabel() { IssueResolution mockIssueResolution = mock(IssueResolution.class); IMarker mockMarker = mock(IMarker.class); @@ -54,8 +54,8 @@ public void testGetLabel() { assertEquals("Adapter delegates get label to resolution.", TEST_LABEL, adapter.getLabel()); //$NON-NLS-1$ } - @Test - public void testGetDescription() { + @org.junit.jupiter.api.Test + void testGetDescription() { IssueResolution mockIssueResolution = mock(IssueResolution.class); IMarker mockMarker = mock(IMarker.class); @@ -66,8 +66,8 @@ public void testGetDescription() { assertEquals("Adapter delegates get description to resolution.", TEST_DESCRIPTION, adapter.getDescription()); //$NON-NLS-1$ } - @Test - public void testGetImage() { + @org.junit.jupiter.api.Test + void testGetImage() { IssueResolution mockIssueResolution = mock(IssueResolution.class); IMarker mockMarker = mock(IMarker.class); @@ -78,8 +78,8 @@ public void testGetImage() { assertEquals("Adapter delegates get Image to resolution.", TEST_IMAGE, adapter.getImage()); //$NON-NLS-1$ } - @Test - public void findOtherMarkers() { + @org.junit.jupiter.api.Test + void findOtherMarkers() { IssueResolution mockIssueResolution = mock(IssueResolution.class); IMarker mockResolutionMarker = mock(IMarker.class); when(mockResolutionMarker.getAttribute(Issue.CODE_KEY, null)).thenReturn(CODE1); diff --git a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/ResourceNameTemplateVariableResolverTest.java b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/ResourceNameTemplateVariableResolverTest.java index ef08e0d168..ab3db5556e 100644 --- a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/ResourceNameTemplateVariableResolverTest.java +++ b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/ResourceNameTemplateVariableResolverTest.java @@ -17,8 +17,8 @@ import org.eclipse.xtext.XtextRuntimeModule; import org.eclipse.xtext.ui.editor.model.IXtextDocument; import org.eclipse.xtext.ui.editor.templates.XtextTemplateContext; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; @@ -77,28 +77,28 @@ public void testResolveValuesWithNullContext() { } @Test - public void testResolveValuesWithFileWithoutExtension() throws TemplateException { + void testResolveValuesWithFileWithoutExtension() throws TemplateException { final String filename = "filenamewithnoextension"; //$NON-NLS-1$ testResolveValues(FILE, filename, filename); } @Test - public void testResolveValuesWithFileWithExtension() throws TemplateException { + void testResolveValuesWithFileWithExtension() throws TemplateException { testResolveValues(FILE, "filename.with.extension", "filename.with"); //$NON-NLS-1$//$NON-NLS-2$ } - @Test - public void testResolveValuesWithExtraParams() throws TemplateException { + @org.junit.jupiter.api.Test + void testResolveValuesWithExtraParams() throws TemplateException { testResolveValues(new Object[] {FILE[0], "other", "random", "values"}, FILENAME, FILENAME); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - @Test - public void testResolveValuesWithUnknownParam() throws TemplateException { + @org.junit.jupiter.api.Test + void testResolveValuesWithUnknownParam() throws TemplateException { testResolveValues(new Object[] {"This is not the parameter you are looking for"}, FILENAME); //$NON-NLS-1$ } @Test - public void testResolveValuesWithWrongTypeOfParam() throws TemplateException { + void testResolveValuesWithWrongTypeOfParam() throws TemplateException { testResolveValues(new Object[] {42}, FILENAME); } @@ -121,7 +121,7 @@ public void testResolveValues(final Object[] values, final String filename, fina final String[] actualResolvedValues = Iterables.toArray(resolver.resolveValues(variable, mockContext), String.class); // ASSERT - Assert.assertArrayEquals("Resolved values", expectedResolvedValues, actualResolvedValues); //$NON-NLS-1$ + Assertions.assertArrayEquals("Resolved values", expectedResolvedValues, actualResolvedValues); //$NON-NLS-1$ } } diff --git a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/SimpleEnumTemplateVariableResolverTest.java b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/SimpleEnumTemplateVariableResolverTest.java index 0cf3acb883..6394c61944 100644 --- a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/SimpleEnumTemplateVariableResolverTest.java +++ b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/SimpleEnumTemplateVariableResolverTest.java @@ -11,7 +11,7 @@ package com.avaloq.tools.ddk.xtext.ui.templates; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.mockito.Mockito.mock; import java.util.List; @@ -20,7 +20,7 @@ import org.eclipse.jface.text.templates.TemplateVariable; import org.eclipse.xtext.XtextRuntimeModule; import org.eclipse.xtext.ui.editor.templates.XtextTemplateContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import com.avaloq.tools.ddk.test.core.AfterAll; @@ -50,18 +50,18 @@ public void afterAll() { resolver = null; } - @Test(expected = NullPointerException.class) + @org.junit.jupiter.api.Test(expected = NullPointerException.class) public void testResolveValuesWithNullVariable() { resolver.resolveValues(null, mockContext); } - @Test - public void testResolveValuesWithOneParam() throws TemplateException { + @org.junit.jupiter.api.Test + void testResolveValuesWithOneParam() throws TemplateException { testResolveValues("Value"); //$NON-NLS-1$ } - @Test - public void testResolveValuesWithMultipleParams() throws TemplateException { + @org.junit.jupiter.api.Test + void testResolveValuesWithMultipleParams() throws TemplateException { testResolveValues("Value 1", "Value 2", "Value 3"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } diff --git a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/TemplateProposalProviderHelperTest.xtend b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/TemplateProposalProviderHelperTest.xtend index 6285b36de7..76df10a143 100644 --- a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/TemplateProposalProviderHelperTest.xtend +++ b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/TemplateProposalProviderHelperTest.xtend @@ -22,11 +22,11 @@ import org.eclipse.jface.text.templates.Template import org.eclipse.xtext.XtextRuntimeModule import org.eclipse.xtext.ui.editor.templates.XtextTemplateContext import org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.runner.RunWith -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 static org.mockito.ArgumentMatchers.anyInt import static org.mockito.Mockito.mock import static org.mockito.Mockito.spy diff --git a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/TemplateVariableResolverTestHelper.java b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/TemplateVariableResolverTestHelper.java index 35fe8a7a65..bbca30b73d 100644 --- a/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/TemplateVariableResolverTestHelper.java +++ b/com.avaloq.tools.ddk.xtext.ui.test/src/com/avaloq/tools/ddk/xtext/ui/templates/TemplateVariableResolverTestHelper.java @@ -11,7 +11,7 @@ package com.avaloq.tools.ddk.xtext.ui.templates; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.text.templates.TemplateException; import org.eclipse.jface.text.templates.TemplateTranslator;