diff options
| author | Pierre-Charles David | 2017-12-26 10:13:34 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2017-12-26 10:13:34 +0000 |
| commit | 2da114f896d8ad761c9653d5e909109878529ab9 (patch) | |
| tree | 9bd18a91bd197ea188acae58fa1d1971e38500d4 | |
| parent | 73eef225134c9ece0a18d71eb2c0095f9b47f057 (diff) | |
| download | org.eclipse.sirius-2da114f896d8ad761c9653d5e909109878529ab9.tar.gz org.eclipse.sirius-2da114f896d8ad761c9653d5e909109878529ab9.tar.xz org.eclipse.sirius-2da114f896d8ad761c9653d5e909109878529ab9.zip | |
[526258] Add test for modeling project structure detection
Bug: 526258
Change-Id: I27c6cc628545a4d2ca0e0bcef45a20ff4ef28a7a
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
7 files changed, 115 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/.project b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/.project new file mode 100644 index 0000000000..c1b2d68445 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/.project @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>MultiAirdNoViewpoints</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + </buildSpec> + <natures> + <nature>org.eclipse.sirius.nature.modelingproject</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My.ecore new file mode 100644 index 0000000000..a02535c9e8 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My.ecore @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + name=""> + <eSubpackages href="My_.ecore#/"/> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My_.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My_.aird new file mode 100644 index 0000000000..6a710cca63 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My_.aird @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description"> + <viewpoint:DAnalysis xmi:id="_eVpXUOYtEeea2e6qd-mYiQ" selectedViews="_eVsaoOYtEeea2e6qd-mYiQ" version="12.1.0.201708031200"> + <semanticResources>My_.ecore</semanticResources> + </viewpoint:DAnalysis> +</xmi:XMI> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My_.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My_.ecore new file mode 100644 index 0000000000..31aefc15b8 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/My_.ecore @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"/> diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/representations.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/representations.aird new file mode 100644 index 0000000000..239d4bdea8 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/project/MultiAirdNoViewpoints/representations.aird @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description"> + <viewpoint:DAnalysis xmi:id="_QL0V4OYtEeea2e6qd-mYiQ" version="12.1.0.201708031200"> + <referencedAnalysis xmi:type="viewpoint:DAnalysis" href="My_.aird#_eVpXUOYtEeea2e6qd-mYiQ"/> + <semanticResources>My.ecore</semanticResources> + </viewpoint:DAnalysis> +</xmi:XMI> diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java index baafedc0e5..a2383eff38 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java @@ -32,6 +32,7 @@ import org.eclipse.sirius.tests.unit.api.initialization.InitializationTest; import org.eclipse.sirius.tests.unit.api.interpreter.CompletionTests; import org.eclipse.sirius.tests.unit.api.interpreter.crossReferencer.AcceleoCrossReferencerTest; import org.eclipse.sirius.tests.unit.api.mm.DAnnotationTest; +import org.eclipse.sirius.tests.unit.api.modelingproject.ModelingProjectDetectionTest; import org.eclipse.sirius.tests.unit.api.modelingproject.SaveWhenNoEditorsTests; import org.eclipse.sirius.tests.unit.api.modelingproject.SemanticResourcesManagementTests; import org.eclipse.sirius.tests.unit.api.navigator.GroupingContentProviderByContainingTest; @@ -337,6 +338,7 @@ public class AllCommonPluginTests extends TestCase { suite.addTestSuite(DAnnotationTest.class); suite.addTestSuite(PageOrdererTest.class); + suite.addTestSuite(ModelingProjectDetectionTest.class); } /** diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/modelingproject/ModelingProjectDetectionTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/modelingproject/ModelingProjectDetectionTest.java new file mode 100644 index 0000000000..a8cf0c310c --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/modelingproject/ModelingProjectDetectionTest.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.tests.unit.api.modelingproject; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.sirius.business.api.session.SessionManager; +import org.eclipse.sirius.tests.SiriusTestsPlugin; +import org.eclipse.sirius.tests.support.api.EclipseTestsSupportHelper; +import org.eclipse.sirius.tests.support.api.SiriusTestCase; +import org.eclipse.sirius.tools.api.command.ICommandFactory; +import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager; +import org.eclipse.ui.actions.WorkspaceModifyOperation; + +/** + * Tests that Modeling Projects are properly detected and opened even if they + * have non-standard structure (i.e. structure that can be difficult or + * impossible to obtain manually but that can occur programmatically). + * + * @author pcdavid + */ +public class ModelingProjectDetectionTest extends SiriusTestCase { + + private static final String FIXTURE_ROOT = "data/unit/project/MultiAirdNoViewpoints"; + + private static final String[] FIXTURE_FILES = { "My_.aird", "My_.ecore", "My.ecore", "representations.aird" }; + + /** + * Tests that a modeling project which contains multiple (fragmented) aird + * files but no ownedViews is still properly analyzed and opened. + * <p> + * This used to cause a misdetection of the project structure in the SAX + * parser, causing this error: "Found 2 main representations files (that + * means not referenced by another) in "DesignerTestProject": + * representations.airdand My_.aird. A modeling project must contain only + * one." + * + * @throws Exception + * if an unexpected error occurs during the test. + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=526258" + */ + public void test_modeling_project_with_multiple_aird_and_no_viewpoints() throws Exception { + // Create a Modeling project from the fixture files. + WorkspaceModifyOperation op = new WorkspaceModifyOperation() { + @Override + protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { + for (String file : FIXTURE_FILES) { + EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, FIXTURE_ROOT + "/" + file, TEMPORARY_PROJECT_NAME + "/" + file); + } + ModelingProjectManager.INSTANCE.convertToModelingProject(ResourcesPlugin.getWorkspace().getRoot().getProject(TEMPORARY_PROJECT_NAME), new NullProgressMonitor()); + } + }; + op.run(new NullProgressMonitor()); + // Check the session was correctly opened, including the referenced + // analysis + session = SessionManager.INSTANCE.getSession(URI.createPlatformResourceURI(TEMPORARY_PROJECT_NAME + "/representations.aird", true), new NullProgressMonitor()); + assertNotNull(session); + assertTrue("The session was not automatically opened", session.isOpen()); + assertEquals("The aird fragment was not correctly detected", 2, session.getAllSessionResources().size()); + assertEquals("The sample data project should not have any ownedView (see #526258)", 0, session.getOwnedViews().size()); + } + + @Override + protected ICommandFactory getCommandFactory() { + return null; + } +} |
