diff options
Diffstat (limited to 'tests/junit')
25 files changed, 845 insertions, 124 deletions
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/resource/tests/CDOAwareModelSetTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/resource/tests/CDOAwareModelSetTest.java index 5d69a8cb927..27a69ac726b 100644 --- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/resource/tests/CDOAwareModelSetTest.java +++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/resource/tests/CDOAwareModelSetTest.java @@ -9,6 +9,7 @@ * Contributors: * CEA LIST - Initial API and implementation * Christian W. Damus (CEA) - bug 429242 + * Christian W. Damus (CEA) - bug 429826 * *****************************************************************************/ package org.eclipse.papyrus.cdo.core.resource.tests; @@ -38,6 +39,7 @@ import org.eclipse.papyrus.cdo.core.resource.PapyrusCDOResourceFactory; import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest; import org.eclipse.papyrus.infra.core.Activator; import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis; import org.eclipse.papyrus.infra.core.services.ExtensionServicesRegistry; import org.eclipse.papyrus.infra.core.services.ServiceMultiException; import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException; @@ -107,7 +109,7 @@ public class CDOAwareModelSetTest extends AbstractPapyrusCDOTest { CDOTransaction transaction = getTransaction(fixture); Resource resource = transaction.getOrCreateResource(getResourcePath(MODEL_FILENAME)); - assertThat(fixture.getReadOnlyHandler().anyReadOnly(new URI[]{ resource.getURI() }), is(Optional.of(false))); + assertThat(fixture.getReadOnlyHandler().anyReadOnly(ReadOnlyAxis.anyAxis(), new URI[]{ resource.getURI() }), is(Optional.of(false))); } @Test diff --git a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF index c8514a339c6..03d3428ab1a 100644 --- a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF @@ -6,7 +6,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.pde;bundle-version="3.7.0",
org.eclipse.pde.core,
org.eclipse.update.configurator,
- org.junit;bundle-version="4.10.0"
+ org.junit;bundle-version="4.10.0",
+ org.eclipse.papyrus.junit.utils;bundle-version="1.0.0"
Export-Package: org.eclipse.papyrus.bundles.tests
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
diff --git a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java index 5b43e68aedb..8d90eb5853f 100644 --- a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java +++ b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,8 +22,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.junit.utils.TestMode;
import org.eclipse.pde.internal.core.feature.Feature;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -113,6 +115,8 @@ public class BundlesTests { */
@Test
public void importPackage() {
+ Assume.assumeTrue("Usage of importPackage is discouraged", TestMode.isStrict()); //$NON-NLS-1$
+
testManifestProperty(BundleTestsUtils.BUNDLE_IMPORT_PACKAGE, "", true, false); //$NON-NLS-1$
}
@@ -121,6 +125,8 @@ public class BundlesTests { */
@Test
public void reexportDependencies() {
+ Assume.assumeTrue("Usage of reexported dependencies is discouraged", TestMode.isStrict());
+
StringBuffer message = new StringBuffer();
int nb = 0;
for(final Bundle current : BundleTestsUtils.getPapyrusBundles()) {
@@ -139,18 +145,18 @@ public class BundlesTests { if(bundle.contains(";")) { //$NON-NLS-1$
localMessage.append(NLS.bind("\n - {0}", bundle.substring(0, bundle.indexOf(";")))); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- localMessage.append(NLS.bind("\n - {0}", bundle)); //$NON-NLS-1$
+ localMessage.append(NLS.bind("\n - {0}", bundle)); //$NON-NLS-1$
}
}
}
if(localMessage.length() != 0) {
message.append(localMessage);
- message.append("\n");//$NON-NLS-1$
+ message.append("\n");//$NON-NLS-1$
}
}
StringBuffer errorMessage = new StringBuffer();
errorMessage.append(nb);
- errorMessage.append(" problems!");//$NON-NLS-1$
+ errorMessage.append(" problems!");//$NON-NLS-1$
errorMessage.append(message);
Assert.assertTrue(errorMessage.toString(), nb == 0);
}
@@ -416,6 +422,8 @@ public class BundlesTests { */
@Test
public void documentationFileTest() {
+ Assume.assumeTrue("It is a good practice to add a plugin.pdoc file to each plug-in", TestMode.isStrict());
+
String message = null;
int nb = 0;
for(final Bundle bundle : BundleTestsUtils.getPapyrusBundles()) {
@@ -439,8 +447,8 @@ public class BundlesTests { StringBuffer errorMessage = new StringBuffer();
StringBuffer warningMessage = new StringBuffer();
final Collection<String> possibleIds = new ArrayList<String>();
- possibleIds.add("ID");//$NON-NLS-1$
- possibleIds.add("PLUGIN_ID");//$NON-NLS-1$
+ possibleIds.add("ID");//$NON-NLS-1$
+ possibleIds.add("PLUGIN_ID");//$NON-NLS-1$
int nbError = 0;
int nbWarning = 0;
for(final Bundle current : BundleTestsUtils.getPapyrusBundles()) {
@@ -480,10 +488,10 @@ public class BundlesTests { finalErrorMessage.append(nbError);
finalErrorMessage.append(" problems! ");//$NON-NLS-1$
finalErrorMessage.append(errorMessage);
- Assert.assertTrue(finalErrorMessage.toString(), nbError == 0); //$NON-NLS-1$
+ Assert.assertTrue(finalErrorMessage.toString(), nbError == 0);
// Do not fail on warnings
- //Assert.assertTrue(nbWarning + "warning!" + warningMessage, nbWarning == 0);//$NON-NLS-1$
+ //Assert.assertTrue(nbWarning + "warning!" + warningMessage, nbWarning == 0);//$NON-NLS-1$
}
}
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/Bug323802.uml b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/Bug323802.uml index cccdefe7e34..6c61fbbcb57 100644 --- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/Bug323802.uml +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/Bug323802.uml @@ -1,5 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <uml:Model xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_-3u4cJW3EeOfoK3RwHm3pQ" name="bug323802"> + <packageImport xmi:id="_ycYPAKkTEeOizeYRjNFxJg"> + <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/> + </packageImport> <packagedElement xmi:type="uml:Class" xmi:id="_C3c2UJW4EeOfoK3RwHm3pQ" name="A" useCase="_0S-V8KYuEeO-ZNuEJamMWA"/> <packagedElement xmi:type="uml:UseCase" xmi:id="_0S-V8KYuEeO-ZNuEJamMWA" name="DoIt" subject="_C3c2UJW4EeOfoK3RwHm3pQ"/> </uml:Model> diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomainTest.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomainTest.java index 8cd46a7768c..808347fffcb 100644 --- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomainTest.java +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomainTest.java @@ -15,6 +15,7 @@ package org.eclipse.papyrus.infra.emf.readonly; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; @@ -34,11 +35,17 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.RollbackException; +import org.eclipse.emf.transaction.TransactionalCommandStack; import org.eclipse.emf.workspace.AbstractEMFOperation; import org.eclipse.emf.workspace.IWorkspaceCommandStack; import org.eclipse.papyrus.infra.core.resource.IRollbackStatus; +import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis; import org.eclipse.papyrus.infra.core.resource.RollbackStatus; +import org.eclipse.papyrus.infra.core.utils.TransactionHelper; +import org.eclipse.papyrus.junit.utils.rules.ProjectFixture; import org.eclipse.uml2.common.util.UML2Util; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Model; @@ -48,6 +55,7 @@ import org.eclipse.uml2.uml.UseCase; import org.eclipse.uml2.uml.resource.UMLResource; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import com.google.common.collect.Iterables; @@ -58,6 +66,9 @@ import com.google.common.collect.Iterables; */ public class PapyrusROTransactionalEditingDomainTest { + @Rule + public final ProjectFixture project = new ProjectFixture(); + private PapyrusROTransactionalEditingDomain fixture; private Model model; @@ -161,6 +172,56 @@ public class PapyrusROTransactionalEditingDomainTest { assertThat(Iterables.filter(status[0].getCausalObjects(), Type.class), hasItem(string[0])); } + /** + * Test that transaction options can be used to influence the domain's read-only check. + */ + @Test + public void testReadOnlyAxisTransactionOption() throws Exception { + // Make our model read-only on the filesystem + project.setReadOnly(model.eResource()); + TransactionalCommandStack stack = (TransactionalCommandStack)fixture.getCommandStack(); + + RecordingCommand cmd = new RecordingCommand(fixture) { + + @Override + protected void doExecute() { + UseCase doIt = (UseCase)model.getOwnedType("DoIt"); + assertThat(doIt, notNullValue()); + + // try to delete from the read-only model + EcoreUtil.remove(doIt); + } + }; + + try { + stack.execute(cmd, TransactionHelper.interactiveOption(false)); + fail("Should have thrown RollbackException."); + } catch (RollbackException e) { + // Success + } + + // The command was rolled back, so it wasn't stacked + assertThat(fixture.getCommandStack().canUndo(), is(false)); + + // The change was rolled back + UseCase doIt = (UseCase)model.getOwnedType("DoIt"); + assertThat(doIt, notNullValue()); + assertThat(doIt.getSubjects().size(), is(1)); + assertThat(doIt.getSubjects().get(0).getName(), is("A")); + + // Now, try again with only the discretionary read-only-ness enforced + stack.execute(cmd, TransactionHelper.readOnlyAxisOption(ReadOnlyAxis.DISCRETION)); + + // The command was *not* rolled back, so it *was* stacked + assertThat(fixture.getCommandStack().canUndo(), is(true)); + + // The change was *not* rolled back + assertThat(doIt.eResource(), nullValue()); + assertThat(doIt.eContainer(), nullValue()); + doIt = (UseCase)model.getOwnedType("DoIt"); + assertThat(doIt, nullValue()); + } + // // Test framework // @@ -169,13 +230,14 @@ public class PapyrusROTransactionalEditingDomainTest { public void createFixture() throws Exception { fixture = (PapyrusROTransactionalEditingDomain)new PapyrusROTransactionalEditingDomainProvider().createTransactionalEditingDomain(new ResourceSetImpl()); - Resource res = fixture.getResourceSet().createResource(URI.createURI("platform:/resource/bogus/model.uml")); + Resource res = fixture.getResourceSet().createResource(project.getURI("model.uml")); InputStream input = PapyrusROTransactionalEditingDomainTest.class.getResourceAsStream("Bug323802.uml"); try { res.load(input, null); } finally { input.close(); } + res.save(null); model = (Model)res.getContents().get(0); } diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManagerTest.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManagerTest.java index 585d7e5309f..584282cb6a8 100644 --- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManagerTest.java +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManagerTest.java @@ -14,20 +14,12 @@ package org.eclipse.papyrus.infra.emf.readonly; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; -import java.io.InputStream; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourceAttributes; -import org.eclipse.core.runtime.CoreException; import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis; +import org.eclipse.papyrus.infra.emf.readonly.tests.PapyrusModelSetFixture; +import org.eclipse.papyrus.junit.utils.rules.JavaResource; import org.eclipse.papyrus.junit.utils.rules.ProjectFixture; -import org.eclipse.uml2.uml.Model; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -37,16 +29,15 @@ import org.junit.Test; /** * Test suite for the {@link ReadOnlyManager} class. */ +@JavaResource("Bug323802.uml") public class ReadOnlyManagerTest { @Rule - public final ProjectFixture project = new ProjectFixture(); - - private ReadOnlyManager fixture; + public final PapyrusModelSetFixture domain = new PapyrusModelSetFixture(); - private TransactionalEditingDomain domain; + private final ProjectFixture project = domain.getProject(); - private Model model; + private ReadOnlyManager fixture; public ReadOnlyManagerTest() { super(); @@ -54,78 +45,47 @@ public class ReadOnlyManagerTest { @Test public void testIsReadOnlyEObject() { - setReadOnly(project.getFile(model.eResource().getURI())); - assertThat(fixture.isReadOnly(model).or(false), is(true)); + project.setReadOnly(domain.getModelResource()); + assertThat(fixture.isReadOnly(ReadOnlyAxis.anyAxis(), domain.getModel()).or(false), is(true)); } @Test public void testCanMakeWritableEObject() { - setReadOnly(project.getFile(model.eResource().getURI())); - assertThat(fixture.canMakeWritable(model).or(false), is(true)); + project.setReadOnly(domain.getModelResource()); + assertThat(fixture.canMakeWritable(ReadOnlyAxis.anyAxis(), domain.getModel()).or(false), is(true)); } @Test public void testAnyReadOnlyURIs() { - URI uri = model.eResource().getURI(); - setReadOnly(project.getFile(uri)); - assertThat(fixture.anyReadOnly(new URI[]{ uri }).or(false), is(true)); + URI uri = domain.getModelResourceURI(); + project.setReadOnly(domain.getModelResource()); + assertThat(fixture.anyReadOnly(ReadOnlyAxis.anyAxis(), new URI[]{ uri }).or(false), is(true)); } @Test public void testCanMakeWritableURIs() { - URI uri = model.eResource().getURI(); - setReadOnly(project.getFile(uri)); - assertThat(fixture.canMakeWritable(new URI[]{ uri }).or(false), is(true)); + URI uri = domain.getModelResourceURI(); + project.setReadOnly(domain.getModelResource()); + assertThat(fixture.canMakeWritable(ReadOnlyAxis.anyAxis(), new URI[]{ uri }).or(false), is(true)); } + @Test + public void testSashModelReadOnlyIfPermissionReadOnly() { + URI sashModelURI = URI.createPlatformPluginURI("org.eclipse.papyrus.foo/models/bogus.di", true); + assertThat(fixture.anyReadOnly(ReadOnlyAxis.anyAxis(), new URI[]{ sashModelURI }).or(false), is(true)); + } + // // Test framework // @Before public void createFixture() throws Exception { - domain = (PapyrusROTransactionalEditingDomain)new PapyrusROTransactionalEditingDomainProvider().createTransactionalEditingDomain(new ResourceSetImpl()); - fixture = new ReadOnlyManager(domain); - - Resource res = domain.getResourceSet().createResource(project.getURI("model.uml")); - InputStream input = ReadOnlyManagerTest.class.getResourceAsStream("Bug323802.uml"); - try { - res.load(input, null); - } finally { - input.close(); - } - res.save(null); // Make sure it exists - model = (Model)res.getContents().get(0); + fixture = new ReadOnlyManager(domain.getEditingDomain()); } @After public void destroyFixture() { - ResourceSet rset = domain.getResourceSet(); - - model = null; - - domain.dispose(); - domain = null; fixture = null; - - for(Resource next : rset.getResources()) { - next.unload(); - next.eAdapters().clear(); - } - - rset.getResources().clear(); - rset.eAdapters().clear(); - } - - void setReadOnly(IFile file) { - ResourceAttributes attr = file.getResourceAttributes(); - attr.setReadOnly(true); - - try { - file.setResourceAttributes(attr); - } catch (CoreException e) { - e.getLocalizedMessage(); - fail("Failed to make workspace file read-only: " + e.getLocalizedMessage()); - } } } diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyTesterTest.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyTesterTest.java new file mode 100644 index 00000000000..7b1951eea28 --- /dev/null +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyTesterTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2014 CEA and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.emf.readonly; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.eclipse.papyrus.infra.emf.readonly.tests.PapyrusROEditingDomainFixture; +import org.eclipse.papyrus.junit.utils.rules.JavaResource; +import org.eclipse.papyrus.junit.utils.rules.ProjectFixture; +import org.eclipse.uml2.uml.Type; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import com.google.common.collect.Iterators; + + +/** + * This is the ReadOnlyTesterTest type. Enjoy. + */ +@JavaResource("Bug323802.uml") +public class ReadOnlyTesterTest { + + @Rule + public final PapyrusROEditingDomainFixture domain = new PapyrusROEditingDomainFixture(); + + private final ProjectFixture project = domain.getProject(); + + private ReadOnlyTester fixture; + + @Test + public void testAsBoolean() { + assertThat(fixture.asBoolean(true), is(true)); + assertThat(fixture.asBoolean(false), is(false)); + assertThat(fixture.asBoolean("hello"), is(true)); + assertThat(fixture.asBoolean(null), is(true)); + } + + @Test + public void testIsReadOnly() { + assertThat(fixture.testIsReadOnly(Iterators.singletonIterator(domain.getModel()), false), is(true)); + + Type string = domain.getModel().getImportedPackages().get(0).getOwnedType("String"); + assertThat(fixture.testIsReadOnly(Iterators.singletonIterator(string), true), is(true)); + + project.setReadOnly(domain.getModelResource()); + assertThat(fixture.testIsReadOnly(Iterators.singletonIterator(domain.getModel()), true), is(true)); + } + + @Test + public void testCanMakeWritable() { + // If it's already writable, well, then it's trivially easy to make it writable + assertThat(fixture.canMakeWritable(Iterators.singletonIterator(domain.getModel()), true), is(true)); + + Type string = domain.getModel().getImportedPackages().get(0).getOwnedType("String"); + assertThat(fixture.canMakeWritable(Iterators.singletonIterator(string), true), is(false)); + + project.setReadOnly(domain.getModelResource()); + assertThat(fixture.canMakeWritable(Iterators.singletonIterator(domain.getModel()), true), is(true)); + } + + // + // Test framework + // + + @Before + public void createFixture() throws Exception { + fixture = new ReadOnlyTester(); + } + + @After + public void destroyFixture() { + fixture = null; + } + +} diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandlerTest.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandlerTest.java index 6f638990388..b8bd67a125b 100644 --- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandlerTest.java +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandlerTest.java @@ -12,6 +12,7 @@ */ package org.eclipse.papyrus.infra.emf.readonly; +import static org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis.discretionAxes; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; @@ -124,8 +125,8 @@ public class ReferencedModelReadOnlyHandlerTest { public void testCrossReferencedWorkspaceModelElementsMadeWritable() { Property ssn = person.getAttribute("ssn", null); assumeReadOnly(ssn.getType()); - assertThat(fixture.canMakeWritable(ssn.getType()).or(false), is(true)); - assertThat(fixture.makeWritable(ssn.getType()).or(false), is(true)); + assertThat(fixture.canMakeWritable(discretionAxes(), ssn.getType()).or(false), is(true)); + assertThat(fixture.makeWritable(discretionAxes(), ssn.getType()).or(false), is(true)); assertNotReadOnly(ssn.getType()); assertNotReadOnly(person.getAttribute("registered", null).getType()); } @@ -174,8 +175,8 @@ public class ReferencedModelReadOnlyHandlerTest { public void testObjectURIsWithFragment() { Property ssn = person.getAttribute("ssn", null); URI uri = EcoreUtil.getURI(ssn); - assertThat(fixture.anyReadOnly(new URI[]{ uri }).or(false), is(false)); - assertThat(fixture.canMakeWritable(new URI[]{ uri }).or(true), is(false)); + assertThat(fixture.anyReadOnly(discretionAxes(), new URI[]{ uri }).or(false), is(false)); + assertThat(fixture.canMakeWritable(discretionAxes(), new URI[]{ uri }).or(true), is(false)); } // @@ -310,17 +311,17 @@ public class ReferencedModelReadOnlyHandlerTest { } void assertReadOnly(EObject object) { - Optional<Boolean> status = fixture.isReadOnly(object); + Optional<Boolean> status = fixture.isReadOnly(discretionAxes(), object); assertThat("Not read-only", status.or(false), is(true)); } void assertNotReadOnly(EObject object) { - Optional<Boolean> status = fixture.isReadOnly(object); + Optional<Boolean> status = fixture.isReadOnly(discretionAxes(), object); assertThat("Should not be either read-only or definitely writable", status.isPresent(), is(false)); } void assumeReadOnly(EObject object) { - Optional<Boolean> status = fixture.isReadOnly(object); + Optional<Boolean> status = fixture.isReadOnly(discretionAxes(), object); assumeThat("Not read-only", status.or(false), is(true)); } diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/AllTests.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/AllTests.java index b7d564ad280..12d2f83dd10 100644 --- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/AllTests.java +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/AllTests.java @@ -14,6 +14,7 @@ package org.eclipse.papyrus.infra.emf.readonly.tests; import org.eclipse.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomainTest; import org.eclipse.papyrus.infra.emf.readonly.ReadOnlyManagerTest; +import org.eclipse.papyrus.infra.emf.readonly.ReadOnlyTesterTest; import org.eclipse.papyrus.infra.emf.readonly.ReferencedModelReadOnlyHandlerTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -25,7 +26,7 @@ import org.junit.runners.Suite.SuiteClasses; */ @RunWith(Suite.class) @SuiteClasses({ -PapyrusROTransactionalEditingDomainTest.class, ReferencedModelReadOnlyHandlerTest.class, ReadOnlyManagerTest.class +PapyrusROTransactionalEditingDomainTest.class, ReferencedModelReadOnlyHandlerTest.class, ReadOnlyManagerTest.class, ReadOnlyTesterTest.class }) public class AllTests { diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/PapyrusModelSetFixture.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/PapyrusModelSetFixture.java new file mode 100644 index 00000000000..6f96df8d47e --- /dev/null +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/PapyrusModelSetFixture.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014 CEA and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.emf.readonly.tests; + +import static org.junit.Assert.fail; + +import java.util.Collections; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.resource.EditingDomainServiceFactory; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor.ServiceTypeKind; +import org.eclipse.papyrus.infra.core.services.ServiceStartKind; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomain; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceInitializerService; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet; +import org.eclipse.papyrus.junit.utils.rules.AbstractModelFixture; +import org.junit.runner.Description; + + +/** + * This is the PapyrusModelSetFixture type. Enjoy. + */ +public class PapyrusModelSetFixture extends AbstractModelFixture<PapyrusROTransactionalEditingDomain> { + + public PapyrusModelSetFixture() { + super(); + } + + protected PapyrusROTransactionalEditingDomain createEditingDomain() { + try { + ServicesRegistry services = createServiceRegistry(); + return (PapyrusROTransactionalEditingDomain)services.getService(ModelSet.class).getTransactionalEditingDomain(); + } catch (Exception e) { + e.printStackTrace(); + fail("Failed to initialize service registry and/or editing domain: " + e.getLocalizedMessage()); + return null; // unreachable + } + } + + @Override + protected void finished(Description description) { + ResourceSet rset = getEditingDomain().getResourceSet(); + + try { + ServicesRegistry services = ServiceUtilsForResourceSet.getInstance().getServiceRegistry(rset); + services.disposeRegistry(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + super.finished(description); + } + } + + protected ServicesRegistry createServiceRegistry() throws Exception { + ServicesRegistry result = new ServicesRegistry(); + result.add(ModelSet.class, 10, new ModelSet()); + result.add(ServiceUtilsForResourceInitializerService.class, 10, new ServiceUtilsForResourceInitializerService()); + + ServiceDescriptor desc = new ServiceDescriptor(TransactionalEditingDomain.class, EditingDomainServiceFactory.class.getName(), ServiceStartKind.STARTUP, 10, Collections.singletonList(ModelSet.class.getName())); + desc.setServiceTypeKind(ServiceTypeKind.serviceFactory); + desc.setClassBundleID(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID); + result.add(desc); + + result.startRegistry(); + + return result; + } +} diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/PapyrusROEditingDomainFixture.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/PapyrusROEditingDomainFixture.java new file mode 100644 index 00000000000..3f1db0e0338 --- /dev/null +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly.tests/src/org/eclipse/papyrus/infra/emf/readonly/tests/PapyrusROEditingDomainFixture.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 CEA and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.emf.readonly.tests; + +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomain; +import org.eclipse.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomainProvider; +import org.eclipse.papyrus.junit.utils.rules.AbstractModelFixture; + + +/** + * This is the PapyrusROEditingDomainFixture type. Enjoy. + */ +public class PapyrusROEditingDomainFixture extends AbstractModelFixture<PapyrusROTransactionalEditingDomain> { + + public PapyrusROEditingDomainFixture() { + super(); + } + + protected PapyrusROTransactionalEditingDomain createEditingDomain() { + return (PapyrusROTransactionalEditingDomain)new PapyrusROTransactionalEditingDomainProvider().createTransactionalEditingDomain(new ResourceSetImpl()); + } +} diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF index 915af9d0366..fa967ff57b5 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.infra.emf.appearance;bundle-version="1.0.0",
org.junit;bundle-version="4.10.0",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
- org.eclipse.core.databinding;bundle-version="1.4.1"
+ org.eclipse.core.databinding;bundle-version="1.4.1",
+ org.eclipse.papyrus.junit.utils;bundle-version="1.0.0"
Export-Package: org.eclipse.papyrus.infra.gmfdiag.css.tests,
org.eclipse.papyrus.infra.gmfdiag.css.tests.tests
Bundle-Vendor: Eclipse Modeling Project
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java index 0f43da39e6d..d2d3e4b59c6 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java @@ -36,11 +36,12 @@ import org.eclipse.papyrus.infra.gmfdiag.css.helper.CSSHelper; import org.eclipse.papyrus.infra.gmfdiag.css.helper.ResetStyleHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
import org.eclipse.papyrus.infra.gmfdiag.css.tests.Activator;
+import org.eclipse.papyrus.junit.utils.TestMode;
import org.eclipse.uml2.uml.NamedElement;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -111,9 +112,8 @@ public class CSSCompartmentsTests { /* Test Enumeration1 */
@Test
- //Currently fails. The "case insensitive" attributes are not supported by Eclipse E4 CSS
- @Ignore("The 'case insensitive' attributes are not supported by Eclipse E4 CSS")
public void testCaseInsensitiveForEnumeration() {
+ Assume.assumeTrue("The 'case insensitive' attributes are not supported by Eclipse E4 CSS", TestMode.isStrict());
Shape enumeration = findShape("Enumeration1");
BasicCompartment compartment = findCompartment(enumeration, ENUMERATION_LITERAL_COMPARTMENT_TYPE);
@@ -121,7 +121,6 @@ public class CSSCompartmentsTests { }
/* Test Interface 1 and Interface 2 */
- //Currently fails. The interface compartments are not defined in the NotationTypesMap
@Test
public void testAttributeCompartmentForInterface() {
Shape interface1 = findShape("Interface1");
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/TestMode.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/TestMode.java new file mode 100644 index 00000000000..1cfcfb95686 --- /dev/null +++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/TestMode.java @@ -0,0 +1,42 @@ +/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.junit.utils;
+
+
+
+/**
+ * This class is used to configure a test job. In strict mode, all tests are executed.
+ * When the strict mode is disabled, the tests which are known to be failing are ignored.
+ *
+ * This is useful for test-driven development, when tests are implemented before the feature:
+ * we can still have "green builds" (by ignoring these specific tests) and test for non-regression.
+ *
+ * Usage: When a test is known to be failing, add: Assume.assumeTrue("Why the test is disabled", TestMode.isStrict());
+ *
+ * The test will be run only in strict mode, and ignored during non-regression testing
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class TestMode {
+
+ private static boolean strictMode = false;
+
+ public static boolean isStrict() {
+ return strictMode;
+ }
+
+ public static void setStrict(boolean strictMode) {
+ TestMode.strictMode = strictMode;
+ }
+
+}
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java new file mode 100644 index 00000000000..25829351a1f --- /dev/null +++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2014 CEA and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.junit.utils.rules; + +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; + +import java.io.InputStream; +import java.lang.reflect.Method; +import java.net.URL; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.junit.utils.rules.ProjectFixture; +import org.eclipse.uml2.uml.Model; +import org.junit.Rule; +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + + +/** + * Abstract superclass for JUnit test fixture rules that provide: + * <ul> + * <li>an editing domain of some kind (subclasses must create it)</li> + * <li>a test project in the workspace, exposed via a nested {@link ProjectFixture} rule</li> + * <li>a test {@link Model} loaded from a resource in the plug-in and saved as <tt>model.uml</tt> in the test project. This model is specified using + * an annotation on the test, as described below</li> + * </ul> + * The test model template to load into the editing domain and project must be specified by one of the following annotations: + * <ul> + * <li>{@link JavaResource @JavaResource}: specifies the path to a resource to be loaded from the test class's classpath, using the + * {@link Class#getResource(String)} API</li> + * <li>{@link PluginResource @PluginResource}: specifies a path relative to the root of the OSGi bundle containing the test class, to be loaded via + * the {@link Bundle#getEntry(String)} API</li> + * </ul> + * The resource annotation may be specified either on the test method, in which case it applies to that test case, or on the test + * class, in which case it applies to all test methods in the class that do not have a resource annotation of their own (method + * annotations take precedence over the class annotation). + */ +public abstract class AbstractModelFixture<T extends EditingDomain> extends TestWatcher { + + private final ProjectFixture project = new ProjectFixture(); + + private T domain; + + private Model model; + + public AbstractModelFixture() { + super(); + } + + public Statement apply(Statement base, Description description) { + // Wrap myself in the project rule so that the project exists when I start + Statement result = super.apply(base, description); + result = project.apply(result, description); + return result; + } + + /** + * 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() { + return project; + } + + public T getEditingDomain() { + return domain; + } + + /** + * 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 Model getModel() { + return model; + } + + public Resource getModelResource() { + return getModel().eResource(); + } + + public URI getModelResourceURI() { + return getModelResource().getURI(); + } + + public URI getModelURI() { + return EcoreUtil.getURI(getModel()); + } + + protected abstract T createEditingDomain(); + + @Override + protected void starting(Description description) { + domain = createEditingDomain(); + + Resource res = domain.getResourceSet().createResource(project.getURI("model.uml")); + + try { + InputStream input = getResourceURL(description).openStream(); + try { + res.load(input, null); + } finally { + input.close(); + } + res.save(null); // Make sure it exists + } catch (Exception e) { + e.printStackTrace(); + fail("Failed to load test resource: " + e.getLocalizedMessage()); + } + + model = (Model)res.getContents().get(0); + } + + @Override + protected void finished(Description description) { + ResourceSet rset = domain.getResourceSet(); + + model = null; + + if(domain instanceof TransactionalEditingDomain) { + ((TransactionalEditingDomain)domain).dispose(); + } + domain = null; + + for(Resource next : rset.getResources()) { + next.unload(); + next.eAdapters().clear(); + } + + rset.getResources().clear(); + rset.eAdapters().clear(); + } + + protected URL getResourceURL(Description description) { + URL result = null; + + Class<?> testClass = description.getTestClass(); + + Method testMethod = null; + try { + testMethod = testClass.getDeclaredMethod(description.getMethodName()); + } catch (Exception e) { + e.printStackTrace(); + fail("Could not access test method via JUnit framework."); + } + + if(testMethod.isAnnotationPresent(JavaResource.class)) { + result = testClass.getResource(testMethod.getAnnotation(JavaResource.class).value()); + } else if(testMethod.isAnnotationPresent(PluginResource.class)) { + result = FrameworkUtil.getBundle(testClass).getEntry(testMethod.getAnnotation(PluginResource.class).value()); + } else { + // The class must have an annotation + if(testClass.isAnnotationPresent(JavaResource.class)) { + result = testClass.getResource(testClass.getAnnotation(JavaResource.class).value()); + } else if(testClass.isAnnotationPresent(PluginResource.class)) { + result = FrameworkUtil.getBundle(testClass).getEntry(testClass.getAnnotation(PluginResource.class).value()); + } + } + + assertThat("No JavaResource or PluginResource annotation found on test.", result, notNullValue()); + + return result; + } +} diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/JavaResource.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/JavaResource.java new file mode 100644 index 00000000000..d9aa6b14340 --- /dev/null +++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/JavaResource.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 CEA and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.junit.utils.rules; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Annotation indicating the classpath-relative path to a resource from which to load the test model of an {@link AbstractModelFixture}. + * + * @see AbstractModelFixture + * @see PluginResource + */ +@Target({ ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface JavaResource { + + String value(); +} diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PluginResource.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PluginResource.java new file mode 100644 index 00000000000..dc1e7e6eacd --- /dev/null +++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PluginResource.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 CEA and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.junit.utils.rules; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Annotation indicating the bundle-relative path to a resource from which to load the test model of an {@link AbstractModelFixture}. + * + * @see AbstractModelFixture + * @see JavaResource + */ +@Target({ ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface PluginResource { + + String value(); +} diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ProjectFixture.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ProjectFixture.java index f808abda246..1cdd9f45c72 100644 --- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ProjectFixture.java +++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ProjectFixture.java @@ -12,6 +12,10 @@ */ package org.eclipse.papyrus.junit.utils.rules; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -22,6 +26,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; @@ -122,4 +128,37 @@ public class ProjectFixture implements TestRule { resource.setResourceAttributes(attr); } } + + public void setReadOnly(String projectRelativePath) { + setReadOnly(new Path(projectRelativePath)); + } + + public void setReadOnly(IPath projectRelativePath) { + setReadOnly(project.findMember(projectRelativePath)); + } + + public void setReadOnly(Resource resource) { + IFile file = WorkspaceSynchronizer.getFile(resource); + assertThat("Cannot set non-workspace resource read-only", file, notNullValue()); + setReadOnly(file); + } + + public void setReadOnly(IResource resource) { + setReadOnly(resource, true); + } + + public void setReadOnly(IResource resource, boolean readOnly) { + ResourceAttributes attr = resource.getResourceAttributes(); + + if(attr.isReadOnly() != readOnly) { + attr.setReadOnly(readOnly); + + try { + resource.setResourceAttributes(attr); + } catch (CoreException e) { + e.getLocalizedMessage(); + fail(String.format("Failed to make workspace resource %s: %s", readOnly ? "read-only" : "writable", e.getLocalizedMessage())); + } + } + } } diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/META-INF/MANIFEST.MF index 709baa3a4ca..99d55f5daec 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/META-INF/MANIFEST.MF @@ -8,7 +8,8 @@ Require-Bundle: org.junit;bundle-version="4.8.1", org.eclipse.ui.workbench;bundle-version="3.103.1",
org.eclipse.ui.ide;bundle-version="3.8.1",
org.eclipse.jface;bundle-version="3.8.101",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.0"
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
+ com.google.guava;bundle-version="11.0.0"
Bundle-Vendor: %providerName
Bundle-Version: 1.0.0.qualifier
Bundle-Name: %pluginName
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestCreateModelWizard.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestCreateModelWizard.java index 2dfa3809df2..e525636b733 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestCreateModelWizard.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestCreateModelWizard.java @@ -1,3 +1,16 @@ +/***************************************************************************** + * Copyright (c) 2013, 2014 LIFL, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * LIFL - Initial API and implementation + * CEA LIST - Update tests and re-integrate into automation suite + * + *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.wizards; import org.eclipse.papyrus.uml.diagram.profile.CreateProfileModelCommand; @@ -32,7 +45,7 @@ public class TestCreateModelWizard extends TestNewModelWizardBase { @Test public void testDiagramFileExtentionLabel() { - final String expectedExtension = "test.xxx"; + final String expectedExtension = "di"; // the extension is always *.di IWorkbenchWizard wizard = new InitModelWizard() { @Override @@ -48,8 +61,8 @@ public class TestCreateModelWizard extends TestNewModelWizardBase { }; initWizardDialog(wizard); - NewModelFilePage page = (NewModelFilePage)wizard.getPages()[0]; - //assertEquals(expectedExtension, page.getFileExtension()); + NewModelFilePage page = getPage(wizard, NewModelFilePage.class); + assertEquals(expectedExtension, page.getFileExtension()); } @Test @@ -69,9 +82,12 @@ public class TestCreateModelWizard extends TestNewModelWizardBase { }; + // ensure that the dialog would create a profile + settings.saveDefaultDiagramCategory(new String[] {"profile"}); + initWizardDialog(wizard); - // String actual = wizard.getDiagramFileExtension(); - // assertEquals(expectedExtension, actual); + NewModelFilePage page = getPage(wizard, NewModelFilePage.class); + assertEquals(expectedExtension, page.getFileExtension()); } @Test @@ -92,8 +108,8 @@ public class TestCreateModelWizard extends TestNewModelWizardBase { }; initWizardDialog(wizard); - // String actual = wizard.getDiagramFileExtension(); - // assertEquals(expectedExtension, actual); + NewModelFilePage page = getPage(wizard, NewModelFilePage.class); + assertEquals(expectedExtension, page.getFileExtension()); } } diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestCreateSysMLModelWizard.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestCreateSysMLModelWizard.java index 93885ee3d2d..cf8de01ccac 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestCreateSysMLModelWizard.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestCreateSysMLModelWizard.java @@ -1,3 +1,16 @@ +/***************************************************************************** + * Copyright (c) 2013, 2014 LIFL, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * LIFL - Initial API and implementation + * CEA LIST - Update tests and re-integrate into automation suite + * + *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.wizards; import org.eclipse.papyrus.sysml.diagram.common.commands.CreateSysMLModelCommand; @@ -55,8 +68,8 @@ public class TestCreateSysMLModelWizard extends TestNewModelWizardBase { }; initWizardDialog(wizard); - // String actual = wizard.getDiagramFileExtension(); - // assertEquals(expectedExtension, actual); + NewModelFilePage page = getPage(wizard, NewModelFilePage.class); + assertEquals(expectedExtension, page.getFileExtension()); } } diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestInitModelWizard.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestInitModelWizard.java index 620076b8710..fcb9a7c7323 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestInitModelWizard.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestInitModelWizard.java @@ -1,6 +1,18 @@ +/***************************************************************************** + * Copyright (c) 2013, 2014 LIFL, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * LIFL - Initial API and implementation + * CEA LIST - Update tests and re-integrate into automation suite + * + *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.wizards; -import org.eclipse.core.resources.IFile; import org.eclipse.papyrus.uml.diagram.profile.CreateProfileModelCommand; import org.eclipse.papyrus.uml.diagram.wizards.pages.NewModelFilePage; import org.eclipse.papyrus.uml.diagram.wizards.pages.SelectDiagramCategoryPage; @@ -29,13 +41,9 @@ public class TestInitModelWizard extends TestNewModelWizardBase { return new String[]{ "uml" }; } - // @Override - // public String getDiagramFileExtension(String categoryId, String defaultExtension) { - // return "test.uml"; - // } - - protected String getDiagramFileName(IFile domainModel) { - return "test.uml"; + @Override + public String getDiagramFileExtension(String categoryId, String defaultExtension) { + return "uml"; } }; @@ -43,7 +51,7 @@ public class TestInitModelWizard extends TestNewModelWizardBase { @Test public void testDiagramFileExtentionLabel() { - final String expectedExtension = "test.xxx"; + final String expectedExtension = "di"; // the extension is always *.di IWorkbenchWizard wizard = new InitModelWizard() { @Override @@ -51,14 +59,15 @@ public class TestInitModelWizard extends TestNewModelWizardBase { return isCreateFromExistingModel; } - protected String getDiagramFileName(IFile domainModel) { + @Override + public String getDiagramFileExtension(String categoryId, String defaultExtension) { return "tanya"; // arbitrary extension to avoid NPE } }; initWizardDialog(wizard); - NewModelFilePage page = (NewModelFilePage)wizard.getPages()[0]; + NewModelFilePage page = getPage(wizard, NewModelFilePage.class); assertEquals(expectedExtension, page.getFileExtension()); } @@ -73,7 +82,7 @@ public class TestInitModelWizard extends TestNewModelWizardBase { @Test public void testDiagramFileExtenstionForUML() { // 333849 - [Wizard] Init Diagram: Respect file extension of the UML model - final String expectedExtension = "di"; + final String expectedExtension = "di"; // init-from-existing always uses this, even for profiles InitModelWizard wizard = new InitModelWizard() { @Override @@ -82,8 +91,9 @@ public class TestInitModelWizard extends TestNewModelWizardBase { } - protected String getDiagramFileName(IFile domainModel) { - return "tanya"; // arbitrary extension to avoid NPE + @Override + public String getDiagramFileExtension(String categoryId, String defaultExtension) { + return "profile.di"; // arbitrary extension to avoid NPE } @Override @@ -93,9 +103,12 @@ public class TestInitModelWizard extends TestNewModelWizardBase { }; + // ensure that the dialog would create a profile + settings.saveDefaultDiagramCategory(new String[] {"profile"}); + initWizardDialog(wizard); - // String actual = wizard.getDiagramFileExtension(); - // assertEquals(expectedExtension, actual); + NewModelFilePage page = getPage(wizard, NewModelFilePage.class); + assertEquals(expectedExtension, page.getFileExtension()); } diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestNewModelWizardBase.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestNewModelWizardBase.java index 7b9ea500023..6346f889d1e 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestNewModelWizardBase.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestNewModelWizardBase.java @@ -1,30 +1,72 @@ +/***************************************************************************** + * Copyright (c) 2013, 2014 LIFL, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * LIFL - Initial API and implementation + * CEA LIST - Update tests and re-integrate into automation suite + * + *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.wizards; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.Arrays; + import junit.framework.TestCase; +import org.eclipse.jface.dialogs.DialogSettings; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.layout.PixelConverter; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.papyrus.uml.diagram.wizards.pages.SelectStorageProviderPage; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchWizard; +import org.junit.After; import org.junit.Before; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; + public abstract class TestNewModelWizardBase extends TestCase { - protected static final IStructuredSelection EMPTY_SELECTION = new StructuredSelection(); + protected static final IStructuredSelection EMPTY_SELECTION = StructuredSelection.EMPTY; + protected SettingsHelper settings; + protected abstract IWorkbenchWizard createWizard(); + private String settingsBackup; + @Override @Before - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); + + initSettingsHelper(); + } + + @Override + @After + public void tearDown() throws Exception { + try { + restoreDialogSettings(); + } finally { + super.tearDown(); + } } protected IStructuredSelection getSelection() { @@ -61,14 +103,28 @@ public abstract class TestNewModelWizardBase extends TestCase { return Activator.getDefault().getWorkbench(); } + protected <P extends IWizardPage> P getPage(IWizard wizard, Class<P> pageType) { + P result = Iterables.find(Iterables.filter(Arrays.asList(wizard.getPages()), pageType), Predicates.alwaysTrue(), null); + assertNotNull("Did not find page of type " + pageType.getSimpleName(), result); + return result; + } + protected void testOrderOfPages(IWorkbenchWizard wizard, Class<?>[] expectedPages) { + Class<?> optionalInitialPage = SelectStorageProviderPage.class; + IWizardPage next = wizard.getPages()[0]; for(int i = 0; i < expectedPages.length; i++) { String isNullMessageFormat = "page %s expected, but actual is: null"; assertNotNull(String.format(isNullMessageFormat, i), next); - testPageInstanceOf(next, expectedPages[i], i); - + if((optionalInitialPage != null) && (i == 0) && optionalInitialPage.isInstance(next)) { + // we have tested the optional initial page; don't do it again + optionalInitialPage = null; + i--; + } else { + testPageInstanceOf(next, expectedPages[i], i); + } + next = next.getNextPage(); } String noMorePagesExpectedMessageFormat = "page %s is not expected"; @@ -81,5 +137,39 @@ public abstract class TestNewModelWizardBase extends TestCase { assertTrue(String.format(wrongClassFormat, index, next.getClass()), expectedClass.isInstance(next)); } - + private void initSettingsHelper() { + IDialogSettings workbenchSettings = Activator.getDefault().getDialogSettings(); + IDialogSettings settings = workbenchSettings.getSection(CreateModelWizard.NEW_MODEL_SETTINGS); + if(settings == null) { + settings = workbenchSettings.addNewSection(CreateModelWizard.NEW_MODEL_SETTINGS); + } + this.settings = new SettingsHelper(settings); + + StringWriter backupWriter = new StringWriter(); + try { + settings.save(backupWriter); + } catch (IOException e) { + e.printStackTrace(); + fail("Impossible IO exception on string writer: " + e.getLocalizedMessage()); + } + this.settingsBackup = backupWriter.toString(); + } + + private void restoreDialogSettings() { + if(settingsBackup != null) { + IDialogSettings workbenchSettings = Activator.getDefault().getDialogSettings(); + IDialogSettings settings = workbenchSettings.getSection(CreateModelWizard.NEW_MODEL_SETTINGS); + if(settings != null) { + ((DialogSettings)workbenchSettings).removeSection(settings); + settings = workbenchSettings.addNewSection(settings.getName()); + + try { + settings.load(new StringReader(settingsBackup)); + } catch (IOException e) { + e.printStackTrace(); + fail("Impossible IO exception on string read: " + e.getLocalizedMessage()); + } + } + } + } } diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestNewProjectWizard.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestNewProjectWizard.java index 065cf35df8f..7e4ffca0b9e 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestNewProjectWizard.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards.tests/test/org/eclipse/papyrus/uml/diagram/wizards/TestNewProjectWizard.java @@ -1,3 +1,16 @@ +/***************************************************************************** + * Copyright (c) 2013, 2014 LIFL, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * LIFL - Initial API and implementation + * CEA LIST - Update tests and re-integrate into automation suite + * + *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.wizards; import org.eclipse.papyrus.uml.diagram.wizards.pages.SelectDiagramCategoryPage; diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/DependencyManagementTest.java b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/DependencyManagementTest.java index 8badbb23d40..36d89cc8e52 100644 --- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/DependencyManagementTest.java +++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/DependencyManagementTest.java @@ -1,6 +1,6 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,6 +23,7 @@ import org.eclipse.papyrus.infra.emf.resource.DependencyManagementHelper; import org.eclipse.papyrus.junit.utils.ModelUtils;
import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils;
import org.eclipse.papyrus.junit.utils.ProjectUtils;
+import org.eclipse.papyrus.junit.utils.TestMode;
import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest;
import org.eclipse.papyrus.uml.tools.tests.Activator;
import org.eclipse.uml2.uml.Model;
@@ -31,6 +32,7 @@ import org.eclipse.uml2.uml.Profile; import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.util.UMLUtil;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Ignore;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -106,12 +108,12 @@ public class DependencyManagementTest extends AbstractEditorTest { }
//Switch from two different versions of a profile
- //Problem: !!Stereotypes are not references!! They are instances. After the switch, the new
+ //Problem: !!Stereotypes are not references!! They are instances. After the switch, the new
//profile is correctly applied, but the applied Stereotypes are the ones from the initial Profile
- //
- //Current state: FAILS
@Test
public void testSwitchProfilesWithStereotypes() throws Exception {
+ Assume.assumeTrue("Bug 408491 is not yet implemented", TestMode.isStrict());
+
IProject project = ProjectUtils.createProject("dependencyManagement.switchProfiles");
PapyrusProjectUtils.copyPapyrusModel(project, getBundle(), getSourcePath(), "profiles/model");
PapyrusProjectUtils.copyPapyrusModel(project, getBundle(), getSourcePath(), "profiles/p1/profile1.profile");
@@ -143,7 +145,7 @@ public class DependencyManagementTest extends AbstractEditorTest { });
- //After the transformation, stereotypes from the target profile must be applied
+ //After the transformation, stereotypes from the target profile must be applied
checkAppliedProfileAndStereotypes(modelSet, rootModel, targetProfileURI);
//Save, reload, and check again
|