Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorytanguy2012-01-23 17:02:37 +0000
committerytanguy2012-01-23 17:02:37 +0000
commit2649258c7840b98ff269d0d09d1bed78c229d550 (patch)
tree406c0b82c08d192845c887e8ea7e3e46e56077a2 /tests
parent90af8d9bc365c35f575cfdec9cb3950ab1eb1435 (diff)
downloadorg.eclipse.papyrus-2649258c7840b98ff269d0d09d1bed78c229d550.tar.gz
org.eclipse.papyrus-2649258c7840b98ff269d0d09d1bed78c229d550.tar.xz
org.eclipse.papyrus-2649258c7840b98ff269d0d09d1bed78c229d550.zip
NEW - bug 369422: [Refactoring] Adapt Element Edit Service JUnit tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=369422
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.classpath7
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.project28
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF10
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/about.html28
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/build.properties4
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.di9
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.notation2
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.uml2
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/plugin.properties14
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java104
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java78
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java87
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/context/TestClientContext.java24
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/helper/EPackageEditHelper.java35
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java114
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceProvider.java159
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceProviderFactory.java37
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceUtils.java42
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestElementTypeValidator.java32
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java56
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.classpath7
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.project28
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF10
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/about.html28
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/build.properties4
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/plugin.properties14
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/src/org/eclipse/papyrus/sysml/service/types/tests/registry/TestElementTypeRegistryContent.java234
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.classpath7
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.project28
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF11
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/about.html28
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/build.properties4
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/plugin.properties14
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/registry/TestElementTypeRegistryContent.java101
37 files changed, 1414 insertions, 0 deletions
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.classpath b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.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/J2SE-1.5"/>
+ <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/services/org.eclipse.papyrus.infra.services.edit.tests/.project b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.project
new file mode 100644
index 00000000000..7afd1891f3b
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.services.edit.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/services/org.eclipse.papyrus.infra.services.edit.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..a9c958114ad
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Thu Jun 09 15:15:42 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..20fbc73c04b
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Require-Bundle: org.junit;bundle-version="4.8.2"
+Bundle-Vendor: %providerName
+Fragment-Host: org.eclipse.papyrus.infra.services.edit;bundle-version="0.9.0.qualifier"
+Bundle-Version: 0.9.0.qualifier
+Bundle-Name: %pluginName
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.infra.services.edit.tests
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/about.html b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.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 (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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/services/org.eclipse.papyrus.infra.services.edit.tests/build.properties b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/build.properties
new file mode 100644
index 00000000000..41eb6ade2b4
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.di b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.di
new file mode 100644
index 00000000000..67cd21c0e77
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.di
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
+ <pageList/>
+ <sashModel currentSelection="//@sashModel/@windows.0/@children.0">
+ <windows>
+ <children xsi:type="di:TabFolder"/>
+ </windows>
+ </sashModel>
+</di:SashWindowsMngr>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.notation b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.notation
new file mode 100644
index 00000000000..8634d4c00e0
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.notation
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.uml b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.uml
new file mode 100644
index 00000000000..d208fdf1a1f
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/model/EmptyModel.uml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="_UV0P8EAREeCMpNWxgNcrog" name="model"/>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/plugin.properties b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/plugin.properties
new file mode 100644
index 00000000000..8cd059de3ac
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/plugin.properties
@@ -0,0 +1,14 @@
+#################################################################################
+# Copyright (c) 2011 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.
+#
+##################################################################################
+pluginName=Papyrus Edit Service Tests (Incubation)
+providerName=Eclipse Modeling Project
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java
new file mode 100644
index 00000000000..6e6a584f191
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java
@@ -0,0 +1,104 @@
+package org.eclipse.papyrus.infra.services.edit.tests;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.MetamodelType;
+import org.eclipse.papyrus.infra.services.edit.Activator;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditServiceProvider;
+import org.eclipse.papyrus.infra.services.edit.tests.edit.helper.EPackageEditHelper;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * Abstract Papyrus initialization class (required to get Service activation).
+ */
+public abstract class AbstractTestElementEditService {
+
+ protected static final String PAPYRUS_CONTEXT_ID = "org.eclipse.papyrus.infra.services.edit.TypeContext"; //$NON-NLS-1$
+
+ protected IElementType eClassType;
+ protected IElementType ePackgType;
+
+ protected IElementEditServiceProvider service;
+
+ @BeforeClass
+ public static void openPapyrusWithAnEmptyProject() {
+
+ try {
+ // Prepare new project for tests
+ IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
+ if (! testProject.exists()) {
+ testProject.create(new NullProgressMonitor());
+ }
+ if (! testProject.isOpen()) {
+ testProject.open(new NullProgressMonitor());
+ }
+
+ // Copy EmptyModel from bundle to the test project
+ IFile emptyModel_di = testProject.getFile("EmptyModel.di");
+ IFile emptyModel_no = testProject.getFile("EmptyModel.notation");
+ IFile emptyModel_uml = testProject.getFile("EmptyModel.uml");
+
+ emptyModel_di.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.di").openStream(), true, new NullProgressMonitor());
+ emptyModel_no.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.notation").openStream(), true, new NullProgressMonitor());
+ emptyModel_uml.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.uml").openStream(), true, new NullProgressMonitor());
+
+ // Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(emptyModel_di.getName());
+ page.openEditor(new FileEditorInput(emptyModel_di), desc.getId());
+
+ } catch (Exception e) {
+ fail("Papyrus initialization failed ("+ e.getMessage() +")."); // $NON-NLS-1$
+ }
+ }
+
+ @Before
+ public void setUp() {
+ // To prepare this test two element types are added to Papyrus Client Context
+ ElementTypeRegistry.getInstance().register(new MetamodelType("ECLASS_TEST_ID", null, "ECLASS", EcorePackage.eINSTANCE.getEClass(), null)); //$NON-NLS-1$
+ ElementTypeRegistry.getInstance().register(new MetamodelType("EPACKG_TEST_ID", null, "EPACKG", EcorePackage.eINSTANCE.getEPackage(), new EPackageEditHelper())); //$NON-NLS-1$
+
+ eClassType = ElementTypeRegistry.getInstance().getType("ECLASS_TEST_ID");
+ ePackgType = ElementTypeRegistry.getInstance().getType("EPACKG_TEST_ID");
+
+ IClientContext context = ClientContextManager.getInstance().getClientContext(PAPYRUS_CONTEXT_ID);
+ context.bindId("ECLASS_TEST_ID"); //$NON-NLS-1$
+ context.bindId("EPACKG_TEST_ID"); //$NON-NLS-1$
+
+ service = ElementEditServiceUtils.getEditServiceProvider();
+ }
+
+ @AfterClass
+ public static void closePapyrusAndCleanProject() {
+ // Close all editors
+ boolean closed = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ if (! closed) {
+ fail("Could not close editors correctly.");
+ }
+
+ // Delete test project
+ IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
+ try {
+ testProject.delete(true, new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("Could delete test project correctly ("+e.getMessage()+").");
+ }
+ }
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java
new file mode 100644
index 00000000000..55e8cf4edb9
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java
@@ -0,0 +1,78 @@
+package org.eclipse.papyrus.infra.services.edit.tests.commands;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.services.edit.commands.ConfigureFeatureCommandFactory;
+import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory;
+import org.eclipse.papyrus.infra.services.edit.internal.ElementEditService;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link ConfigureFeatureCommandFactory} class.
+ */
+public class TestConfigureFeatureCommandFactory extends AbstractTestElementEditService {
+
+ IClientContext context;
+
+ IElementEditService ePckgService;
+
+ EPackage ePckg;
+
+ @Before
+ public void setUp() {
+ super.setUp();
+
+ context = ClientContextManager.getInstance().getClientContext(PAPYRUS_CONTEXT_ID);
+ ePckgService = new ElementEditService(ePackgType, context);
+ ePckg = EcoreFactory.eINSTANCE.createEPackage();
+ }
+
+ @Test
+ public void testGetEditCommand() {
+ try {
+
+ ICommand correctCommand = ePckgService.getEditCommand(prepareCorrectRequest());
+
+ // Try to execute command and make quick result verification.
+ assertTrue("The service command should be executable.", correctCommand.canExecute());
+ correctCommand.execute(new NullProgressMonitor(), null);
+ assertTrue("The service command result is incorrect.", !ePckg.getESubpackages().isEmpty());
+ assertTrue("The service configure command result is incorrect.", "ASpecificName".equals(ePckg.getESubpackages().get(0).getName()));
+
+ } catch (ServiceException e) {
+ fail("Test aborted - Papyrus editing domain not found.");
+ } catch (ExecutionException e) {
+ fail("Test aborted - Command execution failed.");
+ }
+ }
+
+ /** Prepare a creation request (create a EPackage in an EPackage) and adds a ConfigureFeatureCommand */
+ @SuppressWarnings("unchecked")
+ private IEditCommandRequest prepareCorrectRequest() throws ServiceException {
+ TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ IEditCommandRequest request = new CreateElementRequest(editingDomain, ePckg, ePackgType);
+
+ // Create a configure command factory and add it to the request
+ IConfigureCommandFactory factory = new ConfigureFeatureCommandFactory(EcorePackage.eINSTANCE.getENamedElement_Name(), "ASpecificName");
+ request.getParameters().put(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, factory);
+
+ return request;
+ }
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java
new file mode 100644
index 00000000000..d503b63d217
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java
@@ -0,0 +1,87 @@
+package org.eclipse.papyrus.infra.services.edit.tests.commands;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.services.edit.commands.ConfigureFeatureListCommandFactory;
+import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory;
+import org.eclipse.papyrus.infra.services.edit.internal.ElementEditService;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link ConfigureFeatureListCommandFactory} class.
+ */
+public class TestConfigureFeatureListCommandFactory extends AbstractTestElementEditService {
+
+ IClientContext context;
+
+ IElementEditService ePckgService;
+
+ EPackage ePckg;
+
+ @Before
+ public void setUp() {
+ super.setUp();
+
+ context = ClientContextManager.getInstance().getClientContext(PAPYRUS_CONTEXT_ID);
+ ePckgService = new ElementEditService(ePackgType, context);
+ ePckg = EcoreFactory.eINSTANCE.createEPackage();
+ }
+
+ @Test
+ public void testGetEditCommand() {
+ try {
+
+ ICommand correctCommand = ePckgService.getEditCommand(prepareCorrectRequest());
+
+ // Try to execute command and make quick result verification.
+ assertTrue("The service command should be executable.", correctCommand.canExecute());
+ correctCommand.execute(new NullProgressMonitor(), null);
+ assertTrue("The service command result is incorrect.", !ePckg.getESubpackages().isEmpty());
+ assertTrue("The service configure command result is incorrect.", "ASpecificName".equals(ePckg.getESubpackages().get(0).getName()));
+ assertTrue("The service configure command result is incorrect.", "ASpecificNsURI".equals(ePckg.getESubpackages().get(0).getNsURI()));
+
+ } catch (ServiceException e) {
+ fail("Test aborted - Papyrus editing domain not found.");
+ } catch (ExecutionException e) {
+ fail("Test aborted - Command execution failed.");
+ }
+ }
+
+ /** Prepare a creation request (create a EPackage in an EPackage) and adds a ConfigureFeatureCommand */
+ @SuppressWarnings("unchecked")
+ private IEditCommandRequest prepareCorrectRequest() throws ServiceException {
+ TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ IEditCommandRequest request = new CreateElementRequest(editingDomain, ePckg, ePackgType);
+
+ // Create a configure command factory and add it to the request
+ Map<EStructuralFeature, Object> featureValueMap = new HashMap<EStructuralFeature, Object>();
+ featureValueMap.put(EcorePackage.eINSTANCE.getENamedElement_Name(), "ASpecificName");
+ featureValueMap.put(EcorePackage.eINSTANCE.getEPackage_NsURI(), "ASpecificNsURI");
+
+ IConfigureCommandFactory factory = new ConfigureFeatureListCommandFactory(featureValueMap);
+ request.getParameters().put(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, factory);
+
+ return request;
+ }
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/context/TestClientContext.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/context/TestClientContext.java
new file mode 100644
index 00000000000..bfbd2f1a332
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/context/TestClientContext.java
@@ -0,0 +1,24 @@
+package org.eclipse.papyrus.infra.services.edit.tests.context;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.junit.Test;
+
+/**
+ * JUnit tests Papyrus ElementTypeRegistry binding context.
+ */
+public class TestClientContext {
+
+ private static final String PAPYRUS_CONTEXT_ID = "org.eclipse.papyrus.infra.services.edit.TypeContext"; //$NON-NLS-1$
+
+ @Test
+ public void testClientContextExist() {
+ IClientContext context = ClientContextManager.getInstance().getClientContext(PAPYRUS_CONTEXT_ID);
+ if (context == null) {
+ fail("Papyrus IClientContext could not be found.");
+ }
+ }
+
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/helper/EPackageEditHelper.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/helper/EPackageEditHelper.java
new file mode 100644
index 00000000000..75bc95b3b76
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/helper/EPackageEditHelper.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ *
+ * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.edit.tests.edit.helper;
+
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory;
+
+public class EPackageEditHelper extends AbstractEditHelper {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICommand getConfigureCommand(ConfigureRequest req) {
+ if (req.getParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID) != null) {
+ IConfigureCommandFactory factory = (IConfigureCommandFactory) req.getParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID);
+ return factory.create(req);
+ }
+ return super.getConfigureCommand(req);
+ }
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java
new file mode 100644
index 00000000000..0bbcbabf842
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java
@@ -0,0 +1,114 @@
+package org.eclipse.papyrus.infra.services.edit.tests.service;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.services.edit.internal.ElementEditService;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link ElementEditService} class.
+ */
+public class TestElementEditService extends AbstractTestElementEditService {
+
+ // IElementType declared for testing purpose in super class:
+ // MetamodelType("ECLASS_TEST_ID", null, "ECLASS", EcorePackage.eINSTANCE.getEClass(), null); //$NON-NLS-1$
+ // MetamodelType("EPACKG_TEST_ID", null, "EPACKG", EcorePackage.eINSTANCE.getEPackage(), null); //$NON-NLS-1$
+
+ IClientContext context;
+
+ IElementEditService ePckgService;
+
+ IElementEditService eClassService;
+
+ EPackage ePckg;
+
+ EClass eClass;
+
+ @Before
+ public void setUp() {
+ super.setUp();
+
+ context = ClientContextManager.getInstance().getClientContext(PAPYRUS_CONTEXT_ID);
+
+ ePckgService = new ElementEditService(ePackgType, context);
+ eClassService = new ElementEditService(eClassType, context);
+
+ ePckg = EcoreFactory.eINSTANCE.createEPackage();
+ eClass = EcoreFactory.eINSTANCE.createEClass();
+ }
+
+ @Test
+ public void testCanEdit() {
+ try {
+ assertTrue("The service should be able to edit the request.", ePckgService.canEdit(prepareCorrectRequest()));
+ assertFalse("The service should not be able to edit the request.", ePckgService.canEdit(prepareIncorrectRequest()));
+ } catch (ServiceException e) {
+ fail("Test aborted - Papyrus editing domain not found.");
+ }
+ }
+
+ @Test
+ public void testGetEditCommand() {
+ try {
+
+ ICommand correctCommand = ePckgService.getEditCommand(prepareCorrectRequest());
+ ICommand incorrectCommand = ePckgService.getEditCommand(prepareIncorrectRequest());
+
+ // Try to execute command and make quick result verification.
+ assertTrue("The service command should be executable.", correctCommand.canExecute());
+ correctCommand.execute(new NullProgressMonitor(), null);
+ assertTrue("The service command result is incorrect.", !ePckg.getESubpackages().isEmpty());
+
+ // With incorrect request the command should not be executable.
+ assertFalse("The service command should not be executable.", incorrectCommand.canExecute());
+
+ } catch (ServiceException e) {
+ fail("Test aborted - Papyrus editing domain not found.");
+ } catch (ExecutionException e) {
+ fail("Test aborted - Command execution failed.");
+ }
+ }
+
+ @Test
+ public void testGetDisplayName() {
+ String displayName = ePckgService.getDisplayName();
+ assertTrue("Incorrect display name retrieved.", displayName.equals("EPACKG"));
+ }
+
+ @Test
+ public void testGetAdapter() {
+ IElementType type = (IElementType)ePckgService.getAdapter(IElementType.class);
+ assertTrue("Incorrect type adaptation.", type == ePackgType);
+ }
+
+ /** Correct creation request (create a EPackage in an EPackage) */
+ private IEditCommandRequest prepareCorrectRequest() throws ServiceException {
+ TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ return new CreateElementRequest(editingDomain, ePckg, ePackgType);
+ }
+
+ /** Incorrect creation request (create a EClass in an EPackage) */
+ private IEditCommandRequest prepareIncorrectRequest() throws ServiceException {
+ TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ return new CreateElementRequest(editingDomain, eClass, ePackgType);
+ }
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceProvider.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceProvider.java
new file mode 100644
index 00000000000..f09b50894b8
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceProvider.java
@@ -0,0 +1,159 @@
+package org.eclipse.papyrus.infra.services.edit.tests.service;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.IMetamodelType;
+import org.eclipse.gmf.runtime.emf.type.core.MetamodelType;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.services.edit.internal.ElementEditServiceProvider;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditServiceProvider;
+import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link ElementEditServiceProvider} class.
+ */
+public class TestElementEditServiceProvider extends AbstractTestElementEditService {
+
+ IElementEditServiceProvider provider;
+
+ @Before
+ public void setUp() {
+ super.setUp();
+
+ try {
+ provider = ElementEditServiceProvider.getInstance();
+ } catch (ServiceException e) {
+ fail("Test aborted - Singleton IElementEditServiceProvider not found.");
+ }
+ }
+
+ @Test
+ public void testGetEditService_EClass() {
+
+ try {
+ IElementEditService attService = provider.getEditService(EcorePackage.eINSTANCE.getEAttribute());
+ assertTrue("No IElementEditService found for EAttribute.", attService != null);
+ String attServiceDisplayName = attService.getDisplayName();
+ assertTrue("Default IElementEditService should match EAttribute.", attServiceDisplayName.equals("Generic Element"));
+
+ IElementEditService packService = provider.getEditService(EcorePackage.eINSTANCE.getEPackage());
+ assertTrue("No IElementEditService found for EPackage.", packService != null);
+ // Check result
+ assertTrue("The IElementEditService should be EPackage related.", packService.getDisplayName().equals("EPACKG"));
+
+ } catch (ServiceException e) {
+ fail("Test aborted - Service exception in ElementEditServiceProvider::getEditService(EClass).");
+ }
+ }
+
+ @Test
+ public void testGetEditService_EObject() {
+
+ try {
+ EAttribute att = EcoreFactory.eINSTANCE.createEAttribute();
+ EPackage pack = EcoreFactory.eINSTANCE.createEPackage();
+
+ IElementEditService attService = provider.getEditService(att);
+ assertTrue("No IElementEditService found for EAttribute.", attService != null);
+ String attServiceDisplayName = attService.getDisplayName();
+ assertTrue("Default IElementEditService should match EAttribute.", attServiceDisplayName.equals("Generic Element"));
+
+ IElementEditService packService = provider.getEditService(pack);
+ assertTrue("No IElementEditService found for EPackage.", packService != null);
+
+ // Check result
+ assertTrue("The IElementEditService should be EPackage related.", packService.getDisplayName().equals("EPACKG"));
+
+ } catch (ServiceException e) {
+ fail("Test aborted - Service exception in ElementEditServiceProvider::getEditService(EObject).");
+ }
+ }
+
+ @Test
+ public void testGetEditService_IElementType() {
+
+ try {
+
+ IElementEditService packService = provider.getEditService(ePackgType);
+ assertTrue("No IElementEditService found for EPackage.", packService != null);
+ // Check result
+ assertTrue("The IElementEditService should be EPackage related.", packService.getDisplayName().equals("EPACKG"));
+
+ } catch (ServiceException e) {
+ fail("Test aborted - Service exception in ElementEditServiceProvider::getEditService(EObject).");
+ }
+
+ try {
+
+ ElementTypeRegistry.getInstance().register(new MetamodelType("ETT_TEST_ID", null, "EATT", EcorePackage.eINSTANCE.getEAttribute(), null)); //$NON-NLS-1$
+ IElementType eAtt = ElementTypeRegistry.getInstance().getType("ETT_TEST_ID");
+ IElementEditService attService = provider.getEditService(eAtt);
+ assertTrue("No IElementEditService should match EAttribute.", attService == null);
+
+ } catch (ServiceException e) {
+ // Exception expected.
+ return;
+ }
+
+ fail("The service is supposed to thow exception when the IElementType is incorrect.");
+ }
+
+ @Test
+ public void testGetEditService_Unknown() {
+ try {
+ provider.getEditService("Incorrect_Object");
+ } catch (ServiceException e) {
+ // An exception should be thrown
+ return;
+ }
+
+ fail("No exception thrown will the object cannot be handled.");
+ }
+
+ @Test
+ public void testGetContainedTypeEditServices() {
+ EPackage aPackage = EcoreFactory.eINSTANCE.createEPackage();
+ EClass aClass = EcoreFactory.eINSTANCE.createEClass();
+
+ try {
+ List<IElementEditService> package_ESubpackages = provider.getContainedTypeEditServices(aPackage, EcorePackage.eINSTANCE.getEPackage_ESubpackages());
+ assertTrue("Only 1 IElementEditService should match EcorePackage.eINSTANCE.getEPackage_ESubpackages()", package_ESubpackages.size() == 1);
+
+ // Check result
+ IElementEditService service = package_ESubpackages.get(0);
+ assertTrue("The IElementEditService should be EPackage related.", service.getDisplayName().equals("EPACKG"));
+
+ List<IElementEditService> class_EOperations = provider.getContainedTypeEditServices(aClass, EcorePackage.eINSTANCE.getEClass_EOperations());
+ assertTrue("No IElementEditService should match EcorePackage.eINSTANCE.getEClass_EOperations()", class_EOperations.size() == 0);
+
+ } catch (ServiceException e) {
+ fail("Test aborted - Service exception in ElementEditServiceProvider::getContainedTypeEditServices.");
+ }
+ }
+
+ @Test
+ public void testIsKnownElementType() {
+ assertFalse("Current IElementType id should not be known.", provider.isKnownElementType("unknown_id"));
+ assertTrue("Current IElementType id should be known.", provider.isKnownElementType(eClassType.getId()));
+
+ // Add an IElementType, not bound to Papyrus context - Should be considered as ignored
+ IMetamodelType eAttr = new MetamodelType("out_of_context_id", null, "EATTR", EcorePackage.eINSTANCE.getEAttribute(), null); //$NON-NLS-1$
+ ElementTypeRegistry.getInstance().register(eAttr);
+
+ assertFalse("Current IElementType id should not be known.", provider.isKnownElementType(eAttr.getId()));
+ }
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceProviderFactory.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceProviderFactory.java
new file mode 100644
index 00000000000..5053143ee12
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceProviderFactory.java
@@ -0,0 +1,37 @@
+package org.eclipse.papyrus.infra.services.edit.tests.service;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.services.edit.internal.ElementEditServiceProviderFactory;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditServiceProvider;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link ElementEditServiceProviderFactory} class.
+ * No specific implementation (no specific test) provided for start / dispose / init.
+ */
+public class TestElementEditServiceProviderFactory {
+
+ @Test
+ public void testCreateServiceInstance() {
+
+ Object service = null;
+
+ try {
+
+ ElementEditServiceProviderFactory factory = new ElementEditServiceProviderFactory();
+ service = factory.createServiceInstance();
+
+ } catch (ServiceException e) {
+ fail("Factory throws exception during service creation ("+e.getMessage()+").");
+ return;
+ }
+
+ assertNotNull("Created service is null.", service);
+ assertTrue("Unexpected kind of service created.", service instanceof IElementEditServiceProvider);
+ }
+
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceUtils.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceUtils.java
new file mode 100644
index 00000000000..1313db097fc
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditServiceUtils.java
@@ -0,0 +1,42 @@
+package org.eclipse.papyrus.infra.services.edit.tests.service;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditServiceProvider;
+import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
+import org.junit.Test;
+
+public class TestElementEditServiceUtils extends AbstractTestElementEditService {
+
+ @Test
+ public void testGetCommandProvider() {
+
+ // Test EPackage access
+ EPackage eP = EcoreFactory.eINSTANCE.createEPackage();
+ IElementEditService serviceForEPack = ElementEditServiceUtils.getCommandProvider(eP);
+
+ if(serviceForEPack == null) {
+ fail("No IElementEditService found for EPackage.");
+ }
+
+ // Try to get related IElementType to ensure a correct provider is returned
+ IElementType elementType = (IElementType)serviceForEPack.getAdapter(IElementType.class);
+ if(elementType != ePackgType) {
+ fail("The IElementEditService does not rely on the correct IElementType.");
+ }
+ }
+
+ @Test
+ public void testGetEditServiceProvider() {
+ IElementEditServiceProvider provider = ElementEditServiceUtils.getEditServiceProvider();
+ if(provider == null) {
+ fail("Element edit service can not be found.");
+ }
+ }
+
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestElementTypeValidator.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestElementTypeValidator.java
new file mode 100644
index 00000000000..815c27c347d
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestElementTypeValidator.java
@@ -0,0 +1,32 @@
+package org.eclipse.papyrus.infra.services.edit.tests.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
+import org.eclipse.papyrus.infra.services.edit.utils.ElementTypeValidator;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link ElementTypeValidator} class.
+ */
+public class TestElementTypeValidator extends AbstractTestElementEditService {
+
+ @Test
+ public void testValidate() {
+
+ // Prepare validator.
+ ElementTypeValidator validator = new ElementTypeValidator(ePackgType);
+
+ Object[] test1 = {EcoreFactory.eINSTANCE.createEPackage()};
+ assertTrue("Should validate EPackage.", validator.validate(test1).isOK());
+
+ Object[] test2 = {EcoreFactory.eINSTANCE.createEAttribute()};
+ assertFalse("Should not validate EAttribute.", validator.validate(test2).isOK());
+
+ Object[] test3 = {};
+ assertFalse("Should not validate empty selection.", validator.validate(test3).isOK());
+ }
+
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java
new file mode 100644
index 00000000000..6062e867bb7
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java
@@ -0,0 +1,56 @@
+package org.eclipse.papyrus.infra.services.edit.tests.utils;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
+import org.eclipse.papyrus.infra.services.edit.utils.GMFCommandUtils;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link GMFCommandUtils} class.
+ */
+public class TestGMFCommandUtils extends AbstractTestElementEditService {
+
+ @Test
+ public void testGetCommandEObjectResult() {
+
+ try {
+
+ TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+
+ // Prepare and execute a command that adds a sub-EPackage
+ EPackage ePckg = EcoreFactory.eINSTANCE.createEPackage();
+ CreateElementRequest req = new CreateElementRequest(editingDomain, ePckg, ePackgType);
+ ICommand createCommand = ElementEditServiceUtils.getCommandProvider(ePckg).getEditCommand(req);
+
+ // Try to execute command and make quick result verification.
+ assertTrue("The service command should be executable.", createCommand.canExecute());
+ createCommand.execute(new NullProgressMonitor(), null);
+
+ // Inspect the result (should be a new EObject)
+ EObject eObject = GMFCommandUtils.getCommandEObjectResult(createCommand);
+ assertTrue("Could not get new element from command.", eObject != null);
+ assertTrue("New element from command should be an EPackage.", eObject instanceof EPackage);
+
+ } catch (ServiceException e) {
+ fail("Test aborted - Service exception.");
+
+ } catch (ExecutionException e) {
+ fail("Test aborted - Command execution failed.");
+ }
+
+ }
+
+}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.classpath b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.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/J2SE-1.5"/>
+ <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/sysml/org.eclipse.papyrus.sysml.service.types.tests/.project b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.project
new file mode 100644
index 00000000000..b031b85f98b
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.sysml.service.types.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/sysml/org.eclipse.papyrus.sysml.service.types.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..632650e3ffb
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Jun 15 11:30:47 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..8f61b5ca225
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Require-Bundle: org.junit;bundle-version="4.8.2"
+Bundle-Vendor: %providerName
+Fragment-Host: org.eclipse.papyrus.sysml.service.types;bundle-version="0.9.0"
+Bundle-Version: 0.9.0.qualifier
+Bundle-Name: %pluginName
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.sysml.service.types.tests
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/about.html b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.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 (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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/sysml/org.eclipse.papyrus.sysml.service.types.tests/build.properties b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/build.properties
new file mode 100644
index 00000000000..41eb6ade2b4
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/plugin.properties b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/plugin.properties
new file mode 100644
index 00000000000..75f628673d6
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/plugin.properties
@@ -0,0 +1,14 @@
+#################################################################################
+# Copyright (c) 2011 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.
+#
+##################################################################################
+pluginName=Papyrus SysML Service Types Tests (Incubation)
+providerName=Eclipse Modeling Project
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/src/org/eclipse/papyrus/sysml/service/types/tests/registry/TestElementTypeRegistryContent.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/src/org/eclipse/papyrus/sysml/service/types/tests/registry/TestElementTypeRegistryContent.java
new file mode 100644
index 00000000000..6677128ef81
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/src/org/eclipse/papyrus/sysml/service/types/tests/registry/TestElementTypeRegistryContent.java
@@ -0,0 +1,234 @@
+package org.eclipse.papyrus.sysml.service.types.tests.registry;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditServiceProvider;
+import org.eclipse.papyrus.sysml.allocations.AllocationsPackage;
+import org.eclipse.papyrus.sysml.blocks.BlocksPackage;
+import org.eclipse.papyrus.sysml.constraints.ConstraintsPackage;
+import org.eclipse.papyrus.sysml.modelelements.ModelelementsPackage;
+import org.eclipse.papyrus.sysml.portandflows.PortandflowsPackage;
+import org.eclipse.papyrus.sysml.requirements.RequirementsPackage;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestElementTypeRegistryContent {
+
+ private static final String PAPYRUS_CONTEXT_ID = "org.eclipse.papyrus.infra.services.edit.TypeContext"; //$NON-NLS-1$
+
+ private static final String PAPYRUS_ELEMENT_TYPE_PREFIX = "org.eclipse.papyrus.sysml."; //$NON-NLS-1$
+
+ @Test
+ public void testRegistryContentForSysMLModelElements() {
+
+ // Iterate over SysML ModelElements sub-profile contents
+ Iterator<EObject> it = ModelelementsPackage.eINSTANCE.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof EClass) {
+
+ EClass eClass = (EClass) eObject;
+ assertTrue("No type found in Papyrus context for " + eClass.getName(),
+ ElementEditServiceUtils.getEditServiceProvider().isKnownElementType(PAPYRUS_ELEMENT_TYPE_PREFIX + eClass.getName()));
+ }
+ }
+ }
+
+ @Test
+ public void testRegistryContentForSysMLBlocks() {
+
+ // Iterate over SysML Blocks sub-profile contents
+ Iterator<EObject> it = BlocksPackage.eINSTANCE.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof EClass) {
+ EClass eClass = (EClass) eObject;
+
+ if ("DistributedProperty".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ if ("NestedConnectorEnd".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ if ("ParticipantProperty".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ if ("ConnectorProperty".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ if ("BindingConnector".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ if ("PropertySpecificType".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ assertTrue("No type found in Papyrus context for " + eClass.getName(),
+ ElementEditServiceUtils.getEditServiceProvider().isKnownElementType(PAPYRUS_ELEMENT_TYPE_PREFIX + eClass.getName()));
+ }
+ }
+ }
+
+ @Test
+ public void testRegistryContentForSysMLConstraints() {
+
+ // Iterate over SysML Constraints sub-profile contents
+ Iterator<EObject> it = ConstraintsPackage.eINSTANCE.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof EClass) {
+
+ EClass eClass = (EClass) eObject;
+ assertTrue("No type found in Papyrus context for " + eClass.getName(),
+ ElementEditServiceUtils.getEditServiceProvider().isKnownElementType(PAPYRUS_ELEMENT_TYPE_PREFIX + eClass.getName()));
+ }
+ }
+ }
+
+ @Test
+ public void testRegistryContentForSysMLRequirements() {
+
+ // Iterate over SysML Requirements sub-profile contents
+ Iterator<EObject> it = RequirementsPackage.eINSTANCE.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof EClass) {
+ EClass eClass = (EClass) eObject;
+
+ if ("TestCase".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ if ("RequirementRelated".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ assertTrue("No type found in Papyrus context for " + eClass.getName(),
+ ElementEditServiceUtils.getEditServiceProvider().isKnownElementType(PAPYRUS_ELEMENT_TYPE_PREFIX + eClass.getName()));
+ }
+ }
+ }
+
+ @Test
+ public void testRegistryContentForSysMLAllocations() {
+
+ // Iterate over SysML Allocations sub-profile contents
+ Iterator<EObject> it = AllocationsPackage.eINSTANCE.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof EClass) {
+ EClass eClass = (EClass) eObject;
+
+ if ("Allocated".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ if ("AllocateActivityPartition".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ assertTrue("No type found in Papyrus context for " + eClass.getName(),
+ ElementEditServiceUtils.getEditServiceProvider().isKnownElementType(PAPYRUS_ELEMENT_TYPE_PREFIX + eClass.getName()));
+ }
+ }
+ }
+
+ @Test
+ public void testRegistryContentForSysMLPortAndFlows() {
+
+ // Iterate over SysML PortAndFlows sub-profile contents
+ Iterator<EObject> it = PortandflowsPackage.eINSTANCE.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof EClass) {
+
+ EClass eClass = (EClass) eObject;
+ assertTrue("No type found in Papyrus context for " + eClass.getName(),
+ ElementEditServiceUtils.getEditServiceProvider().isKnownElementType(PAPYRUS_ELEMENT_TYPE_PREFIX + eClass.getName()));
+ }
+ }
+ }
+
+ @Test
+ public void testRegistryContentForSysMLAssociations() {
+
+ IClientContext context = ClientContextManager.getInstance().getClientContext(PAPYRUS_CONTEXT_ID);
+ if (context == null) {
+ fail("Papyrus IClientContext could not be found.");
+ }
+
+ IElementEditServiceProvider service = ElementEditServiceUtils.getEditServiceProvider();
+
+ assertTrue("No ISpecializationType found for SysML Association in Papyrus context", service.isKnownElementType("org.eclipse.papyrus.sysml.Association"));
+
+ assertTrue("Incorrect constant initialization for SysML Association", SysMLElementTypes.ASSOCIATION != null);
+ assertTrue("Incorrect constant initialization for SysML AssociationComposite", SysMLElementTypes.ASSOCIATION_COMPOSITE != null);
+ assertTrue("Incorrect constant initialization for SysML AssociationCompositeDirected", SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED != null);
+ assertTrue("Incorrect constant initialization for SysML AssociationNone", SysMLElementTypes.ASSOCIATION_NONE != null);
+ assertTrue("Incorrect constant initialization for SysML AssociationNoneDirected", SysMLElementTypes.ASSOCIATION_NONE_DIRECTED != null);
+ assertTrue("Incorrect constant initialization for SysML AssociationShared", SysMLElementTypes.ASSOCIATION_SHARED != null);
+ assertTrue("Incorrect constant initialization for SysML AssociationSharedDirected", SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED != null);
+
+ assertTrue("No ISpecializationType found for SysML Association in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION.getId()));
+ assertTrue("No ISpecializationType found for SysML AssociationComposite in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_COMPOSITE.getId()));
+ assertTrue("No ISpecializationType found for SysML AssociationCompositeDirected in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.getId()));
+ assertTrue("No ISpecializationType found for SysML AssociationNone in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_NONE.getId()));
+ assertTrue("No ISpecializationType found for SysML AssociationNoneDirected in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.getId()));
+ assertTrue("No ISpecializationType found for SysML AssociationShared in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_SHARED.getId()));
+ assertTrue("No ISpecializationType found for SysML AssociationSharedDirected in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.getId()));
+
+ assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION.getId() +")", SysMLElementTypes.ASSOCIATION instanceof ISpecializationType);
+ assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_COMPOSITE.getId() +")", SysMLElementTypes.ASSOCIATION_COMPOSITE instanceof ISpecializationType);
+ assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.getId() +")", SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED instanceof ISpecializationType);
+ assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_NONE.getId() +")", SysMLElementTypes.ASSOCIATION_NONE instanceof ISpecializationType);
+ assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.getId() +")", SysMLElementTypes.ASSOCIATION_NONE_DIRECTED instanceof ISpecializationType);
+ assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_SHARED.getId() +")", SysMLElementTypes.ASSOCIATION_SHARED instanceof ISpecializationType);
+ assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.getId() +")", SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED instanceof ISpecializationType);
+
+ ISpecializationType association = (ISpecializationType) SysMLElementTypes.ASSOCIATION;
+ ISpecializationType associationComposite = (ISpecializationType) SysMLElementTypes.ASSOCIATION_COMPOSITE;
+ ISpecializationType associationCompositeDirected = (ISpecializationType) SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED;
+ ISpecializationType associationNone = (ISpecializationType) SysMLElementTypes.ASSOCIATION_NONE;
+ ISpecializationType associationNoneDirected = (ISpecializationType) SysMLElementTypes.ASSOCIATION_NONE_DIRECTED;
+ ISpecializationType associationShared = (ISpecializationType) SysMLElementTypes.ASSOCIATION_SHARED;
+ ISpecializationType associationSharedDirected = (ISpecializationType) SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED;
+
+ assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION.getId(), association.isSpecializationOf(UMLElementTypes.ASSOCIATION_BASE));
+ assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_COMPOSITE.getId(), associationComposite.isSpecializationOf(association));
+ assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.getId(), associationCompositeDirected.isSpecializationOf(association));
+ assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_NONE.getId(), associationNone.isSpecializationOf(association));
+ assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.getId(), associationNoneDirected.isSpecializationOf(association));
+ assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_SHARED.getId(), associationShared.isSpecializationOf(association));
+ assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.getId(), associationSharedDirected.isSpecializationOf(association));
+
+ }
+
+}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.classpath b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.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/J2SE-1.5"/>
+ <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/uml/org.eclipse.papyrus.uml.service.types.tests/.project b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.project
new file mode 100644
index 00000000000..bb00c355cb3
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.uml.service.types.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/uml/org.eclipse.papyrus.uml.service.types.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..63ea330d31d
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Jun 15 11:24:40 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..7a1880368ed
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Require-Bundle: org.junit;bundle-version="4.8.2"
+Bundle-Vendor: %providerName
+Fragment-Host: org.eclipse.papyrus.uml.service.types;bundle-version="0
+ .8.0"
+Bundle-Version: 0.8.2.qualifier
+Bundle-Name: %pluginName
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.uml.service.types.tests
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/about.html b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.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 (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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/uml/org.eclipse.papyrus.uml.service.types.tests/build.properties b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/build.properties
new file mode 100644
index 00000000000..41eb6ade2b4
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/plugin.properties b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/plugin.properties
new file mode 100644
index 00000000000..15f85719208
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/plugin.properties
@@ -0,0 +1,14 @@
+#################################################################################
+# Copyright (c) 2011 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.
+#
+##################################################################################
+pluginName=Papyrus UML Service Types Tests (Incubation)
+providerName=Eclipse Modeling Project
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/registry/TestElementTypeRegistryContent.java b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/registry/TestElementTypeRegistryContent.java
new file mode 100644
index 00000000000..fbebbd6143e
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/src/org/eclipse/papyrus/uml/service/types/tests/registry/TestElementTypeRegistryContent.java
@@ -0,0 +1,101 @@
+package org.eclipse.papyrus.uml.service.types.tests.registry;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.uml.service.types.helper.DefaultEditHelper;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.profile.l2.L2Package;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestElementTypeRegistryContent {
+
+ private static final String PAPYRUS_CONTEXT_ID = "org.eclipse.papyrus.infra.services.edit.TypeContext"; //$NON-NLS-1$
+
+ private static final String PAPYRUS_ELEMENT_TYPE_PREFIX = "org.eclipse.papyrus.uml."; //$NON-NLS-1$
+
+ private static final String PAPYRUS_INVALID_PREFIX = "org.eclipse.papyrus.uml.diagram"; //$NON-NLS-1$
+
+ @Test
+ public void testRegistryContentForUML() {
+
+ IClientContext context = ClientContextManager.getInstance().getClientContext(PAPYRUS_CONTEXT_ID);
+ if (context == null) {
+ fail("Papyrus IClientContext could not be found.");
+ }
+
+ // Iterate over UML2 contents
+ Iterator<EObject> it = UMLPackage.eINSTANCE.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof EClass) {
+ EClass eClass = (EClass) eObject;
+ IElementType elementType = ElementTypeRegistry.getInstance().getElementType(eClass, context);
+
+ // An IElementType is supposed to be registered for any meta-class in the UML type service.
+ assertTrue("No IElementType registered for eClass ("+eClass.getName()+")", elementType != null);
+ // An IElementType is supposed to be registered for any meta-class in the UML type service.
+ assertTrue("Unexpected IElementType id ("+elementType.getId()+")", elementType.getId().startsWith(PAPYRUS_ELEMENT_TYPE_PREFIX));
+ assertFalse("Unexpected IElementType id ("+elementType.getId()+")", elementType.getId().startsWith(PAPYRUS_INVALID_PREFIX));
+ // Ensure a correct base is used for Helper
+ assertTrue("Incorrect edit helper hierarchy for element type ("+elementType.getId()+")", elementType.getEditHelper() instanceof DefaultEditHelper);
+ }
+ }
+ }
+
+ @Test
+ public void testRegistryContentForUMLStandard() {
+
+ // Iterate over UML2 Standard profile contents
+ Iterator<EObject> it = L2Package.eINSTANCE.eAllContents();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof EClass) {
+ EClass eClass = (EClass) eObject;
+
+ if (!"Trace".equals(eClass.getName())) {
+ // Not implemented
+ continue;
+ }
+
+ assertTrue("No type found in Papyrus context for " + eClass.getName(),
+ ElementEditServiceUtils.getEditServiceProvider().isKnownElementType(PAPYRUS_ELEMENT_TYPE_PREFIX + eClass.getName()));
+
+ }
+ }
+ }
+
+ @Test
+ public void testRegistryContentForUMLAssociations() {
+
+ IClientContext context = ClientContextManager.getInstance().getClientContext(PAPYRUS_CONTEXT_ID);
+ if (context == null) {
+ fail("Papyrus IClientContext could not be found.");
+ }
+
+ IElementType associationBaseElementType = ElementTypeRegistry.getInstance().getElementType(UMLPackage.eINSTANCE.getAssociation(), context);
+ assertTrue("Incorrect id for base Association element type ("+associationBaseElementType.getId()+")", associationBaseElementType.getId().equals("org.eclipse.papyrus.uml.AssociationBase"));
+
+ IElementType associationElementType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Association");
+ assertTrue("No ISpecializationType found for UML Association in Papyrus context", ElementEditServiceUtils.getEditServiceProvider().isKnownElementType("org.eclipse.papyrus.uml.Association"));
+ assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ associationElementType.getId() +")", associationElementType instanceof ISpecializationType);
+ ISpecializationType associationSpecializationType = (ISpecializationType) associationElementType;
+ assertTrue("Incorrect specialization type hierarchy for "+ associationElementType.getId(), associationSpecializationType.isSpecializationOf(associationBaseElementType));
+
+ }
+
+}

Back to the top