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
5 changes: 2 additions & 3 deletions com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Bundle-SymbolicName: com.avaloq.tools.ddk.check.ui.test
Bundle-Version: 16.3.0.qualifier
Bundle-Vendor: Avaloq Group AG
Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: org.junit,
com.avaloq.tools.ddk.check.ui,
Require-Bundle: com.avaloq.tools.ddk.check.ui,
com.avaloq.tools.ddk.xtext.test.core,
com.avaloq.tools.ddk.test.core,
com.avaloq.tools.ddk.test.ui,
Expand All @@ -23,7 +22,7 @@ Require-Bundle: org.junit,
org.objectweb.asm;resolution:=optional,
junit-jupiter-api,
junit-jupiter-engine,
junit-vintage-engine
junit-platform-suite-api
Export-Package: com.avaloq.tools.ddk.check.ui.test,
com.avaloq.tools.ddk.check.ui.test.util,
com.avaloq.tools.ddk.check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
package com.avaloq.tools.ddk.check.ui.test;

import static com.avaloq.tools.ddk.test.ui.swtbot.util.SwtBotWizardUtil.selectProjectFolder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;

import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
Expand All @@ -32,19 +32,21 @@
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.xtext.Grammar;
import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.extensions.InjectionExtension;
import org.eclipse.xtext.ui.util.PluginProjectFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.ui.test.internal.CheckWizardUiTestInjectorProvider;
import com.avaloq.tools.ddk.check.ui.test.util.CheckWizardTestUtil;
import com.avaloq.tools.ddk.check.ui.util.CheckResourceUtil;
import com.avaloq.tools.ddk.check.ui.wizard.Messages;
import com.avaloq.tools.ddk.test.core.BugTest;
import com.avaloq.tools.ddk.test.ui.swtbot.SwtWizardBot;
import com.avaloq.tools.ddk.xtext.test.junit.runners.XtextClassRunner;
import com.google.inject.Inject;
import com.google.inject.Provider;

Expand All @@ -53,8 +55,9 @@
* The CheckProjectWizardTestBackup tests the Check Project Wizard.
*/
@InjectWith(CheckWizardUiTestInjectorProvider.class)
@RunWith(XtextClassRunner.class)
@ExtendWith(InjectionExtension.class)
@SuppressWarnings("nls")
@TestInstance(Lifecycle.PER_CLASS)
public class CheckCatalogWizardTest {

/** This is the name of the catalog wizard. It's the name SWTBot uses to look up the wizard. */
Expand Down Expand Up @@ -117,7 +120,7 @@ protected void execute(final IProgressMonitor monitor) throws CoreException, Inv
* Initializes this test class pre-loading grammar access instances, which might involve bundle activation and class loading.
* </p>
*/
@Before
@BeforeEach
public void setUp() {
wizard = new SwtWizardBot();
project = createProject();
Expand All @@ -142,7 +145,7 @@ public void testPackageSelected() {
selectProjectFolder(wizard, VALID_PACKAGE_NAME);
initializeWizardBot();
// because the selected item is a package initially, this package is shown in the field.
assertEquals("Initial package is entered", VALID_PACKAGE_NAME, wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText());
assertEquals(VALID_PACKAGE_NAME, wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText(), "Initial package is entered");
}

/**
Expand All @@ -155,7 +158,7 @@ public void testCheckCatalogWizardIsEnabled() {
// that way, the wizard page should be enabled.
initializeWizardBot();

assertEquals("new check catalog page was loaded", Messages.CATALOG_WIZARD_WINDOW_TITLE, wizard.activeShell().getText());
assertEquals(Messages.CATALOG_WIZARD_WINDOW_TITLE, wizard.activeShell().getText(), "new check catalog page was loaded");
wizard.waitUntil(Conditions.widgetIsEnabled(wizard.textWithLabel(Messages.CATALOG_FIELD_NAME_LABEL)), SwtWizardBot.SWTBOT_TIMEOUT);
wizard.waitUntil(Conditions.widgetIsEnabled(wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL)), SwtWizardBot.SWTBOT_TIMEOUT);
CheckWizardTestUtil.assertButtonsEnabled(false, true, false, wizard);
Expand All @@ -170,7 +173,7 @@ public void testInitiallyNoPackageSelected() {
initializeWizardBot();

// because the selected item is not a package initially, the field has to be empty.
assertSame("Initially, no package is selected", wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText().length(), 0);
assertSame(wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText().length(), 0, "Initially, no package is selected");
}

/**
Expand Down Expand Up @@ -259,7 +262,7 @@ public void testInitiallyNoGrammarSelected() {
* @throws CoreException
* if project doesn't exist.
*/
@After
@AfterEach
public void tearDown() throws CoreException {
wizard.closeWizard();
project.delete(true, new NullProgressMonitor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@
*******************************************************************************/
package com.avaloq.tools.ddk.check.ui.test;

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

import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.xtext.testing.InjectWith;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.eclipse.xtext.testing.extensions.InjectionExtension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.ui.test.internal.CheckWizardUiTestInjectorProvider;
import com.avaloq.tools.ddk.check.ui.test.util.CheckWizardTestUtil;
import com.avaloq.tools.ddk.check.ui.wizard.Messages;
import com.avaloq.tools.ddk.test.core.BugTest;
import com.avaloq.tools.ddk.test.ui.swtbot.SwtWizardBot;
import com.avaloq.tools.ddk.xtext.test.junit.runners.XtextClassRunner;


/**
* The CheckProjectWizardTest tests the Check Project Wizard.
*/
@InjectWith(CheckWizardUiTestInjectorProvider.class)
@RunWith(XtextClassRunner.class)
@ExtendWith(InjectionExtension.class)
@SuppressWarnings("nls")
public class CheckProjectWizardTest {

Expand All @@ -48,7 +48,7 @@ public class CheckProjectWizardTest {
/**
* Start again the Check project wizard before every test.
*/
@Before
@BeforeEach
public void setUp() {
wizard = new SwtWizardBot();
wizard.openNewWizard(CHECK_PROJECT_WIZARD_NAME);
Expand All @@ -59,7 +59,7 @@ public void setUp() {
*/
@Test
public void testCheckProjectWizardIsAvailable() {
assertNotNull("the project wizard was found", wizard);
assertNotNull(wizard, "the project wizard was found");
CheckWizardTestUtil.assertButtonsEnabled(false, true, false, wizard);
}

Expand Down Expand Up @@ -101,9 +101,9 @@ public void fieldValuesAfterPageChange() {
wizard.writeToTextField(Messages.PROJECT_NAME_LABEL, CORRECT_PROJECT_NAME);
wizard.changeToPreviousPage();
wizard.changeToNextPage();
assertEquals("Project input stays unchanged", CORRECT_PROJECT_NAME, wizard.textWithLabel(Messages.PROJECT_NAME_LABEL).getText());
assertEquals(CORRECT_PROJECT_NAME, wizard.textWithLabel(Messages.PROJECT_NAME_LABEL).getText(), "Project input stays unchanged");
wizard.changeToNextPage();
assertEquals("Initially, package name equals to project name", CORRECT_PROJECT_NAME, wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText());
assertEquals(CORRECT_PROJECT_NAME, wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL).getText(), "Initially, package name equals to project name");
}

/**
Expand All @@ -115,13 +115,13 @@ public void testNextButtonChangesPage() {
SWTBotShell projectPage = wizard.shell(Messages.PROJECT_WIZARD_WINDOW_TITLE);
wizard.changeToNextPage();
SWTBotShell catalogPage = wizard.shell(Messages.PROJECT_WIZARD_WINDOW_TITLE);
assertNotSame("Next button changed page", projectPage, catalogPage);
assertNotSame(projectPage, catalogPage, "Next button changed page");
}

/**
* Close the wizard after every test.
*/
@After
@AfterEach
public void tearDown() {
wizard.closeWizard();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*******************************************************************************/
package com.avaloq.tools.ddk.check.ui.test;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

import com.avaloq.tools.ddk.check.ui.test.builder.CheckContextsExtensionTest;
import com.avaloq.tools.ddk.check.ui.test.builder.CheckMarkerHelpExtensionTest;
Expand All @@ -21,11 +21,11 @@


/**
* Empty class serving only as holder for JUnit4 annotations.
* Empty class serving only as holder for JUnit5 annotations.
*/
@RunWith(Suite.class)
// @Format-Off
@Suite.SuiteClasses({
@Suite
@SelectClasses({
CheckQuickfixTest.class,
CheckProjectWizardTest.class,
CheckCatalogWizardTest.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
*******************************************************************************/
package com.avaloq.tools.ddk.check.ui.test.builder;

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -19,11 +23,11 @@
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel;
import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
import org.eclipse.xtext.testing.extensions.InjectionExtension;
import org.eclipse.xtext.testing.util.ParseHelper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.check.CheckCatalog;
import com.avaloq.tools.ddk.check.ui.builder.util.CheckContextsExtensionHelper;
Expand All @@ -33,16 +37,14 @@
import com.google.common.collect.Lists;
import com.google.inject.Inject;

import junit.framework.TestCase;


/**
* Tests CheckContextExtensionUtil.
*/
@SuppressWarnings({"restriction", "nls"})
@InjectWith(CheckWizardUiTestInjectorProvider.class)
@RunWith(XtextRunner.class)
public class CheckContextsExtensionTest extends TestCase {
@ExtendWith(InjectionExtension.class)
public class CheckContextsExtensionTest {

private static final String CATALOG_WITH_FIRST_CHECK_LIVE = "package com.test catalog c for grammar g { live error \"First Check\"{ for g { issue }}}";

Expand All @@ -56,10 +58,13 @@ public class CheckContextsExtensionTest extends TestCase {
@Inject
private IWorkspace workspace;

@Override
@Before
public void setUp() throws Exception {
catalog = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE);
@BeforeEach
public void setUp() {
try {
catalog = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE);
} catch (Exception e) {
throw new AssertionError(e);
}
IFile pluginxml = workspace.getRoot().getFile(new Path("/test/plugin.xml"));
pluginModel = new WorkspacePluginModel(pluginxml, false);
}
Expand All @@ -74,10 +79,10 @@ public void setUp() throws Exception {
public void testCreateExtension() throws CoreException {
IPluginExtension extension = contextsUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null);
// Test if the extension has been created.
assertEquals("Contexts extension has been created.", CheckContextsExtensionHelper.CONTEXTS_EXTENSION_POINT_ID, extension.getPoint());
assertEquals(CheckContextsExtensionHelper.CONTEXTS_EXTENSION_POINT_ID, extension.getPoint(), "Contexts extension has been created.");
// Test if the attributes are set correctly
String contextsFileName = ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckContextsExtensionHelper.FILE_ATTRIBUTE_TAG).getValue();
assertEquals("Contexts File name is set correctly", CheckContextsExtensionHelper.CONTEXTS_FILE_NAME, contextsFileName);
assertEquals(CheckContextsExtensionHelper.CONTEXTS_FILE_NAME, contextsFileName, "Contexts File name is set correctly");
}

/**
Expand All @@ -90,7 +95,7 @@ public void testCreateExtension() throws CoreException {
public void testIsExtensionUpdateRequiredTrue() throws CoreException {
IPluginExtension extension = createErroneousExtension();
Iterable<IPluginElement> elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class);
assertTrue("Extension update is required", contextsUtil.isExtensionUpdateRequired(catalog, extension, elements));
assertTrue(contextsUtil.isExtensionUpdateRequired(catalog, extension, elements), "Extension update is required");
}

/**
Expand All @@ -103,7 +108,7 @@ public void testIsExtensionUpdateRequiredTrue() throws CoreException {
public void testIsExtensionUpdateRequiredFalse() throws CoreException {
IPluginExtension extension = contextsUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null);
Iterable<IPluginElement> elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class);
assertFalse("No extension update is required ", contextsUtil.isExtensionUpdateRequired(catalog, extension, elements));
assertFalse(contextsUtil.isExtensionUpdateRequired(catalog, extension, elements), "No extension update is required ");
}

/**
Expand Down
Loading