Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/RemoveStereotypeApplicationPseudoConflictTest.java71
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/left.uml10
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/origin.uml13
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/right.uml10
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java12
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java8
7 files changed, 119 insertions, 8 deletions
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF
index 7921486f1..61b3200bf 100644
--- a/plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF
@@ -27,7 +27,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.uml2.uml.edit;bundle-version="5.0.0";visibility:=reexport,
org.eclipse.uml2.common.edit;visibility:=reexport,
org.eclipse.emf.compare.uml2.edit,
- org.eclipse.emf.compare.edit
+ org.eclipse.emf.compare.edit,
+ org.eclipse.emf.compare.ide.ui.tests.framework
Bundle-ActivationPolicy: lazy
Import-Package: com.google.common.base;version="[11.0.0,16.0.0)",
com.google.common.collect;version="[11.0.0,16.0.0)"
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/RemoveStereotypeApplicationPseudoConflictTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/RemoveStereotypeApplicationPseudoConflictTest.java
new file mode 100644
index 000000000..1714b0561
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/RemoveStereotypeApplicationPseudoConflictTest.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Services GmbH 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:
+ * Martin Fleck - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.uml2.tests.resourceattachment.stereotype;
+
+import static com.google.common.collect.Iterables.tryFind;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Conflict;
+import org.eclipse.emf.compare.ConflictKind;
+import org.eclipse.emf.compare.ide.ui.tests.framework.RuntimeTestRunner;
+import org.eclipse.emf.compare.ide.ui.tests.framework.annotations.Compare;
+import org.junit.runner.RunWith;
+
+/**
+ * This test makes sure that bug 493527 is fixed. The bug reports that when we use the default conflict
+ * detector a stereotype application is removed on both sides, a REAL conflict is produced instead of PSEUDO
+ * conflicts. The bug does not occur with the scalable conflict detector (MatchBasedConflictDetector).
+ *
+ * @author Martin Fleck <mfleck@eclipsesource.com>
+ */
+@RunWith(RuntimeTestRunner.class)
+public class RemoveStereotypeApplicationPseudoConflictTest {
+
+ private static Predicate<? super Conflict> hasConflict(final ConflictKind... kinds) {
+ return new Predicate<Conflict>() {
+ public boolean apply(Conflict input) {
+ return input != null && Arrays.asList(kinds).contains(input.getKind());
+ }
+ };
+ }
+
+ /**
+ * Checks whether no REAL conflicts are created when the same stereotype application is removed on both
+ * sides. In the origin model the UML compare testing profile is used and a stereotype is applied on a
+ * single class. In the left model and the right model the stereotype application is removed but the
+ * profile application remains intact. With no further changes, the left and right model are equal and the
+ * comparison yields the same set of differences when comparing the models to the origin: ReferenceChange
+ * for the stereotype application base class (unset), ResourceAttachment deletion for the applied
+ * stereotype and a StereotypeApplicationChange deletion refined by the previous two differences.
+ * Therefore, any conflicts that are detected between the left and right model should only be PSEUDO
+ * conflicts.
+ *
+ * @throws IOException
+ * Thrown if we could not access or find the input data.
+ */
+ @Compare(left = "data/left.uml", right = "data/right.uml", ancestor = "data/origin.uml")
+ public void testPseudoConflictForStereotypeRemoval(Comparison comparison) throws IOException {
+ final EList<Conflict> conflicts = comparison.getConflicts();
+ final Optional<Conflict> realConflict = tryFind(conflicts, hasConflict(ConflictKind.REAL));
+
+ assertEquals(2, conflicts.size());
+ assertFalse(realConflict.isPresent());
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/left.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/left.uml
new file mode 100644
index 000000000..616c58061
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/left.uml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_qd69wBdtEeag8pemRXzpyg" name="MyModel">
+ <packagedElement xmi:type="uml:Class" xmi:id="_rIasQBdtEeag8pemRXzpyg" name="MyClass"/>
+ <profileApplication xmi:id="_XfvAABduEeag8pemRXzpyg">
+ <eAnnotations xmi:id="_XfvnEBduEeag8pemRXzpyg" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#//uml2comparetestprofile"/>
+ </eAnnotations>
+ <appliedProfile href="platform:/plugin/org.eclipse.emf.compare.uml2.tests/model/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/>
+ </profileApplication>
+</uml:Model>
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/origin.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/origin.uml
new file mode 100644
index 000000000..b5ccb1f7b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/origin.uml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#//uml2comparetestprofile">
+ <uml:Model xmi:id="_qd69wBdtEeag8pemRXzpyg" name="MyModel">
+ <packagedElement xmi:type="uml:Class" xmi:id="_rIasQBdtEeag8pemRXzpyg" name="MyClass"/>
+ <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_XfvAABduEeag8pemRXzpyg">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_XfvnEBduEeag8pemRXzpyg" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#//uml2comparetestprofile"/>
+ </eAnnotations>
+ <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/>
+ </profileApplication>
+ </uml:Model>
+ <testProfile:ACliche xmi:id="_YtvrQBduEeag8pemRXzpyg" base_Class="_rIasQBdtEeag8pemRXzpyg" singleValuedAttribute="This is just a test"/>
+</xmi:XMI>
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/right.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/right.uml
new file mode 100644
index 000000000..616c58061
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/resourceattachment/stereotype/data/right.uml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_qd69wBdtEeag8pemRXzpyg" name="MyModel">
+ <packagedElement xmi:type="uml:Class" xmi:id="_rIasQBdtEeag8pemRXzpyg" name="MyClass"/>
+ <profileApplication xmi:id="_XfvAABduEeag8pemRXzpyg">
+ <eAnnotations xmi:id="_XfvnEBduEeag8pemRXzpyg" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#//uml2comparetestprofile"/>
+ </eAnnotations>
+ <appliedProfile href="platform:/plugin/org.eclipse.emf.compare.uml2.tests/model/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/>
+ </profileApplication>
+</uml:Model>
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java
index d20020be0..0b92adb86 100644
--- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java
@@ -9,13 +9,10 @@
* Obeo - initial API and implementation
* Philip Langer - addition of OpaqueTest
* Stefan Dirix - addition of PseudoConflictTest
+ * Martin Fleck - addition of RemoveStereotypeApplicationPseudoConflictTest
*******************************************************************************/
package org.eclipse.emf.compare.uml2.tests.suite;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.textui.TestRunner;
-
import org.eclipse.emf.compare.uml2.tests.association.AddAssociation2Test;
import org.eclipse.emf.compare.uml2.tests.association.AddAssociation3Test;
import org.eclipse.emf.compare.uml2.tests.association.AddAssociationTest;
@@ -47,6 +44,7 @@ import org.eclipse.emf.compare.uml2.tests.opaque.OpaqueElementBodyChangeDiffTest
import org.eclipse.emf.compare.uml2.tests.opaque.OpaqueElementBodyChangeMergeTest;
import org.eclipse.emf.compare.uml2.tests.profiles.DynamicProfileTest;
import org.eclipse.emf.compare.uml2.tests.profiles.StaticProfileTest;
+import org.eclipse.emf.compare.uml2.tests.resourceattachment.stereotype.RemoveStereotypeApplicationPseudoConflictTest;
import org.eclipse.emf.compare.uml2.tests.stereotypes.DanglingStereotypeApplicationTest;
import org.eclipse.emf.compare.uml2.tests.stereotypes.DynamicStereotypeTest;
import org.eclipse.emf.compare.uml2.tests.stereotypes.DynamicStereotypedElementChangeTests;
@@ -57,6 +55,10 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import junit.textui.TestRunner;
+
/**
* This test suite allows us to launch all tests for EMF Compare at once.
*
@@ -77,7 +79,7 @@ import org.junit.runners.Suite.SuiteClasses;
StaticStereotypedElementItemProviderTest.class, DynamicStereotypedElementItemProviderTest.class,
OpaqueElementBodyChangeDiffTest.class, OpaqueElementBodyChangeMergeTest.class,
DanglingStereotypeApplicationTest.class, MergeDiffInvolvingRefineDiffTest.class,
- TestNonRegPseudoConflict_484576.class })
+ TestNonRegPseudoConflict_484576.class, RemoveStereotypeApplicationPseudoConflictTest.class })
public class AllTests {
/**
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
index 3a1e5a133..93ae28528 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
@@ -8,6 +8,7 @@
* Contributors:
* Obeo - initial API and implementation
* Philip Langer - bugs 446947, 479449
+ * Martin Fleck - bug 493527
*******************************************************************************/
package org.eclipse.emf.compare.conflict;
@@ -924,8 +925,11 @@ public class DefaultConflictDetector implements IConflictDetector {
if (diff.getKind() == DifferenceKind.DELETE && match == candidate.getMatch()
&& getRelatedModelElement(diff) == null) {
if (candidate.getKind() != DifferenceKind.DELETE) {
- // The EObject that owns the changed EReference has been deleted on the other side
- conflictOn(comparison, diff, candidate, ConflictKind.REAL);
+ if (!ComparisonUtil.isDeleteOrUnsetDiff(candidate)) {
+ // The EObject that owns the changed EReference has been deleted on the other side
+ // [493527] deleted or unset references do not conflict with deleted element
+ conflictOn(comparison, diff, candidate, ConflictKind.REAL);
+ }
}
} else {
// Any ReferenceChange that references the affected root is a possible conflict

Back to the top