Init first test
- register the profile to this URI
http://www.eclipse.org/papyrus/iotML/0.7/IotML
- check that the profile is correctly registered in a first test
Change-Id: I0bb556da1d604a3cd8f342d6a383d447a4138f6f
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
diff --git a/org.eclipse.papyrus.iotml.profile.tests/.classpath b/org.eclipse.papyrus.iotml.profile.tests/.classpath
new file mode 100644
index 0000000..83be1d9
--- /dev/null
+++ b/org.eclipse.papyrus.iotml.profile.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.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="test"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.papyrus.iotml.profile.tests/.project b/org.eclipse.papyrus.iotml.profile.tests/.project
new file mode 100644
index 0000000..bcebe13
--- /dev/null
+++ b/org.eclipse.papyrus.iotml.profile.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.iotml.profile.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/org.eclipse.papyrus.iotml.profile.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.papyrus.iotml.profile.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/org.eclipse.papyrus.iotml.profile.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.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/org.eclipse.papyrus.iotml.profile.tests/META-INF/MANIFEST.MF b/org.eclipse.papyrus.iotml.profile.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..8aa8a1d
--- /dev/null
+++ b/org.eclipse.papyrus.iotml.profile.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Profile Tests
+Bundle-SymbolicName: org.eclipse.papyrus.iotml.profile.tests
+Bundle-Version: 0.7.0.qualifier
+Fragment-Host: org.eclipse.papyrus.iotml.profile;bundle-version="0.7.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.junit
diff --git a/org.eclipse.papyrus.iotml.profile.tests/build.properties b/org.eclipse.papyrus.iotml.profile.tests/build.properties
new file mode 100644
index 0000000..e0715e4
--- /dev/null
+++ b/org.eclipse.papyrus.iotml.profile.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = test/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/org.eclipse.papyrus.iotml.profile.tests/pom.xml b/org.eclipse.papyrus.iotml.profile.tests/pom.xml
new file mode 100644
index 0000000..998c14a
--- /dev/null
+++ b/org.eclipse.papyrus.iotml.profile.tests/pom.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.iotml.parent</artifactId>
+ <groupId>org.eclipse.papyrus.iotml</groupId>
+ <version>0.7.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.iotml.profile.tests</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+</project>
\ No newline at end of file
diff --git a/org.eclipse.papyrus.iotml.profile.tests/test/org/eclipse/papyrus/iotml/profile/tests/resources/ModelValidationTest.java b/org.eclipse.papyrus.iotml.profile.tests/test/org/eclipse/papyrus/iotml/profile/tests/resources/ModelValidationTest.java
new file mode 100644
index 0000000..409c7da
--- /dev/null
+++ b/org.eclipse.papyrus.iotml.profile.tests/test/org/eclipse/papyrus/iotml/profile/tests/resources/ModelValidationTest.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2018 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:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.iotml.profile.tests.resources;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * This is a parameterized test to validate all model in the plugin
+ *
+ * @author Benoit Maggi
+ */
+@SuppressWarnings("nls")
+@RunWith(Parameterized.class)
+@Ignore("The profile v0.7 is invalid")
+public class ModelValidationTest {
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ {"/model/IoT-ML.profile.uml"},
+ });
+ }
+
+ private String modelPath;
+
+ public ModelValidationTest(String modelPath) {
+ this.modelPath = modelPath;
+ }
+
+ /**
+ * Validate the model with the rules defined in the meta-model tooling
+ */
+ @Test
+ public void validateModel() {
+ String fullPath = "org.eclipse.papyrus.iotml.profile" + this.modelPath;
+ URI modelPlatformURI = URI.createPlatformPluginURI(fullPath, true);
+ Resource resource = new ResourceSetImpl().getResource(modelPlatformURI, true);
+ Diagnostic diagnostic = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ Assert.assertEquals("The "+modelPath+" model is invalid "+print(diagnostic), Diagnostic.OK, diagnostic.getSeverity());
+ }
+
+ // FIXME : Something should exist in API to do that
+ private String print(Diagnostic diagnostic) {
+ List<Diagnostic> children = diagnostic.getChildren();
+ StringBuilder stringBuilder = new StringBuilder(diagnostic.getMessage());
+ for (Diagnostic diagnosticChildren : children) {
+ stringBuilder.append("\n"); //$NON-NLS-1$
+ stringBuilder.append(diagnosticChildren.getMessage());
+ }
+ return stringBuilder.toString();
+ }
+
+}
diff --git a/org.eclipse.papyrus.iotml.profile.tests/test/org/eclipse/papyrus/iotml/tests/IotMLProfileTest.java b/org.eclipse.papyrus.iotml.profile.tests/test/org/eclipse/papyrus/iotml/tests/IotMLProfileTest.java
new file mode 100644
index 0000000..db5bddf
--- /dev/null
+++ b/org.eclipse.papyrus.iotml.profile.tests/test/org/eclipse/papyrus/iotml/tests/IotMLProfileTest.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2018 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:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.iotml.tests;
+
+import org.eclipse.uml2.uml.UMLPlugin;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Basic test for IoTML profile
+ *
+ * @author Benoit Maggi
+ */
+@SuppressWarnings("nls")
+public class IotMLProfileTest {
+
+ /**
+ * Check that we have a profile registered here :
+ * "http://www.eclipse.org/papyrus/iotML/0.7/IotML"
+ */
+ @Test
+ public void testProfilRegistration() {
+ Assert.assertNotNull(
+ UMLPlugin.getEPackageNsURIToProfileLocationMap().get("http://www.eclipse.org/papyrus/iotML/0.7/IotML"));
+ }
+
+}
diff --git a/org.eclipse.papyrus.iotml.profile/plugin.xml b/org.eclipse.papyrus.iotml.profile/plugin.xml
index 33b293c..e6bbf39 100644
--- a/org.eclipse.papyrus.iotml.profile/plugin.xml
+++ b/org.eclipse.papyrus.iotml.profile/plugin.xml
@@ -94,4 +94,9 @@
</profile>
</extension>
+ <extension point="org.eclipse.uml2.uml.generated_package">
+ <profile uri="http://www.eclipse.org/papyrus/iotML/0.7/IotML"
+ location="pathmap://IOTML_PROFILE/IoT-ML.profile.uml#_gF1qcCtgEeepEtCwqDnj2w"/>
+ </extension>
+
</plugin>
diff --git a/pom.xml b/pom.xml
index 504914b..f485dad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,7 @@
<modules>
<module>org.eclipse.papyrus.iotml.targetplatform.oxygen</module>
<module>org.eclipse.papyrus.iotml.profile</module>
+ <module>org.eclipse.papyrus.iotml.profile.tests</module>
<!-- <module>releng</module> -->
</modules>
<properties>