Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorvlorenzo2014-02-05 12:13:43 +0000
committervlorenzo2014-02-05 12:13:43 +0000
commita4e6dec57fa72cfa143e35ba60deda3eeb1a7f2f (patch)
treeed718fd48285186c8e2354947db7c375502b0e03 /tests
parent820b57897582e51aed3ebbe4bf350e6f0602b688 (diff)
downloadorg.eclipse.papyrus-a4e6dec57fa72cfa143e35ba60deda3eeb1a7f2f.tar.gz
org.eclipse.papyrus-a4e6dec57fa72cfa143e35ba60deda3eeb1a7f2f.tar.xz
org.eclipse.papyrus-a4e6dec57fa72cfa143e35ba60deda3eeb1a7f2f.zip
try to fix the test
org.eclipse.papyrus.sysml.nattable.requirement.tests.tests.OpenTableTest.testOpenExistingTable on Hudson
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEditorTest.java51
1 files changed, 41 insertions, 10 deletions
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEditorTest.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEditorTest.java
index a5f4b1ccb65..8ff09c1adc6 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEditorTest.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/tests/AbstractEditorTest.java
@@ -13,7 +13,11 @@ package org.eclipse.papyrus.junit.utils.tests;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
@@ -22,10 +26,14 @@ import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.junit.utils.Activator;
import org.eclipse.papyrus.junit.utils.EditorUtils;
+import org.eclipse.papyrus.junit.utils.ModelExplorerUtils;
import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils;
import org.eclipse.papyrus.junit.utils.ProjectUtils;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.uml2.uml.Model;
import org.junit.After;
import org.junit.Assert;
import org.osgi.framework.Bundle;
@@ -37,6 +45,9 @@ public abstract class AbstractEditorTest {
protected IProject project;
+ protected static ModelExplorerView view;
+
+ protected static Model rootModel;
/**
*
* @return
@@ -51,23 +62,43 @@ public abstract class AbstractEditorTest {
* Fails or throws an exception if an error occurs
*
* @param bundle
- * TODO
+ * the bundle to use to create the project and init the model
*/
- protected void initModel(String projectName, String modelName, Bundle bundle) throws Exception {
- project = ProjectUtils.createProject(projectName);
- final IFile diModelFile = PapyrusProjectUtils.copyPapyrusModel(project, bundle, getSourcePath(), modelName);
- Display.getDefault().syncExec(new Runnable() {
+ protected void initModel(String projectName, String modelName, final Bundle bundle) throws Exception {
+ ProjectUtils.removeAllProjectFromTheWorkspace();
+ IProject testProject = ProjectUtils.createProject(projectName);
+ final IFile file = PapyrusProjectUtils.copyPapyrusModel(testProject, bundle, getSourcePath(), modelName);
+ RunnableWithResult<?> runnableWithResult = new RunnableWithResult.Impl<Object>() {
+
public void run() {
try {
- editor = EditorUtils.openPapyrusEditor(diModelFile);
- } catch (Exception ex) {
- Activator.log.error(ex);
- Assert.fail(ex.getMessage());
+ editor = EditorUtils.openPapyrusEditor(file);
+ } catch (PartInitException e) {
+ setStatus(new Status(IStatus.ERROR, bundle.getSymbolicName(), e.getMessage()));
}
+ try {
+ AbstractEditorTest.view = ModelExplorerUtils.openModelExplorerView();
+ } catch (PartInitException e) {
+ setStatus(new Status(IStatus.ERROR, bundle.getSymbolicName(), e.getMessage()));
+ }
+ EObject root = ModelExplorerUtils.getRootInModelExplorer(AbstractEditorTest.view);
+ rootModel = (Model)root;
+
+ if(rootModel != null) {
+ setStatus(Status.OK_STATUS);
+
+ } else {
+ setStatus(new Status(IStatus.ERROR, bundle.getSymbolicName(), "Requirement1 not found")); //$NON-NLS-1$
+
+ }
+
}
- });
+ };
+ Display.getDefault().syncExec(runnableWithResult);
+
+ Assert.assertEquals(runnableWithResult.getStatus().getMessage(), IStatus.OK, runnableWithResult.getStatus().getSeverity());
Assert.assertNotNull(editor);
}

Back to the top