Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian W. Damus2016-06-20 23:08:35 +0000
committerChristian W. Damus2016-06-21 12:00:14 +0000
commit9c8164bdfca8d8eb55f3925332b079d63ce93654 (patch)
treecd44a419ffa47f151e6ec885cdf489141cbd30d5 /tests
parentda232baf5ed359e641090de829fee43273d3bf48 (diff)
downloadorg.eclipse.papyrus-9c8164bdfca8d8eb55f3925332b079d63ce93654.tar.gz
org.eclipse.papyrus-9c8164bdfca8d8eb55f3925332b079d63ce93654.tar.xz
org.eclipse.papyrus-9c8164bdfca8d8eb55f3925332b079d63ce93654.zip
Bug 496439: [RSA Import] Give mapping traces to extension transformations
https://bugs.eclipse.org/bugs/show_bug.cgi?id=496439 Carry mapping traces forward from each transformation in the chain to the next. Provide a black-box library with custom operations that query the mapping traces to find sources for generated outputs because the standard invresolve and invresolveone operations only inspect the traces of the current transformation, not any previous. Provide also a new API for execution of a transformation that automatically includes the traces, so that extensions can make use of them, too (otherwise, as currently in Papyrus-RT, they will always have to reimplement access to the executor pool, which is a detail that should be abstracted away from them). Change-Id: Ibeece23d01bf8fb86bf714995141cfc01685a509
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/org.eclipse.papyrus.migration.rsa.tests.launch83
-rw-r--r--tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/resources/traces/asserttraces.qvto33
-rw-r--r--tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/AllTests.java9
-rw-r--r--tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/AbstractTransformationTest.java61
-rw-r--r--tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/TracesTest.java49
5 files changed, 188 insertions, 47 deletions
diff --git a/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/org.eclipse.papyrus.migration.rsa.tests.launch b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/org.eclipse.papyrus.migration.rsa.tests.launch
index dc0c7a5baf3..5d743ced21b 100644
--- a/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/org.eclipse.papyrus.migration.rsa.tests.launch
+++ b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/org.eclipse.papyrus.migration.rsa.tests.launch
@@ -1,41 +1,42 @@
-<?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-migration-workspace"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/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"/>
-<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.migration.rsa.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.migration.rsa.tests"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms512m -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M"/>
-<stringAttribute key="pde.version" value="3.3"/>
-<stringAttribute key="product" value="org.eclipse.platform.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>
+<?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-migration-workspace"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/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.8"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.papyrus.migration.rsa.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.migration.rsa.tests"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms512m -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.platform.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/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/resources/traces/asserttraces.qvto b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/resources/traces/asserttraces.qvto
new file mode 100644
index 00000000000..b9f7cf2a2a1
--- /dev/null
+++ b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/resources/traces/asserttraces.qvto
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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 - Initial API and implementation
+ *
+ *****************************************************************************/
+
+import org.eclipse.papyrus.m2m.qvto.Traces;
+
+modeltype uml "strict" uses 'http://www.eclipse.org/uml2/5.0.0/UML';
+modeltype notation "strict" uses 'http://www.eclipse.org/gmf/runtime/1.0.2/notation';
+modeltype sash "strict" uses 'http://www.eclipse.org/papyrus/0.7.0/sashdi';
+modeltype config "strict" uses 'http:///RSAToPapyrusParameters.ecore';
+
+transformation PapyrusRTDiagrams(inout semantics : uml, inout graphics : notation, out di : sash, in param : config);
+
+main() {
+ graphics.rootObjects()[notation::Diagram].map checkTraces();
+}
+
+mapping inout notation::Diagram::checkTraces()
+{
+ var source := self.traceFrom('notation::Diagram');
+ assert fatal (not source.oclIsUndefined() and
+ source.oclIsKindOf(notation::Diagram) and
+ source <> self);
+}
diff --git a/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/AllTests.java b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/AllTests.java
index 3c7bcd6fff7..4e18eae4798 100644
--- a/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/AllTests.java
+++ b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/AllTests.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,7 @@
* Contributors:
* Thibault Le Ouay (Sherpa Engineering) t.leouay@sherpa-eng.com - Initial API and implementation
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
+ * Christian W. Damus - bug 496439
*****************************************************************************/
package org.eclipse.papyrus.migration.rsa.tests;
@@ -17,6 +18,7 @@ import org.eclipse.papyrus.migration.rsa.tests.qvt.BatchImportTest;
import org.eclipse.papyrus.migration.rsa.tests.qvt.ImportDiagramTest;
import org.eclipse.papyrus.migration.rsa.tests.qvt.ImportModelsTest;
import org.eclipse.papyrus.migration.rsa.tests.qvt.ImportProfilesTest;
+import org.eclipse.papyrus.migration.rsa.tests.qvt.TracesTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -24,7 +26,10 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({ ImportDiagramTest.class, ImportModelsTest.class, BatchImportTest.class, ImportProfilesTest.class, ThreadSafeResourceSetTest.class })
+@SuiteClasses({
+ ImportDiagramTest.class, ImportModelsTest.class, BatchImportTest.class, ImportProfilesTest.class,
+ TracesTest.class,
+ ThreadSafeResourceSetTest.class })
public class AllTests {
// Test suite
}
diff --git a/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/AbstractTransformationTest.java b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/AbstractTransformationTest.java
index dd82013060d..27fe81b3db7 100644
--- a/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/AbstractTransformationTest.java
+++ b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/AbstractTransformationTest.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST.
+ * Copyright (c) 2015, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,9 +8,12 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 496439
*****************************************************************************/
package org.eclipse.papyrus.migration.rsa.tests.qvt;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -29,6 +32,7 @@ import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusT
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.Config;
import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.RSAToPapyrusParametersFactory;
+import org.eclipse.papyrus.migration.rsa.transformation.DependencyAnalysisHelper;
import org.eclipse.papyrus.migration.rsa.transformation.ImportTransformation;
import org.eclipse.papyrus.migration.rsa.transformation.ImportTransformationLauncher;
import org.eclipse.papyrus.uml.tools.model.UmlModel;
@@ -74,7 +78,7 @@ public class AbstractTransformationTest extends AbstractPapyrusTest {
config.setAlwaysAcceptSuggestedMappings(true);
config.setRemoveUnmappedProfilesAndStereotypes(true);
- ImportTransformationLauncher launcher = new ImportTransformationLauncher(config);
+ ImportTransformationLauncher launcher = createTransformationLauncher(config);
launcher.run(Collections.singletonList(sourceURI));
launcher.waitForCompletion();
@@ -85,7 +89,7 @@ public class AbstractTransformationTest extends AbstractPapyrusTest {
Config config = RSAToPapyrusParametersFactory.eINSTANCE.createConfig();
config.setRemoveUnmappedProfilesAndStereotypes(true);
- ImportTransformation transformation = new ImportTransformation(sourceURI, config, null);
+ ImportTransformation transformation = createTransformation(sourceURI, config, null);
transformation.run(false);
transformation.waitForCompletion();
@@ -132,7 +136,8 @@ public class AbstractTransformationTest extends AbstractPapyrusTest {
config.setMaxThreads(4);
config.setAlwaysAcceptSuggestedMappings(true);
config.setRemoveUnmappedProfilesAndStereotypes(true);
- ImportTransformationLauncher launcher = new ImportTransformationLauncher(config);
+
+ ImportTransformationLauncher launcher = createTransformationLauncher(config);
launcher.run(urisToImport);
launcher.waitForCompletion();
@@ -144,6 +149,54 @@ public class AbstractTransformationTest extends AbstractPapyrusTest {
}
}
+ private ImportTransformationLauncher createTransformationLauncher(Config config) {
+ ImportTransformationLauncher result;
+
+ final URI[] additionalTransformations = getAdditionalTransformations();
+ if (additionalTransformations.length == 0) {
+ result = new ImportTransformationLauncher(config);
+ } else {
+ // Append some more transformations to the chain
+ result = new ImportTransformationLauncher(config) {
+ @Override
+ protected ImportTransformation createTransformation(URI transformationURI) {
+ return AbstractTransformationTest.this.createTransformation(
+ transformationURI, config, analysisHelper);
+ }
+ };
+ }
+
+ return result;
+ }
+
+ private ImportTransformation createTransformation(URI transformationURI, Config config, DependencyAnalysisHelper analysisHelper) {
+ ImportTransformation result;
+
+ final URI[] additionalTransformations = getAdditionalTransformations();
+ if (additionalTransformations.length == 0) {
+ result = new ImportTransformation(transformationURI, config, analysisHelper);
+ } else {
+ result = new ImportTransformation(transformationURI, config, analysisHelper) {
+ @Override
+ protected Collection<URI> getAdditionalTransformationURIs() {
+ return Arrays.asList(additionalTransformations);
+ }
+ };
+ }
+
+ return result;
+ }
+
+ /**
+ * Obtains the URIs of zero or more additional transformations to append to the
+ * standard transformation chain.
+ *
+ * @return additional transformations, or an empty array if none
+ */
+ protected URI[] getAdditionalTransformations() {
+ return new URI[0];
+ }
+
protected void checkResultFile(IFile sourceFile) {
IPath targetPath;
if ("emx".equals(sourceFile.getFullPath().getFileExtension())) {
diff --git a/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/TracesTest.java b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/TracesTest.java
new file mode 100644
index 00000000000..a4bad746f52
--- /dev/null
+++ b/tests/junit/extraplugins/migration/org.eclipse.papyrus.migration.rsa.tests/src/org/eclipse/papyrus/migration/rsa/tests/qvt/TracesTest.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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 - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.migration.rsa.tests.qvt;
+
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.migration.rsa.tests.Activator;
+import org.junit.Test;
+
+public class TracesTest extends AbstractTransformationTest {
+ private static final String BASE_PATH = "resources/fragments/";
+
+ @Test
+ public void testTraces() throws Exception {
+
+ String mainFile = BASE_PATH + "Blank Package.emx";
+
+ String[] additionalFiles = new String[] {
+ BASE_PATH + "Class3.efx",
+ BASE_PATH + "Interface - Fragment.efx",
+ BASE_PATH + "Package - Fragment.efx"
+ };
+
+ simpleImport(mainFile, additionalFiles);
+
+ // Don't need to open the editor. The import succeeded
+ }
+
+ //
+ // Test framework
+ //
+
+ @Override
+ protected URI[] getAdditionalTransformations() {
+ return new URI[] {
+ URI.createPlatformPluginURI(Activator.PLUGIN_ID + "/resources/traces/asserttraces.qvto", true),
+ };
+ }
+}

Back to the top