Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2019-07-09 16:04:01 +0000
committerPatrick Tessier2019-08-20 12:43:17 +0000
commit7a81d8195a4060aaf3a975024dcd863f71f99962 (patch)
treeba6eacf625611e3dfb49e2251136a6e4fec1fa4e
parentfc697c6c175c7fcf25773eb7afb5e4d5855c78d4 (diff)
downloadorg.eclipse.papyrus-7a81d8195a4060aaf3a975024dcd863f71f99962.tar.gz
org.eclipse.papyrus-7a81d8195a4060aaf3a975024dcd863f71f99962.tar.xz
org.eclipse.papyrus-7a81d8195a4060aaf3a975024dcd863f71f99962.zip
Bug 549108: [Tests] PapyrusEditorFixture must support more file extension that only uml, notation and di...
Change-Id: I9dd99c8db8bebbb54fa5dc16e3a00b440dcea538 Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rwxr-xr-xtests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java46
-rw-r--r--tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ModelSetFixture.java22
-rw-r--r--tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java33
-rw-r--r--tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ResourceSetFixture.java23
4 files changed, 103 insertions, 21 deletions
diff --git a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java
index bf26e031c18..77e6a9452a8 100755
--- a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java
+++ b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java
@@ -1,6 +1,6 @@
-/*
+/**
* Copyright (c) 2014, 2016 CEA, 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
* which accompanies this distribution, and is available at
@@ -11,7 +11,7 @@
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
* Christian W. Damus - bugs 399859, 451230, 458685, 469188, 485220, 496299
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 549108
*/
package org.eclipse.papyrus.junit.utils.rules;
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedList;
@@ -81,9 +82,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import com.google.common.io.ByteSource;
import com.google.common.io.ByteStreams;
-import com.google.common.io.CharStreams;
import com.google.common.io.Resources;
@@ -117,10 +116,33 @@ public abstract class AbstractModelFixture<T extends EditingDomain> extends Test
private Iterable<URI> initialResourceURIs;
+ /**
+ * @since 2.3
+ */
+ private List<String> managedFileExtension;
+
public AbstractModelFixture() {
super();
+ this.managedFileExtension = new ArrayList<>();
+ this.managedFileExtension.add(DiModel.DI_FILE_EXTENSION);
+ this.managedFileExtension.add(UmlModel.UML_FILE_EXTENSION);
+ this.managedFileExtension.add(NotationModel.NOTATION_FILE_EXTENSION);
}
+ /**
+ *
+ * Constructor.
+ *
+ * @param additionalFileExtension
+ * the extension of additional files to manage during the project creation
+ * @since 2.3
+ */
+ public AbstractModelFixture(final List<String> additionalFileExtension) {
+ this();
+ this.managedFileExtension.addAll(additionalFileExtension);
+ }
+
+
@Override
public Statement apply(Statement base, Description description) {
testClass = JUnitUtils.getTestClass(description);
@@ -134,7 +156,7 @@ public abstract class AbstractModelFixture<T extends EditingDomain> extends Test
/**
* Obtains the nested project fixture rule. If stored in a field of the test class, it must not be annotated as a {@link Rule @Rule} because that
* would result in double initialization of the rule.
- *
+ *
* @return the nested project fixture
*/
public ProjectFixture getProject() {
@@ -194,7 +216,7 @@ public abstract class AbstractModelFixture<T extends EditingDomain> extends Test
/**
* Obtains the first root of the main test resource.
- *
+ *
* @return the first test resource root
*/
public EObject getRoot() {
@@ -203,7 +225,7 @@ public abstract class AbstractModelFixture<T extends EditingDomain> extends Test
/**
* Obtains the test model, which is resident in the <tt>model.uml</tt> file in the test project (as indicated by its {@linkplain #getModelResourceURI() URI}).
- *
+ *
* @return the test model
*/
public Package getModel() {
@@ -445,9 +467,9 @@ public abstract class AbstractModelFixture<T extends EditingDomain> extends Test
// Default manifest
result = Maps.newHashMap();
IPath basePath = manifestPath.removeFileExtension();
- result.put(basePath.addFileExtension(DiModel.DI_FILE_EXTENSION), true);
- result.put(basePath.addFileExtension(UmlModel.UML_FILE_EXTENSION), true);
- result.put(basePath.addFileExtension(NotationModel.NOTATION_FILE_EXTENSION), true);
+ for (final String current : this.managedFileExtension) {
+ result.put(basePath.addFileExtension(current), true);
+ }
}
return result;
@@ -493,7 +515,7 @@ public abstract class AbstractModelFixture<T extends EditingDomain> extends Test
if (result == null) {
String extension = modelURI.fileExtension();
- if (DiModel.DI_FILE_EXTENSION.equals(extension) || UmlModel.UML_FILE_EXTENSION.equals(extension) || NotationModel.NOTATION_FILE_EXTENSION.equals(extension)) {
+ if (this.managedFileExtension.contains(extension)) {
// Default load behaviour
result = resourceSet.createResource(modelURI);
} else {
diff --git a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ModelSetFixture.java b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ModelSetFixture.java
index 46a255efb33..564a466c106 100644
--- a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ModelSetFixture.java
+++ b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ModelSetFixture.java
@@ -1,6 +1,6 @@
-/*
- * Copyright (c) 2014, 2016 CEA, Christian W. Damus, and others.
- *
+/**
+ * Copyright (c) 2014, 2016, 2019 CEA, 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
* which accompanies this distribution, and is available at
@@ -11,13 +11,14 @@
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
* Christian W. Damus - bugs 399859, 485220
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 549108
*/
package org.eclipse.papyrus.junit.utils.rules;
import static org.junit.Assert.fail;
import java.util.Collections;
+import java.util.List;
import java.util.regex.Pattern;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -43,6 +44,19 @@ public class ModelSetFixture extends AbstractModelFixture<TransactionalEditingDo
super();
}
+ /**
+ *
+ * Constructor.
+ *
+ * @param additionalFileExtension
+ * a list of additional file extension to manage
+ * @since 2.3
+ */
+ public ModelSetFixture(final List<String> additionalFileExtension) {
+ super(additionalFileExtension);
+ }
+
+
@Override
public ModelSet getResourceSet() {
return (ModelSet) super.getResourceSet();
diff --git a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
index d3976f8e091..8f59b899337 100644
--- a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
+++ b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014, 2018 CEA, Christian W. Damus, and others.
+ * Copyright (c) 2014, 2018, 2019 CEA, 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
@@ -13,6 +13,7 @@
* Christian W. Damus - bugs 433206, 465416, 434983, 483721, 469188, 485220, 491542, 497865, 533673, 533682, 533676, 533679, 536486
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 521550
* EclipseSource - Bug 536631
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 549108
*****************************************************************************/
package org.eclipse.papyrus.junit.utils.rules;
@@ -222,11 +223,41 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
*/
public PapyrusEditorFixture(boolean ensureOperationHistoryIntegrity) {
super();
+ this.ensureOperationHistoryIntegrity = ensureOperationHistoryIntegrity;
+ }
+ /**
+ *
+ * Constructor.
+ *
+ * @param ensureOperationHistoryIntegrity
+ *
+ * @param additionalFileExtension
+ * a list of additional file extension to manage
+ * @since 2.3
+ */
+ public PapyrusEditorFixture(boolean ensureOperationHistoryIntegrity, final List<String> additionalFileExtension) {
+ super(additionalFileExtension);
this.ensureOperationHistoryIntegrity = ensureOperationHistoryIntegrity;
}
/**
+ *
+ * Constructor.
+ *
+ * @param ensureOperationHistoryIntegrity
+ *
+ * @param additionalFileExtension
+ * a list of additional file extension to manage
+ * @since 2.3
+ */
+ public PapyrusEditorFixture(final List<String> additionalFileExtension) {
+ super(additionalFileExtension);
+ this.ensureOperationHistoryIntegrity = true;
+ }
+
+
+ /**
* @since 2.0
*/
public IMultiDiagramEditor getEditor() {
diff --git a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ResourceSetFixture.java b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ResourceSetFixture.java
index 9911f99a653..b860fd725ca 100644
--- a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ResourceSetFixture.java
+++ b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ResourceSetFixture.java
@@ -1,6 +1,6 @@
-/*
- * Copyright (c) 2014 CEA and others.
- *
+/**
+ * Copyright (c) 2014, 2019 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
@@ -10,10 +10,12 @@
*
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 549108
*/
package org.eclipse.papyrus.junit.utils.rules;
+import java.util.List;
+
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
@@ -30,6 +32,19 @@ public class ResourceSetFixture extends AbstractModelFixture<EditingDomain> {
super();
}
+ /**
+ *
+ * Constructor.
+ *
+ * @param additionalFileExtension
+ * the extension of additional files to manage during the project creation
+ * @since 2.3
+ */
+ public ResourceSetFixture(final List<String> additionalFileExtension) {
+ super(additionalFileExtension);
+ }
+
+ @Override
protected EditingDomain createEditingDomain() {
return new AdapterFactoryEditingDomain(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE), new BasicCommandStack());
}

Back to the top