Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-06-04 13:33:56 +0000
committerCamille Letavernier2015-06-05 08:25:19 +0000
commitd2dc2fd8777bbd50aa0ac10845b156d64be5695d (patch)
tree7c39ae39f95ff2040c17b9225bee3e2201485fa8 /tests/junit/plugins/uml/decoratormodel
parentd5706b93beee4419dc3634b24b6e6300441c9659 (diff)
downloadorg.eclipse.papyrus-d2dc2fd8777bbd50aa0ac10845b156d64be5695d.tar.gz
org.eclipse.papyrus-d2dc2fd8777bbd50aa0ac10845b156d64be5695d.tar.xz
org.eclipse.papyrus-d2dc2fd8777bbd50aa0ac10845b156d64be5695d.zip
Bug 468030: [Papyrus Core] Papyrus DI Model should support the notion of Language
https://bugs.eclipse.org/bugs/show_bug.cgi?id=468030 Implement a Language Service for configuration of the Papyrus ModelSet to support custom implementations of UML and other modeling languages. Includes: * language service providing languages before the ModelSet loads any resources * hooks for languages to configure and unconfigure a ModelSet * implementation of a language provider that maps applied profiles to languages * addition of a profile index service that provides the URIs of profiles applied to model resources without having to load them in a resource set * a stub of a UML-RT language with placeholder for configuration of the ModelSet * a standard UML language * implementation of the profile index service using an enhanced DecoratorModelIndex that now also index the normal profile applications in user models Papyrus Service Registry changes: * fix the explicit starting of lazy services * new AbstractServiceUtils API for requesting optional or defaultable services Also includes the very barest of JUnit tests covering: * the new profile index service * using the language service to query content-type-based languages * UML languages: UML models have the UML language, itself, and proper matching and installation of profile languages Change-Id: I9d5175cfbefbe40864f04ea4215e18556e3739df Reviewed-on: https://git.eclipse.org/r/49152 Tested-by: Hudson CI Reviewed-by: Camille Letavernier <camille.letavernier@cea.fr>
Diffstat (limited to 'tests/junit/plugins/uml/decoratormodel')
-rw-r--r--tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/resources/profile/profile1.profile.uml6
-rw-r--r--tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/internal/resource/index/tests/ProfileIndexTest.java126
-rw-r--r--tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/AllTests.java7
3 files changed, 137 insertions, 2 deletions
diff --git a/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/resources/profile/profile1.profile.uml b/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/resources/profile/profile1.profile.uml
index d31a167e41f..109549216ed 100644
--- a/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/resources/profile/profile1.profile.uml
+++ b/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/resources/profile/profile1.profile.uml
@@ -97,4 +97,10 @@
<ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_HjbNQkihEeSRp-p9nf2EsA" name="extension_Import" type="_Eo_ccEihEeSRp-p9nf2EsA" aggregation="composite" association="_HjbNQUihEeSRp-p9nf2EsA"/>
</packagedElement>
</packagedElement>
+ <profileApplication xmi:id="_u86TkArJEeWL040BhEwTcg">
+ <eAnnotations xmi:id="_u8-lAArJEeWL040BhEwTcg" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="pathmap://UML_PROFILES/Ecore.profile.uml#_z1OFcHjqEdy8S4Cr8Rc_NA"/>
+ </eAnnotations>
+ <appliedProfile href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
+ </profileApplication>
</uml:Profile>
diff --git a/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/internal/resource/index/tests/ProfileIndexTest.java b/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/internal/resource/index/tests/ProfileIndexTest.java
new file mode 100644
index 00000000000..34a7a676372
--- /dev/null
+++ b/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/internal/resource/index/tests/ProfileIndexTest.java
@@ -0,0 +1,126 @@
+/*****************************************************************************
+ * Copyright (c) 2015 Christian W. Damus and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.decoratormodel.internal.resource.index.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.junit.utils.rules.ProjectFixture;
+import org.eclipse.papyrus.uml.tools.profile.index.IProfileIndex;
+import org.eclipse.uml2.uml.resource.UMLResource;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Tests the implementation of the Profile Index Service.
+ */
+public class ProfileIndexTest {
+ @ClassRule
+ public static final ProjectFixture project = new ProjectFixture();
+
+ static ServicesRegistry registry;
+
+ public ProfileIndexTest() {
+ super();
+ }
+
+ @Test
+ public void decoratorIndexing() throws ServiceException {
+ IProfileIndex index = registry.getService(IProfileIndex.class);
+
+ ListenableFuture<Set<URI>> futureProfileURIs = index.getAppliedProfiles(project.getURI("testmodel.uml"));
+ Set<URI> profileURIs = trimFragments(Futures.get(futureProfileURIs, 1L, TimeUnit.MINUTES, ServiceException.class));
+
+ Set<URI> expected = ImmutableSet.of(
+ project.getURI("profile/profile1.profile.uml"), // an externally applied profile
+ URI.createURI(UMLResource.ECORE_PROFILE_URI), // also externally applied
+ URI.createURI(UMLResource.STANDARD_PROFILE_URI)); // internally applied, actually
+ assertThat(profileURIs, is(expected));
+ }
+
+ @Test
+ public void userModelIndexing() throws ServiceException {
+ IProfileIndex index = registry.getService(IProfileIndex.class);
+
+ ListenableFuture<Set<URI>> futureProfileURIs = index.getAppliedProfiles(project.getURI("profile/profile1.profile.uml"));
+ Set<URI> profileURIs = trimFragments(Futures.get(futureProfileURIs, 1L, TimeUnit.MINUTES, ServiceException.class));
+
+ assertThat(profileURIs, is(Collections.singleton(URI.createURI(UMLResource.ECORE_PROFILE_URI))));
+ }
+
+ @Test
+ public void decoratorAsUserModelIndexing() throws ServiceException {
+ IProfileIndex index = registry.getService(IProfileIndex.class);
+
+ ListenableFuture<Set<URI>> futureProfileURIs = index.getAppliedProfiles(project.getURI("package2.decorator.uml"));
+ Set<URI> profileURIs = trimFragments(Futures.get(futureProfileURIs, 1L, TimeUnit.MINUTES, ServiceException.class));
+
+ Set<URI> expected = Collections.emptySet(); // We don't index these as user models, but as decorators only
+ assertThat(profileURIs, is(expected));
+ }
+
+ //
+ // Test framework
+ //
+
+ @BeforeClass
+ public static void createResources() throws IOException {
+ project.createFile(ProfileIndexTest.class, "resources/testmodel.uml");
+ project.createFile(ProfileIndexTest.class, "resources/package2.decorator.uml");
+ project.createFile(ProfileIndexTest.class, "resources/package2.ecore.uml");
+ project.createFile("profile/profile1.profile.uml", ProfileIndexTest.class, "resources/profile/profile1.profile.uml");
+ }
+
+ @SuppressWarnings("restriction")
+ @BeforeClass
+ public static void createRegistry() throws Exception {
+ registry = new ServicesRegistry();
+ registry.add(IProfileIndex.class, 1, new org.eclipse.papyrus.uml.decoratormodel.internal.resource.index.ProfileIndex());
+ registry.startRegistry();
+ }
+
+ @AfterClass
+ public static void destroyRegistry() throws Exception {
+ if (registry != null) {
+ registry.disposeRegistry();
+ }
+ registry = null;
+ }
+
+ static Set<URI> trimFragments(Set<URI> uris) {
+ return ImmutableSet.copyOf(Iterables.transform(uris,
+ new Function<URI, URI>() {
+ @Override
+ public URI apply(URI input) {
+ return input.trimFragment();
+ }
+ }));
+ }
+}
diff --git a/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/AllTests.java b/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/AllTests.java
index ef35f6847c9..2ad71f08213 100644
--- a/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/AllTests.java
+++ b/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/AllTests.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2014 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2013, 2015 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,7 @@
* Contributors:
* Remi Schnekenburger (CEA LIST) - Initial API and implementation
* Christian W. Damus - bug 399859
+ * Christian W. Damus - bug 468030
*
*****************************************************************************/
package org.eclipse.papyrus.uml.decoratormodel.tests;
@@ -16,6 +17,7 @@ package org.eclipse.papyrus.uml.decoratormodel.tests;
import org.eclipse.papyrus.uml.decoratormodel.helper.tests.DecoratorModelUtilsTest;
import org.eclipse.papyrus.uml.decoratormodel.helper.tests.PapyrusStereotypeApplicationHelperTest;
import org.eclipse.papyrus.uml.decoratormodel.internal.expressions.tests.FilePropertyTesterTest;
+import org.eclipse.papyrus.uml.decoratormodel.internal.resource.index.tests.ProfileIndexTest;
import org.eclipse.papyrus.uml.decoratormodel.internal.resource.tests.DecoratorModelCopierTest;
import org.eclipse.papyrus.uml.decoratormodel.internal.resource.tests.DecoratorModelIndexTest;
import org.junit.runner.RunWith;
@@ -32,7 +34,8 @@ import org.junit.runners.Suite.SuiteClasses;
ProfileMigrationTest.class, StereotypeApplicationRepairTest.class, //
DecoratorModelIndexTest.class, DecoratorModelCopierTest.class, //
DecoratorModelUtilsTest.class, PapyrusStereotypeApplicationHelperTest.class, //
- FilePropertyTesterTest.class
+ FilePropertyTesterTest.class,
+ ProfileIndexTest.class
})
public class AllTests {
// Test suite

Back to the top