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 extends TestSource> 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 extends TestSource> 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 extends EObject> firstExpectedObjectCollection, final Collection extends EObject>... furtherExpectedObjectCollections) {
- Assert.isNotNull(firstExpectedObjectCollection, "firstExpectedObjectCollection");
- Assert.isNotNull(furtherExpectedObjectCollections, "furtherExpectedObjectCollections");
+ Assertions.isNotNull(firstExpectedObjectCollection, "firstExpectedObjectCollection");
+ Assertions.isNotNull(furtherExpectedObjectCollections, "furtherExpectedObjectCollections");
Collection consolidatedList = Lists.newArrayList(firstExpectedObjectCollection);
for (Collection extends EObject> 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 extends EObject> 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