Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2012-01-30 15:01:16 +0000
committercdumoulin2012-01-30 15:01:16 +0000
commitf63af2d644915df932c6d8d179d54191e4f3722d (patch)
tree8ad1f80171457549d7223c91c0066e789fb34e1d
parent7a7b79e3ca007526180f7fded16327c578ff8ddf (diff)
downloadorg.eclipse.papyrus-f63af2d644915df932c6d8d179d54191e4f3722d.tar.gz
org.eclipse.papyrus-f63af2d644915df932c6d8d179d54191e4f3722d.tar.xz
org.eclipse.papyrus-f63af2d644915df932c6d8d179d54191e4f3722d.zip
ASSIGNED - bug 370129: [Core] ServicesRegistry should be accessible from any EObject attached to a Papyrus ResourceSet
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370129 Add associated tests
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/.classpath7
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/.project28
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF13
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/build.properties4
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/plugin.properties12
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java104
6 files changed, 168 insertions, 0 deletions
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/.classpath b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/.classpath
new file mode 100644
index 00000000000..14c329f3779
--- /dev/null
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.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="tests"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/.project b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/.project
new file mode 100644
index 00000000000..c45d0ac7154
--- /dev/null
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.emf.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/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..0fc1624eea2
--- /dev/null
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.infra.emf.tests
+Bundle-Version: 0.9.0.qualifier
+Fragment-Host: org.eclipse.papyrus.infra.emf;bundle-version="0.9.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.infra.emf.utils
+Require-Bundle: org.junit,
+ org.eclipse.emf.ecore.xmi;bundle-version="2.8.0"
+Bundle-Vendor: %providerName
+
+
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/build.properties b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/build.properties
new file mode 100644
index 00000000000..29ac9b90bf3
--- /dev/null
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = tests/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/plugin.properties b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/plugin.properties
new file mode 100644
index 00000000000..438acf1e574
--- /dev/null
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2012 Cedric Dumoulin.
+# 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:
+# Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+##################################################################################
+pluginName=Papyrus EMF Tests
+providerName=Eclipse Modeling Project
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java
new file mode 100644
index 00000000000..327bf460d33
--- /dev/null
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java
@@ -0,0 +1,104 @@
+/**
+ *
+ */
+package org.eclipse.papyrus.infra.emf.utils;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.emf.common.util.URI;
+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.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceMultiException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author dumoulin
+ *
+ */
+public class ServiceUtilsForResourceTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource#getInstance()}.
+ */
+ @Test
+ public void testGetInstance() {
+
+ assertNotNull("Instance ready", ServiceUtilsForResource.getInstance());
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource#getServiceRegistry(org.eclipse.emf.ecore.resource.Resource)}.
+ * @throws ServiceException
+ */
+ @Test
+ public void testGetServiceRegistryResource() throws ServiceException {
+
+
+ // Create services
+ ServicesRegistry servicesRegistry = new ServicesRegistry();
+
+ ModelSet modelSet = new ModelSet();
+ URI uri = URI.createURI("temp.ecore");
+
+ // Register the default resource factory -- only needed for stand-alone!
+ modelSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
+ Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
+
+ Resource resource = modelSet.createResource(uri);
+ assertNotNull("resource created", resource);
+
+ EClass obj1 = EcoreFactory.eINSTANCE.createEClass();
+ EPackage pack2 = EcoreFactory.eINSTANCE.createEPackage();
+ EClass obj2 = EcoreFactory.eINSTANCE.createEClass();
+ pack2.getEClassifiers().add(obj2);
+ resource.getContents().add(obj1);
+ resource.getContents().add(pack2);
+
+ servicesRegistry.add(ModelSet.class, 1, modelSet);
+
+ ServiceUtilsForResourceInitializerService initService = new ServiceUtilsForResourceInitializerService();
+ servicesRegistry.add(ServiceUtilsForResourceInitializerService.class, 1, initService);
+
+ servicesRegistry.startRegistry();
+
+ // Check registry
+ assertNotNull("service ModelSEt", servicesRegistry.getService(ModelSet.class) );
+ assertNotNull("service initializer", servicesRegistry.getService(ServiceUtilsForResourceInitializerService.class) );
+ assertNotNull("ModelSet service correctly initialized", ServiceUtils.getInstance().getModelSet(servicesRegistry) );
+
+ // Do tests
+ ServicesRegistry r2 = ServiceUtilsForResource.getInstance().getServiceRegistry(obj1.eResource());
+ assertNotNull("found from obj1", r2);
+
+ r2 = ServiceUtilsForResource.getInstance().getServiceRegistry(obj2.eResource());
+ assertNotNull("found from obj2", r2);
+
+ r2 = ServiceUtilsForResource.getInstance().getServiceRegistry(pack2.eResource());
+ assertNotNull("found from pack2", r2);
+ }
+
+}

Back to the top