Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Dumoulin2014-01-27 07:43:59 -0500
committerCedric Dumoulin2014-01-27 08:57:45 -0500
commit3a883be079ef0db188b9718ec75dbfac9788f87c (patch)
tree487b231c0a9b45fa4cc194a10bc856ce8fae7c54 /tests/integration
parentefbaec61cbec28ce3344c136bebf63f98a799f64 (diff)
downloadorg.eclipse.papyrus-3a883be079ef0db188b9718ec75dbfac9788f87c.tar.gz
org.eclipse.papyrus-3a883be079ef0db188b9718ec75dbfac9788f87c.tar.xz
org.eclipse.papyrus-3a883be079ef0db188b9718ec75dbfac9788f87c.zip
330199 - Add tests on attached state for reloaded layers tree.
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/META-INF/MANIFEST.MF1
-rw-r--r--tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.di17
-rw-r--r--tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.notation37
-rw-r--r--tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.uml4
-rw-r--r--tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/EclipseProject.java216
-rw-r--r--tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditor.java134
-rw-r--r--tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/EclipseProjectTest.java109
-rw-r--r--tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditorTest.java62
8 files changed, 539 insertions, 41 deletions
diff --git a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/META-INF/MANIFEST.MF b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/META-INF/MANIFEST.MF
index f848ee13106..2fa9f53fae9 100644
--- a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/META-INF/MANIFEST.MF
+++ b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/META-INF/MANIFEST.MF
@@ -24,4 +24,5 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
+Export-Package: org.eclipse.papyrus.integrationtests.editor
diff --git a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.di b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.di
new file mode 100644
index 00000000000..3628d4d1db8
--- /dev/null
+++ b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.di
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
+ <pageList>
+ <availablePage>
+ <emfPageIdentifier href="modelTestLoadModel.notation#_cW2QoH71EeOkT5h268q24w"/>
+ </availablePage>
+ </pageList>
+ <sashModel currentSelection="//@sashModel/@windows.0/@children.0">
+ <windows>
+ <children xsi:type="di:TabFolder">
+ <children>
+ <emfPageIdentifier href="modelTestLoadModel.notation#_cW2QoH71EeOkT5h268q24w"/>
+ </children>
+ </children>
+ </windows>
+ </sashModel>
+</di:SashWindowsMngr>
diff --git a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.notation b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.notation
new file mode 100644
index 00000000000..856d89e4d76
--- /dev/null
+++ b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.notation
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_cW2QoH71EeOkT5h268q24w" type="PapyrusUMLClassDiagram" name="diagram1" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_c9YsMH71EeOkT5h268q24w" type="2008" fontName="Segoe UI" lineColor="0">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_c9YsMn71EeOkT5h268q24w" source="ShadowFigure">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_c9YsM371EeOkT5h268q24w" key="ShadowFigure_Value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_c9YsNH71EeOkT5h268q24w" source="displayNameLabelIcon">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_c9YsNX71EeOkT5h268q24w" key="displayNameLabelIcon_value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_c9YsNn71EeOkT5h268q24w" source="QualifiedName">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_c9YsN371EeOkT5h268q24w" key="QualifiedNameDepth" value="1000"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="_c9YsOH71EeOkT5h268q24w" type="5029"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_c9YsOX71EeOkT5h268q24w" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_c9YsOn71EeOkT5h268q24w"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_c9YsO371EeOkT5h268q24w"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_c9YsPH71EeOkT5h268q24w"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_c9YsPX71EeOkT5h268q24w"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_c9YsPn71EeOkT5h268q24w" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_c9YsP371EeOkT5h268q24w"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_c9YsQH71EeOkT5h268q24w"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_c9YsQX71EeOkT5h268q24w"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_c9YsQn71EeOkT5h268q24w"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_c9YsQ371EeOkT5h268q24w" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_c9YsRH71EeOkT5h268q24w"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_c9YsRX71EeOkT5h268q24w"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_c9YsRn71EeOkT5h268q24w"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_c9YsR371EeOkT5h268q24w"/>
+ </children>
+ <element xmi:type="uml:Class" href="modelTestLoadModel.uml#_c8pFUH71EeOkT5h268q24w"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_c9YsMX71EeOkT5h268q24w" x="156" y="167"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_cW2QoX71EeOkT5h268q24w"/>
+ <element xmi:type="uml:Model" href="modelTestLoadModel.uml#_cWjVsH71EeOkT5h268q24w"/>
+</notation:Diagram>
diff --git a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.uml b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.uml
new file mode 100644
index 00000000000..a0c1c0d789b
--- /dev/null
+++ b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/models/modelTestLoadModel.uml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_cWjVsH71EeOkT5h268q24w" name="model">
+ <packagedElement xmi:type="uml:Class" xmi:id="_c8pFUH71EeOkT5h268q24w" name="Class1"/>
+</uml:Model>
diff --git a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/EclipseProject.java b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/EclipseProject.java
new file mode 100644
index 00000000000..1dcf703c148
--- /dev/null
+++ b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/EclipseProject.java
@@ -0,0 +1,216 @@
+/*****************************************************************************
+ * Copyright (c) 2014 Cedric Dumoulin.
+ *
+ *
+ * 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.integrationtests.editor;
+
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+
+/**
+ * This class allows to create or load an Eclipse Project.
+ * This is the projects found in the project explorer.
+ * This class is mainly used in tests.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class EclipseProject {
+
+ /**
+ * The underlying Eclipse project.
+ *
+ */
+ protected IProject project;
+
+ protected IProgressMonitor monitor = new NullProgressMonitor();
+
+ /**
+ * Constructor.
+ * Create or load the specified project.
+ * @throws ExecutionException
+ */
+ public EclipseProject( String projectName ) throws ExecutionException {
+ // Create the project
+ initProject(projectName);
+ }
+
+ /**
+ * Create or load the project.
+ *
+ * @param projectName
+ * @throws ExecutionException
+ */
+ protected void initProject(String projectName ) throws ExecutionException {
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ if( project == null) {
+ throw new ExecutionException("Can't get project '" + projectName + "' from workspace.");
+ }
+
+ if(project != null && !project.exists()) {
+// IProgressMonitor monitor = new NullProgressMonitor();
+ try {
+ project.create(monitor);
+ } catch (CoreException e) {
+ throw new ExecutionException("Can't create project '" + projectName + "'.", e);
+ }
+ }
+
+ if(!project.isOpen()) {
+ try {
+ project.open(null);
+ } catch (CoreException e) {
+ throw new ExecutionException("Can't open project '" + projectName + "'.", e);
+ }
+ }
+
+
+
+ }
+
+
+ /**
+ * @return the project
+ */
+ public IProject getProject() {
+ return project;
+ }
+
+ /**
+ *
+ * @param fromBundle
+ * @param fromResourceName
+ * @param toResourceName
+ * @return
+ * @throws ExecutionException
+ */
+ public IFile copyResource( String fromBundle, String fromResourceName, String toResourceName) throws ExecutionException {
+
+ try {
+ Path toURL = new Path(toResourceName);
+ System.out.println(toURL);
+
+ IFile file = project.getFile(toResourceName);
+ // link all the models resources
+ if(!file.exists()) {
+ // Create intermediate folders
+ ensureFolders(file);
+
+ URL url = FileLocator.find(Platform.getBundle(fromBundle), new Path(fromResourceName), null);
+ URL newFile = FileLocator.resolve(url);
+
+ // encode the URI for spaces in the path
+ // And then create a link to the file
+ file.createLink(new URL(newFile.toString().replaceAll(" ", "%20")).toURI(), IResource.REPLACE, monitor);
+ }
+ return file;
+ } catch (Exception e) {
+ throw new ExecutionException("Can't copy resource '" + toResourceName + "'.", e);
+ }
+ }
+
+ /**
+ * Copy the specified resource from the specified bundle to this project.
+ * Use the same path in src and target.
+ *
+ * @param fromBundle
+ * @param fromResourceName
+ * @return
+ * @throws ExecutionException
+ */
+ public IFile copyResource( String fromBundle, String fromResourceName) throws ExecutionException {
+
+ return copyResource(fromBundle, fromResourceName, fromResourceName);
+ }
+
+ /**
+ *
+ * @param fromBundle
+ * @param fromResourceNames
+ * @throws ExecutionException
+ */
+ public void copyResources(String fromBundle, String ...fromResourceNames) throws ExecutionException {
+
+ for(String fromResourceName : fromResourceNames) {
+ copyResource(fromBundle, fromResourceName);
+ }
+ }
+
+ /**
+ * Ensure that the intermediates folders exist in the project.
+ *
+ * @param project
+ * @param name
+ * @throws CoreException
+ */
+ protected void ensureFolders(IFile file) throws CoreException {
+
+ IPath path = file.getProjectRelativePath();
+ IPath folderPath = path.removeLastSegments(1);
+
+ String[] segments = folderPath.segments();
+
+ for( int i = segments.length-1; i>=0; i--) {
+ IPath curFolderPath = folderPath.removeLastSegments(i);
+ createFolder(curFolderPath);
+ }
+
+
+ }
+
+ /**
+ *
+ * @param folderPath
+ * @throws CoreException
+ */
+ private void createFolder(IPath folderPath) throws CoreException {
+ IFolder parent = project.getFolder(folderPath);
+ if(!parent.exists()) {
+ parent.create(true, true, monitor);
+ }
+ assert (parent.exists()); }
+
+ /**
+ * Creates all the folders that are needed to contains the resource.
+ *
+ * @param modelName
+ * @throws ExecutionException
+ */
+ public void createFolders(String modelName) throws ExecutionException {
+ try {
+ IFile file = project.getFile(modelName);
+ // link all the models resources
+ if(!file.exists()) {
+ // Create intermediate folders
+ ensureFolders(file);
+ }
+ } catch (CoreException e) {
+ throw new ExecutionException("Can't create intermediate folders for '" + modelName + ". ", e);
+ }
+ }
+
+}
diff --git a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditor.java b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditor.java
index a80da31ea8a..fdb5e5ca498 100644
--- a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditor.java
+++ b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/src/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditor.java
@@ -19,10 +19,6 @@ import java.io.IOException;
import org.eclipse.core.commands.operations.IOperationHistory;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -50,13 +46,13 @@ import org.eclipse.ui.part.FileEditorInput;
*/
public class ProgramaticPapyrusEditor {
- protected static final String DEFAULT_PROJECT_NAME = "org.eclipse.org.infra.core.defaultproject.integration";
+ protected static final String DEFAULT_PROJECT_NAME = "org.eclipse.papyrus.integrationtests.editor";
protected static final String DEFAULT_MODEL_NAME = "papyrusModelForIntegration";
/**
* Name of the project that will contains Model
*/
- protected String projectName = DEFAULT_PROJECT_NAME;
+// protected String projectName = DEFAULT_PROJECT_NAME;
/**
* Name of the model to create.
@@ -67,7 +63,7 @@ public class ProgramaticPapyrusEditor {
// protected ModelSet modelSet;
/** The file. */
- protected IFile file;
+// protected IFile file;
/** The page. */
protected IWorkbenchPage page;
@@ -76,10 +72,16 @@ public class ProgramaticPapyrusEditor {
protected IMultiDiagramEditor papyrusEditor;
/** The project. */
- protected IProject project;
+// protected IProject project;
+
+ /**
+ * An object representing an EclipseProject.
+ */
+ protected EclipseProject eclipseProject;
+
/** The root. */
- protected IWorkspaceRoot root;
+// protected IWorkspaceRoot root;
/**
@@ -89,10 +91,35 @@ public class ProgramaticPapyrusEditor {
* @param modelName
* @throws EditorCreationException If the creation fails.
*/
- public ProgramaticPapyrusEditor(String projectName, String modelName) throws EditorCreationException {
- this.projectName = projectName;
+ public ProgramaticPapyrusEditor(String projectName, String modelName) throws ExecutionException {
+ this.modelName = modelName;
+
+ // Create an Eclipse project
+ eclipseProject = new EclipseProject(projectName);
+ // Create a suitable EclipseProject
+ initResources(false);
+
+ // Create editor
+ createEditor();
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param projectName
+ * @param modelName
+ * @throws EditorCreationException If the creation fails.
+ */
+ public ProgramaticPapyrusEditor(EclipseProject eclipseProject, String modelName) throws ExecutionException {
this.modelName = modelName;
+ if( eclipseProject == null ) {
+ throw new ExecutionException("The argument 'EclipseProject' should be initialized.");
+ }
+ this.eclipseProject = eclipseProject;
+ // Create a suitable EclipseProject
+ initResources(false);
+
// Create editor
createEditor();
}
@@ -104,13 +131,48 @@ public class ProgramaticPapyrusEditor {
* @throws EditorCreationException If the creation fails.
*
*/
- public ProgramaticPapyrusEditor() throws EditorCreationException {
+ public ProgramaticPapyrusEditor() throws ExecutionException {
+
+ // Create an Eclipse project
+ eclipseProject = new EclipseProject(DEFAULT_PROJECT_NAME);
+ // Create a suitable EclipseProject
+ initResources(true);
+
// Create editor
createEditor();
}
/**
+ * Init the resources.
+ * The {@link #eclipseProject} should be initialized.
+ *
+ * @throws ExecutionException
+ * @throws CoreException
+ * @throws IOException
+ */
+ private void initResources(boolean deleteFileIfExists) throws ExecutionException {
+ try {
+ // Ensure path to specified resource
+ eclipseProject.createFolders(modelName);
+
+ // delete existing files, and then create a new model
+ IFile file = eclipseProject.getProject().getFile(modelName + ".di");
+ if(deleteFileIfExists && file.exists()) {
+ file.delete(true, new NullProgressMonitor());
+ }
+
+ if(!file.exists()) {
+ // Create the model
+ createModel(file);
+ }
+ } catch (Exception e) {
+ throw new ExecutionException("Can't init Project and Resources" , e );
+ }
+ }
+
+
+ /**
* Create a model suitable for Papyrus uml.
* Save it in the provided file.
* @param file
@@ -141,29 +203,29 @@ public class ProgramaticPapyrusEditor {
* @throws EditorCreationException
*/
protected IMultiDiagramEditor createEditor() throws EditorCreationException {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- root = workspace.getRoot();
- project = root.getProject(projectName);
- file = project.getFile(modelName + ".di");
+// IWorkspace workspace = ResourcesPlugin.getWorkspace();
+// root = workspace.getRoot();
+// project = root.getProject(projectName);
+ IFile file = eclipseProject.getProject().getFile(modelName + ".di");
try {
- //at this point, no resources have been created
- if(!project.exists()) {
- project.create(null);
- }
- if(!project.isOpen()) {
- project.open(null);
- }
-
- if(file.exists()) {
- file.delete(true, new NullProgressMonitor());
- }
-
- if(!file.exists()) {
- // Create the model
- createModel(file);
- }
-
+// //at this point, no resources have been created
+// if(!project.exists()) {
+// project.create(null);
+// }
+// if(!project.isOpen()) {
+// project.open(null);
+// }
+//
+// if(file.exists()) {
+// file.delete(true, new NullProgressMonitor());
+// }
+//
+// if(!file.exists()) {
+// // Create the model
+// createModel(file);
+// }
+//
// Create the editor
page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
@@ -174,8 +236,8 @@ public class ProgramaticPapyrusEditor {
throw new EditorCreationException("Can't create editor", e);
} catch (CoreException e) {
throw new EditorCreationException("Can't create editor", e);
- } catch (IOException e) {
- throw new EditorCreationException("Can't create editor", e);
+// } catch (IOException e) {
+// throw new EditorCreationException("Can't create editor", e);
}
}
@@ -197,7 +259,7 @@ public class ProgramaticPapyrusEditor {
// papyrusEditor.dispose();
page.closeAllEditors(true);
try {
- project.delete(true, new NullProgressMonitor());
+ eclipseProject.getProject().delete(true, new NullProgressMonitor());
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/EclipseProjectTest.java b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/EclipseProjectTest.java
new file mode 100644
index 00000000000..39a4cd54e4c
--- /dev/null
+++ b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/EclipseProjectTest.java
@@ -0,0 +1,109 @@
+/*****************************************************************************
+ * Copyright (c) 2014 Cedric Dumoulin.
+ *
+ *
+ * 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.integrationtests.editor;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * @author cedric dumoulin
+ *
+ */
+public class EclipseProjectTest {
+
+ private static final String PROJECT_NAME = "org.eclipse.papyrus.integrationtests.editor.project";
+ private static final String FROM_BUNDLE_NAME = "org.eclipse.papyrus.integrationtests.editor";
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.integrationtests.editor.EclipseProject#EclipseProject(java.lang.String)}.
+ * @throws ExecutionException
+ */
+ @Test
+ public void testEclipseProject() throws ExecutionException {
+ EclipseProject project = new EclipseProject(PROJECT_NAME);
+
+ assertNotNull( "object created", project);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.integrationtests.editor.EclipseProject#getProject()}.
+ * @throws ExecutionException
+ */
+ @Test
+ public void testGetProject() throws ExecutionException {
+ EclipseProject project = new EclipseProject(PROJECT_NAME);
+
+ assertNotNull( "object created", project.getProject());
+
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.integrationtests.editor.EclipseProject#copyResource(java.lang.String, java.lang.String, java.lang.String)}.
+ * @throws ExecutionException
+ */
+ @Test
+ public void testCopyResource() throws ExecutionException {
+
+ String fromFile = "META-INF/MANIFEST.MF";
+ String toFile = "a/b/META-INF/MANIFEST.MF";
+
+ EclipseProject project = new EclipseProject(PROJECT_NAME);
+
+ project.copyResource(FROM_BUNDLE_NAME, fromFile, toFile);
+
+ assertNotNull( "file copied", project.getProject().findMember(toFile));
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.integrationtests.editor.EclipseProject#copyResource(java.lang.String, java.lang.String, java.lang.String)}.
+ * @throws ExecutionException
+ */
+ @Test
+ public void testCopyResources() throws ExecutionException {
+
+ String fromFile1 = "META-INF/MANIFEST.MF";
+ String fromFile2 = "about.html";
+
+ EclipseProject project = new EclipseProject(PROJECT_NAME);
+
+ assertNull( "file copied", project.getProject().findMember(fromFile1));
+ assertNull( "file copied", project.getProject().findMember(fromFile2));
+
+ project.copyResources(FROM_BUNDLE_NAME, fromFile1, fromFile2);
+
+ assertNotNull( "file copied", project.getProject().findMember(fromFile1));
+ assertNotNull( "file copied", project.getProject().findMember(fromFile2));
+ }
+
+
+}
diff --git a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditorTest.java b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditorTest.java
index 6b4595a53fc..96702f3b28f 100644
--- a/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditorTest.java
+++ b/tests/integration/plugins/org.eclipse.papyrus.integrationtests.editor/test/org/eclipse/papyrus/integrationtests/editor/ProgramaticPapyrusEditorTest.java
@@ -16,8 +16,14 @@ package org.eclipse.papyrus.integrationtests.editor;
import static org.junit.Assert.*;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.resource.BadArgumentExcetion;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -32,6 +38,17 @@ import org.junit.Test;
public class ProgramaticPapyrusEditorTest {
/**
+ * Name of the plugin that is created.
+ */
+ final protected String PLUGIN_PROJECT_NAME = "org.eclipse.papyrus.integrationtests.editor.tests";
+
+ /**
+ * Name of the bundle containing resources to copied.
+ */
+ final protected String BUNDLE_NAME = "org.eclipse.papyrus.integrationtests.editor";
+
+
+ /**
* @throws java.lang.Exception
*/
@Before
@@ -47,10 +64,10 @@ public class ProgramaticPapyrusEditorTest {
/**
* Test method for {@link org.eclipse.papyrus.integrationtests.editor.ProgramaticPapyrusEditor#createEditor()}.
- * @throws EditorCreationException
+ * @throws ExecutionException
*/
@Test
- public void testCreateEditor() throws EditorCreationException {
+ public void testCreateEditor() throws ExecutionException {
ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor();
IMultiDiagramEditor editor = editorHandler.getEditor();
@@ -60,9 +77,10 @@ public class ProgramaticPapyrusEditorTest {
/**
* Test method for {@link org.eclipse.papyrus.integrationtests.editor.ProgramaticPapyrusEditor#dispose()}.
+ * @throws ExecutionException
*/
@Test
- public void testDispose() throws EditorCreationException {
+ public void testDispose() throws ExecutionException {
ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor();
IMultiDiagramEditor editor = editorHandler.getEditor();
@@ -74,9 +92,10 @@ public class ProgramaticPapyrusEditorTest {
/**
* Test method for {@link org.eclipse.papyrus.integrationtests.editor.ProgramaticPapyrusEditor#getEditor()}.
+ * @throws ExecutionException
*/
@Test
- public void testGetEditor() throws EditorCreationException {
+ public void testGetEditor() throws ExecutionException {
ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor();
IMultiDiagramEditor editor = editorHandler.getEditor();
@@ -87,9 +106,10 @@ public class ProgramaticPapyrusEditorTest {
/**
* Test method for {@link org.eclipse.papyrus.integrationtests.editor.ProgramaticPapyrusEditor#getServiceRegistry()}.
+ * @throws ExecutionException
*/
@Test
- public void testGetServiceRegistry() throws EditorCreationException {
+ public void testGetServiceRegistry() throws ExecutionException {
ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor();
IMultiDiagramEditor editor = editorHandler.getEditor();
@@ -102,4 +122,36 @@ public class ProgramaticPapyrusEditorTest {
editorHandler.dispose();
}
+ /**
+ * Test method for {@link org.eclipse.papyrus.integrationtests.editor.ProgramaticPapyrusEditor#getEditor()}.
+ * @throws ServiceException
+ * @throws BadArgumentExcetion
+ * @throws NotFoundException
+ * @throws ExecutionException
+ */
+ @Test
+ public void testGetEditorAndLoadModel() throws ServiceException, NotFoundException, BadArgumentExcetion, ExecutionException {
+
+ String modelName = "models/modelTestLoadModel";
+// String modelName = "modelTestLoadModel";
+ String diagramName = "diagram1";
+ EclipseProject eclipseProject = new EclipseProject(PLUGIN_PROJECT_NAME);
+ eclipseProject.copyResources(BUNDLE_NAME, modelName+".di", modelName+".notation", modelName+".uml" );
+
+ ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor(eclipseProject, modelName);
+ IMultiDiagramEditor editor = editorHandler.getEditor();
+
+ assertNotNull("editor created", editor);
+
+ NotationModel notationModel = (NotationModel)editorHandler.getModelSet().getModel(NotationModel.MODEL_ID);
+ assertNotNull("notation model loaded", notationModel);
+
+ // If the following assertion is false, this means that the model is not loaded from file (it has been created)
+ Diagram diagram = notationModel.getDiagram(diagramName);
+ assertNotNull("diagram loaded", diagram);
+
+ editorHandler.dispose();
+ }
+
+
}

Back to the top