diff options
author | Remi Schnekenburger | 2015-10-26 15:38:15 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-05-30 10:56:40 +0000 |
commit | 30de6ff4a0c63639177ac46873e0742e90595229 (patch) | |
tree | fc73eae30631d71e0ca92d03b0b3494a09530be1 /tests/junit/plugins/junit | |
parent | bdd19048b40d549cdf341116efd953c97fdd8a16 (diff) | |
download | org.eclipse.papyrus-30de6ff4a0c63639177ac46873e0742e90595229.tar.gz org.eclipse.papyrus-30de6ff4a0c63639177ac46873e0742e90595229.tar.xz org.eclipse.papyrus-30de6ff4a0c63639177ac46873e0742e90595229.zip |
480663: [Tests] Papyrus configuration resources shall be tested
https://bugs.eclipse.org/bugs/show_bug.cgi?id=480663
Change-Id: Ida388bd93f3a6d3e13e5642de7643f1db830e04f
Signed-off-by: Remi Schnekenburger <remi.schnekenburger@cea.fr>
Diffstat (limited to 'tests/junit/plugins/junit')
-rw-r--r-- | tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEMFResourceTest.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEMFResourceTest.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEMFResourceTest.java new file mode 100644 index 00000000000..69066e9706d --- /dev/null +++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEMFResourceTest.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.junit.utils.tests; + +import java.util.List; + +import org.eclipse.emf.common.util.Diagnostic; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.Diagnostician; +import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest; +import org.junit.Assert; + +/** + * Abstract test class for all EMF-based configuration models (property view, palettes, etc.) + */ +public abstract class AbstractEMFResourceTest extends AbstractPapyrusTest { + + /** + * URI of the EMF resource to test + * + * @return + */ + public abstract String getFileUri(); + + /** + * do the validation checks on the EMF resource + */ + protected void doValidateResource() { + URI createPlatformPluginURI = URI.createPlatformPluginURI(getFileUri(), true); + Resource resource = new ResourceSetImpl().getResource(createPlatformPluginURI, true); + Diagnostic diagnostic = Diagnostician.INSTANCE.validate(resource.getContents().get(0)); + Assert.assertEquals("The constraint model is not valid: " + printDiagnostic(diagnostic), Diagnostic.OK, diagnostic.getSeverity()); + } + + // FIXME : Something should exist in API to do that + protected String printDiagnostic(Diagnostic diagnostic) { + String message = diagnostic.getMessage(); + List<Diagnostic> children = diagnostic.getChildren(); + for (Diagnostic diagnostic2 : children) { + message += "\n" + diagnostic2.getMessage(); + } + return message; + } +} |