Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2021-01-14 19:05:37 +0000
committerPatrick Tessier2021-03-29 19:15:05 +0000
commitf4cc368beb7e01d2e3993f0f01cf4e3d93225d27 (patch)
tree0c602dd5e9a3e219f99844b29c2d21f8bf90a7c0
parent0ef1840a153574d221726c3d7fe4d0197fdf3971 (diff)
downloadorg.eclipse.papyrus-f4cc368beb7e01d2e3993f0f01cf4e3d93225d27.tar.gz
org.eclipse.papyrus-f4cc368beb7e01d2e3993f0f01cf4e3d93225d27.tar.xz
org.eclipse.papyrus-f4cc368beb7e01d2e3993f0f01cf4e3d93225d27.zip
Bug 542945: [Architecture Framework] wrong context id in element type registration breaks AF
Implement plug-in validation builder checks for: - element type set registration uses a client context that exists - architecture context referenced element type sets are registered with its ID if they are registered on the extension point at all Change-Id: Ibaef4d792d2846f49719480cc46beeff3a09918c Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/META-INF/MANIFEST.MF4
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java28
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/Messages.java5
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/messages.properties3
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/ProjectManagementUtils.java137
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/META-INF/MANIFEST.MF3
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginXMLValidator.java31
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/Messages.java1
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/messages.properties3
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/resources/bug542945/plugin-typesMultiContextIDs.xml51
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/resources/bug542945/plugin-typesWrongContextID.xml48
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java24
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/BookStore.architecture9
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/plugin-customClientContext.xml47
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/plugin-customClientContextGMF.xml55
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-extensions/plugin-wrongPath.xml4
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-ok/plugin.xml2
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/tests/ElementTypesPluginXMLBuilderTest.java43
18 files changed, 487 insertions, 11 deletions
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/META-INF/MANIFEST.MF b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/META-INF/MANIFEST.MF
index 35a83266059..b60942bf8dc 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/META-INF/MANIFEST.MF
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/META-INF/MANIFEST.MF
@@ -14,7 +14,9 @@ Require-Bundle:
org.eclipse.uml2.uml;bundle-version="[5.5.0,6.0.0)",
org.eclipse.papyrus.infra.core.architecture;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.architecture.representation;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.representation;bundle-version="[3.0.0,4.0.0)"
+ org.eclipse.papyrus.infra.gmfdiag.representation;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.types;bundle-version="[5.0.0,6.0.0)",
+ org.eclipse.papyrus.infra.types.core;bundle-version="[5.0.0,6.0.0)"
Export-Package:
org.eclipse.papyrus.toolsmiths.validation.architecture,
org.eclipse.papyrus.toolsmiths.validation.architecture.checkers,
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java
index 0babc0e069e..70ef53f239c 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java
@@ -15,7 +15,13 @@
package org.eclipse.papyrus.toolsmiths.validation.architecture.internal.checkers;
+import static org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.ProjectManagementUtils.getExtensionElements;
+import static org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.ProjectManagementUtils.hasAttribute;
+import static org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.ProjectManagementUtils.resourcePathIs;
+
+import java.util.Collection;
import java.util.Map;
+import java.util.stream.Collectors;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
@@ -23,15 +29,21 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.papyrus.infra.core.architecture.ADElement;
+import org.eclipse.papyrus.infra.core.architecture.ArchitectureContext;
import org.eclipse.papyrus.infra.core.architecture.RepresentationKind;
+import org.eclipse.papyrus.infra.types.ElementTypeSetConfiguration;
+import org.eclipse.papyrus.infra.types.core.extensionpoints.IElementTypeSetExtensionPoint;
import org.eclipse.papyrus.toolsmiths.validation.architecture.internal.messages.Messages;
import org.eclipse.papyrus.toolsmiths.validation.common.checkers.CustomModelChecker;
+import org.eclipse.pde.core.plugin.IPluginElement;
/**
* Custom validation rules for <em>Architecture Domain</em> models.
*/
public class ArchitectureCustomValidator extends CustomModelChecker.SwitchValidator {
+ private static final String ELEM_ELEMENT_TYPE_SET = "elementTypeSet"; //$NON-NLS-1$
+
public ArchitectureCustomValidator(String nsURI) {
super(nsURI);
}
@@ -66,4 +78,20 @@ public class ArchitectureCustomValidator extends CustomModelChecker.SwitchValida
}
}
+ public void validate(ArchitectureContext architecture, DiagnosticChain diagnostics, Map<Object, Object> context) {
+ if (architecture.getId() != null) { // Missing ID is reported separately
+ architecture.getElementTypes().forEach(typeSet -> validateElementTypesContextID(architecture, typeSet, diagnostics, context));
+ }
+ }
+
+ private void validateElementTypesContextID(ArchitectureContext architecture, ElementTypeSetConfiguration typeSet, DiagnosticChain diagnostics, Map<Object, Object> context) {
+ Collection<IPluginElement> registrations = getExtensionElements(IElementTypeSetExtensionPoint.EXTENSION_POINT_ID, ELEM_ELEMENT_TYPE_SET)
+ .filter(resourcePathIs(IElementTypeSetExtensionPoint.PATH, typeSet.eResource().getURI()))
+ .collect(Collectors.toList());
+
+ if (!registrations.isEmpty() && registrations.stream().noneMatch(hasAttribute(IElementTypeSetExtensionPoint.CLIENT_CONTEXT_ID, architecture.getId()::equals))) {
+ diagnostics.add(createDiagnostic(Diagnostic.WARNING, architecture, format(Messages.ArchitectureCustomValidator_2, context, typeSet)));
+ }
+ }
+
}
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/Messages.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/Messages.java
index 2aac2f7eca3..241b35143c9 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/Messages.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/Messages.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2021 Christian W. Damus, CEA LIST, and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*
* Contributors:
* Christian W. Damus - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.validation.architecture.internal.messages;
@@ -25,6 +25,7 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.toolsmiths.validation.architecture.internal.messages.messages"; //$NON-NLS-1$
public static String ArchitectureCustomValidator_0;
public static String ArchitectureCustomValidator_1;
+ public static String ArchitectureCustomValidator_2;
public static String ArchitecturePluginChecker_0;
public static String ArchitecturePluginChecker_1;
static {
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/messages.properties b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/messages.properties
index 2c035245f9c..423a3830098 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/messages.properties
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/messages/messages.properties
@@ -10,11 +10,12 @@
#
# Contributors:
# CEA LIST - Initial API and implementation
-# Christian W. Damus - bug 570097
+# Christian W. Damus - bugs 570097, 542945
#
##################################################################################
ArchitectureCustomValidator_0=Invalid icon URI ''{1}'' in {0}.
ArchitectureCustomValidator_1=No such icon resource ''{1}'' in {0}.
+ArchitectureCustomValidator_2=''{0}'' is registered to a different context.
ArchitecturePluginChecker_0=Validate Architecture plug-in
ArchitecturePluginChecker_1=Prepare plug-in validation
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/ProjectManagementUtils.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/ProjectManagementUtils.java
index 78bbef97469..c66b89dc52e 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/ProjectManagementUtils.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/ProjectManagementUtils.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2019 CEA LIST, and others.
+ * Copyright (c) 2019, 2021 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 542945
*
*****************************************************************************/
@@ -21,15 +22,22 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.papyrus.toolsmiths.validation.common.Activator;
import org.eclipse.pde.core.build.IBuildModel;
+import org.eclipse.pde.core.plugin.IExtensions;
+import org.eclipse.pde.core.plugin.IPluginAttribute;
+import org.eclipse.pde.core.plugin.IPluginElement;
import org.eclipse.pde.core.plugin.IPluginExtension;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.PluginRegistry;
@@ -206,4 +214,131 @@ public class ProjectManagementUtils {
private static boolean isCorrespondingFile(final IFile file, final String foundFile, final boolean isExtensionCheck) {
return isExtensionCheck ? file.getName().endsWith("." + foundFile) : file.getName().equals(foundFile); //$NON-NLS-1$
}
+
+ /**
+ * Find an extension element from the current PDE target overlaid with workspace plug-in models.
+ *
+ * @param extensionPoint
+ * the point on which to search extension elements
+ * @param elementName
+ * the extension element name to search
+ * @param attributes
+ * optional attributes by which to filter the search, as name/value pairs
+ *
+ * @return the found extension element
+ *
+ * @throws ArrayIndexOutOfBoundsException
+ * if the {@code attributes} array has a name without a following value
+ */
+ public static Optional<IPluginElement> findExtensionElement(String extensionPoint, String elementName, String... attributes) {
+ return getExtensionElements(extensionPoint, elementName, attributes).findAny();
+ }
+
+ /**
+ * Get extension elements from the current PDE target overlaid with workspace plug-in models.
+ *
+ * @param extensionPoint
+ * the point on which to search extension elements
+ * @param elementName
+ * the extension element name to search
+ * @param attributes
+ * optional attributes by which to filter the search, as name/value pairs
+ *
+ * @return the matching extension elements
+ *
+ * @throws ArrayIndexOutOfBoundsException
+ * if the {@code attributes} array has a name without a following value
+ */
+ public static Stream<IPluginElement> getExtensionElements(String extensionPoint, String elementName, String... attributes) {
+ Predicate<IPluginElement> elementFilter = element -> elementName.equals(element.getName());
+
+ if (attributes.length > 0) {
+ elementFilter = elementFilter.and(hasAttributes(attributes));
+ }
+
+ return Stream.of(PluginRegistry.getActiveModels())
+ .map(IPluginModelBase::getExtensions)
+ .map(IExtensions::getExtensions).flatMap(Stream::of)
+ .filter(ext -> extensionPoint.equals(ext.getPoint()))
+ .map(IPluginExtension::getChildren).flatMap(Stream::of)
+ .filter(IPluginElement.class::isInstance).map(IPluginElement.class::cast)
+ .filter(elementFilter);
+ }
+
+ /**
+ * Create a predicate that matches <tt>plugin.xml</tt> elements having the given {@code attributes}.
+ * In the unhelpful case of an empty array of {@code attributes}, the result is an always-{@code true}
+ * predicate.
+ *
+ * @param attributes
+ * attributes by which to filter the search, as name/value pairs
+ *
+ * @return a filter matching extension elements that have these {@code attributes}
+ *
+ * @throws ArrayIndexOutOfBoundsException
+ * if the {@code attributes} array has a name without a following value
+ */
+ public static Predicate<IPluginElement> hasAttributes(String... attributes) {
+ Predicate<IPluginElement> result = __ -> true;
+
+ for (int i = 0; i < attributes.length; i = i + 2) {
+ String name = attributes[i];
+ String value = attributes[i + 1];
+
+ Predicate<IPluginElement> next = element -> value.equals(element.getAttribute(name).getValue());
+ result = i > 0 ? result.and(next) : next;
+ }
+
+ return result;
+ }
+
+ /**
+ * Create a predicate that matches <tt>plugin.xml</tt> elements having an {@code attribute} matching the given {@code predicate}.
+ *
+ * @param attribute
+ * the attribute name to test
+ * @param predicate
+ * a predicate to match the {@code attribute} value
+ *
+ * @return a filter matching extension elements that have an {@code attribute} matching the given {@code predicate}
+ */
+ public static Predicate<IPluginElement> hasAttribute(String attribute, Predicate<? super String> predicate) {
+ return element -> Optional.ofNullable(element.getAttribute(attribute)).map(IPluginAttribute::getValue).filter(predicate).isPresent();
+ }
+
+ /**
+ * Obtain a predicate matching a <tt>plugin.xml</tt> element whose resource path matches a given URI.
+ * The path attribute is assumed to be either a relative path within the bundle that defines the extension
+ * or else a <tt>platform:/plugin</tt> URI.
+ *
+ * @param pathAttribute
+ * the attribute name that indicates the resource path
+ * @param uri
+ * the resource location to match against the path specification
+ *
+ * @return the element predicate
+ */
+ public static Predicate<IPluginElement> resourcePathIs(String pathAttribute, URI uri) {
+ return element -> Optional.ofNullable(element.getAttribute(pathAttribute)).map(attr -> resourcePathMatches(attr, uri)).orElse(false);
+ }
+
+ private static boolean resourcePathMatches(IPluginAttribute attribute, URI uri) {
+ String path = attribute.getValue();
+ if (path == null || path.isBlank()) {
+ return false;
+ }
+
+ try {
+ URI pathURI = URI.createURI(path, true);
+ if (pathURI.isRelative()) {
+ pathURI = URI.createPlatformPluginURI(String.format("%s/%s", attribute.getPluginBase().getId(), pathURI), false); //$NON-NLS-1$
+ }
+
+ return pathURI.equals(uri) || (pathURI.isPlatform() && uri.isPlatform() && pathURI.toPlatformString(false).equals(uri.toPlatformString(false)));
+ } catch (Exception e) {
+ // Cannot parse it as an URI? Then it cannot be matched against a valid URI
+ return false;
+ }
+ }
+
}
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/META-INF/MANIFEST.MF b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/META-INF/MANIFEST.MF
index 5581288a719..0a1b95226fc 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/META-INF/MANIFEST.MF
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/META-INF/MANIFEST.MF
@@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.6.0,4.0.0)",
org.eclipse.papyrus.uml.types.core;bundle-version="[5.0.0,6.0.0)",
org.eclipse.papyrus.infra.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.papyrus.emf;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.emf;bundle-version="[4.0.0,5.0.0)"
+ org.eclipse.papyrus.infra.emf;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.papyrus.uml.architecture;bundle-version="[2.0.0,3.0.0)"
Export-Package: org.eclipse.papyrus.toolsmiths.validation.elementtypes,
org.eclipse.papyrus.toolsmiths.validation.elementtypes.checkers,
org.eclipse.papyrus.toolsmiths.validation.elementtypes.constants,
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginXMLValidator.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginXMLValidator.java
index aabe9b4e13e..12d88340962 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginXMLValidator.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginXMLValidator.java
@@ -22,9 +22,13 @@ import java.util.Optional;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
import org.eclipse.papyrus.infra.types.ElementTypeSetConfiguration;
import org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.PluginErrorReporter;
+import org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.ProjectManagementUtils;
import org.eclipse.papyrus.toolsmiths.validation.elementtypes.internal.messages.Messages;
+import org.eclipse.pde.core.plugin.IPluginElement;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -38,6 +42,10 @@ final class ElementTypesPluginXMLValidator {
static final String CLIENT_CONTEXT_ID = "clientContextID"; //$NON-NLS-1$
static final String PATH = "path"; //$NON-NLS-1$
+ private static final String EXTPT_ELEMENT_TYPE_BINDINGS = "org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings"; //$NON-NLS-1$
+ private static final String ELEM_CLIENT_CONTEXT = "clientContext"; //$NON-NLS-1$
+ private static final String ATT_ID = "id"; //$NON-NLS-1$
+
private final IFile modelFile;
/**
@@ -81,6 +89,8 @@ final class ElementTypesPluginXMLValidator {
String clientContextID = element.getAttribute(CLIENT_CONTEXT_ID);
if (clientContextID == null || clientContextID.isBlank()) {
problems.reportProblem(Diagnostic.ERROR, element, Messages.ElementTypesPluginXMLValidator_0, CATEGORY, null);
+ } else if (!findArchitectureContext(clientContextID) && !findGMFClientContext(clientContextID)) {
+ problems.reportProblem(Diagnostic.WARNING, element, NLS.bind(Messages.ElementTypesPluginXMLValidator_1, clientContextID), CATEGORY, null);
}
break;
default:
@@ -88,4 +98,25 @@ final class ElementTypesPluginXMLValidator {
}
}
+ private boolean findArchitectureContext(String id) {
+ return ArchitectureDomainManager.getInstance().getArchitectureContextById(id) != null;
+ }
+
+ private boolean findGMFClientContext(String id) {
+ return getClientContextRegistration(id).isPresent();
+ }
+
+ /**
+ * Find the registration of the given client context on the GMF extension point.
+ *
+ * @param clientContextID
+ * a client context ID
+ * @return the registration of it on the GMF extension point
+ */
+ public static Optional<IPluginElement> getClientContextRegistration(String clientContextID) {
+ return ProjectManagementUtils.findExtensionElement(EXTPT_ELEMENT_TYPE_BINDINGS,
+ ELEM_CLIENT_CONTEXT,
+ ATT_ID, clientContextID);
+ }
+
}
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/Messages.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/Messages.java
index 038cd21595e..f962d027766 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/Messages.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/Messages.java
@@ -33,6 +33,7 @@ public class Messages extends NLS {
public static String ElementTypesPluginChecker_0;
public static String ElementTypesPluginChecker_1;
public static String ElementTypesPluginXMLValidator_0;
+ public static String ElementTypesPluginXMLValidator_1;
public static String StereotypeApplicationMatcherCustomValidator_0;
public static String StereotypeApplicationMatcherCustomValidator_1;
public static String StereotypePropertyReferenceEdgeAdviceCustomValidator_0;
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/messages.properties b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/messages.properties
index e3922797b1d..181f7abbc75 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/messages.properties
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/messages/messages.properties
@@ -10,7 +10,7 @@
#
# Contributors:
# CEA LIST - Initial API and implementation
-# Christian W. Damus - bug 570097
+# Christian W. Damus - bugs 570097, 542945
#
##################################################################################
@@ -24,6 +24,7 @@ ElementTypesCustomValidator_2=No such icon resource ''{1}'' in {0}.
ElementTypesPluginChecker_0=Validate Element Types plug-in
ElementTypesPluginChecker_1=Prepare plug-in validation
ElementTypesPluginXMLValidator_0=Missing client context ID.
+ElementTypesPluginXMLValidator_1=Unknown architecture context or GMF client context ''{0}''.
StereotypeApplicationMatcherCustomValidator_0=Unresolved profile ''{1}'' in {0}.
StereotypeApplicationMatcherCustomValidator_1=Unresolved stereotype in {0}.
StereotypePropertyReferenceEdgeAdviceCustomValidator_0=Unresolved stereotype in {0}.
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/resources/bug542945/plugin-typesMultiContextIDs.xml b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/resources/bug542945/plugin-typesMultiContextIDs.xml
new file mode 100644
index 00000000000..9db9daba95e
--- /dev/null
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/resources/bug542945/plugin-typesMultiContextIDs.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2021 Christian W. Damus, CEA LIST, and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+
+ Contributors:
+ Christian W. Damus - Initial API and implementation
+-->
+
+<plugin>
+
+ <extension
+ point="org.eclipse.emf.ecore.dynamic_package">
+ <resource
+ uri="http://www.eclipse.org/Papyrus/test/toolsmiths/architecturebuilder/BookStore"
+ location="resources/BookStore.profile.uml#_e24cAVG7EeuXzM4mqVly4g">
+ </resource>
+ </extension>
+ <extension
+ point="org.eclipse.uml2.uml.dynamic_package">
+ <profile
+ uri="http://www.eclipse.org/Papyrus/test/toolsmiths/architecturebuilder/BookStore"
+ location="resources/BookStore.profile.uml#_gnO0wFG6EeuXzM4mqVly4g">
+ </profile>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.architecture.models">
+ <model
+ path="resources/BookStore.architecture">
+ </model>
+ </extension>
+
+ <extension
+ point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
+ <elementTypeSet
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
+ path="resources/BookStore.elementtypesconfigurations"/>
+ <elementTypeSet
+ clientContextID="org.eclipse.papyrus.toolsmiths.validation.architecture.example.bookstorelang"
+ path="resources/BookStore.elementtypesconfigurations"/>
+ </extension>
+
+</plugin>
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/resources/bug542945/plugin-typesWrongContextID.xml b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/resources/bug542945/plugin-typesWrongContextID.xml
new file mode 100644
index 00000000000..19e45105b33
--- /dev/null
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/resources/bug542945/plugin-typesWrongContextID.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2021 Christian W. Damus, CEA LIST, and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+
+ Contributors:
+ Christian W. Damus - Initial API and implementation
+-->
+
+<plugin>
+
+ <extension
+ point="org.eclipse.emf.ecore.dynamic_package">
+ <resource
+ uri="http://www.eclipse.org/Papyrus/test/toolsmiths/architecturebuilder/BookStore"
+ location="resources/BookStore.profile.uml#_e24cAVG7EeuXzM4mqVly4g">
+ </resource>
+ </extension>
+ <extension
+ point="org.eclipse.uml2.uml.dynamic_package">
+ <profile
+ uri="http://www.eclipse.org/Papyrus/test/toolsmiths/architecturebuilder/BookStore"
+ location="resources/BookStore.profile.uml#_gnO0wFG6EeuXzM4mqVly4g">
+ </profile>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.architecture.models">
+ <model
+ path="resources/BookStore.architecture">
+ </model>
+ </extension>
+
+ <extension
+ point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
+ <elementTypeSet
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
+ path="resources/BookStore.elementtypesconfigurations"/>
+ </extension>
+
+</plugin>
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java
index 9498a86e59a..9891ce616e0 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java
@@ -135,6 +135,30 @@ public class ArchitectureModelBuilderTest extends AbstractPapyrusTest {
assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_ERROR)).and(isMarkerMessage(containsString("Invalid icon URI"))))); //$NON-NLS-1$
}
+
+ /**
+ * Test the reporting of an Architecture Context ID that doesn't match the registration of one of its element type sets.
+ */
+ @Test
+ @OverlayFile(value = "bug542945/plugin-typesWrongContextID.xml", path = "plugin.xml")
+ public void clientContextIDMismatch() {
+ final List<IMarker> modelMarkers = fixture.getMarkers("resources/BookStore.architecture"); //$NON-NLS-1$
+
+ assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_WARNING)).and(
+ isMarkerMessage(containsString("is registered to a different context"))))); //$NON-NLS-1$
+ }
+
+ /**
+ * Test that no problem is reported for an element types configuration set that is registered to another
+ * client context ID but is also registered explicitly to our Architecture Context.
+ */
+ @Test
+ @OverlayFile(value = "bug542945/plugin-typesMultiContextIDs.xml", path = "plugin.xml")
+ public void multipleClientContexts() {
+ final List<IMarker> modelMarkers = fixture.getMarkers("resources/BookStore.architecture"); //$NON-NLS-1$
+
+ assertThat(modelMarkers, not(hasItem(isMarkerMessage(containsString("is registered to a different context"))))); //$NON-NLS-1$
+ }
}
}
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/BookStore.architecture b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/BookStore.architecture
new file mode 100644
index 00000000000..3c2d09ee314
--- /dev/null
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/BookStore.architecture
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<architecture:ArchitectureDomain xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:architecture="http://www.eclipse.org/papyrus/infra/core/architecture" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmi:id="_W0vj0FG2EeuXzM4mqVly4g" id="org.eclipse.papyrus.toolsmiths.validation.elementtypes.example.bookstore" name="BookStore" description="Example architecture domain for testing: a book store modeling language.">
+ <stakeholders xmi:type="architecture:Stakeholder" xmi:id="_zYz54FG5EeuXzM4mqVly4g" id="org.eclipse.papyrus.toolsmiths.validation.elementtypes.example.bookvendor" name="Book Vendor" description="A seller of books, in a bookstore." concerns="_95r3oFG5EeuXzM4mqVly4g"/>
+ <concerns xmi:type="architecture:Concern" xmi:id="_95r3oFG5EeuXzM4mqVly4g" id="org.eclipse.papyrus.toolsmiths.validation.elementtypes.example.bookselling" name="Book Selling" description="The concern of selling books, in a book store."/>
+ <contexts xmi:type="architecture:ArchitectureDescriptionLanguage" xmi:id="_Ty_tQFG6EeuXzM4mqVly4g" id="org.eclipse.papyrus.toolsmiths.validation.elementtypes.context" name="BookStore" extensionPrefix="bookstore">
+ <elementTypes xmi:type="elementtypesconfigurations:ElementTypeSetConfiguration" href="platform:/plugin/org.eclipse.papyrus.toolsmiths.validation.elementtypes.example/resources/BookStore.elementtypesconfigurations#_c0DGsGBhEemoFuWBTUmJOQ"/>
+ <metamodel xmi:type="ecore:EPackage" href="http://www.eclipse.org/uml2/5.0.0/UML#/"/>
+ </contexts>
+</architecture:ArchitectureDomain>
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/plugin-customClientContext.xml b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/plugin-customClientContext.xml
new file mode 100644
index 00000000000..66fdd696c37
--- /dev/null
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/plugin-customClientContext.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2019, 2021 CEA LIST, Christian W. Damus, and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+
+ Contributors:
+ Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ Christian W. Damus - bugs 569357, 542945
+-->
+
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
+ <elementTypeSet
+ clientContextID="org.eclipse.papyrus.toolsmiths.validation.elementtypes.context"
+ path="resources/BookStore.elementtypesconfigurations"/>
+ </extension>
+ <extension
+ point="org.eclipse.emf.ecore.uri_mapping">
+ <mapping
+ source="pathmap://TEST/BOOK_STORE/"
+ target="platform:/plugin/org.eclipse.papyrus.toolsmiths.validation.elementtypes.example/resources/">
+ </mapping>
+ </extension>
+ <extension
+ point="org.eclipse.emf.ecore.dynamic_package">
+ <resource
+ location="pathmap://TEST/BOOK_STORE/BookStore.profile.uml#_pafKgTpKEeubmtHuaj6Y7A"
+ uri="http://www.eclipse.org/Papyrus/2020/Toolsmiths/test/builder/elementtypes/BookStore">
+ </resource>
+ </extension>
+ <extension
+ point="org.eclipse.uml2.uml.dynamic_package">
+ <profile
+ location="pathmap://TEST/BOOK_STORE/BookStore.profile.uml#_3SkxIDpJEeubmtHuaj6Y7A"
+ uri="http://www.eclipse.org/Papyrus/2020/Toolsmiths/test/builder/elementtypes/BookStore">
+ </profile>
+ </extension>
+</plugin>
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/plugin-customClientContextGMF.xml b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/plugin-customClientContextGMF.xml
new file mode 100644
index 00000000000..9c20c7c45df
--- /dev/null
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug542945/plugin-customClientContextGMF.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2019, 2021 CEA LIST, Christian W. Damus, and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+
+ Contributors:
+ Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ Christian W. Damus - bugs 569357, 542945
+-->
+
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
+ <elementTypeSet
+ clientContextID="org.eclipse.papyrus.toolsmiths.validation.elementtypes.context"
+ path="resources/BookStore.elementtypesconfigurations"/>
+ </extension>
+ <extension
+ point="org.eclipse.emf.ecore.uri_mapping">
+ <mapping
+ source="pathmap://TEST/BOOK_STORE/"
+ target="platform:/plugin/org.eclipse.papyrus.toolsmiths.validation.elementtypes.example/resources/">
+ </mapping>
+ </extension>
+ <extension
+ point="org.eclipse.emf.ecore.dynamic_package">
+ <resource
+ location="pathmap://TEST/BOOK_STORE/BookStore.profile.uml#_pafKgTpKEeubmtHuaj6Y7A"
+ uri="http://www.eclipse.org/Papyrus/2020/Toolsmiths/test/builder/elementtypes/BookStore">
+ </resource>
+ </extension>
+ <extension
+ point="org.eclipse.uml2.uml.dynamic_package">
+ <profile
+ location="pathmap://TEST/BOOK_STORE/BookStore.profile.uml#_3SkxIDpJEeubmtHuaj6Y7A"
+ uri="http://www.eclipse.org/Papyrus/2020/Toolsmiths/test/builder/elementtypes/BookStore">
+ </profile>
+ </extension>
+
+ <!-- Explicit definition of the custom client context in the core (GMF) framework. -->
+ <extension
+ point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
+ <clientContext
+ id="org.eclipse.papyrus.toolsmiths.validation.elementtypes.context">
+ </clientContext>
+ </extension>
+</plugin>
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-extensions/plugin-wrongPath.xml b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-extensions/plugin-wrongPath.xml
index 46bf3319dc1..24e38ae04e7 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-extensions/plugin-wrongPath.xml
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-extensions/plugin-wrongPath.xml
@@ -19,13 +19,13 @@
<extension
point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
<elementTypeSet
- clientContextID="org.eclipse.papyrus.infra.types.context"
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
path="resources/BookStore.elementtypesconfigurations"/>
</extension>
<extension
point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
<elementTypeSet
- clientContextID="org.eclipse.papyrus.infra.types.context"
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
path="resources/NoSuchFile.elementtypesconfigurations"/>
</extension>
</plugin>
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-ok/plugin.xml b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-ok/plugin.xml
index 750ac3eace9..d9cbd0f03d3 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-ok/plugin.xml
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/resources/bug569357-ok/plugin.xml
@@ -20,7 +20,7 @@
<extension
point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
<elementTypeSet
- clientContextID="org.eclipse.papyrus.infra.types.context"
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
path="resources/BookStore.elementtypesconfigurations"/>
</extension>
<extension
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/tests/ElementTypesPluginXMLBuilderTest.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/tests/ElementTypesPluginXMLBuilderTest.java
index e50742e3e3c..63094fe87a4 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/tests/ElementTypesPluginXMLBuilderTest.java
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.elementtypes.tests/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/tests/ElementTypesPluginXMLBuilderTest.java
@@ -83,7 +83,7 @@ public class ElementTypesPluginXMLBuilderTest extends AbstractPapyrusTest {
public void noClientContext() {
final List<IMarker> modelMarkers = fixture.getMarkers("plugin.xml"); //$NON-NLS-1$
- assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_ERROR)).and(isMarkerMessage(containsString("client context ID"))))); //$NON-NLS-1$
+ assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_ERROR)).and(isMarkerMessage(containsString("Missing client context ID"))))); //$NON-NLS-1$
}
/**
@@ -98,4 +98,45 @@ public class ElementTypesPluginXMLBuilderTest extends AbstractPapyrusTest {
assertThat(modelMarkers, not(hasItem(anything())));
}
+ /**
+ * Test the reporting of a client-context ID that is not known either in GMF nor in any Architecture Context.
+ *
+ * @see <a href="http://eclip.se/542945">bug 542945</a>
+ */
+ @Test
+ @OverlayFile(value = "bug542945/plugin-customClientContext.xml", path = "plugin.xml")
+ public void unknownClientContextID() {
+ final List<IMarker> modelMarkers = fixture.getMarkers("plugin.xml"); //$NON-NLS-1$
+
+ assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_WARNING)).and(
+ isMarkerMessage(containsString("Unknown architecture context or GMF client context")))));
+ }
+
+ /**
+ * Test that a client context is matched against a registered Architecture Context.
+ *
+ * @see <a href="http://eclip.se/542945">bug 542945</a>
+ */
+ @Test
+ @OverlayFile(value = "bug542945/plugin-customClientContext.xml", path = "plugin.xml")
+ @OverlayFile(value = "bug542945/BookStore.architecture", path = "resources/BookStore.architecture")
+ public void clientContextIDViaArchitectureCongtext() {
+ final List<IMarker> modelMarkers = fixture.getMarkers("plugin.xml"); //$NON-NLS-1$
+
+ assertThat(modelMarkers, not(hasItem(anything())));
+ }
+
+ /**
+ * Test that a client context is matched against a registration of the ID in GMF.
+ *
+ * @see <a href="http://eclip.se/542945">bug 542945</a>
+ */
+ @Test
+ @OverlayFile(value = "bug542945/plugin-customClientContextGMF.xml", path = "plugin.xml")
+ public void clientContextIDViaGMF() {
+ final List<IMarker> modelMarkers = fixture.getMarkers("plugin.xml"); //$NON-NLS-1$
+
+ assertThat(modelMarkers, not(hasItem(anything())));
+ }
+
}

Back to the top