diff options
author | Christian W. Damus | 2014-04-25 13:28:56 +0000 |
---|---|---|
committer | Christian W. Damus | 2014-04-25 18:01:48 +0000 |
commit | 87baaaa8c423a5f7b405e8aecb3e074918fcc03b (patch) | |
tree | a56058260e014587d9a970a81730bf0f55f0efea /tests | |
parent | 0a14a5ec711d2295378d6cd95e18112d80f05599 (diff) | |
download | org.eclipse.papyrus-87baaaa8c423a5f7b405e8aecb3e074918fcc03b.tar.gz org.eclipse.papyrus-87baaaa8c423a5f7b405e8aecb3e074918fcc03b.tar.xz org.eclipse.papyrus-87baaaa8c423a5f7b405e8aecb3e074918fcc03b.zip |
433310: The Repair Stereotypes functionality should improve the 'Apply Profile' dialog
https://bugs.eclipse.org/bugs/show_bug.cgi?id=433310
Improve resolution and presentation of progress metering in the repair actions and present a progress-monitor appears in the dialog (the busyCursorWhile API doesn't show one because the Stereotype Repair dialog is modal).
Includes a new test plug-in for the oep.infra.tools plug-in, which has a new UIUtil class that is JUnit-tested.
Diffstat (limited to 'tests')
11 files changed, 388 insertions, 1 deletions
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF index d74ba0b5edc..a4ae515f434 100644 --- a/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF @@ -45,6 +45,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
org.eclipse.papyrus.infra.emf.readonly;bundle-version="1.0.0",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.tools.tests;bundle-version="1.0.0",
org.eclipse.papyrus.uml.diagram.wizards.tests;bundle-version="1.0.0",
org.eclipse.papyrus.uml.modelrepair;bundle-version="1.0.0",
org.eclipse.papyrus.diagram.profile.tests;bundle-version="1.0.0"
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java index adf8088bd65..d6ac5ca53b1 100644 --- a/tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java +++ b/tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java @@ -8,7 +8,7 @@ *
* Contributors:
* Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bugs 402525, 323802, 431953
+ * Christian W. Damus (CEA) - bugs 402525, 323802, 431953, 433310
*
*****************************************************************************/
package org.eclipse.papyrus.tests;
@@ -47,6 +47,7 @@ public class AllTests { suiteClasses.add(new FragmentTestSuiteClass(org.eclipse.papyrus.infra.services.resourceloading.Activator.PLUGIN_ID, "org.eclipse.papyrus.core.resourceloading.tests.AllTests"));
/* infra */
+ suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.infra.tools.tests.AllTests.class));
suiteClasses.add(new FragmentTestSuiteClass(org.eclipse.papyrus.infra.services.edit.Activator.PLUGIN_ID, "org.eclipse.papyrus.infra.services.edit.tests.suites.AllTests"));
suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.infra.services.labelprovider.tests.AllTests.class));
suiteClasses.add(new FragmentTestSuiteClass(org.eclipse.papyrus.infra.emf.Activator.PLUGIN_ID, "org.eclipse.papyrus.infra.emf.tests.AllTests"));
diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.classpath b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.project b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.project new file mode 100644 index 00000000000..f22aeb4942e --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.papyrus.infra.tools.tests</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..c537b63063c --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..bbe31368136 --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Papyrus Infrastructure Tools Tests (Incubation) +Bundle-SymbolicName: org.eclipse.papyrus.infra.tools.tests;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: Eclipse Modeling Project +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.junit;bundle-version="4.10.0", + org.eclipse.papyrus.junit.utils;bundle-version="1.0.0", + org.eclipse.papyrus.infra.tools;bundle-version="1.0.0", + org.eclipse.swt;bundle-version="3.100.0", + org.eclipse.core.runtime;bundle-version="3.10.0" +Export-Package: org.eclipse.papyrus.infra.tools.tests, + org.eclipse.papyrus.infra.tools.util diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/about.html b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/about.html new file mode 100644 index 00000000000..d35d5aed64c --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 5, 2007</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> + +</body> +</html> diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/build.properties b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/build.properties new file mode 100644 index 00000000000..45e33b593cc --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/build.properties @@ -0,0 +1,17 @@ +# Copyright (c) 2014 CEA LIST. +# +# 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: +# CEA LIST - Initial API and implementation +# + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html +src.includes = about.html diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/org.eclipse.papyrus.infra.tools.tests.launch b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/org.eclipse.papyrus.infra.tools.tests.launch new file mode 100644 index 00000000000..7f9fe40a296 --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/org.eclipse.papyrus.infra.tools.tests.launch @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig"> +<booleanAttribute key="append.args" value="true"/> +<booleanAttribute key="askclear" value="false"/> +<booleanAttribute key="automaticAdd" value="true"/> +<booleanAttribute key="automaticValidate" value="false"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="true"/> +<booleanAttribute key="clearws" value="true"/> +<booleanAttribute key="clearwslog" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> +<booleanAttribute key="default" value="true"/> +<booleanAttribute key="includeOptional" value="true"/> +<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.papyrus.infra.tools.tests/src/org/eclipse/papyrus/infra/tools/tests/AllTests.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> +<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> +<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> +<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> +<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/> +<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.papyrus.infra.tools.tests.AllTests"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.papyrus.infra.tools.tests"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="pde.version" value="3.3"/> +<stringAttribute key="product" value="org.eclipse.sdk.ide"/> +<booleanAttribute key="run_in_ui_thread" value="true"/> +<booleanAttribute key="show_selected_only" value="false"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="false"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<booleanAttribute key="useDefaultConfigArea" value="false"/> +<booleanAttribute key="useProduct" value="true"/> +</launchConfiguration> diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/src/org/eclipse/papyrus/infra/tools/tests/AllTests.java b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/src/org/eclipse/papyrus/infra/tools/tests/AllTests.java new file mode 100644 index 00000000000..c85893c795e --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/src/org/eclipse/papyrus/infra/tools/tests/AllTests.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 CEA 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: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.tools.tests; + +import org.eclipse.papyrus.infra.tools.util.UIUtilTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * The master test suite for the plug-in. + */ +@RunWith(Suite.class) +@SuiteClasses({ UIUtilTest.class }) +public class AllTests { + + public AllTests() { + super(); + } + +} diff --git a/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/src/org/eclipse/papyrus/infra/tools/util/UIUtilTest.java b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/src/org/eclipse/papyrus/infra/tools/util/UIUtilTest.java new file mode 100644 index 00000000000..e6fb0385950 --- /dev/null +++ b/tests/junit/plugins/infra/org.eclipse.papyrus.infra.tools.tests/src/org/eclipse/papyrus/infra/tools/util/UIUtilTest.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2014 CEA 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: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.tools.util; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; + +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.papyrus.junit.utils.tests.AbstractPapyrusTest; +import org.eclipse.swt.widgets.Display; +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.runners.Enclosed; +import org.junit.runner.RunWith; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + + +/** + * Test cases for the {@link UIUtil} class. + */ +@RunWith(Enclosed.class) +public class UIUtilTest { + + public UIUtilTest() { + super(); + } + + // + // Test suites + // + + public static class ExecutorServiceTest extends AbstractPapyrusTest { + + private ExecutorService fixture; + + public ExecutorServiceTest() { + super(); + } + + @Test + public void testSubmit() { + Future<Boolean> future = fixture.submit(new Task()); + assertThat(future.isCancelled(), is(false)); + assertThat(future.isDone(), is(false)); + + flushDisplayEvents(); + + assertThat(future.isDone(), is(true)); + assertResult(future, is(true)); + } + + @Test + public void testShutdown() { + Future<Boolean> future = fixture.submit(new Task()); + + fixture.shutdown(); + + assertThat(fixture.isShutdown(), is(true)); + assertThat(fixture.isTerminated(), is(false)); + + flushDisplayEvents(); + + assertThat(fixture.isTerminated(), is(true)); + + // The task did execute + assertResult(future, is(true)); + } + + @Test + public void testShutdownNow() { + Future<Boolean> future = fixture.submit(new Task()); + + List<Runnable> cancelled = fixture.shutdownNow(); + + assertThat(cancelled.size(), is(1)); + + assertThat(fixture.isTerminated(), is(true)); + + assertThat(future.isDone(), is(false)); + } + + @Test + public void testAwaitTermination_finishes() { + Future<Boolean> future = fixture.submit(new Task()); + + fixture.shutdown(); + + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future<Boolean> waiter = executor.submit(new AwaitTermination(10)); + try { + flushDisplayEvents(); + + assertResult(waiter, is(true)); + + // The task did execute + assertResult(future, is(true)); + } finally { + executor.shutdown(); + } + } + + @Test + public void testAwaitTermination_timesOut() { + fixture.submit(new Task()); + + fixture.shutdown(); + + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future<Boolean> waiter = executor.submit(new AwaitTermination(1)); + + try { + assertResult(waiter, is(false)); + } finally { + executor.shutdown(); + } + } + + // + // Test framework + // + + @Before + public void createFixture() { + fixture = UIUtil.createUIExecutor(Display.getCurrent()); + } + + @After + public void disposeFixture() { + fixture.shutdown(); + fixture = null; + + // Ensure that any remaining runnables are processed + flushDisplayEvents(); + } + + <V> void assertResult(Future<? extends V> future, Matcher<? super V> assertion) { + try { + assertThat(future.get(), assertion); + } catch (Exception e) { + e.printStackTrace(); + fail("Failed to get future result: " + e.getLocalizedMessage()); + } + } + + private static class Task implements Callable<Boolean> { + + @Override + public Boolean call() { + return true; + } + } + + private class AwaitTermination implements Callable<Boolean> { + + private final int timeoutSeconds; + + public AwaitTermination(int timeoutSeconds) { + super(); + + this.timeoutSeconds = timeoutSeconds; + } + + @Override + public Boolean call() throws Exception { + return fixture.awaitTermination(timeoutSeconds, TimeUnit.SECONDS); + } + } + } + + // + // Shared test framework + // + + + static void flushDisplayEvents() { + for(;;) { + try { + if(!Display.getCurrent().readAndDispatch()) { + break; + } + } catch (Exception e) { + Bundle testBundle = FrameworkUtil.getBundle(UIUtilTest.class); + Platform.getLog(testBundle).log(new Status(IStatus.ERROR, testBundle.getSymbolicName(), "Uncaught exception in display runnable.", e)); + } + } + } + +} |