[512520] Qualifying named element cache with resource context.
diff --git a/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug512520Test.java b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug512520Test.java
new file mode 100644
index 0000000..29405ed
--- /dev/null
+++ b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug512520Test.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2017 CEA 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:
+ * Kenn Hussey (CEA) - Initial API and implementation
+ *
+ */
+
+package org.eclipse.uml2.uml.bug.tests;
+
+import java.util.Collections;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.tests.util.StandaloneSupport;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class Bug512520Test
+ extends TestCase {
+
+ private ResourceSet rset;
+
+ public Bug512520Test() {
+ super();
+ }
+
+ @Override
+ protected void setUp()
+ throws Exception {
+
+ rset = new ResourceSetImpl();
+
+ if (StandaloneSupport.isStandalone()) {
+ StandaloneSupport.init(rset);
+ }
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception {
+
+ for (Resource next : rset.getResources()) {
+ next.unload();
+ next.eAdapters().clear();
+ }
+
+ rset.getResources().clear();
+ rset.eAdapters().clear();
+ }
+
+ public static Test suite() {
+ return new TestSuite(Bug512520Test.class, "Bug 512520 tests"); //$NON-NLS-1$
+ }
+
+ public void testGetAppliedStereotype() {
+ final URI modelURI = URI
+ .createURI("pathmap://UML_TEST_MODELS/Bug401804.uml", true);
+
+ URIConverter.URI_MAP.putAll(
+ EcorePlugin.computePlatformResourceToPlatformPluginMap(Collections
+ .singleton(URIConverter.INSTANCE.normalize(modelURI))));
+
+ Model model1 = UML2Util.load(rset, modelURI, UMLPackage.Literals.MODEL);
+
+ Type sessionManagerBean1 = model1.getOwnedType("SessionManager");
+
+ Stereotype bean1 = sessionManagerBean1
+ .getAppliedStereotype("bug401804::Bean");
+
+ Stereotype specification1 = sessionManagerBean1
+ .getAppliedStereotype("StandardProfile::Specification");
+
+ ResourceSet rset2 = new ResourceSetImpl();
+
+ if (StandaloneSupport.isStandalone()) {
+ StandaloneSupport.init(rset2);
+ }
+
+ Model model2 = UML2Util.load(rset2, modelURI,
+ UMLPackage.Literals.MODEL);
+
+ Type sessionManagerBean2 = model2.getOwnedType("SessionManager");
+
+ Stereotype bean2 = sessionManagerBean2
+ .getAppliedStereotype("bug401804::Bean");
+
+ Stereotype specification2 = sessionManagerBean2
+ .getAppliedStereotype("StandardProfile::Specification");
+
+ assertSame(bean1,
+ sessionManagerBean1.getAppliedStereotype("bug401804::Bean"));
+
+ assertNotSame(bean2,
+ sessionManagerBean1.getAppliedStereotype("bug401804::Bean"));
+
+ bean1 = sessionManagerBean1.getAppliedStereotype("bug401804::Bean");
+
+ assertSame(specification1, sessionManagerBean1
+ .getAppliedStereotype("StandardProfile::Specification"));
+
+ assertNotSame(specification2, sessionManagerBean1
+ .getAppliedStereotype("StandardProfile::Specification"));
+
+ specification1 = sessionManagerBean1
+ .getAppliedStereotype("StandardProfile::Specification");
+
+ bean2 = sessionManagerBean2.getAppliedStereotype("bug401804::Bean");
+
+ specification2 = sessionManagerBean2
+ .getAppliedStereotype("StandardProfile::Specification");
+
+ for (Resource next : rset2.getResources()) {
+ next.unload();
+ next.eAdapters().clear();
+ }
+
+ rset2.getResources().clear();
+ rset2.eAdapters().clear();
+
+ assertSame(bean1,
+ sessionManagerBean1.getAppliedStereotype("bug401804::Bean"));
+
+ assertNotSame(bean2,
+ sessionManagerBean1.getAppliedStereotype("bug401804::Bean"));
+
+ assertSame(specification1, sessionManagerBean1
+ .getAppliedStereotype("StandardProfile::Specification"));
+
+ assertNotSame(specification2, sessionManagerBean1
+ .getAppliedStereotype("StandardProfile::Specification"));
+
+ }
+
+}
diff --git a/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java
index d9865e3..a3fab39 100644
--- a/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java
+++ b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java
@@ -9,7 +9,7 @@
* Christian W. Damus (CEA) - initial API and implementation
* Christian W. Damus (CEA) - 409396, 403365, 300957, 405061, 401682, 176998, 180744, 403374, 420338, 405065, 332057, 431342, 433149, 437977
* Manuel Bork <bork@yatta.de> (Yatta Solutions GmbH) - 421756, 422000
- * Kenn Hussey (CEA) - 424895, 511674
+ * Kenn Hussey (CEA) - 424895, 511674, 512520
* Christian W. Damus - 444588, 497359, 501740
*
*/
@@ -65,6 +65,7 @@
result.addTest(Bug497359Test.suite());
result.addTest(Bug501740Test.suite());
result.addTest(Bug511674Test.suite());
+ result.addTest(Bug512520Test.suite());
// keep this one at the end because it runs long
result.addTest(Bug332057Test.suite());