Skip to content
Merged
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 @@ -8,13 +8,13 @@ Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.xtext,
com.avaloq.tools.ddk.test.ui,
com.avaloq.tools.ddk.test.ui,
com.avaloq.tools.ddk.check.runtime.core,
org.junit,
com.google.guava,
junit-jupiter-api,
junit-jupiter-engine,
junit-vintage-engine
junit-vintage-engine,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have overlooked this in the other PRs. Should we not be able to remove junit-vintage-engine now?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not completely I think.. if our downstream (asmd) project inherits or uses the abstract classes it might still need the vintage engine. just to be safe let's remove it when both asmd and ddk are completely running in native junit5 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, since we are not reexporthing them, what we have here is not relevantt for other plugins, so we should be able to remove them already.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. then I will remove the vintage engine on packages that are not exported. thanks!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the cleanup in this pr #1209 1209

junit-platform-suite-api
Export-Package: com.avaloq.tools.ddk.check.runtime.test.core
Import-Package: org.mockito,
org.mockito.stubbing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
*******************************************************************************/
package com.avaloq.tools.ddk.check.runtime.context;

import org.eclipse.emf.ecore.EObject;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import junit.framework.TestCase;
import org.eclipse.emf.ecore.EObject;
import org.junit.jupiter.api.Test;


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

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

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@
*******************************************************************************/
package com.avaloq.tools.ddk.check.runtime.core.registry;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.List;
import java.util.NoSuchElementException;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

import junit.framework.TestCase;


/**
* Provides some test cases for the Check extension point.
*/
@SuppressWarnings("nls")
public class CheckExtensionPointTests extends TestCase {
class CheckExtensionPointTests {

private static final String DUMMY_EXTENSION_ID = "com.avaloq.tools.ddk.check.runtime.core.test";
private static final String CHECK_EXTENSION_ID = "com.avaloq.tools.ddk.check.runtime.core";
Expand Down Expand Up @@ -86,7 +88,7 @@ private IConfigurationElement findConfigurationElement(final IConfigurationEleme
* @see Platform#getExtensionRegistry()
*/
@Test
public void testExtensionPointIsRegistered() {
void testExtensionPointIsRegistered() {
try {
findCheckExtensionPoint(findExtensionPoints());
} catch (NoSuchElementException e) {
Expand All @@ -99,34 +101,34 @@ public void testExtensionPointIsRegistered() {
* point.
*/
@Test
public void testDummyClientRegistered() {
assertNotNull("Test plugin successfully registered to the check extension point", findCheckExtensionPoint(findExtensionPoints()).getExtension(DUMMY_EXTENSION_ID));
void testDummyClientRegistered() {
assertNotNull(findCheckExtensionPoint(findExtensionPoints()).getExtension(DUMMY_EXTENSION_ID), "Test plugin successfully registered to the check extension point");
}

/**
* Tests that a non-existing client is not registered with the extension
* point registry.
*/
@Test
public void testInvalidClientNotRegistered() {
assertNull("Non-existing client not registered to the check extension point", findCheckExtensionPoint(findExtensionPoints()).getExtension("a.b.c"));
void testInvalidClientNotRegistered() {
assertNull(findCheckExtensionPoint(findExtensionPoints()).getExtension("a.b.c"), "Non-existing client not registered to the check extension point");
}

/**
* Tests that the check extension point has an attribute {@value #TARGET_CLASS_ATTRIBUTE}.
*/
@Test
public void testTargetClassAttributeFound() {
void testTargetClassAttributeFound() {
IExtensionPoint point = findCheckExtensionPoint(findExtensionPoints());
assertNotNull("Found a configuration element with attribute \"targetClass\"", findConfigurationElement(point.getConfigurationElements(), TARGET_CLASS_ATTRIBUTE));
assertNotNull(findConfigurationElement(point.getConfigurationElements(), TARGET_CLASS_ATTRIBUTE), "Found a configuration element with attribute \"targetClass\"");
}

/**
* Tests that the check extension point has an attribute {@value #LANGUAGE_ATTRIBUTE}.
*/
@Test
public void testLanguageAttributeFound() {
void testLanguageAttributeFound() {
IExtensionPoint point = findCheckExtensionPoint(findExtensionPoints());
assertNotNull("Found a configuration element with attribute \"language\"", findConfigurationElement(point.getConfigurationElements(), LANGUAGE_ATTRIBUTE));
assertNotNull(findConfigurationElement(point.getConfigurationElements(), LANGUAGE_ATTRIBUTE), "Found a configuration element with attribute \"language\"");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*******************************************************************************/
package com.avaloq.tools.ddk.check.runtime.core.validation;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.avaloq.tools.ddk.check.runtime.issue.ICheckValidatorImpl;
import com.avaloq.tools.ddk.check.runtime.validation.AbstractCheckValidator;
Expand All @@ -24,7 +24,7 @@
* Performs some basic validation tests on the {@link AbstractCheckValidator}.
*/
@SuppressWarnings("nls")
public class CheckValidatorTest extends AbstractCheckValidator {
class CheckValidatorTest extends AbstractCheckValidator {
/**
* Represents the dummy language which is also registered in the plugin.xml.
*/
Expand All @@ -46,8 +46,8 @@ protected String getHostLanguage() {
* @see {@link com.avaloq.tools.ddk.check.extensionpoint.test.validation.DummyValidator}
*/
@Test
public void testAtLeastOneValidatorFound() {
void testAtLeastOneValidatorFound() {
ICheckValidatorImpl dummyValidator = Iterables.getOnlyElement(getValidators(Maps.newHashMap(), null));
assertEquals("Dummy validator found", "DummyValidator", dummyValidator.getClass().getSimpleName());
assertEquals("DummyValidator", dummyValidator.getClass().getSimpleName(), "Dummy validator found");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

package com.avaloq.tools.ddk.check.runtime.label;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
Expand All @@ -23,9 +23,9 @@
import java.util.Collections;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.avaloq.tools.ddk.check.runtime.issue.ICheckValidatorImpl;
import com.avaloq.tools.ddk.check.runtime.registry.ICheckValidatorRegistry;
Expand All @@ -40,7 +40,7 @@
* Unit test for {@link DefaultCheckRuleLabelProvider}.
*/
@SuppressWarnings("nls")
public class CheckRuleLabelProviderTest {
class CheckRuleLabelProviderTest {

// Test data
private static final int NUM_VALIDATORS = 3;
Expand Down Expand Up @@ -72,8 +72,8 @@ public class CheckRuleLabelProviderTest {
/**
* Setup done before each test.
*/
@Before
public void setUp() {
@BeforeEach
void setUp() {

// Create mocks
mockCheckValidatorRegistry = mock(ICheckValidatorRegistry.class);
Expand All @@ -97,8 +97,8 @@ protected void configure() {
/**
* Teardown done after each test.
*/
@After
public void tearDown() {
@AfterEach
void tearDown() {

mockCheckValidatorRegistry = null;
mockValidators = null;
Expand Down Expand Up @@ -127,16 +127,16 @@ private void mockValidatorsWithChecks() {
* Test the default binding.
*/
@Test
public void testBinding() {
void testBinding() {
// ASSERT
assertSame("Binding of label provider incorrect.", CheckRuleLabelProvider.class, checkRuleLabelProvider.getClass());
assertSame(CheckRuleLabelProvider.class, checkRuleLabelProvider.getClass(), "Binding of label provider incorrect.");
}

/**
* Test successfully getting a check label.
*/
@Test
public void testSuccess() {
void testSuccess() {
// ARRANGE
mockValidatorsWithChecks();

Expand All @@ -150,7 +150,7 @@ public void testSuccess() {
/**
* Test trying to get the check label for an issue code which is not present.
*/
public void testWhenIssueCodeNotPresent() {
void testWhenIssueCodeNotPresent() {
// ARRANGE
mockValidatorsWithChecks();

Expand All @@ -165,7 +165,7 @@ public void testWhenIssueCodeNotPresent() {
* Test trying to get the check label for a null issue code.
*/
@Test
public void testWithNullID() {
void testWithNullID() {
// ARRANGE
mockValidatorsWithChecks();

Expand All @@ -180,7 +180,7 @@ public void testWithNullID() {
* Test trying to get a check label when there are no validators.
*/
@Test
public void testWithNoValidators() {
void testWithNoValidators() {
// ARRANGE
when(mockCheckValidatorRegistry.getValidators()).thenReturn(Collections.emptyList());

Expand All @@ -195,7 +195,7 @@ public void testWithNoValidators() {
* Test trying to get a check label when there are no checks registered.
*/
@Test
public void testWithNoChecks() {
void testWithNoChecks() {
// ARRANGE
when(mockCheckValidatorRegistry.getValidators()).thenReturn(mockValidators);
for (ICheckValidatorImpl mockValidator : mockValidators) {
Expand All @@ -213,7 +213,7 @@ public void testWithNoChecks() {
* Test trying to get the check label for an issue code which is not a check issue code.
*/
@Test
public void testWhenIssueCodeIsNotACheckIssueCode() {
void testWhenIssueCodeIsNotACheckIssueCode() {
// ARRANGE
final String notACheckIssueCode = "package.name.SomeOtherClass.issue.code";

Expand All @@ -233,7 +233,7 @@ public void testWhenIssueCodeIsNotACheckIssueCode() {
* Test that check labels are cached.
*/
@Test
public void testCaching() {
void testCaching() {
// ARRANGE
mockValidatorsWithChecks();

Expand All @@ -258,7 +258,7 @@ private static final class CheckRuleLabelProviderWithInvalidateCacheExposed exte
/**
* Call protected method {link CheckRuleLabelProvider.invalidateCache}.
*/
public void publicInvalidateCache() {
void publicInvalidateCache() {
super.invalidateCache();
}
}
Expand All @@ -267,7 +267,7 @@ public void publicInvalidateCache() {
* Test that the cache can be invalidated by subclasses.
*/
@Test
public void testInvalidatingCache() {
void testInvalidatingCache() {
// ARRANGE
final CheckRuleLabelProviderWithInvalidateCacheExposed checkRuleLabelProviderWithInvalidateCacheExposed = injector.getInstance(CheckRuleLabelProviderWithInvalidateCacheExposed.class);

Expand All @@ -291,12 +291,12 @@ public void testInvalidatingCache() {
* Test that the class is bound as a singleton.
*/
@Test
public void testClassIsSingleton() {
void testClassIsSingleton() {
// ACT
final ICheckRuleLabelProvider otherCheckRuleLabelProvider = injector.getInstance(CheckRuleLabelProvider.class);

// ASSERT
assertSame("Only one instance of CheckRuleLabelProvider expected", checkRuleLabelProvider, otherCheckRuleLabelProvider);
assertSame(checkRuleLabelProvider, otherCheckRuleLabelProvider, "Only one instance of CheckRuleLabelProvider expected");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@
*******************************************************************************/
package com.avaloq.tools.ddk.check.runtime.test.core;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

import com.avaloq.tools.ddk.check.runtime.context.CheckContextTest;
import com.avaloq.tools.ddk.check.runtime.core.registry.CheckExtensionPointTests;
import com.avaloq.tools.ddk.check.runtime.core.validation.CheckValidatorTest;
import com.avaloq.tools.ddk.check.runtime.label.CheckRuleLabelProviderTest;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.Suite;


/**
* The test suite for Check core tests.
* Junit5 version of test suites. does not implement the logic in our DiscerningSuite.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({CheckExtensionPointTests.class, CheckValidatorTest.class, CheckContextTest.class, CheckRuleLabelProviderTest.class})
@Suite
@SelectPackages({
// @Format-Off
"com.avaloq.tools.ddk.check.runtime.context",
"com.avaloq.tools.ddk.check.runtime.core.registry",
"com.avaloq.tools.ddk.check.runtime.core.validation",
"com.avaloq.tools.ddk.check.runtime.label"
// @Format-On
})
public class CheckRuntimeTestSuite {

}