[571198]wip test case
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/models/uml/Bug571198.profile.uml b/tests/org.eclipse.ocl.examples.xtext.tests/models/uml/Bug571198.profile.uml
new file mode 100644
index 0000000..320e148
--- /dev/null
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/models/uml/Bug571198.profile.uml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/5" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/5 pathmap://UML_PROFILES/Ecore.profile.uml#_z1OFcHjqEdy8S4Cr8Rc_NA">
+  <uml:Profile xmi:id="_9qywsGEHEeu3-bh5n6XVFQ" name="ValidationProblem" metaclassReference="_CtE-0GEIEeu3-bh5n6XVFQ _oTto8GEIEeu3-bh5n6XVFQ">
+    <elementImport xmi:type="uml:ElementImport" xmi:id="_CtE-0GEIEeu3-bh5n6XVFQ" alias="Element">
+      <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Element"/>
+    </elementImport>
+    <elementImport xmi:type="uml:ElementImport" xmi:id="_oTto8GEIEeu3-bh5n6XVFQ" alias="Dependency">
+      <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Dependency"/>
+    </elementImport>
+    <packageImport xmi:type="uml:PackageImport" xmi:id="_9tQ14GEHEeu3-bh5n6XVFQ">
+      <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+    </packageImport>
+    <packageImport xmi:type="uml:PackageImport" xmi:id="_9tRc8GEHEeu3-bh5n6XVFQ">
+      <importedPackage xmi:type="uml:Model" href="pathmap://UML_METAMODELS/UML.metamodel.uml#_0"/>
+    </packageImport>
+    <packagedElement xmi:type="uml:Stereotype" xmi:id="_gH0SQG9xEeuH2ehzOaTC3Q" name="A">
+      <ownedAttribute xmi:type="uml:Property" xmi:id="_rBfxkm9xEeuH2ehzOaTC3Q" name="b" type="_lLdyUG9xEeuH2ehzOaTC3Q" association="_rBejcG9xEeuH2ehzOaTC3Q">
+        <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_Bj5LAG9zEeuH2ehzOaTC3Q"/>
+        <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_BkC8AG9zEeuH2ehzOaTC3Q" value="*"/>
+      </ownedAttribute>
+      <ownedAttribute xmi:type="uml:Property" xmi:id="_gB_hoG9yEeuH2ehzOaTC3Q" name="base_Element" association="_gB-TgG9yEeuH2ehzOaTC3Q">
+        <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Element"/>
+        <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_gB_hoW9yEeuH2ehzOaTC3Q"/>
+      </ownedAttribute>
+    </packagedElement>
+    <packagedElement xmi:type="uml:Stereotype" xmi:id="_lLdyUG9xEeuH2ehzOaTC3Q" name="B">
+      <ownedAttribute xmi:type="uml:Property" xmi:id="_xoMYwG9xEeuH2ehzOaTC3Q" name="derived_a" type="_gH0SQG9xEeuH2ehzOaTC3Q" isReadOnly="true" isDerived="true" isDerivedUnion="true">
+        <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_2HyJgG9xEeuH2ehzOaTC3Q"/>
+        <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_2H6FUG9xEeuH2ehzOaTC3Q" value="*"/>
+      </ownedAttribute>
+      <ownedAttribute xmi:type="uml:Property" xmi:id="_gj574W9yEeuH2ehzOaTC3Q" name="base_Element" association="_gj5U0G9yEeuH2ehzOaTC3Q">
+        <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Element"/>
+        <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_gj574m9yEeuH2ehzOaTC3Q"/>
+      </ownedAttribute>
+    </packagedElement>
+    <packagedElement xmi:type="uml:Association" xmi:id="_rBejcG9xEeuH2ehzOaTC3Q" memberEnd="_rBfxkm9xEeuH2ehzOaTC3Q _rBgYoG9xEeuH2ehzOaTC3Q" navigableOwnedEnd="_rBgYoG9xEeuH2ehzOaTC3Q">
+      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_rBfxkG9xEeuH2ehzOaTC3Q" source="org.eclipse.papyrus">
+        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_rBfxkW9xEeuH2ehzOaTC3Q" key="nature" value="UML_Nature"/>
+      </eAnnotations>
+      <ownedEnd xmi:type="uml:Property" xmi:id="_rBgYoG9xEeuH2ehzOaTC3Q" name="a" type="_gH0SQG9xEeuH2ehzOaTC3Q" subsettedProperty="_xoMYwG9xEeuH2ehzOaTC3Q" association="_rBejcG9xEeuH2ehzOaTC3Q">
+        <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_CJVaYG9zEeuH2ehzOaTC3Q"/>
+        <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_CJcvIG9zEeuH2ehzOaTC3Q" value="*"/>
+      </ownedEnd>
+    </packagedElement>
+    <packagedElement xmi:type="uml:Extension" xmi:id="_gB-TgG9yEeuH2ehzOaTC3Q" name="E_A_Element9" memberEnd="_gB-6kG9yEeuH2ehzOaTC3Q _gB_hoG9yEeuH2ehzOaTC3Q">
+      <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_gB-6kG9yEeuH2ehzOaTC3Q" name="extension_A" type="_gH0SQG9xEeuH2ehzOaTC3Q" aggregation="composite" association="_gB-TgG9yEeuH2ehzOaTC3Q"/>
+    </packagedElement>
+    <packagedElement xmi:type="uml:Extension" xmi:id="_gj5U0G9yEeuH2ehzOaTC3Q" name="E_B_Element10" memberEnd="_gj574G9yEeuH2ehzOaTC3Q _gj574W9yEeuH2ehzOaTC3Q">
+      <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_gj574G9yEeuH2ehzOaTC3Q" name="extension_B" type="_lLdyUG9xEeuH2ehzOaTC3Q" aggregation="composite" association="_gj5U0G9yEeuH2ehzOaTC3Q"/>
+    </packagedElement>
+    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_9rIH4GEHEeu3-bh5n6XVFQ">
+      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_9rIH4WEHEeu3-bh5n6XVFQ" 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 xmi:type="uml:Profile" href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
+    </profileApplication>
+  </uml:Profile>
+  <Ecore:EPackage xmi:id="_g7qLYGEKEeu3-bh5n6XVFQ" base_Package="_9qywsGEHEeu3-bh5n6XVFQ" packageName="bug571198" nsPrefix="ValidationProblem" nsURI="http://www.papyrus.com/ValidationProblem/1" basePackage="com.validationproblem.profile" prefix="ValidationProblem"/>
+</xmi:XMI>
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/models/uml/Bug571198.uml b/tests/org.eclipse.ocl.examples.xtext.tests/models/uml/Bug571198.uml
new file mode 100644
index 0000000..5b98b62
--- /dev/null
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/models/uml/Bug571198.uml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ValidationProblem="http://www.papyrus.com/ValidationProblem/1" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML">
+  <uml:Model xmi:id="_wWxjoGEMEeuARqXYJDgAdA" name="ValidationProblemApp">
+    <packageImport xmi:type="uml:PackageImport" xmi:id="_wYQKUGEMEeuARqXYJDgAdA">
+      <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+    </packageImport>
+    <packagedElement xmi:type="uml:Class" xmi:id="_NV518G9yEeuNJIzc4t-lCw" name="ClassA"/>
+    <packagedElement xmi:type="uml:Class" xmi:id="_OJcywG9yEeuNJIzc4t-lCw" name="ClassB"/>
+    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_YkQUMGENEeusZPn9AqGX4w">
+      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_YkVMsGENEeusZPn9AqGX4w" source="http://www.eclipse.org/uml2/2.0.0/UML">
+        <references xmi:type="ecore:EPackage" href="http://www.papyrus.com/ValidationProblem/1#/"/>
+      </eAnnotations>
+      <appliedProfile xmi:type="uml:Profile" href="pathmap://VALIDATIONPROBLEM_PROFILE/ValidationProblem.profile.uml#_9qywsGEHEeu3-bh5n6XVFQ"/>
+    </profileApplication>
+  </uml:Model>
+  <ValidationProblem:A xmi:id="_pBhocG9yEeubTJ2NkrcKxw" b="_pnkUwG9yEeubTJ2NkrcKxw" base_Element="_NV518G9yEeuNJIzc4t-lCw"/>
+  <ValidationProblem:B xmi:id="_pnkUwG9yEeubTJ2NkrcKxw" base_Element="_OJcywG9yEeuNJIzc4t-lCw"/>
+</xmi:XMI>
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/UsageTests.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/UsageTests.java
index 9062007..8595df8 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/UsageTests.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/UsageTests.java
@@ -640,6 +640,7 @@
 
 	protected void doUMLCompile(@NonNull TestOCL ocl, @NonNull String testProjectName) throws Exception {
 		JavaClasspath classpath = JavaFileUtil.createDefaultOCLClasspath();
+		classpath.addClass(org.eclipse.uml2.common.util.UML2Util.class);
 		classpath.addClass(org.eclipse.uml2.types.TypesPackage.class);
 		classpath.addClass(org.eclipse.uml2.uml.UMLPackage.class);
 		doCompile(ocl, classpath, testProjectName);
@@ -1334,6 +1335,72 @@
 		});
 	}
 
+	/*
+	 * Verify that the static profile in Bug571198.profile.uml model can be generated and compiled
+	 * and that the Bug571198.uml model can then validate.
+	 */
+	public void testBug571198_uml() throws Throwable {
+		doTestRunnable(new TestRunnable() {
+			@Override
+			public void runWithThrowable() throws Exception {
+				TestOCL ocl1 = createOCL();
+				String testFileStem = "Bug571198";
+				String testProjectName = testFileStem; //"bug570894";
+				TestFile umlModelFile = getTestFile(testFileStem + ".uml", ocl1, getTestModelURI("models/uml/" + testFileStem + ".uml"));
+			//	TestFile umlLibraryFile = getTestFile(testFileStem + ".library.uml", ocl1, getTestModelURI("models/uml/" + testFileStem + ".library.uml"));
+				TestFile umlProfileFile = getTestFile(testFileStem + ".profile.uml", ocl1, getTestModelURI("models/uml/" + testFileStem + ".profile.uml"));
+				Resource umlProfileResource = loadUmlProfile(ocl1.getResourceSet(), umlProfileFile.getURI());
+				String ecoreFileContent = createUMLEcoreModelContent(umlProfileResource);
+				String genmodelFileContent = createUMLGenModelContent(umlProfileResource, testFileStem, null);
+				createManifestFile();
+				createTestFileWithContent(getTestProject().getOutputFile(testFileStem + ".profile.ecore"), ecoreFileContent);
+				URI genModelURI = createTestFileWithContent(getTestProject().getOutputFile(testFileStem + ".profile.genmodel"), genmodelFileContent);
+				Path genModelPath = new Path("/" + getTestProject().getName() + "/" + testFileStem + ".profile.genmodel");
+				//
+				TestUMLImporter importer = new TestUMLImporter(ocl1.getResourceSet().getPackageRegistry());
+				importer.reloadGenModel(genModelPath);
+				ocl1.dispose();
+				//
+				doGenModel(genModelURI);
+				//
+				int oldAbstractEnvironmentFactory_CONSTRUCTION_COUNT = AbstractEnvironmentFactory.CONSTRUCTION_COUNT;
+				int oldAbstractModelManager_CONSTRUCTION_COUNT = AbstractModelManager.CONSTRUCTION_COUNT;
+				int oldExecutorManager_CONSTRUCTION_COUNT = ExecutorManager.CONSTRUCTION_COUNT;
+				int oldAbstractExecutor_CONSTRUCTION_COUNT = AbstractExecutor.CONSTRUCTION_COUNT;
+				TestOCL ocl2 = createOCL();
+				doUMLCompile(ocl2, testProjectName);
+
+				//
+				// Execute the profile
+				String qualifiedPackageClassName = "Bug571198.bug571198.ValidationProblemPackage";
+				String pathMapName = "pathmap://VALIDATIONPROBLEM_PROFILE/";
+				Map<URI, URI> extraUriMap = new HashMap<URI, URI>();
+			//	extraUriMap.put(URI.createURI("pathmap://VALIDATIONPROBLEM_LIBRARY/ValidationProblem-Library.uml"), umlLibraryFile.getURI());
+				extraUriMap.put(URI.createURI("pathmap://VALIDATIONPROBLEM_PROFILE/ValidationProblem.profile.uml"), umlProfileFile.getURI());
+				Resource umlModelResource = validateUmlModel(umlModelFile.getURI(), qualifiedPackageClassName, pathMapName, extraUriMap);
+				assertEquals("AbstractEnvironmentFactory.CONSTRUCTION_COUNT", 1, AbstractEnvironmentFactory.CONSTRUCTION_COUNT-oldAbstractEnvironmentFactory_CONSTRUCTION_COUNT);
+				assertEquals("AbstractModelManager.CONSTRUCTION_COUNT", 0, AbstractModelManager.CONSTRUCTION_COUNT-oldAbstractModelManager_CONSTRUCTION_COUNT);
+				assertEquals("ExecutorManager.CONSTRUCTION_COUNT", 0, ExecutorManager.CONSTRUCTION_COUNT-oldExecutorManager_CONSTRUCTION_COUNT);
+				assertEquals("AbstractExecutor.CONSTRUCTION_COUNT", 0, AbstractExecutor.CONSTRUCTION_COUNT-oldAbstractExecutor_CONSTRUCTION_COUNT);
+				for (@NonNull EObject eObject : umlModelResource.getContents()) {
+					EClass eClass = eObject.eClass();
+					if ("Farm".equals(eClass.getName())) {
+						EStructuralFeature animalFeature = eClass.getEStructuralFeature("animal");
+						EStructuralFeature chickenFeature = eClass.getEStructuralFeature("chicken");
+						EStructuralFeature duckFeature = eClass.getEStructuralFeature("duck");
+						Object animals = eObject.eGet(animalFeature);
+						assertEquals(4, ((Collection<?>)animals).size());
+						@SuppressWarnings("unused")
+						Object chicken = eObject.eGet(chickenFeature);
+						@SuppressWarnings("unused")
+						Object duck = eObject.eGet(duckFeature);
+					}
+				}
+				ocl2.dispose();
+			}
+		});
+	}
+
 	/**
 	 * Verify that the static profile in Bug571407.profile.uml model can be generated and compiled.
 	 */