[500551] Test UML.ocl for validation errors
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/LoadTests.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/LoadTests.java
index 774b0cf..2e7f9fb 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/LoadTests.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/LoadTests.java
@@ -88,6 +88,8 @@
@SuppressWarnings("null")
public class LoadTests extends XtextTestCase
{
+ protected static final @NonNull String @NonNull [] NO_MESSAGES = new @NonNull String[] {};
+
/* public void checkMonikers(Resource resource) {
Map<String, NamedElementCS> sigMap = new HashMap<String, NamedElementCS>();
for (Iterator<EObject> it = resource.getAllContents(); it.hasNext(); ) {
@@ -266,19 +268,19 @@
// return xmiResource;
}
- public Model doLoadUML(@NonNull OCL ocl, @NonNull URI inputURI, boolean ignoreNonExistence, boolean validateEmbeddedOCL, boolean validateCompleteOCL, @NonNull String @Nullable [] messages) throws IOException, ParserException {
- return doLoadUML(ocl, inputURI, new AbstractLoadCallBack(ignoreNonExistence, validateCompleteOCL, validateEmbeddedOCL), messages);
+ public Model doLoadUML(@NonNull OCL ocl, @NonNull URI inputURI, boolean ignoreNonExistence, boolean validateEmbeddedOCL, @NonNull String @Nullable [] validateCompleteOCLMessages, @NonNull String @Nullable [] messages) throws IOException, ParserException {
+ return doLoadUML(ocl, inputURI, new AbstractLoadCallBack(ignoreNonExistence, validateCompleteOCLMessages, validateEmbeddedOCL), messages);
}
private static class AbstractLoadCallBack implements ILoadCallBack
{
private final boolean ignoreNonExistence;
- private final boolean validateCompleteOCL;
+ private final @NonNull String @Nullable [] validateCompleteOCLMessages;
private final boolean validateEmbeddedOCL;
- private AbstractLoadCallBack(boolean ignoreNonExistence, boolean validateCompleteOCL, boolean validateEmbeddedOCL) {
+ private AbstractLoadCallBack(boolean ignoreNonExistence, @NonNull String @Nullable [] validateCompleteOCLMessages, boolean validateEmbeddedOCL) {
this.ignoreNonExistence = ignoreNonExistence;
- this.validateCompleteOCL = validateCompleteOCL;
+ this.validateCompleteOCLMessages = validateCompleteOCLMessages;
this.validateEmbeddedOCL = validateEmbeddedOCL;
}
@@ -292,12 +294,12 @@
@Override
public void validateCompleteOCL(@NonNull OCL ocl, @NonNull BaseCSResource reloadCS) throws IOException {
- if (validateCompleteOCL) {
+ if (validateCompleteOCLMessages != null) {
reloadCS.load(null);
assertNoResourceErrors("Load failed", reloadCS);
Resource reloadAS = reloadCS.getASResource();
assertNoUnresolvedProxies("Unresolved proxies", reloadAS);
- assertNoValidationErrors("Reloading", reloadAS);
+ assertValidationDiagnostics("Reloading", reloadAS, validateCompleteOCLMessages);
}
}
@@ -1189,14 +1191,14 @@
// EPackage.Registry.INSTANCE.put("http://www.omg.org/spec/UML/20120801", UMLPackage.eINSTANCE);
// resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", XMI2UMLResource.Factory.INSTANCE);
URI uri = URI.createPlatformResourceURI("/org.eclipse.ocl.examples.xtext.tests/model/Internationalized.profile.uml", true);
- doLoadUML(ocl, uri, false, false, false, null);
+ doLoadUML(ocl, uri, false, false, null, null);
ocl.dispose();
}
public void testLoad_NullFree_uml() throws IOException, InterruptedException, ParserException {
OCLInternal ocl = createOCL();
URI uri = getProjectFileURI("NullFree.uml");
- Model model = doLoadUML(ocl, uri, false, true, true, null);
+ Model model = doLoadUML(ocl, uri, false, true, NO_MESSAGES, null);
org.eclipse.ocl.pivot.Package asPackage = model.getOwnedPackages().get(0);
org.eclipse.ocl.pivot.Class asInheritedNullFree = NameUtil.getNameable(asPackage.getOwnedClasses(), "InheritedNullFree");
org.eclipse.ocl.pivot.Class asNonNullFree = NameUtil.getNameable(asPackage.getOwnedClasses(), "NonNullFree");
@@ -1221,7 +1223,7 @@
// EPackage.Registry.INSTANCE.put("http://www.omg.org/spec/UML/20120801", UMLPackage.eINSTANCE);
// resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", XMI2UMLResource.Factory.INSTANCE);
URI uri = getProjectFileURI("StereotypeApplications.uml");
- doLoadUML(ocl, uri, new AbstractLoadCallBack(false, false, false) {
+ doLoadUML(ocl, uri, new AbstractLoadCallBack(false, NO_MESSAGES, false) {
@Override
public void postLoad(@NonNull OCL ocl, @NonNull ASResource asResource) {
for (TreeIterator<EObject> tit = asResource.getAllContents(); tit.hasNext(); ) {
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/UML25LoadTests.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/UML25LoadTests.java
index dab5564..f2d4d42 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/UML25LoadTests.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/UML25LoadTests.java
@@ -65,7 +65,7 @@
// Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMLResourceFactoryImpl());
ocl.getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", XMI2UMLResource.Factory.INSTANCE);
URI uml_2_5 = URI.createPlatformResourceURI("/UML-2.5/XMI-2.5-Beta/PrimitiveTypes.xmi", true);
- doLoadUML(ocl, uml_2_5, true, true, true, null);
+ doLoadUML(ocl, uml_2_5, true, true, NO_MESSAGES, null);
ocl.dispose();
}
@@ -145,7 +145,7 @@
public void testLoad_UML_2_5_Final_PrimitiveTypes() throws IOException, InterruptedException, ParserException {
OCL ocl = createOCL();
URI uml_2_5 = URI.createPlatformResourceURI("/org.eclipse.ocl.examples.uml25/model/PrimitiveTypes.xmi", true);
- doLoadUML(ocl, uml_2_5, true, true, true, null);
+ doLoadUML(ocl, uml_2_5, true, true, NO_MESSAGES, null);
ocl.dispose();
}
@@ -167,21 +167,21 @@
public void testLoad_UML_2_5_Final_DC() throws IOException, InterruptedException, ParserException {
OCL ocl = createOCL();
URI uml_2_5 = URI.createPlatformResourceURI("/org.eclipse.ocl.examples.uml25/model/DC.xmi", true);
- doLoadUML(ocl, uml_2_5, true, true, true, null);
+ doLoadUML(ocl, uml_2_5, true, true, NO_MESSAGES, null);
ocl.dispose();
}
public void testLoad_UML_2_5_Final_DI() throws IOException, InterruptedException, ParserException {
OCL ocl = createOCL();
URI uml_2_5 = URI.createPlatformResourceURI("/org.eclipse.ocl.examples.uml25/model/DI.xmi", true);
- doLoadUML(ocl, uml_2_5, true, true, true, null);
+ doLoadUML(ocl, uml_2_5, true, true, NO_MESSAGES, null);
ocl.dispose();
}
public void testLoad_UML_2_5_Final_DG() throws IOException, InterruptedException, ParserException {
OCL ocl = createOCL();
URI uml_2_5 = URI.createPlatformResourceURI("/org.eclipse.ocl.examples.uml25/model/DG.xmi", true);
- doLoadUML(ocl, uml_2_5, true, true, true, new @NonNull String[] {
+ doLoadUML(ocl, uml_2_5, true, true, NO_MESSAGES, new @NonNull String[] {
"The 'Class::NameIsNotNull' constraint is violated for 'DG::null'"
});
ocl.dispose();
@@ -191,22 +191,29 @@
OCLInternal ocl = createOCL();
GlobalEnvironmentFactory.getInstance().setSafeNavigationValidationSeverity(StatusCodes.Severity.IGNORE);
URI uml_2_5 = URI.createPlatformResourceURI("/org.eclipse.ocl.examples.uml25/model/UML.xmi", true);
- doLoadUML(ocl, uml_2_5, true, true, false, null); // FIXME BUG 419132 eliminate last argument; always true
+ doLoadUML(ocl, uml_2_5, true, true, new @NonNull String[] {
+ "The 'Operation::CompatibleReturn' constraint is violated for 'UML::Classification::Operation::returnResult() : Set(UML::Classification::Parameter)'", // needs ->asSet()
+ "The 'Operation::CompatibleReturn' constraint is violated for 'UML::CommonStructure::MultiplicityElement::upperBound() : UnlimitedNatural[1]'", // FIXME Bug 522087 - needs oclAsType(UnlimitedNatural)
+ "The 'Operation::CompatibleReturn' constraint is violated for 'UML::StructuredClassifiers::Association::endType() : Set(UML::CommonStructure::Type[+|1])'", // needs ->oclAsType(Set(uml::CommonStructure::Type[+|1]))
+ "The 'Operation::CompatibleReturn' constraint is violated for 'UML::StructuredClassifiers::StructuredClassifier::part() : Set(UML::Classification::Property)'", // needs ->asSet()
+ "The 'Property::CompatibleDefaultExpression' constraint is violated for 'UML::Values::LiteralUnlimitedNatural::value'" // FIXME Bug 522087 - needs oclAsType(UnlimitedNatural)
+ }, null); // FIXME BUG 419132 eliminate last argument; always true
ocl.dispose();
}
-
+ /* junit.framework.AssertionFailedError: 5 validation errors
+ */
public void testLoad_UML_2_5_Final_UMLDI() throws IOException, InterruptedException, ParserException {
OCLInternal ocl = createOCL();
GlobalEnvironmentFactory.getInstance().setSafeNavigationValidationSeverity(StatusCodes.Severity.IGNORE);
URI uml_2_5 = URI.createPlatformResourceURI("/org.eclipse.ocl.examples.uml25/model/UMLDI.xmi", true);
- doLoadUML(ocl, uml_2_5, true, true, false, null); // FIXME BUG 419132 eliminate last argument; always true
+ doLoadUML(ocl, uml_2_5, true, true, NO_MESSAGES, null); // FIXME BUG 419132 eliminate last argument; always true
ocl.dispose();
}
public void testLoad_UML_2_5_Final_StandardProfile() throws IOException, InterruptedException, ParserException {
OCL ocl = createOCL();
URI uml_2_5 = URI.createPlatformResourceURI("/org.eclipse.ocl.examples.uml25/model/StandardProfile.xmi", true);
- doLoadUML(ocl, uml_2_5, true, true, true, null);
+ doLoadUML(ocl, uml_2_5, true, true, NO_MESSAGES, null);
ocl.dispose();
}
}