From 6e109e8db7159055446a32881742e152f65bbea6 Mon Sep 17 00:00:00 2001 From: Camille Letavernier Date: Wed, 24 Jul 2013 11:02:23 +0200 Subject: 408491: Papyrus shall enable to easily switch between local and registered profiles. https://bugs.eclipse.org/bugs/show_bug.cgi?id=408491 Add test case--- .../tests/tests/AbstractEditorIntegrationTest.java | 95 +--------------------- .../integration/tests/tests/ModelSetTests.java | 3 +- 2 files changed, 4 insertions(+), 94 deletions(-) (limited to 'tests/junit/plugins/core') diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/AbstractEditorIntegrationTest.java b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/AbstractEditorIntegrationTest.java index a98efb09618..3dc26b39d77 100644 --- a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/AbstractEditorIntegrationTest.java +++ b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/AbstractEditorIntegrationTest.java @@ -11,105 +11,16 @@ *****************************************************************************/ package org.eclipse.papyrus.editor.integration.tests.tests; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.papyrus.editor.integration.tests.Activator; -import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.infra.core.resource.ModelSet; -import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.core.services.ServicesRegistry; -import org.eclipse.papyrus.junit.utils.EditorUtils; -import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils; -import org.eclipse.papyrus.junit.utils.ProjectUtils; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; -import org.junit.After; -import org.junit.Assert; +import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest; import org.osgi.framework.Bundle; -public abstract class AbstractEditorIntegrationTest { +public abstract class AbstractEditorIntegrationTest extends AbstractEditorTest { - protected IMultiDiagramEditor editor; - - protected IProject project; - - /** - * - * @return - * the current bundle - */ + @Override protected Bundle getBundle() { return Activator.getDefault().getBundle(); } - /** - * Inits this.editor - * Fails or throws an exception if an error occurs - * - * @param bundle - * TODO - */ - protected void initModel(String projectName, String modelName, Bundle bundle) throws Exception { - project = ProjectUtils.createProject(projectName); - final IFile diModelFile = PapyrusProjectUtils.copyPapyrusModel(project, getBundle(), getSourcePath(), modelName); - Display.getDefault().syncExec(new Runnable() { - - public void run() { - try { - editor = EditorUtils.openPapyrusEditor(diModelFile); - } catch (Exception ex) { - Activator.log.error(ex); - Assert.fail(ex.getMessage()); - } - } - }); - - Assert.assertNotNull(editor); - } - - @After - public void dispose() throws Exception { - if(editor != null) { - Display.getDefault().syncExec(new Runnable() { - - public void run() { - ((IEditorPart)editor).getSite().getPage().closeEditor(editor, false); - } - }); - - editor = null; - } - - if(project != null) { - project.delete(true, new NullProgressMonitor()); - project = null; - } - } - - protected IPageManager getPageManager() throws ServiceException { - return getServicesRegistry().getService(IPageManager.class); - } - - protected ServicesRegistry getServicesRegistry() throws ServiceException { - return editor.getServicesRegistry(); - } - - protected TransactionalEditingDomain getTransactionalEditingDomain() throws ServiceException { - return getServicesRegistry().getService(TransactionalEditingDomain.class); - } - - protected ModelSet getModelSet() throws ServiceException { - return getServicesRegistry().getService(ModelSet.class); - } - - /** - * The path to the source model folder - * - * @return - */ - protected abstract String getSourcePath(); } diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/ModelSetTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/ModelSetTests.java index d615cba7047..1e449d6bd1b 100644 --- a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/ModelSetTests.java +++ b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/ModelSetTests.java @@ -11,8 +11,6 @@ *****************************************************************************/ package org.eclipse.papyrus.editor.integration.tests.tests; -import junit.framework.Assert; - import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -33,6 +31,7 @@ import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand; import org.eclipse.papyrus.uml.tools.model.UmlModel; import org.eclipse.swt.widgets.Display; import org.eclipse.uml2.uml.Model; +import org.junit.Assert; import org.junit.Test; /** -- cgit v1.2.3