From 9b0309213be3e41eb4891c9d9815a2720a26634b Mon Sep 17 00:00:00 2001 From: Francois Le Fevre MIB Date: Thu, 14 Jan 2016 11:40:38 -0800 Subject: [PATCH 1/2] setting up an example with unit and integration tests Change-Id: I1f4825cefffe7a22f855bd402750734b9bcb4626 Signed-off-by: Francois Le Fevre MIB --- qvto-app/.classpath | 26 ++ qvto-app/.gitignore | 1 + qvto-app/.project | 23 ++ .../org.eclipse.core.resources.prefs | 3 + qvto-app/.settings/org.eclipse.jdt.core.prefs | 5 + qvto-app/.settings/org.eclipse.m2e.core.prefs | 4 + qvto-app/dependency-reduced-pom.xml | 135 +++++++++ qvto-app/pom.xml | 281 ++++++++++-------- qvto-app/src/main/resources/logback.xml | 13 + .../org/fraben/qvtoapp/test/BasicTest.java | 60 ++++ .../resources/integrationTests/testng.xml | 9 + .../qvto4abcmodel/modelSource/MMSource.ecore | 22 ++ .../qvto4abcmodel/modelSource/MSource.xmi | 24 ++ .../transforms/transformationABC.qvto | 31 ++ .../src/test/resources/unitTests/testng.xml | 9 + 15 files changed, 528 insertions(+), 118 deletions(-) create mode 100644 qvto-app/.classpath create mode 100644 qvto-app/.gitignore create mode 100644 qvto-app/.project create mode 100644 qvto-app/.settings/org.eclipse.core.resources.prefs create mode 100644 qvto-app/.settings/org.eclipse.jdt.core.prefs create mode 100644 qvto-app/.settings/org.eclipse.m2e.core.prefs create mode 100644 qvto-app/dependency-reduced-pom.xml create mode 100644 qvto-app/src/main/resources/logback.xml create mode 100644 qvto-app/src/test/java/org/fraben/qvtoapp/test/BasicTest.java create mode 100644 qvto-app/src/test/resources/integrationTests/testng.xml create mode 100644 qvto-app/src/test/resources/qvto4abcmodel/modelSource/MMSource.ecore create mode 100644 qvto-app/src/test/resources/qvto4abcmodel/modelSource/MSource.xmi create mode 100644 qvto-app/src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto create mode 100644 qvto-app/src/test/resources/unitTests/testng.xml diff --git a/qvto-app/.classpath b/qvto-app/.classpath new file mode 100644 index 0000000..f619a53 --- /dev/null +++ b/qvto-app/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qvto-app/.gitignore b/qvto-app/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/qvto-app/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/qvto-app/.project b/qvto-app/.project new file mode 100644 index 0000000..3c1fc43 --- /dev/null +++ b/qvto-app/.project @@ -0,0 +1,23 @@ + + + qvto-app + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/qvto-app/.settings/org.eclipse.core.resources.prefs b/qvto-app/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..e9441bb --- /dev/null +++ b/qvto-app/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding/=UTF-8 diff --git a/qvto-app/.settings/org.eclipse.jdt.core.prefs b/qvto-app/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ec4300d --- /dev/null +++ b/qvto-app/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/qvto-app/.settings/org.eclipse.m2e.core.prefs b/qvto-app/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/qvto-app/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/qvto-app/dependency-reduced-pom.xml b/qvto-app/dependency-reduced-pom.xml new file mode 100644 index 0000000..d4077b9 --- /dev/null +++ b/qvto-app/dependency-reduced-pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + at.ac.wu.nm + qvto-app + QVTo Command-Line App + 0.1-SNAPSHOT + + + + maven-compiler-plugin + 2.3 + + ${jdk.version} + ${jdk.version} + + + + maven-dependency-plugin + 2.10 + + + unpack + process-sources + + unpack + + + + + at.ac.wu.nm + qvt-bundle + 4.4 + repackaged + jar + false + ${project.build.directory} + META-INF/MANIFEST.MF + + + + + + + + maven-jar-plugin + 2.6 + + + ${project.build.directory}/META-INF/MANIFEST.MF + + + + + maven-shade-plugin + 2.3 + + + package + + shade + + + + + + at.ac.wu.nm.qvto.App + + + + + + *:qvt-bundle:* + + *.jar + at/** + org/eclipse/jdt/internal/jarinjarloader/** + META-INF/MANIFEST.MF + + + + + + + + + maven-surefire-plugin + 2.19.1 + + + src/test/resources/unitTests/testng.xml + + + + + maven-failsafe-plugin + 2.19.1 + + + + integration-test + verify + + + + + + src/test/resources/integrationTests/testng.xml + + target/qvto-app-0.1-SNAPSHOT.jar + + + + + + + org.testng + testng + 6.9.8 + test + + + bsh + org.beanshell + + + + + + 1.6.1 + 1.7 + UTF-8 + + + diff --git a/qvto-app/pom.xml b/qvto-app/pom.xml index 3bd99b0..db84398 100644 --- a/qvto-app/pom.xml +++ b/qvto-app/pom.xml @@ -1,121 +1,166 @@ - - 4.0.0 - at.ac.wu.nm - qvto-app - jar - 0.1-SNAPSHOT - QVTo Command-Line App - - 1.7 - UTF-8 - - - - - at.ac.wu.nm - qvt-bundle - 4.4 - repackaged - - - com.beust - jcommander - 1.47 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3 - - ${jdk.version} - ${jdk.version} - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.10 - - - unpack - process-sources - - unpack - - - - - at.ac.wu.nm - qvt-bundle - 4.4 - repackaged - jar - false - ${project.build.directory} - META-INF/MANIFEST.MF - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - - ${project.build.directory}/META-INF/MANIFEST.MF - - - - - org.apache.maven.plugins - maven-shade-plugin - 2.3 - - - package - - shade - - - - - - - at.ac.wu.nm.qvto.App - - - - - - *:qvt-bundle:* - - *.jar - at/** - org/eclipse/jdt/internal/jarinjarloader/** - META-INF/MANIFEST.MF - - - - - - - - - - - - + 4.0.0 + at.ac.wu.nm + qvto-app + jar + 0.1-SNAPSHOT + QVTo Command-Line App + + + 1.7 + UTF-8 + 1.6.1 + + + + + at.ac.wu.nm + qvt-bundle + 4.4 + repackaged + + + com.beust + jcommander + 1.47 + + + org.testng + testng + 6.9.8 + test + + + org.slf4j + slf4j-api + ${slf4jVersion} + + + ch.qos.logback + logback-classic + 1.0.13 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3 + + ${jdk.version} + ${jdk.version} + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + unpack + process-sources + + unpack + + + + + at.ac.wu.nm + qvt-bundle + 4.4 + repackaged + jar + false + ${project.build.directory} + META-INF/MANIFEST.MF + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + ${project.build.directory}/META-INF/MANIFEST.MF + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.3 + + + package + + shade + + + + + + + at.ac.wu.nm.qvto.App + + + + + + *:qvt-bundle:* + + *.jar + at/** + org/eclipse/jdt/internal/jarinjarloader/** + META-INF/MANIFEST.MF + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + src/test/resources/unitTests/testng.xml + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.19.1 + + + src/test/resources/integrationTests/testng.xml + + target/qvto-app-0.1-SNAPSHOT.jar + + + + + integration-test + verify + + + + + + + diff --git a/qvto-app/src/main/resources/logback.xml b/qvto-app/src/main/resources/logback.xml new file mode 100644 index 0000000..ae1cc02 --- /dev/null +++ b/qvto-app/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + \ No newline at end of file diff --git a/qvto-app/src/test/java/org/fraben/qvtoapp/test/BasicTest.java b/qvto-app/src/test/java/org/fraben/qvtoapp/test/BasicTest.java new file mode 100644 index 0000000..bd5bf95 --- /dev/null +++ b/qvto-app/src/test/java/org/fraben/qvtoapp/test/BasicTest.java @@ -0,0 +1,60 @@ +package org.fraben.qvtoapp.test; + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.*; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.ParameterException; + +import at.ac.wu.nm.qvto.App; + +public class BasicTest { + + @BeforeMethod + @BeforeClass + public void setUp() { + // code that will be invoked when this test is instantiated + } + + @Test + public void aFastTest() { + System.out.println("Fast test"); + //java -jar qvto-app-0.1-SNAPSHOT.jar + //-xform + //../src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto + //-src + //../src/test/resources/qvto4abcmodel/modelSource/MMSource.ecore + //../src/test/resources/qvto4abcmodel/modelSource/MSource.xmi + //-tgt + //../src/test/resources/qvto4abcmodel/modelSource/MMSource.ecore + //./src/test/resources/qvto4abcmodel/modelTarget/my.xmi + + + String[] args= new String[8]; + args[0]="-xform"; + args[1]="src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto"; + args[2]="-src"; + args[3]="src/test/resources/qvto4abcmodel/modelSource/MMSource.ecore"; + args[4]="src/test/resources/qvto4abcmodel/modelSource/MSource.xmi"; + args[5]="-tgt"; + args[6]="src/test/resources/qvto4abcmodel/modelSource/MMSource.ecore"; + args[7]="src/test/resources/qvto4abcmodel/modelTarget/my.xmi"; + + + App app = new App(); + JCommander jc = new JCommander(app); + + try { + jc.parse(args); + /* TODO: check whether -src value is an even list */ + } catch (ParameterException pe) { + System.out.println(pe.getMessage()); + jc.usage(); + return; + } + + app.build(); + } + +} diff --git a/qvto-app/src/test/resources/integrationTests/testng.xml b/qvto-app/src/test/resources/integrationTests/testng.xml new file mode 100644 index 0000000..3ffb292 --- /dev/null +++ b/qvto-app/src/test/resources/integrationTests/testng.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MMSource.ecore b/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MMSource.ecore new file mode 100644 index 0000000..84c1130 --- /dev/null +++ b/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MMSource.ecore @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + diff --git a/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MSource.xmi b/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MSource.xmi new file mode 100644 index 0000000..88cfa4f --- /dev/null +++ b/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MSource.xmi @@ -0,0 +1,24 @@ + + + + + + + + + + diff --git a/qvto-app/src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto b/qvto-app/src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto new file mode 100644 index 0000000..4eb069e --- /dev/null +++ b/qvto-app/src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto @@ -0,0 +1,31 @@ +modeltype mmsource "strict" uses "http://www.mmsource.fr"; + + +transformation TransformationABC(in source: mmsource, out target:mmsource); + +main() { + source.rootObjects()[root] . map Root2Root(); +} + +mapping root::Root2Root() : root { + result.element += self.element ->select(a |a.oclIsKindOf(A))[A]-> map A2B(); + result.element += self.element ->select(b |b.oclIsKindOf(B))[B]-> map B2B(); + result.element += self.element ->select(c |c.oclIsKindOf(C))[C]-> map C2C(); +} + + +mapping A::A2B() : B + when {self.Id > 0 } +{ + result.Id := self.Id; + result.b := self.a+" work at FraBen Company"; +} + +mapping B::B2B() : B { + result.Id := self.Id; + result.b := self.b; +} +mapping C::C2C() : C { + result.Id := self.Id; + result.c := self.c; +} \ No newline at end of file diff --git a/qvto-app/src/test/resources/unitTests/testng.xml b/qvto-app/src/test/resources/unitTests/testng.xml new file mode 100644 index 0000000..6ca4a6e --- /dev/null +++ b/qvto-app/src/test/resources/unitTests/testng.xml @@ -0,0 +1,9 @@ + + + + + + + + + From d75aa7bf9090a20ab3d502fe5dd4db7609e48fec Mon Sep 17 00:00:00 2001 From: Francois Le Fevre MIB Date: Sun, 31 Jan 2016 12:35:38 -0800 Subject: [PATCH 2/2] small typo in the model uri adding a tesng.xml file Signed-off-by: Francois Le Fevre MIB --- qvto-app/src/main/java/at/ac/wu/nm/qvto/App.java | 8 +++----- .../test/resources/qvto4abcmodel/modelSource/MSource.xmi | 2 +- .../qvto4abcmodel/transforms/transformationABC.qvto | 3 ++- qvto-app/src/test/resources/testng.xml | 9 +++++++++ 4 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 qvto-app/src/test/resources/testng.xml diff --git a/qvto-app/src/main/java/at/ac/wu/nm/qvto/App.java b/qvto-app/src/main/java/at/ac/wu/nm/qvto/App.java index ac3c69d..6ff8fca 100644 --- a/qvto-app/src/main/java/at/ac/wu/nm/qvto/App.java +++ b/qvto-app/src/main/java/at/ac/wu/nm/qvto/App.java @@ -3,17 +3,15 @@ import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; -import java.util.List; import java.util.ArrayList; +import java.util.List; import org.eclipse.core.runtime.IStatus; import org.eclipse.emf.common.util.BasicDiagnostic; import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; @@ -24,10 +22,10 @@ import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic; import org.eclipse.m2m.qvt.oml.ModelExtent; import org.eclipse.m2m.qvt.oml.TransformationExecutor; -import org.eclipse.uml2.uml.UMLPackage; -import org.eclipse.uml2.uml.resource.UMLResource; import org.eclipse.m2m.qvt.oml.util.Log; import org.eclipse.m2m.qvt.oml.util.WriterLog; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.resource.UMLResource; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; diff --git a/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MSource.xmi b/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MSource.xmi index 88cfa4f..787250c 100644 --- a/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MSource.xmi +++ b/qvto-app/src/test/resources/qvto4abcmodel/modelSource/MSource.xmi @@ -4,7 +4,7 @@ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmsource="http://www.mmsource.fr" - xsi:schemaLocation="http://www.mmsource.fr ../MModelSource/MMSource.ecore"> + xsi:schemaLocation="http://www.mmsource.fr MMSource.ecore"> diff --git a/qvto-app/src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto b/qvto-app/src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto index 4eb069e..da30e05 100644 --- a/qvto-app/src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto +++ b/qvto-app/src/test/resources/qvto4abcmodel/transforms/transformationABC.qvto @@ -1,4 +1,5 @@ -modeltype mmsource "strict" uses "http://www.mmsource.fr"; +modeltype mmsource "strict" uses 'http://www.mmsource.fr'; +//modeltype mmsource "strict" uses mmsource('http://www.mmsource.fr'); transformation TransformationABC(in source: mmsource, out target:mmsource); diff --git a/qvto-app/src/test/resources/testng.xml b/qvto-app/src/test/resources/testng.xml new file mode 100644 index 0000000..2acba2f --- /dev/null +++ b/qvto-app/src/test/resources/testng.xml @@ -0,0 +1,9 @@ + + + + + + + + +