diff options
author | Christian W. Damus | 2021-01-14 19:05:37 +0000 |
---|---|---|
committer | Patrick Tessier | 2021-03-29 19:15:05 +0000 |
commit | f4cc368beb7e01d2e3993f0f01cf4e3d93225d27 (patch) | |
tree | 0c602dd5e9a3e219f99844b29c2d21f8bf90a7c0 /tests/junit | |
parent | 0ef1840a153574d221726c3d7fe4d0197fdf3971 (diff) | |
download | org.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>
Diffstat (limited to 'tests/junit')
9 files changed, 279 insertions, 4 deletions
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()))); + } + } |