Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2016-10-17 14:20:10 +0000
committerGerrit Code Review @ Eclipse.org2016-10-19 09:05:36 +0000
commit5717e5ff33e74718dbd2dab3aaf56b1cdfa82ea1 (patch)
tree434b15c56e31b0157a37f427382a0cf19b206c86
parent6ed0cea998ac53ce143268ec8175c4a740cfc4aa (diff)
downloadorg.eclipse.papyrus-5717e5ff33e74718dbd2dab3aaf56b1cdfa82ea1.tar.gz
org.eclipse.papyrus-5717e5ff33e74718dbd2dab3aaf56b1cdfa82ea1.tar.xz
org.eclipse.papyrus-5717e5ff33e74718dbd2dab3aaf56b1cdfa82ea1.zip
Bug 506088 - [Papyrus] [CDO] correction of failed tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=506088 - amended the necessary classes in Neon - retrigger gerrit Change-Id: I57f421dd2d4323683576206cd22921378ff4594b Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java60
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java9
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java6
3 files changed, 53 insertions, 22 deletions
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java
index 8efbdc7a714..29df1a9311e 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java
@@ -19,10 +19,13 @@ import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
+import java.io.IOException;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.cdo.core.importer.IModelTransferConfiguration;
import org.eclipse.papyrus.cdo.core.importer.IModelTransferNode;
import org.eclipse.papyrus.cdo.core.resource.CDOAwareModelSet;
@@ -61,28 +64,51 @@ public abstract class AbstractModelExportTest extends AbstractPapyrusCDOTest {
protected void createModels() throws Exception {
// create the model that the other model depends on
ServicesRegistry[] services1 = { null };
- ModelSet modelSet1 = createModelSet(DEPENDENCY_MODEL_NAME, services1);
+ final ModelSet modelSet1 = createModelSet(DEPENDENCY_MODEL_NAME, services1);
UmlModel uml1 = (UmlModel) modelSet1.getModel(UmlModel.MODEL_ID);
- Model model1 = (Model) uml1.lookupRoot();
- model1.createOwnedClass("Superclass", false);
-
- modelSet1.save(new NullProgressMonitor());
+ final Model model1 = (Model) uml1.lookupRoot();
+ TransactionalEditingDomain ted1 = modelSet1.getTransactionalEditingDomain();
+ RecordingCommand recording1 = new RecordingCommand(ted1) {
+
+ @Override
+ protected void doExecute() {
+ model1.createOwnedClass("Superclass", false);
+
+ try {
+ modelSet1.save(new NullProgressMonitor());
+ } catch (IOException e) {
+ Activator.log.error("The modelSet of the fixture failed on save", e); // $NON-NLS-1$
+ }
+ }
+ };
+ ted1.getCommandStack().execute(recording1);
// create the model that depends on the first one
ServicesRegistry[] services2 = { null };
- ModelSet modelSet2 = createModelSet(DEPENDENT_MODEL_NAME, services2);
+ final ModelSet modelSet2 = createModelSet(DEPENDENT_MODEL_NAME, services2);
UmlModel uml2 = (UmlModel) modelSet2.getModel(UmlModel.MODEL_ID);
- Model model2 = (Model) uml2.lookupRoot();
- Class subclass = model2.createOwnedClass("Subclass", false);
-
- // add the dependency
- Model dependency = UML2Util.load(modelSet2, getTestResourceURI(DEPENDENCY_MODEL_NAME), UMLPackage.Literals.MODEL);
- model2.createPackageImport(dependency);
- subclass.createGeneralization((Class) dependency.getOwnedType("Superclass"));
-
- modelSet2.save(new NullProgressMonitor());
+ final Model model2 = (Model) uml2.lookupRoot();
+ TransactionalEditingDomain ted2 = modelSet2.getTransactionalEditingDomain();
+ RecordingCommand recording2 = new RecordingCommand(ted2) {
+
+ @Override
+ protected void doExecute() {
+ Class subclass = model2.createOwnedClass("Subclass", false);
+
+ // add the dependency
+ Model dependency = UML2Util.load(modelSet2, getTestResourceURI(DEPENDENCY_MODEL_NAME), UMLPackage.Literals.MODEL);
+ model2.createPackageImport(dependency);
+ subclass.createGeneralization((Class) dependency.getOwnedType("Superclass"));
+ try {
+ modelSet2.save(new NullProgressMonitor());
+ } catch (IOException e) {
+ Activator.log.error("The modelSet of the fixture failed on save", e); // $NON-NLS-1$
+ }
+ }
+ };
+ ted2.getCommandStack().execute(recording2);
// dispose
services1[0].disposeRegistry();
@@ -121,7 +147,7 @@ public abstract class AbstractModelExportTest extends AbstractPapyrusCDOTest {
IModelTransferNode result = null;
for (IModelTransferNode next : config.getModelsToTransfer()) {
- if(next.getPrimaryResourceURI().equals(uri)) {
+ if (next.getPrimaryResourceURI().equals(uri)) {
result = next;
break;
}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java
index d47bece00cc..b820bf3e556 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java
@@ -128,7 +128,7 @@ public class ModelExportMappingTest extends AbstractModelExportTest {
assertThat(child.getMessage(), containsString("No mapping"));
Object actual = child.getData().get(0);
- Object expected = (Object) getNode(uri2);
+ Object expected = getNode(uri2);
assertThat(actual, sameInstance(expected));
}
@@ -143,6 +143,7 @@ public class ModelExportMappingTest extends AbstractModelExportTest {
config = IModelTransferConfiguration.Factory.EXPORT.create(new IModelTransferOperation.Context() {
+ @Override
public Diagnostic run(IModelTransferOperation operation) {
operation.run(new NullProgressMonitor());
return Diagnostic.OK_INSTANCE;
@@ -157,8 +158,10 @@ public class ModelExportMappingTest extends AbstractModelExportTest {
public void disposeTestFixture() {
fixture = null;
- config.dispose();
- config = null;
+ if (null != config) {
+ config.dispose();
+ config = null;
+ }
}
IModelTransferNode getNode(URI uri) {
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java
index 26bb13e97ff..0db43243db7 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java
@@ -116,8 +116,10 @@ public class ModelExporterTest extends AbstractModelExportTest {
public void disposeTestFixture() {
fixture = null;
- config.dispose();
- config = null;
+ if (null != config) {
+ config.dispose();
+ config = null;
+ }
}
void assertResource(IPath path, final String metamodel) {

Back to the top