Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2019-08-22 08:17:46 +0000
committerNicolas FAUVERGUE2019-08-22 08:17:46 +0000
commit3303b45f5d625e65e12728c2d411b2662bd73377 (patch)
tree218a1741e75edf27be8fb1abb6304370a4682fff /tests
parenta3ee443ee0ce065f93fb166427e2a774ed6c5831 (diff)
downloadorg.eclipse.papyrus-3303b45f5d625e65e12728c2d411b2662bd73377.tar.gz
org.eclipse.papyrus-3303b45f5d625e65e12728c2d411b2662bd73377.tar.xz
org.eclipse.papyrus-3303b45f5d625e65e12728c2d411b2662bd73377.zip
Bug 550321: [Tests] Some tests are failing because of
ProxyModificationTrackingAdapter Some tests are failing due to modification without command -> Manage it as commands For the PageManager, we need to open/close the pages without using command Change-Id: Iec25913a8ef372b18f6d74955b2d3cff8164203b Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/editor/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java23
-rw-r--r--tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResourceTest.java133
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java48
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.properties.tests/src/org/eclipse/papyrus/uml/properties/databinding/tests/AbstractObservableTest.java10
6 files changed, 152 insertions, 68 deletions
diff --git a/tests/junit/plugins/editor/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java b/tests/junit/plugins/editor/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java
index d9e4390d321..c3b40f3525c 100644
--- a/tests/junit/plugins/editor/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java
+++ b/tests/junit/plugins/editor/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2013, 2016, 2019 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -12,6 +12,7 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 433371
* Christian W. Damus - bug 485220
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 550321
*
*****************************************************************************/
package org.eclipse.papyrus.editor.integration.tests.tests;
@@ -26,7 +27,6 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.EditingDomain;
@@ -402,32 +402,23 @@ public class PageManagerTests extends AbstractEditorIntegrationTest {
TransactionalEditingDomain editingDomain = editor.getServicesRegistry().getService(TransactionalEditingDomain.class);
- CompoundCommand command = new CompoundCommand("Delete diagram");
+ pageManager.closeAllOpenedPages(page);
+ final Command destroyCommand = new GMFtoEMFCommandWrapper(new DestroyElementPapyrusCommand(new DestroyElementRequest(page, false)));
- Command sashRemoveComd = new RecordingCommand(editingDomain, "Remove page") {
-
- @Override
- protected void doExecute() {
- pageManager.closeAllOpenedPages(page);
- }
-
- };
-
- command.append(sashRemoveComd);
- command.append(new GMFtoEMFCommandWrapper(new DestroyElementPapyrusCommand(new DestroyElementRequest(page, false))));
-
- editingDomain.getCommandStack().execute(command);
+ editingDomain.getCommandStack().execute(destroyCommand);
for (int i = 0; i < 3; i++) { // Undo/Redo 3 times
Assert.assertNull("The editor should be closed", editor.getActiveEditor());
Assert.assertEquals("The page has not been correctly deleted", initialPagesSize - 1, pageManager.allPages().size());
editingDomain.getCommandStack().undo();
+ pageManager.openPage(page);
Assert.assertEquals("The has not been correctly created", initialPagesSize, pageManager.allPages().size());
Assert.assertTrue("The editor has not been correctly opened", expectedEditorClass.isInstance(editor.getActiveEditor()));
editingDomain.getCommandStack().redo();
+ pageManager.closeAllOpenedPages(page);
}
}
diff --git a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF
index 95e2f47aed6..e82cb05caa9 100644
--- a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,8 @@ Manifest-Version: 1.0
Require-Bundle: org.junit;bundle-version="4.10.0",
org.eclipse.papyrus.junit.framework;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.junit.utils;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.core;bundle-version="[3.0.100,4.0.0)"
+ org.eclipse.papyrus.infra.core;bundle-version="[3.0.100,4.0.0)",
+ org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.3.0,2.0.0)"
Export-Package: org.eclipse.papyrus.infra.core.resource,
org.eclipse.papyrus.infra.core.services,
org.eclipse.papyrus.infra.core.tests
diff --git a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResourceTest.java b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResourceTest.java
index 2ec403fcfc0..07d2d36a4e9 100644
--- a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResourceTest.java
+++ b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResourceTest.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 LIFL, CEA, and others.
+ * Copyright (c) 2010, 2014, 2019 LIFL, CEA, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* LIFL - Initial API and implementation
* Christian W. Damus (CEA) - bug 436047
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 550321
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.resource;
@@ -23,15 +24,25 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.List;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource.ModelKind;
+import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.junit.After;
@@ -50,7 +61,7 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
@Rule
public final HouseKeeper houseKeeper = new HouseKeeper();
-
+
/**
* @throws java.lang.Exception
*/
@@ -76,8 +87,8 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
String model2Key = "genmodel";
// Create models with different key, but use same extension (default from FakeModelWithSharedResource)
- FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<EPackage>(ModelKind.master, model1Key, EPackage.class);
- FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<EClass>(model2Key, EClass.class);
+ FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<>(ModelKind.master, model1Key, EPackage.class);
+ FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<>(model2Key, EClass.class);
ModelSet modelSet = houseKeeper.cleanUpLater(new ModelSet());
modelSet.registerModel(model1);
@@ -100,21 +111,21 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
/**
* Create and save models.
- *
+ *
* @throws IOException
* @throws CoreException
*/
private void createAndSave(String model1Key, String model2Key) throws IOException, CoreException {
- FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<EPackage>(ModelKind.master, model1Key, EPackage.class);
- FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<EClass>(model2Key, EClass.class);
+ FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<>(ModelKind.master, model1Key, EPackage.class);
+ FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<>(model2Key, EClass.class);
ModelSet modelSet = houseKeeper.cleanUpLater(new ModelSet());
modelSet.registerModel(model1);
modelSet.registerModel(model2);
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("org.eclipse.papyrus.infra.core");
- if(!p.exists()) {
+ if (!p.exists()) {
p.create(new NullProgressMonitor());
}
p.open(new NullProgressMonitor());
@@ -131,7 +142,7 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
/**
* Test method for {@link org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#loadModel(org.eclipse.core.runtime.IPath)}.
- *
+ *
* @throws CoreException
* @throws IOException
* @throws ModelMultiException
@@ -145,8 +156,8 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
createAndSave(model1Key, model2Key);
- FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<EPackage>(ModelKind.master, model1Key, EPackage.class);
- FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<EClass>(model2Key, EClass.class);
+ FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<>(ModelKind.master, model1Key, EPackage.class);
+ FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<>(model2Key, EClass.class);
ModelSet modelSet = houseKeeper.cleanUpLater(new ModelSet());
modelSet.registerModel(model1);
@@ -167,7 +178,7 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
/**
* Test method for {@link org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#saveModel()}.
- *
+ *
* @throws IOException
* @throws CoreException
*/
@@ -176,15 +187,15 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
String model1Key = "ecore";
String model2Key = "genmodel";
- FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<EPackage>(ModelKind.master, model1Key, EPackage.class);
- FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<EClass>(model2Key, EClass.class);
+ FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<>(ModelKind.master, model1Key, EPackage.class);
+ FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<>(model2Key, EClass.class);
ModelSet modelSet = houseKeeper.cleanUpLater(new ModelSet());
modelSet.registerModel(model1);
modelSet.registerModel(model2);
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("org.eclipse.papyrus.infra.core");
- if(!p.exists()) {
+ if (!p.exists()) {
p.create(new NullProgressMonitor());
}
p.open(new NullProgressMonitor());
@@ -216,8 +227,8 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
String model1Key = "ecore";
String model2Key = "genmodel";
- FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<EPackage>(ModelKind.master, model1Key, EPackage.class);
- FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<EClass>(model2Key, EClass.class);
+ FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<>(ModelKind.master, model1Key, EPackage.class);
+ FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<>(model2Key, EClass.class);
ModelSet modelSet = houseKeeper.cleanUpLater(new ModelSet());
modelSet.registerModel(model1);
@@ -227,14 +238,18 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
IFile model1File = p.getFile("tmp/model1." + model1Key);
+ final TransactionalEditingDomain transactionalEditingDomain = modelSet.getTransactionalEditingDomain();
+
// Call creates
modelSet.createsModels(model1File);
// Add elements in both model
EPackage p1 = EcoreFactory.eINSTANCE.createEPackage();
- model1.addModelRoot(p1);
+ final Command addModelRootCommandp1 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model1.getResouce(), p1));
+ addModelRootCommandp1.execute();
EClass c1 = EcoreFactory.eINSTANCE.createEClass();
- model2.addModelRoot(c1);
+ final Command addModelRootCommandc1 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model2.getResouce(), c1));
+ addModelRootCommandc1.execute();
// Do check
assertEquals("root found", p1, model1.getModelRoot());
@@ -249,8 +264,8 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
String model1Key = "ecore";
String model2Key = "genmodel";
- FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<EPackage>(ModelKind.master, model1Key, EPackage.class);
- FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<EClass>(model2Key, EClass.class);
+ FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<>(ModelKind.master, model1Key, EPackage.class);
+ FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<>(model2Key, EClass.class);
ModelSet modelSet = houseKeeper.cleanUpLater(new ModelSet());
modelSet.registerModel(model1);
@@ -260,22 +275,30 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
IFile model1File = p.getFile("tmp/model1." + model1Key);
+ final TransactionalEditingDomain transactionalEditingDomain = modelSet.getTransactionalEditingDomain();
+
// Call creates
modelSet.createsModels(model1File);
// Add elements in both model
EPackage p1 = EcoreFactory.eINSTANCE.createEPackage();
- model1.addModelRoot(p1);
+ final Command addModelRootCommandp1 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model1.getResouce(), p1));
+ addModelRootCommandp1.execute();
EPackage p2 = EcoreFactory.eINSTANCE.createEPackage();
- model1.addModelRoot(p2);
+ final Command addModelRootCommandp2 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model1.getResouce(), p2));
+ addModelRootCommandp2.execute();
EPackage p3 = EcoreFactory.eINSTANCE.createEPackage();
- model1.addModelRoot(p3);
+ final Command addModelRootCommandp3 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model1.getResouce(), p3));
+ addModelRootCommandp3.execute();
EClass c1 = EcoreFactory.eINSTANCE.createEClass();
- model2.addModelRoot(c1);
+ final Command addModelRootCommandc1 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model2.getResouce(), c1));
+ addModelRootCommandc1.execute();
EClass c2 = EcoreFactory.eINSTANCE.createEClass();
- model2.addModelRoot(c2);
+ final Command addModelRootCommandc2 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model2.getResouce(), c2));
+ addModelRootCommandc2.execute();
EClass c3 = EcoreFactory.eINSTANCE.createEClass();
- model2.addModelRoot(c3);
+ final Command addModelRootCommandc3 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model2.getResouce(), c3));
+ addModelRootCommandc3.execute();
// Do check
List<EPackage> lp = model1.getModelRoots();
@@ -302,8 +325,8 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
String model1Key = "ecore";
String model2Key = "genmodel";
- FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<EPackage>(ModelKind.master, model1Key, EPackage.class);
- FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<EClass>(model2Key, EClass.class);
+ FakeModelWithSharedResource<EPackage> model1 = new FakeModelWithSharedResource<>(ModelKind.master, model1Key, EPackage.class);
+ FakeModelWithSharedResource<EClass> model2 = new FakeModelWithSharedResource<>(model2Key, EClass.class);
ModelSet modelSet = houseKeeper.cleanUpLater(new ModelSet());
modelSet.registerModel(model1);
@@ -313,18 +336,66 @@ public class AbstractModelWithSharedResourceTest extends AbstractPapyrusTest {
IFile model1File = p.getFile("tmp/model1." + model1Key);
+ final TransactionalEditingDomain transactionalEditingDomain = modelSet.getTransactionalEditingDomain();
+
// Call creates
modelSet.createsModels(model1File);
// Add elements in both model
EPackage p1 = EcoreFactory.eINSTANCE.createEPackage();
- model1.addModelRoot(p1);
+ final Command addModelRootCommandp1 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model1.getResouce(), p1));
+ addModelRootCommandp1.execute();
EClass c1 = EcoreFactory.eINSTANCE.createEClass();
- model2.addModelRoot(c1);
+ final Command addModelRootCommandc1 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, model2.getResouce(), c1));
+ addModelRootCommandc1.execute();
// Do check
assertTrue("model contain element", model1.getResouce().getContents().contains(p1));
assertTrue("model contain element", model2.getResouce().getContents().contains(c1));
}
+ /**
+ * This allows to add root to resource by command.
+ */
+ private class AddToResourceCommand extends AbstractTransactionalCommand {
+
+ /**
+ * The resource.
+ */
+ private final Resource resource;
+
+ /**
+ * The object to add to the resource.
+ */
+ private final EObject toAdd;
+
+ /**
+ * Constructor.
+ *
+ * @param domain
+ * The editing domain.
+ * @param resource
+ * the resource.
+ * @param toAdd
+ * the object to add to the resource.
+ */
+ public AddToResourceCommand(final TransactionalEditingDomain domain, final Resource resource, final EObject toAdd) {
+ super(domain, "Add an object to a resource", null);
+ this.resource = resource;
+ this.toAdd = toAdd;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!getEditingDomain().isReadOnly(resource)) {
+ this.resource.getContents().add(this.toAdd);
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ }
}
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF
index 466eb996b8c..f79eae500b0 100644
--- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.emf.ecore.xmi;bundle-version="2.8.0",
org.eclipse.papyrus.junit.framework;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.junit.utils;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.types.core;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.papyrus.infra.services.edit;bundle-version="[3.0.0,4.0.0)"
+ org.eclipse.papyrus.infra.services.edit;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.3.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-Version: 1.5.0.qualifier
Bundle-Name: %pluginName
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java
index 74b919d359a..e13b7784b66 100644
--- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceTest.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2012, 2014 LIFL, CEA, and others.
- *
+ * Copyright (c) 2012, 2014, 2019 LIFL, CEA, and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -11,21 +11,26 @@
* Contributors:
* LIFL - Initial API and implementation
* Christian W. Damus (CEA) - bug 431953 (fix start-up of selective services to require only their dependencies)
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 550321
*/
package org.eclipse.papyrus.infra.emf.utils;
import static org.junit.Assert.assertNotNull;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.commands.AddToResourceCommand;
+import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -55,13 +60,14 @@ public class ServiceUtilsForResourceTest {
*/
@Test
public void testGetInstance() {
-
+
assertNotNull("Instance ready", ServiceUtilsForResource.getInstance());
}
/**
* Test method for {@link org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource#getServiceRegistry(org.eclipse.emf.ecore.resource.Resource)}.
- * @throws ServiceException
+ *
+ * @throws ServiceException
*/
@Test
public void testGetServiceRegistryResource() throws ServiceException {
@@ -69,36 +75,40 @@ public class ServiceUtilsForResourceTest {
// Create services
ServicesRegistry servicesRegistry = new ServicesRegistry();
-
+
ModelSet modelSet = new ModelSet();
URI uri = URI.createURI("temp.ecore");
-
- // Register the default resource factory -- only needed for stand-alone!
+
+ // Register the default resource factory -- only needed for stand-alone!
modelSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
- Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
+ Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
Resource resource = modelSet.createResource(uri);
assertNotNull("resource created", resource);
-
+
EClass obj1 = EcoreFactory.eINSTANCE.createEClass();
EPackage pack2 = EcoreFactory.eINSTANCE.createEPackage();
EClass obj2 = EcoreFactory.eINSTANCE.createEClass();
- pack2.getEClassifiers().add(obj2);
- resource.getContents().add(obj1);
- resource.getContents().add(pack2);
-
+ pack2.getEClassifiers().add(obj2);
+
+ final TransactionalEditingDomain transactionalEditingDomain = modelSet.getTransactionalEditingDomain();
+ final Command addRootCommand1 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, resource, obj1));
+ addRootCommand1.execute();
+ final Command addRootCommand2 = new GMFtoEMFCommandWrapper(new AddToResourceCommand(transactionalEditingDomain, resource, pack2));
+ addRootCommand2.execute();
+
servicesRegistry.add(ModelSet.class, 10, modelSet);
-
+
servicesRegistry.startServicesByClassKeys(ModelSet.class);
-
+
// Check registry
- assertNotNull("service ModelSet", servicesRegistry.getService(ModelSet.class) );
- assertNotNull("ModelSet service not correctly initialized", ServiceUtils.getInstance().getModelSet(servicesRegistry) );
-
+ assertNotNull("service ModelSet", servicesRegistry.getService(ModelSet.class));
+ assertNotNull("ModelSet service not correctly initialized", ServiceUtils.getInstance().getModelSet(servicesRegistry));
+
// Do tests
ServicesRegistry r2 = ServiceUtilsForResource.getInstance().getServiceRegistry(obj1.eResource());
assertNotNull("found from obj1", r2);
-
+
r2 = ServiceUtilsForResource.getInstance().getServiceRegistry(obj2.eResource());
assertNotNull("found from obj2", r2);
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.properties.tests/src/org/eclipse/papyrus/uml/properties/databinding/tests/AbstractObservableTest.java b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.properties.tests/src/org/eclipse/papyrus/uml/properties/databinding/tests/AbstractObservableTest.java
index ae4f5fa27f5..73e96a6aad4 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.properties.tests/src/org/eclipse/papyrus/uml/properties/databinding/tests/AbstractObservableTest.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.properties.tests/src/org/eclipse/papyrus/uml/properties/databinding/tests/AbstractObservableTest.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElement;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -51,6 +52,15 @@ public abstract class AbstractObservableTest extends AbstractPapyrusTest {
public void setup() {
domain = editorFixture.getEditingDomain();
}
+
+ /**
+ * This allows to dispose the needed elements.
+ */
+ @After
+ public void dispose() {
+ domain = null;
+ contextObject = null;
+ }
/**
* This allows to define if the property can be modified or not.

Back to the top