diff --git a/com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF index 3c5df2d214..cb6fc23968 100644 --- a/com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF @@ -20,7 +20,6 @@ Require-Bundle: com.avaloq.tools.ddk.check.core, org.eclipse.xtend.lib, org.eclipse.xtext.ui.testing, org.eclipse.xtext.testing, - org.junit, org.mockito.mockito-core, com.avaloq.tools.ddk.check.runtime.core, org.eclipse.ui.workbench;resolution:=optional, @@ -31,15 +30,11 @@ Require-Bundle: com.avaloq.tools.ddk.check.core, org.eclipse.xtext.xbase.testing, junit-jupiter-api, junit-jupiter-engine, - junit-vintage-engine + junit-vintage-engine, + junit-platform-suite-api Export-Package: com.avaloq.tools.ddk.check.core.test, com.avaloq.tools.ddk.check.core.test.util, com.avaloq.tools.ddk.check.test.core, com.avaloq.tools.ddk.check -Import-Package: org.junit.runner;version="4.5.0", - org.junit.runner.manipulation;version="4.5.0", - org.junit.runner.notification;version="4.5.0", - org.junit.runners;version="4.5.0", - org.junit.runners.model;version="4.5.0", - org.hamcrest.core +Import-Package: org.hamcrest.core Automatic-Module-Name: com.avaloq.tools.ddk.check.core.test 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..7a53cffd08 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 @@ -12,17 +12,18 @@ package com.avaloq.tools.ddk.check.core.generator import org.eclipse.xtext.testing.InjectWith -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 java.util.List import org.eclipse.xtext.xbase.testing.JavaSource import java.io.ByteArrayInputStream +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test +import static org.junit.jupiter.api.Assertions.assertTrue @InjectWith(CheckInjectorProvider) -@RunWith(XtextRunner) +@ExtendWith(InjectionExtension) class IssueCodeValueTest extends AbstractCheckGenerationTestCase { static final String PACKAGE_NAME = "mypackage" @@ -96,7 +97,7 @@ class IssueCodeValueTest extends AbstractCheckGenerationTestCase { for (issueCode: expectedIssueCodeValues.entrySet) { val expectedIssueCodeAssignment = '''public static final String «issueCode.key» = "«PACKAGE_NAME».«CATALOG_NAME»«ISSUE_CODES_SUFFIX».«issueCode.value»";''' - assertTrue('''«issueCodesClassName» contains correct initialization of «issueCode.key»''', issueCodesClass.contains(expectedIssueCodeAssignment)) + assertTrue(issueCodesClass.contains(expectedIssueCodeAssignment), '''«issueCodesClassName» contains correct initialization of «issueCode.key»''') } } diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/AbstractCheckGenerationTestCase.java b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/AbstractCheckGenerationTestCase.java index 566394cacc..aca59bac33 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/AbstractCheckGenerationTestCase.java +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/AbstractCheckGenerationTestCase.java @@ -11,6 +11,10 @@ package com.avaloq.tools.ddk.check.core.test; +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.io.InputStream; import java.util.Collections; @@ -76,7 +80,7 @@ public List generateAndCompile(final InputStream sourceStream) { fail("Could not load test resource" + e.getMessage()); } CheckCatalog root = (CheckCatalog) res.getContents().get(0); - assertNotNull("Resource should contain a CheckCatalog", root); + assertNotNull(root, "Resource should contain a CheckCatalog"); // We also should have some Jvm model here. JvmType type = null; for (EObject obj : res.getContents()) { @@ -85,7 +89,7 @@ public List generateAndCompile(final InputStream sourceStream) { break; } } - assertNotNull("Should have an inferred Jvm model", type); + assertNotNull(type, "Should have an inferred Jvm model"); // Run the generator using an in-memory file system access InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess(); for (OutputConfiguration output : outputConfigurationProvider.getOutputConfigurations()) { @@ -107,7 +111,7 @@ public List generateAndCompile(final InputStream sourceStream) { final InMemoryJavaCompiler.Result result = javaCompiler.compile(sources.toArray(new JavaSource[sources.size()])); // Due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=541225 we must ignore this warning here if (result.getCompilationProblems().stream().anyMatch(p -> "Pb(1102) At least one of the problems in category 'nls' is not analysed due to a compiler option being ignored".equals(p.getMessage()))) { - assertTrue("All sources should have been compiled without errors " + result.getCompilationProblems(), result.getCompilationProblems().isEmpty()); + assertTrue(result.getCompilationProblems().isEmpty(), "All sources should have been compiled without errors " + result.getCompilationProblems()); } return sources; 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 63458ad54e..21ac794f36 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 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.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", "nls"}) -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)); @@ -71,8 +72,7 @@ public abstract class AbstractCheckTestCase extends TestCase { @Inject private Provider resourceSetProvider; - @Override - @Before + @BeforeEach public void setUp() throws Exception { getInjector().injectMembers(this); } @@ -83,7 +83,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 +117,7 @@ public T get(final Class clazz) { /** * Clean up after all tests have terminated. */ - @AfterClass + @AfterAll public static void cleanUp() { PROJECT_MANAGER.teardown(); } @@ -215,7 +215,7 @@ public EObject getModel(final String fileName, final String content) throws Exce IFile file = createFile(fileName, content); Resource resource = get(XtextResourceSet.class).createResource(uri(file)); resource.load(new StringInputStream(content), null); - assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size()); + assertEquals(0, resource.getErrors().size(), resource.getErrors().toString()); return resource.getContents().get(0); } @@ -264,7 +264,7 @@ public EObject getModel(final String fileName) throws Exception { // NOPMD } } } - assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size()); + assertEquals(0, resource.getErrors().size(), resource.getErrors().toString()); return resource.getContents().get(0); } @@ -293,7 +293,7 @@ public boolean apply(final IFile input) { */ protected IProject getOrCreatePluginProject() throws CoreException { IWorkspaceRoot workspaceRoot = EcorePlugin.getWorkspaceRoot(); - assertNotNull("No workspace; project cannot be created or found", workspaceRoot); + assertNotNull(workspaceRoot, "No workspace; project cannot be created or found"); IProject project = workspaceRoot.getProject(PluginTestProjectManager.TEST_PROJECT_NAME); if (!project.exists()) { try { @@ -349,7 +349,7 @@ protected void execute(final IProgressMonitor monitor) throws CoreException, Inv } catch (InterruptedException e) { fail("Error adding files to workspace: " + e.getMessage()); } - assertEquals("All files successfully added to workspace", sourceFileNames.size(), getFiles().size()); + assertEquals(sourceFileNames.size(), getFiles().size(), "All files successfully added to workspace"); } /** 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..42aad415be 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 @@ -4,7 +4,7 @@ * 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 *******************************************************************************/ @@ -19,16 +19,15 @@ import com.avaloq.tools.ddk.check.core.test.util.CheckTestUtil import com.google.inject.Inject 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.runner.RunWith - -import static org.junit.Assert.* +import org.junit.jupiter.api.Test +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.^extension.ExtendWith +import static org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Disabled @InjectWith(typeof(CheckUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class BasicModelTest { @Inject @@ -46,7 +45,7 @@ class BasicModelTest { @Test def void testCreateEmptyModelWithPackageReference() { val model = parser.parse("package p catalog c {}") - assertNotNull("CheckCatalog with EPackage reference successfully created", model); + assertNotNull(model, "CheckCatalog with EPackage reference successfully created") } /** @@ -55,7 +54,7 @@ class BasicModelTest { @Test def void testCreateEmptyModelWithGrammarReference() { val model = parser.parse("package p catalog c for grammar com.avaloq.tools.ddk.check.Check {}") - assertNotNull("CheckCatalog with Grammar reference successfully created", model); + assertNotNull(model, "CheckCatalog with Grammar reference successfully created") } /* Tests that an XIssueExpression takes message parameters. */ @@ -74,10 +73,10 @@ class BasicModelTest { /* Tests that Checks documented with ML_COMMENTs have an inferred description field. */ @Test - @Ignore("Fails because DocumentedImplCustom uses the null resource description provider to get the document provider") + @Disabled("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) + assertEquals(check.description, "No documentation.") } /* Tests that Checks have an implicit name which matches the ID. */ @@ -85,28 +84,33 @@ class BasicModelTest { def void testCheckNameIDIsPresent() { val id = "CheckID" val check = util.getFirstInstanceOf(parser.parse(modelUtil.modelWithCheck(id)), typeof(Check)) - assertEquals("Check name field matches ID field", check.id, check.name) - assertEquals("Check name field matches supplied ID", id, check.name) + assertEquals(check.id, check.name, "Check name field matches ID field") + assertEquals(id, check.name, "Check name field matches supplied ID") } /* Tests that Checks have an implicit name which matches the ID even when the ID is missing. */ @Test def void testCheckNameIDIsMissing() { val check = util.getFirstInstanceOf(parser.parse(modelUtil.modelWithCheck("")), typeof(Check)) - assertNull("Check name is null", check.name) + assertNull(check.name, "Check name is null") } /* Tests that multi- and single-line comments are parsed in a model. */ @Test def void testCommentsInModelParse() { val model = parser.parse(modelUtil.modelWithComments) - assertFalse("Syntax errors not expected but occurred", (model.eResource as XtextResource).parseResult.hasSyntaxErrors) + assertFalse((model.eResource as XtextResource).parseResult.hasSyntaxErrors, + "Syntax errors not expected but occurred") } /* Tests that t.message is allowed, despite "message" being a keyword. */ @Test def void testKeywordAsIdentifier() { - val model = parser.parse(modelUtil.modelWithContext + "try { issue bind (\"mp0\", \"mp1\"); } catch (java.lang.Throwable t) { issue bind (t.message, \"foo\"); }" + "}}}}"); - assertFalse("Syntax errors not expected but occurred", (model.eResource as XtextResource).parseResult.hasSyntaxErrors); + val model = parser.parse( + modelUtil.modelWithContext + + "try { issue bind (\"mp0\", \"mp1\"); } catch (java.lang.Throwable t) { issue bind (t.message, \"foo\"); }" + + "}}}}"); + assertFalse((model.eResource as XtextResource).parseResult.hasSyntaxErrors, + "Syntax errors not expected but occurred") } } diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugAig1314.java b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugAig1314.java index a1d4ea748b..31394387ee 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugAig1314.java +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugAig1314.java @@ -10,9 +10,9 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.core.test; -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.io.InputStream; import java.net.MalformedURLException; @@ -25,9 +25,9 @@ import org.eclipse.xtext.resource.XtextResourceSet; import org.eclipse.xtext.scoping.IScope; import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.avaloq.tools.ddk.check.CheckInjectorProvider; import com.avaloq.tools.ddk.check.runtime.configuration.IModelLocation; @@ -39,10 +39,10 @@ /** * Some tests for AIG-1314, testing that the CatalogFromExtensionPointScope does not make the resource set grow more than expected. */ -@RunWith(XtextRunner.class) +@ExtendWith(InjectionExtension.class) @InjectWith(CheckInjectorProvider.class) @SuppressWarnings("nls") -public class BugAig1314 { +class BugAig1314 { /** Constructor of super class is protected... */ private static class TestScope extends CatalogFromExtensionPointScope { @@ -86,7 +86,7 @@ public InputStream getCatalogStream() { * resource set to check. */ private void assertResourceSetEmpty(final XtextResourceSet rs) { - assertTrue("ResourceSet should be empty", rs.getURIResourceMap().isEmpty() && rs.getResources().isEmpty()); + assertTrue(rs.getURIResourceMap().isEmpty() && rs.getResources().isEmpty(), "ResourceSet should be empty"); } /** @@ -100,12 +100,12 @@ private void assertResourceSetEmpty(final XtextResourceSet rs) { * expected number of resources in the resource map */ private void assertResourceSet(final XtextResourceSet rs, final int expected, final int inMap) { - assertTrue("Test wrong: must expect more than zero resources", expected > 0 && inMap > 0); - assertEquals("ResourceSet should not grow", expected, rs.getResources().size()); - assertEquals("ResourceSet map size", inMap, rs.getURIResourceMap().size()); + assertTrue(expected > 0 && inMap > 0, "Test wrong: must expect more than zero resources"); + assertEquals(expected, rs.getResources().size(), "ResourceSet should not grow"); + assertEquals(inMap, rs.getURIResourceMap().size(), "ResourceSet map size"); for (Resource r : rs.getResources()) { URI uri = r.getURI(); - assertTrue(uri.toString() + " not found in ResourceSet map", rs.getURIResourceMap().containsKey(uri)); + assertTrue(rs.getURIResourceMap().containsKey(uri), uri.toString() + " not found in ResourceSet map"); } } @@ -116,14 +116,14 @@ private void assertResourceSet(final XtextResourceSet rs, final int expected, fi * to check */ private void assertIterableNotEmpty(final Iterable iterable) { - assertFalse("Iterable should not be empty", Iterables.isEmpty(iterable)); + assertFalse(Iterables.isEmpty(iterable), "Iterable should not be empty"); } /** * Tests that querying the same scope twice doesn't make the resource set grow. */ @Test - public void testSameScopeUseTwice() throws MalformedURLException, URISyntaxException { + void testSameScopeUseTwice() throws MalformedURLException, URISyntaxException { XtextResourceSet rs = new XtextResourceSet(); URL url = createURL(); ModelLocation modelLocation = createModelLocation(url); @@ -142,7 +142,7 @@ public void testSameScopeUseTwice() throws MalformedURLException, URISyntaxExcep * Tests that querying two different scopes doesn't make the resource set grow. That one was the real cause of bug AIG-1314. */ @Test - public void testDifferentScopeUseTwice() throws MalformedURLException, URISyntaxException { + void testDifferentScopeUseTwice() throws MalformedURLException, URISyntaxException { XtextResourceSet rs = new XtextResourceSet(); URL url = createURL(); ModelLocation modelLocation = createModelLocation(url); 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..854dace54c 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 @@ -16,15 +16,15 @@ import com.avaloq.tools.ddk.check.check.XIssueExpression import com.google.inject.Inject import org.eclipse.xtext.EcoreUtil2 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.runner.RunWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.^extension.ExtendWith +import org.junit.jupiter.api.Test +import static org.junit.jupiter.api.Assertions.* @InjectWith(typeof(CheckUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class BugAig830 { @Inject @@ -48,9 +48,9 @@ class BugAig830 { def void bugAig830() { val model = parser.parse(getModel()) val issue = EcoreUtil2::getAllContentsOfType(model, typeof(XIssueExpression)).get(0) - Assert::assertNotNull(issue.markerFeature) - Assert::assertFalse(issue.markerFeature.eIsProxy) - Assert::assertEquals(XbasePackage.Literals::XVARIABLE_DECLARATION, issue.markerFeature.EContainingClass) + assertNotNull(issue.markerFeature) + assertFalse(issue.markerFeature.eIsProxy) + assertEquals(XbasePackage.Literals::XVARIABLE_DECLARATION, issue.markerFeature.EContainingClass) } } 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 c6ce548252..3d5e7973ce 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 @@ -14,9 +14,9 @@ import java.io.InputStream; import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.avaloq.tools.ddk.check.CheckInjectorProvider; @@ -25,15 +25,15 @@ * Tests that the java code generated from BugDsl27 has no errors. */ @InjectWith(CheckInjectorProvider.class) -@RunWith(XtextRunner.class) +@ExtendWith(InjectionExtension.class) @SuppressWarnings("nls") -public class BugDsl27 extends AbstractCheckGenerationTestCase { +class BugDsl27 extends AbstractCheckGenerationTestCase { /** * Tests that our test source compiles fine. */ @Test - public void testGeneratedCodeHasNoErrors() { + 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..3c031610bb 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 @@ -4,7 +4,7 @@ * 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 *******************************************************************************/ @@ -20,13 +20,14 @@ import com.google.common.collect.Lists import com.google.inject.Inject 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.runner.RunWith +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test +import static org.junit.jupiter.api.Assertions.* @InjectWith(typeof(CheckUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class CheckScopingTest extends AbstractCheckTestCase { @Inject CheckTestUtil util @@ -61,10 +62,10 @@ class CheckScopingTest extends AbstractCheckTestCase { val model = getModel("CommonChecks") as CheckCatalog val illegalRefImpl = util.getFirstInstanceOf(model, typeof(Implementation)) - val issueExpr = util.getFirstInstanceOf(illegalRefImpl, typeof(XIssueExpression)) + val issueExpr = util.getFirstInstanceOf(illegalRefImpl, typeof(XIssueExpression)) - assertTrue("Referenced check cannot be resolved", issueExpr.check.eIsProxy) - assertNull("Referenced check name is null", issueExpr.check.name) + assertTrue(issueExpr.check.eIsProxy, "Referenced check cannot be resolved") + assertNull(issueExpr.check.name, "Referenced check name is null") } /* @@ -75,6 +76,6 @@ class CheckScopingTest extends AbstractCheckTestCase { def void testCheckDescriptionIsInferred() { initializeTestProject val check = util.getFirstInstanceOf(getModel("CommonChecks"), typeof(Check)) - assertEquals("Referenced check cannot be resolved", "This check is javadoc-like commented.", check.description) + assertEquals(check.description, "Referenced check cannot be resolved", "This check is javadoc-like commented.") } } 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..b0c7826fdf 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 @@ -14,17 +14,18 @@ package com.avaloq.tools.ddk.check.core.test 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.runner.RunWith import java.util.List import org.eclipse.xtext.xbase.testing.JavaSource +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test +import static org.junit.jupiter.api.Assertions.* /** * Unit test for autogeneration of check issue code to label map. */ @InjectWith(CheckInjectorProvider) -@RunWith(XtextRunner) +@ExtendWith(typeof(InjectionExtension)) class IssueCodeToLabelMapGenerationTest extends AbstractCheckGenerationTestCase { static final String PACKAGE_NAME = "mypackage" @@ -121,7 +122,7 @@ class IssueCodeToLabelMapGenerationTest extends AbstractCheckGenerationTestCase val catalogClass = compiledClassesList.findFirst[s | s.fileName.equals(catalogClassName)].code; for (code: expectedCatalog) { - assertTrue('''«catalogClassName» was generated correctly''', catalogClass.replaceAll("\\s+","").contains(code)) + assertTrue( catalogClass.replaceAll("\\s+","").contains(code), '''«catalogClassName» was generated correctly''') } } 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..540d405e8c 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 @@ -19,13 +19,14 @@ import org.eclipse.core.resources.IMarker 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.runner.RunWith import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test +import static org.junit.jupiter.api.Assertions.* @InjectWith(typeof(CheckUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class ProjectBasedTests extends AbstractCheckTestCase { boolean initialized; @@ -65,9 +66,9 @@ class ProjectBasedTests extends AbstractCheckTestCase { val IProject project = getOrCreatePluginProject() val IFile file = project.getFile(fileName); // enumerateContents(project); - assertTrue("Generated file should exist", file.exists); - assertFalse("Generated file should not be empty", isEmpty(file)); - assertTrue("Generated file should not have errors", file.findMaxProblemSeverity(null, true, IResource::DEPTH_INFINITE) < IMarker::SEVERITY_ERROR); + assertTrue( file.exists,"Generated file should exist") + assertFalse( isEmpty(file),"Generated file should not be empty") + assertTrue( file.findMaxProblemSeverity(null, true, IResource::DEPTH_INFINITE) < IMarker::SEVERITY_ERROR,"Generated file should not have errors") } 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..027a376929 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 @@ -16,13 +16,13 @@ import com.google.inject.Inject import org.eclipse.xtext.formatting2.FormatterPreferenceKeys 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.runner.RunWith +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test @InjectWith(typeof(CheckUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class CheckFormattingTest { @Inject diff --git a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/test/core/CheckCoreTestSuite.java b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/test/core/CheckCoreTestSuite.java index dd15402859..79371b1229 100644 --- a/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/test/core/CheckCoreTestSuite.java +++ b/com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/test/core/CheckCoreTestSuite.java @@ -10,42 +10,21 @@ *******************************************************************************/ package com.avaloq.tools.ddk.check.test.core; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -import com.avaloq.tools.ddk.check.core.generator.IssueCodeValueTest; -import com.avaloq.tools.ddk.check.core.test.BasicModelTest; -import com.avaloq.tools.ddk.check.core.test.BugAig1314; -import com.avaloq.tools.ddk.check.core.test.BugAig830; -import com.avaloq.tools.ddk.check.core.test.BugDsl27; -import com.avaloq.tools.ddk.check.core.test.CheckScopingTest; -import com.avaloq.tools.ddk.check.core.test.IssueCodeToLabelMapGenerationTest; -import com.avaloq.tools.ddk.check.core.test.ProjectBasedTests; -import com.avaloq.tools.ddk.check.formatting.CheckFormattingTest; -import com.avaloq.tools.ddk.check.validation.CheckApiAccessValidationsTest; -import com.avaloq.tools.ddk.check.validation.CheckJavaValidatorUtilTest; -import com.avaloq.tools.ddk.check.validation.CheckValidationTest; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; /** - * Empty class serving only as holder for JUnit4 annotations. + * Junit5 version of test suites. does not implement the logic in our DiscerningSuite. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectPackages({ // @Format-Off - BasicModelTest.class, - CheckScopingTest.class, - CheckValidationTest.class, - CheckJavaValidatorUtilTest.class, - CheckFormattingTest.class, - BugAig830.class, - BugAig1314.class, - BugDsl27.class, - ProjectBasedTests.class, - CheckApiAccessValidationsTest.class, - IssueCodeToLabelMapGenerationTest.class, - IssueCodeValueTest.class -// @Format-On + "com.avaloq.tools.ddk.check.core.generator", + "com.avaloq.tools.ddk.check.core.test", + "com.avaloq.tools.ddk.check.formatting", + "com.avaloq.tools.ddk.check.validation" + // @Format-On }) public class CheckCoreTestSuite { 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..0c9f980703 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 @@ -10,18 +10,18 @@ package com.avaloq.tools.ddk.check.validation 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 com.google.inject.Inject import org.eclipse.xtext.testing.util.ParseHelper import com.avaloq.tools.ddk.check.check.CheckCatalog import org.eclipse.xtext.testing.validation.ValidationTestHelper import org.eclipse.xtext.xtype.XtypePackage +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test @InjectWith(typeof(CheckUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class CheckApiAccessValidationsTest{ @Inject 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 1e59ac3a23..b862f5788c 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,26 +10,26 @@ *******************************************************************************/ 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.runner.RunWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; 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. */ @InjectWith(CheckUiInjectorProvider.class) -@RunWith(XtextRunner.class) +@ExtendWith(InjectionExtension.class) @SuppressWarnings("nls") -public class CheckJavaValidatorUtilTest extends TestCase { +class CheckJavaValidatorUtilTest { // assertion messages. private static final String STARTS_WITH_LOWER_CASE = "starts with lower case"; @@ -65,23 +65,23 @@ public class CheckJavaValidatorUtilTest extends TestCase { * Tests checkProjectName. The given values are valid. */ @Test - public void projectNameIsValid() { - assertTrue(QUALIFIED_NAME, util.checkProjectName("project.name").isOK()); - assertTrue(NON_QUALIFIED_NAME, util.checkProjectName("projectname").isOK()); + void projectNameIsValid() { + assertTrue(util.checkProjectName("project.name").isOK(), QUALIFIED_NAME); + assertTrue(util.checkProjectName("projectname").isOK(), NON_QUALIFIED_NAME); } /** * Tests checkProjectName. The given values are invalid. */ @Test - public 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)); - assertTrue(CONTAINS_ILLEGAL_CHARACTER_DOLLAR, util.checkCatalogName("client$project").matches(IStatus.ERROR)); - assertTrue(CONTAINS_ILLEGAL_CHARACTER_WHITESPACE, util.checkProjectName("project.name ").matches(IStatus.ERROR)); - assertTrue(CONTAINS_UPPERCASE_LETTER, util.checkProjectName("proJect.Name").matches(IStatus.ERROR)); - assertTrue(CONTAINS_DOUBLE_DOT, util.checkProjectName("project..name").matches(IStatus.ERROR)); + void projectNameIsInvalid() { + assertTrue(util.checkProjectName(EMPTY_STRING).matches(IStatus.ERROR), NAME_IS_EMPTY); + assertTrue(util.checkProjectName("Project.name").matches(IStatus.ERROR), STARTS_WITH_UPPERCASE_LETTER); + assertTrue(util.checkProjectName(".projectname").matches(IStatus.ERROR), STARTS_WITH_ILLEGAL_CHARACTER_DOT); + assertTrue(util.checkCatalogName("client$project").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER_DOLLAR); + assertTrue(util.checkProjectName("project.name ").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER_WHITESPACE); + assertTrue(util.checkProjectName("proJect.Name").matches(IStatus.ERROR), CONTAINS_UPPERCASE_LETTER); + assertTrue(util.checkProjectName("project..name").matches(IStatus.ERROR), CONTAINS_DOUBLE_DOT); } /** @@ -89,9 +89,9 @@ public void projectNameIsInvalid() { */ @Test - public void packageNameIsValid() { - assertTrue(QUALIFIED_NAME, util.checkPackageName("package.name").isOK()); - assertTrue(NON_QUALIFIED_NAME, util.checkPackageName("packagename").isOK()); + void packageNameIsValid() { + assertTrue(util.checkPackageName("package.name").isOK(), QUALIFIED_NAME); + assertTrue(util.checkPackageName("packagename").isOK(), NON_QUALIFIED_NAME); } /** @@ -99,72 +99,72 @@ public void packageNameIsValid() { */ @Test - public 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)); - assertTrue(CONTAINS_ILLEGAL_CHARACTER_WHITESPACE, util.checkPackageName("packagename ").matches(IStatus.ERROR)); - assertTrue(CONTAINS_ILLEGAL_CHARACTER_DOLLAR, util.checkCatalogName("client$package").matches(IStatus.ERROR)); - assertTrue(CONTAINS_UPPERCASE_LETTER, util.checkPackageName("package.Name").matches(IStatus.ERROR)); - assertTrue(CONTAINS_DOUBLE_DOT, util.checkPackageName("package..name").matches(IStatus.ERROR)); + void packageNameIsInvalid() { + assertTrue(util.checkPackageName(EMPTY_STRING).matches(IStatus.ERROR), NAME_IS_EMPTY); + assertTrue(util.checkPackageName("Package.name").matches(IStatus.ERROR), STARTS_WITH_UPPERCASE_LETTER); + assertTrue(util.checkPackageName(".packagename").matches(IStatus.ERROR), STARTS_WITH_ILLEGAL_CHARACTER_DOT); + assertTrue(util.checkPackageName("packagename ").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER_WHITESPACE); + assertTrue(util.checkCatalogName("client$package").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER_DOLLAR); + assertTrue(util.checkPackageName("package.Name").matches(IStatus.ERROR), CONTAINS_UPPERCASE_LETTER); + assertTrue(util.checkPackageName("package..name").matches(IStatus.ERROR), CONTAINS_DOUBLE_DOT); } /** * Tests checkCatalogName. The given values are valid. */ @Test - public void catalogNameIsValid() { - assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCatalogName("Catalogname").isOK()); - assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCatalogName("CatalogName").isOK()); + void catalogNameIsValid() { + assertTrue(util.checkCatalogName("Catalogname").isOK(), STARTS_WITH_UPPERCASE_LETTER); + assertTrue(util.checkCatalogName("CatalogName").isOK(), STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS); } /** * Tests checkCatalogName. The given values are invalid. */ @Test - public 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)); - assertTrue(CONTAINS_ILLEGAL_CHARACTER_DOLLAR, util.checkCatalogName("Client$Catalog").matches(IStatus.ERROR)); + void catalogNameIsInvalid() { + assertTrue(util.checkCatalogName(EMPTY_STRING).matches(IStatus.ERROR), NAME_IS_EMPTY); + assertTrue(util.checkCatalogName("Catalog.Name").matches(IStatus.ERROR), QUALIFIED_NAME); + assertTrue(util.checkCatalogName(",Catalogname").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER); + assertTrue(util.checkCatalogName("Client$Catalog").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER_DOLLAR); } /** * Tests checkCatalogName. The given values are discouraged. */ @Test - public 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)); + void catalogNameIsDiscouraged() { + assertTrue(util.checkCatalogName("catalogname").matches(IStatus.WARNING), STARTS_WITH_LOWER_CASE); + assertTrue(util.checkCatalogName("catalogName").matches(IStatus.WARNING), STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS); } /** * Tests checkCheckName. The given values are valid. */ @Test - public void checkNameIsValid() { - assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCheckName("Checkname").isOK()); - assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCheckName("CheckName").isOK()); + void checkNameIsValid() { + assertTrue(util.checkCheckName("Checkname").isOK(), STARTS_WITH_UPPERCASE_LETTER); + assertTrue(util.checkCheckName("CheckName").isOK(), STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS); } /** * Tests checkCheckName. The given values are invalid. */ @Test - public 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)); - assertTrue(CONTAINS_ILLEGAL_CHARACTER_DOLLAR, util.checkCatalogName("client$check").matches(IStatus.ERROR)); + void checkNameIsInvalid() { + assertTrue(util.checkCheckName(EMPTY_STRING).matches(IStatus.ERROR), NAME_IS_EMPTY); + assertTrue(util.checkCheckName("Check.name").matches(IStatus.ERROR), QUALIFIED_NAME); + assertTrue(util.checkCheckName(",checkname").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER); + assertTrue(util.checkCatalogName("client$check").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER_DOLLAR); } /** * Tests checkCheckName. The given values are discouraged. */ @Test - public 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)); + void checkNameIsDiscouraged() { + assertTrue(util.checkCheckName("checkname").matches(IStatus.WARNING), STARTS_WITH_LOWER_CASE); + assertTrue(util.checkCheckName("checkName").matches(IStatus.WARNING), STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS); } @@ -172,28 +172,28 @@ public void checkNameIsDiscouraged() { * Tests checkCategoryName. The given values are valid. */ @Test - public void categoryNameIsValid() { - assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCategoryName("Categoryname").isOK()); - assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCategoryName("CategoryName").isOK()); + void categoryNameIsValid() { + assertTrue(util.checkCategoryName("Categoryname").isOK(), STARTS_WITH_UPPERCASE_LETTER); + assertTrue(util.checkCategoryName("CategoryName").isOK(), STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS); } /** * Tests checkCategoryName. The given values are invalid. */ @Test - public 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)); - assertTrue(CONTAINS_ILLEGAL_CHARACTER_DOLLAR, util.checkCatalogName("Client$Category").matches(IStatus.ERROR)); + void categoryNameIsInvalid() { + assertTrue(util.checkCategoryName(EMPTY_STRING).matches(IStatus.ERROR), NAME_IS_EMPTY); + assertTrue(util.checkCategoryName("Category.name").matches(IStatus.ERROR), QUALIFIED_NAME); + assertTrue(util.checkCategoryName("%categoryname").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER); + assertTrue(util.checkCatalogName("Client$Category").matches(IStatus.ERROR), CONTAINS_ILLEGAL_CHARACTER_DOLLAR); } /** * Tests checkCategoryName. The given values are discouraged. */ @Test - public 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)); + void categoryNameIsDiscouraged() { + assertTrue(util.checkCategoryName("categoryname").matches(IStatus.WARNING), STARTS_WITH_LOWER_CASE); + assertTrue(util.checkCategoryName("categoryName").matches(IStatus.WARNING), STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS); } } 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..42420211ec 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 @@ -16,15 +16,15 @@ import com.avaloq.tools.ddk.check.core.test.util.CheckModelUtil import com.google.common.collect.Lists 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.eclipse.xtext.testing.validation.ValidationTestHelper import org.eclipse.xtext.xbase.XbasePackage$Literals -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith import com.avaloq.tools.ddk.check.validation.IssueCodes import com.avaloq.tools.ddk.check.check.CheckPackage +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled /* * Tests for various check validations as implemented in the validation classes @@ -34,7 +34,7 @@ import com.avaloq.tools.ddk.check.check.CheckPackage * */ @InjectWith(typeof(CheckUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class CheckValidationTest { @Inject @@ -97,7 +97,7 @@ class CheckValidationTest { /* Tests checkContextTypeIsUnique(Check) */ @Test - @Ignore("Tests do not work because of scoping issues at run-time") + @Disabled("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.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..c27822ac24 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 @@ -20,14 +20,14 @@ import com.google.common.collect.Lists import com.google.inject.Inject import java.util.List 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.runner.RunWith +import org.junit.jupiter.api.Test +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.^extension.ExtendWith @InjectWith(typeof(TestLanguageUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class CheckConfigurationIsAppliedTest extends AbstractCheckTestCase { @Inject 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..bd0bff2858 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 @@ -19,14 +19,15 @@ import com.avaloq.tools.ddk.check.validation.ExecutionEnvironmentIssueCodes import com.avaloq.tools.ddk.check.validation.LibraryChecksIssueCodes 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.eclipse.xtext.testing.validation.ValidationTestHelper -import org.junit.Test -import org.junit.runner.RunWith +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test + @InjectWith(typeof(TestLanguageUiInjectorProvider)) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class CheckExecutionEnvironmentProjectTest extends AbstractCheckTestCase { @Inject diff --git a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/AbstractCheckContentAssistBugTest.java b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/AbstractCheckContentAssistBugTest.java index 73c7ff5ace..10b0719128 100644 --- a/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/AbstractCheckContentAssistBugTest.java +++ b/com.avaloq.tools.ddk.check.ui.test/src/com/avaloq/tools/ddk/check/ui/test/contentassist/AbstractCheckContentAssistBugTest.java @@ -11,6 +11,7 @@ package com.avaloq.tools.ddk.check.ui.test.contentassist; import static org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.findJavaProject; +import static org.junit.Assert.fail; import java.io.InputStream; diff --git a/com.avaloq.tools.ddk.sample.helloworld.ui.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.sample.helloworld.ui.test/META-INF/MANIFEST.MF index 96fc9d5955..6905750b8c 100644 --- a/com.avaloq.tools.ddk.sample.helloworld.ui.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.sample.helloworld.ui.test/META-INF/MANIFEST.MF @@ -18,7 +18,10 @@ Require-Bundle: com.avaloq.tools.ddk.sample.helloworld, com.avaloq.tools.ddk.check.runtime.core, com.avaloq.tools.ddk.check.runtime.ui, com.avaloq.tools.ddk.check.core.test, - org.eclipse.xtext.xbase.ui.testing + org.eclipse.xtext.xbase.ui.testing, + junit-jupiter-api, + junit-jupiter-engine, + junit-vintage-engine Bundle-RequiredExecutionEnvironment: JavaSE-21 Export-Package: com.avaloq.tools.ddk.sample.helloworld.test, com.avaloq.tools.ddk.sample.helloworld.ui;x-internal=true 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..60376ba251 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 @@ -15,19 +15,19 @@ import com.google.common.collect.Lists import com.google.inject.Inject import java.util.List 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.runner.RunWith import com.avaloq.tools.ddk.sample.helloworld.helloWorld.Model import com.avaloq.tools.ddk.sample.helloworld.ui.internal.HelloworldActivator import com.avaloq.tools.ddk.sample.helloworld.helloWorld.HelloWorldPackage import com.avaloq.tools.ddk.sample.helloworld.validation.ExecutionEnvironmentIssueCodes import com.avaloq.tools.ddk.sample.helloworld.ui.HelloWorldUiInjectorProvider +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test @InjectWith(typeof(HelloWorldUiInjectorProvider)) -@RunWith(XtextRunner) +@ExtendWith(typeof(InjectionExtension)) class CheckConfigurationIsAppliedTest extends AbstractCheckTestCase { @Inject 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..e3df63d53d 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 @@ -13,11 +13,12 @@ package com.avaloq.tools.ddk.sample.helloworld.check import com.avaloq.tools.ddk.check.core.test.AbstractCheckTestCase 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.eclipse.xtext.testing.validation.ValidationTestHelper -import org.junit.Test -import org.junit.runner.RunWith +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test + import com.avaloq.tools.ddk.sample.helloworld.ui.internal.HelloworldActivator import com.avaloq.tools.ddk.sample.helloworld.helloWorld.Model import com.avaloq.tools.ddk.sample.helloworld.helloWorld.HelloWorldPackage @@ -27,7 +28,7 @@ import com.avaloq.tools.ddk.sample.helloworld.validation.IssueCodes import com.avaloq.tools.ddk.sample.helloworld.ui.HelloWorldUiInjectorProvider @InjectWith(HelloWorldUiInjectorProvider) -@RunWith(typeof(XtextRunner)) +@ExtendWith(typeof(InjectionExtension)) class CheckExecutionEnvironmentProjectTest extends AbstractCheckTestCase { @Inject