Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.junit.runner.RunWith
import com.avaloq.tools.ddk.check.CheckInjectorProvider
import org.eclipse.xtext.testing.XtextRunner
import com.avaloq.tools.ddk.check.core.test.AbstractCheckGenerationTestCase
import org.junit.Test
import org.junit.jupiter.api.Test
import java.util.List
import org.eclipse.xtext.xbase.testing.JavaSource
import java.io.ByteArrayInputStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
package com.avaloq.tools.ddk.check.core.test;

import static com.google.common.collect.Sets.newHashSet;
import org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -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;
Expand All @@ -54,14 +57,12 @@
import com.google.inject.Injector;
import com.google.inject.Provider;

import junit.framework.TestCase;


/**
* An abstract test class for tests on Check models. Allows creating a project and adding files.
*/
@SuppressWarnings({"PMD.SignatureDeclareThrowsException", "restriction"})
public abstract class AbstractCheckTestCase extends TestCase {
public abstract class AbstractCheckTestCase {
private static final int TWO_KILO_BYTES = 2048;
protected static final Logger LOGGER = LogManager.getLogger(AbstractCheckTestCase.class);
private static final PluginTestProjectManager PROJECT_MANAGER = new PluginTestProjectManager(CheckActivator.getInstance().getInjector(CheckConstants.GRAMMAR));
Expand All @@ -72,7 +73,7 @@ public abstract class AbstractCheckTestCase extends TestCase {
private Provider<XtextResourceSet> resourceSetProvider;

@Override
@Before
@BeforeEach
public void setUp() throws Exception {
getInjector().injectMembers(this);
}
Expand All @@ -83,7 +84,7 @@ public void setUp() throws Exception {
* @throws Exception
* the exception
*/
@BeforeClass
@BeforeAll
public static void prepareWorkspace() throws Exception {
PROJECT_MANAGER.setup(ImmutableList.<TestSource> of());
}
Expand Down Expand Up @@ -117,7 +118,7 @@ public <T> T get(final Class<T> clazz) {
/**
* Clean up after all tests have terminated.
*/
@AfterClass
@AfterAll
public static void cleanUp() {
PROJECT_MANAGER.teardown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import org.eclipse.xtext.resource.XtextResource
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.testing.util.ParseHelper
import org.junit.Ignore
import org.junit.Test
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith

import static org.junit.Assert.*
import static org.junit.jupiter.api.Assertions.*

@InjectWith(typeof(CheckUiInjectorProvider))
@RunWith(typeof(XtextRunner))
Expand Down Expand Up @@ -73,8 +73,8 @@ class BasicModelTest {
}

/* Tests that Checks documented with ML_COMMENTs have an inferred description field. */
@Disabled("Fails because DocumentedImplCustom uses the null resource description provider to get the document provider")
@Test
@Ignore("Fails because DocumentedImplCustom uses the null resource description provider to get the document provider")
def void testInferingOfDescription() {
val check = util.getFirstInstanceOf(parser.parse(modelUtil.modelWithCheck), typeof(Check))
assertEquals("No documentation.", check.description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.testing.util.ParseHelper
import org.eclipse.xtext.xbase.XbasePackage
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith

@InjectWith(typeof(CheckUiInjectorProvider))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import com.avaloq.tools.ddk.check.CheckInjectorProvider;
Expand All @@ -26,13 +26,13 @@
*/
@InjectWith(CheckInjectorProvider.class)
@RunWith(XtextRunner.class)
public class BugDsl27 extends AbstractCheckGenerationTestCase {

Check warning on line 29 in com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/core/test/BugDsl27.java

View workflow job for this annotation

GitHub Actions / pmd

JUnit 5 tests should be package-private.

Reports JUnit 5 test classes and methods that are not package-private. Contrary to JUnit 4 tests, which required public visibility to be run by the engine, JUnit 5 tests can also be run if they're package-private. Marking them as such is a good practice to limit their visibility. Test methods are identified as those which use `@Test`, `@RepeatedTest`, `@TestFactory`, `@TestTemplate` or `@ParameterizedTest`. JUnit5TestShouldBePackagePrivate (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/snapshot/pmd_rules_java_bestpractices.html#junit5testshouldbepackageprivate

/**
* Tests that our test source compiles fine.
*/
@Test
public void testGeneratedCodeHasNoErrors() {
@org.junit.jupiter.api.Test
void testGeneratedCodeHasNoErrors() {
try (InputStream sourceStream = BugDsl27.class.getResourceAsStream("bugdsl27/BugDsl27")) {
generateAndCompile(sourceStream);
} catch (IOException exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util.List
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil
import org.junit.Test
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith

@InjectWith(typeof(CheckUiInjectorProvider))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.avaloq.tools.ddk.check.CheckInjectorProvider
import java.io.ByteArrayInputStream
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.junit.Test
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith
import java.util.List
import org.eclipse.xtext.xbase.testing.JavaSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.eclipse.core.resources.IProject
import org.eclipse.core.resources.IResource
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.junit.Test
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.eclipse.xtext.preferences.MapBasedPreferenceValues
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.testing.formatter.FormatterTestHelper
import org.junit.Test
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith

@InjectWith(typeof(CheckUiInjectorProvider))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.eclipse.xtext.testing.InjectWith
import org.junit.runner.RunWith
import org.eclipse.xtext.testing.XtextRunner
import com.avaloq.tools.ddk.check.CheckUiInjectorProvider
import org.junit.Test
import org.junit.jupiter.api.Test
import com.google.inject.Inject
import org.eclipse.xtext.testing.util.ParseHelper
import com.avaloq.tools.ddk.check.check.CheckCatalog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@
*******************************************************************************/
package com.avaloq.tools.ddk.check.validation;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import com.avaloq.tools.ddk.check.CheckUiInjectorProvider;
import com.google.inject.Inject;

import junit.framework.TestCase;


/**
* Tests for com.avaloq.tools.ddk.check.validation.CheckJavaValidatorUtil.
*/

@InjectWith(CheckUiInjectorProvider.class)
@RunWith(XtextRunner.class)
public class CheckJavaValidatorUtilTest extends TestCase {
public class CheckJavaValidatorUtilTest {

Check warning on line 31 in com.avaloq.tools.ddk.check.core.test/src/com/avaloq/tools/ddk/check/validation/CheckJavaValidatorUtilTest.java

View workflow job for this annotation

GitHub Actions / pmd

JUnit 5 tests should be package-private.

Reports JUnit 5 test classes and methods that are not package-private. Contrary to JUnit 4 tests, which required public visibility to be run by the engine, JUnit 5 tests can also be run if they're package-private. Marking them as such is a good practice to limit their visibility. Test methods are identified as those which use `@Test`, `@RepeatedTest`, `@TestFactory`, `@TestTemplate` or `@ParameterizedTest`. JUnit5TestShouldBePackagePrivate (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/snapshot/pmd_rules_java_bestpractices.html#junit5testshouldbepackageprivate

// assertion messages.
private static final String STARTS_WITH_LOWER_CASE = "starts with lower case";
Expand Down Expand Up @@ -64,7 +64,7 @@
* Tests checkProjectName. The given values are valid.
*/
@Test
public void projectNameIsValid() {
void projectNameIsValid() {
assertTrue(QUALIFIED_NAME, util.checkProjectName("project.name").isOK());
assertTrue(NON_QUALIFIED_NAME, util.checkProjectName("projectname").isOK());
}
Expand All @@ -73,7 +73,7 @@
* Tests checkProjectName. The given values are invalid.
*/
@Test
public void projectNameIsInvalid() {
void projectNameIsInvalid() {
assertTrue(NAME_IS_EMPTY, util.checkProjectName(EMPTY_STRING).matches(IStatus.ERROR));
assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkProjectName("Project.name").matches(IStatus.ERROR));
assertTrue(STARTS_WITH_ILLEGAL_CHARACTER_DOT, util.checkProjectName(".projectname").matches(IStatus.ERROR));
Expand All @@ -88,7 +88,7 @@
*/

@Test
public void packageNameIsValid() {
void packageNameIsValid() {
assertTrue(QUALIFIED_NAME, util.checkPackageName("package.name").isOK());
assertTrue(NON_QUALIFIED_NAME, util.checkPackageName("packagename").isOK());
}
Expand All @@ -98,7 +98,7 @@
*/

@Test
public void packageNameIsInvalid() {
void packageNameIsInvalid() {
assertTrue(NAME_IS_EMPTY, util.checkPackageName(EMPTY_STRING).matches(IStatus.ERROR));
assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkPackageName("Package.name").matches(IStatus.ERROR));
assertTrue(STARTS_WITH_ILLEGAL_CHARACTER_DOT, util.checkPackageName(".packagename").matches(IStatus.ERROR));
Expand All @@ -112,7 +112,7 @@
* Tests checkCatalogName. The given values are valid.
*/
@Test
public void catalogNameIsValid() {
void catalogNameIsValid() {
assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCatalogName("Catalogname").isOK());
assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCatalogName("CatalogName").isOK());
}
Expand All @@ -121,7 +121,7 @@
* Tests checkCatalogName. The given values are invalid.
*/
@Test
public void catalogNameIsInvalid() {
void catalogNameIsInvalid() {
assertTrue(NAME_IS_EMPTY, util.checkCatalogName(EMPTY_STRING).matches(IStatus.ERROR));
assertTrue(QUALIFIED_NAME, util.checkCatalogName("Catalog.Name").matches(IStatus.ERROR));
assertTrue(CONTAINS_ILLEGAL_CHARACTER, util.checkCatalogName(",Catalogname").matches(IStatus.ERROR));
Expand All @@ -132,7 +132,7 @@
* Tests checkCatalogName. The given values are discouraged.
*/
@Test
public void catalogNameIsDiscouraged() {
void catalogNameIsDiscouraged() {
assertTrue(STARTS_WITH_LOWER_CASE, util.checkCatalogName("catalogname").matches(IStatus.WARNING));
assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCatalogName("catalogName").matches(IStatus.WARNING));
}
Expand All @@ -141,7 +141,7 @@
* Tests checkCheckName. The given values are valid.
*/
@Test
public void checkNameIsValid() {
void checkNameIsValid() {
assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCheckName("Checkname").isOK());
assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCheckName("CheckName").isOK());
}
Expand All @@ -150,7 +150,7 @@
* Tests checkCheckName. The given values are invalid.
*/
@Test
public void checkNameIsInvalid() {
void checkNameIsInvalid() {
assertTrue(NAME_IS_EMPTY, util.checkCheckName(EMPTY_STRING).matches(IStatus.ERROR));
assertTrue(QUALIFIED_NAME, util.checkCheckName("Check.name").matches(IStatus.ERROR));
assertTrue(CONTAINS_ILLEGAL_CHARACTER, util.checkCheckName(",checkname").matches(IStatus.ERROR));
Expand All @@ -161,7 +161,7 @@
* Tests checkCheckName. The given values are discouraged.
*/
@Test
public void checkNameIsDiscouraged() {
void checkNameIsDiscouraged() {
assertTrue(STARTS_WITH_LOWER_CASE, util.checkCheckName("checkname").matches(IStatus.WARNING));
assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCheckName("checkName").matches(IStatus.WARNING));

Expand All @@ -171,7 +171,7 @@
* Tests checkCategoryName. The given values are valid.
*/
@Test
public void categoryNameIsValid() {
void categoryNameIsValid() {
assertTrue(STARTS_WITH_UPPERCASE_LETTER, util.checkCategoryName("Categoryname").isOK());
assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCategoryName("CategoryName").isOK());
}
Expand All @@ -180,7 +180,7 @@
* Tests checkCategoryName. The given values are invalid.
*/
@Test
public void categoryNameIsInvalid() {
void categoryNameIsInvalid() {
assertTrue(NAME_IS_EMPTY, util.checkCategoryName(EMPTY_STRING).matches(IStatus.ERROR));
assertTrue(QUALIFIED_NAME, util.checkCategoryName("Category.name").matches(IStatus.ERROR));
assertTrue(CONTAINS_ILLEGAL_CHARACTER, util.checkCategoryName("%categoryname").matches(IStatus.ERROR));
Expand All @@ -191,7 +191,7 @@
* Tests checkCategoryName. The given values are discouraged.
*/
@Test
public void categoryNameIsDiscouraged() {
void categoryNameIsDiscouraged() {
assertTrue(STARTS_WITH_LOWER_CASE, util.checkCategoryName("categoryname").matches(IStatus.WARNING));
assertTrue(STARTS_WITH_AND_CONTAINS_UPPERCASE_LETTERS, util.checkCategoryName("categoryName").matches(IStatus.WARNING));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.testing.util.ParseHelper
import org.eclipse.xtext.testing.validation.ValidationTestHelper
import org.eclipse.xtext.xbase.XbasePackage$Literals
import org.junit.Ignore
import org.junit.Test
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith
import com.avaloq.tools.ddk.check.validation.IssueCodes
import com.avaloq.tools.ddk.check.check.CheckPackage
Expand Down Expand Up @@ -96,8 +96,8 @@ class CheckValidationTest {
}

/* Tests checkContextTypeIsUnique(Check) */
@Disabled("Tests do not work because of scoping issues at run-time")
@Test
@Ignore("Tests do not work because of scoping issues at run-time")
def void testContextTypeIsUnique() {
// should fail
var contexts = Lists::newArrayList("for C c {issue}", "for C d {issue}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
package com.avaloq.tools.ddk.check.runtime.context;

import org.eclipse.emf.ecore.EObject;
import org.junit.Assert;
import org.junit.Test;

import junit.framework.TestCase;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;


/**
* Provides some tests of the reflective {@link AbstractCheckContext} framework.
*/
public class CheckContextTest extends TestCase {
public class CheckContextTest {

Check warning on line 21 in com.avaloq.tools.ddk.check.runtime.core.test/src/com/avaloq/tools/ddk/check/runtime/context/CheckContextTest.java

View workflow job for this annotation

GitHub Actions / pmd

JUnit 5 tests should be package-private.

Reports JUnit 5 test classes and methods that are not package-private. Contrary to JUnit 4 tests, which required public visibility to be run by the engine, JUnit 5 tests can also be run if they're package-private. Marking them as such is a good practice to limit their visibility. Test methods are identified as those which use `@Test`, `@RepeatedTest`, `@TestFactory`, `@TestTemplate` or `@ParameterizedTest`. JUnit5TestShouldBePackagePrivate (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/snapshot/pmd_rules_java_bestpractices.html#junit5testshouldbepackageprivate

public static final String ENABLED_ISSUE_CODE = "Enabled.Issue.Code";
public static final String DISABLED_ISSUE_CODE = "Disabled.Issue.Code";
Expand All @@ -33,13 +31,13 @@
* Tests that the {@link DummyCheckContext} properly marks issue codes as enabled and disabled.
*/
@Test
public void testIssuesEnabledDisabled() {
void testIssuesEnabledDisabled() {
ICheckContext checkContext = new DummyCheckContext();
Assert.assertTrue("Check an issue code in annotations but enabled is still enabled", checkContext.isCheckValid(DUMMY_CONTEXT, ENABLED_ISSUE_CODE));
Assert.assertTrue("Check an issue code not in any annotations is still enabled", checkContext.isCheckValid(DUMMY_CONTEXT, NOT_MENTIONED_ISSUE_CODE));
Assert.assertFalse("Check an issue code in annotations is disabled", checkContext.isCheckValid(DUMMY_CONTEXT, DISABLED_ISSUE_CODE));
Assert.assertFalse("Check disabling has priority over enabling", checkContext.isCheckValid(DUMMY_CONTEXT, DISABLED_AND_ENABLED_ISSUE_CODE));
Assert.assertFalse("Check disabling has priority over enabling, using different order", checkContext.isCheckValid(DUMMY_CONTEXT, ENABLED_AND_DISABLED_ISSUE_CODE));
Assertions.assertTrue("Check an issue code in annotations but enabled is still enabled", checkContext.isCheckValid(DUMMY_CONTEXT, ENABLED_ISSUE_CODE));
Assertions.assertTrue("Check an issue code not in any annotations is still enabled", checkContext.isCheckValid(DUMMY_CONTEXT, NOT_MENTIONED_ISSUE_CODE));
Assertions.assertFalse("Check an issue code in annotations is disabled", checkContext.isCheckValid(DUMMY_CONTEXT, DISABLED_ISSUE_CODE));
Assertions.assertFalse("Check disabling has priority over enabling", checkContext.isCheckValid(DUMMY_CONTEXT, DISABLED_AND_ENABLED_ISSUE_CODE));
Assertions.assertFalse("Check disabling has priority over enabling, using different order", checkContext.isCheckValid(DUMMY_CONTEXT, ENABLED_AND_DISABLED_ISSUE_CODE));

}
}
Loading
Loading