Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Dirix2015-02-27 08:16:32 -0500
committerAxel RICHARD2015-03-09 04:12:25 -0400
commit92029f6241a7a1a0e7e6584690ec43a746938fd6 (patch)
treec03a17ac156f8c65aa4044f242b79450faeb4cd0 /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare
parentbf9717a69a20da626b1d8955c8c371973396b531 (diff)
downloadorg.eclipse.emf.compare-92029f6241a7a1a0e7e6584690ec43a746938fd6.tar.gz
org.eclipse.emf.compare-92029f6241a7a1a0e7e6584690ec43a746938fd6.tar.xz
org.eclipse.emf.compare-92029f6241a7a1a0e7e6584690ec43a746938fd6.zip
[457652] Give xmi:ids higher priority than attribute ids
The IdentifierEObjectMatcher will now give xmi:ids priority over attribute ids to prevent models with duplicate xmi:ids. Includes testcases. Bug: 457652 Signed-off-by: Stefan Dirix <sdirix@eclipsesource.com> Change-Id: Ia3ba4222837ecc7f6a17bccc3973ecaee334fad0
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/conflict/data/complex/conflict_complex_right.nodes64
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/left.nodes6
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/right.nodes6
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/left.nodes6
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/right.nodes6
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/left.nodes8
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/right.nodes8
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes2
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/XMIMatchingTest.java158
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/MatchInputData.java24
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/setidattribute/left.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/setidattribute/right.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a1/left.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a1/right.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a2/left.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a2/right.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/left.nodes7
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/origin.nodes7
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/right.nodes8
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/origin.nodes19
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/side-of-move.nodes20
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/unchanged.nodes19
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java9
24 files changed, 351 insertions, 96 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/conflict/data/complex/conflict_complex_right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/conflict/data/complex/conflict_complex_right.nodes
index fe918c0bc..75d9e40ff 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/conflict/data/complex/conflict_complex_right.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/conflict/data/complex/conflict_complex_right.nodes
@@ -1,32 +1,32 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<nodes:Node
- xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI"
- xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
- xmi:id="_lWvuEJ9kEeGIqdNxMDsohw"
- name="Root">
- <containmentRef1
- xmi:id="_pVIPMJ9kEeGIqdNxMDsohw"
- name="Node6"/>
- <containmentRef1
- xmi:id="_oKlHoJ9kEeGIqdNxMDsohw"
- name="Node2"/>
- <containmentRef1
- xmi:id="_zODcIJ9kEeGIqdNxMDsohw"
- name="Node9"/>
- <containmentRef1
- xmi:id="_pBEDsJ9kEeGIqdNxMDsohw"
- name="Node3"/>
- <containmentRef1
- xmi:id="_9r-_zerSEJ9kEeGIqdNxMDsohw"
- name="Node0"/>
- <containmentRef1
- xmi:id="_nBpJoJ9kEeGIqdNxMDsohw"
- name="Node1"/>
- <containmentRef1
- xmi:id="_pndVUJ9kEeGIqdNxMDsohw"
- name="Node4"/>
- <containmentRef1
- xmi:id="_owScwJ9kEeGIqdNxMDsohw"
- name="Node7"/>
-</nodes:Node>
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_lWvuEJ9kEeGIqdNxMDsohw"
+ name="Root">
+ <containmentRef1
+ xmi:id="_pVIPMJ9kEeGIqdNxMDsohw"
+ name="Node6"/>
+ <containmentRef1
+ xmi:id="_oKlHoJ9kEeGIqdNxMDsohw"
+ name="Node2"/>
+ <containmentRef1
+ xmi:id="_zODcIJ9kEeGIqdNxMDsohw"
+ name="Node9"/>
+ <containmentRef1
+ xmi:id="_pBEDsJ9kEeGIqdNxMDsohw"
+ name="Node3"/>
+ <containmentRef1
+ xmi:id="_zerSEJ9kEeGIqdNxMDsohw"
+ name="Node0"/>
+ <containmentRef1
+ xmi:id="_nBpJoJ9kEeGIqdNxMDsohw"
+ name="Node1"/>
+ <containmentRef1
+ xmi:id="_pndVUJ9kEeGIqdNxMDsohw"
+ name="Node4"/>
+ <containmentRef1
+ xmi:id="_owScwJ9kEeGIqdNxMDsohw"
+ name="Node7"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/left.nodes
index ec5f2a5ac..5c5bb4d0d 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/left.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/left.nodes
@@ -6,8 +6,8 @@
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
xmi:id="_root"
name="Root">
- <containmentRef1 xsi:type="nodes:NodeFeatureMapContainment2" name="n1">
- <single name="a"/>
- <multiple name="b"/>
+ <containmentRef1 xsi:type="nodes:NodeFeatureMapContainment2" name="n1" xmi:id="_n1">
+ <single name="a" xmi:id="_a"/>
+ <multiple name="b" xmi:id="_b"/>
</containmentRef1>
</nodes:Node> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/right.nodes
index 54602874f..b755f54e0 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/right.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/right.nodes
@@ -6,8 +6,8 @@
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
xmi:id="_root"
name="Root">
- <containmentRef1 xsi:type="nodes:NodeFeatureMapContainment2" name="n2">
- <multiple name="b"/>
- <single name="a"/>
+ <containmentRef1 xsi:type="nodes:NodeFeatureMapContainment2" name="n2" xmi:id="_n2">
+ <multiple name="b" xmi:id="_b"/>
+ <single name="a" xmi:id="_a"/>
</containmentRef1>
</nodes:Node> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/left.nodes
index ffa1dc34f..46d4b090f 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/left.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/left.nodes
@@ -6,7 +6,7 @@
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
xmi:id="_root"
name="Root">
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node1" source="Node3"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node2"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node3" destination="Node1"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node1" source="_node3" xmi:id="_node1"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node2" xmi:id="_node2"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node3" destination="_node1" xmi:id="_node3"/>
</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/right.nodes
index 9acb1b5a5..4e72c2eea 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/right.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c5/right.nodes
@@ -6,7 +6,7 @@
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
xmi:id="_root"
name="Root">
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node1" source="Node4"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node2"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node4" destination="Node1"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node1" source="_node4" xmi:id="_node1"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node2" xmi:id="_node2"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node4" destination="_node1" xmi:id="_node4"/>
</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/left.nodes
index dac0c1198..0fba40ce5 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/left.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/left.nodes
@@ -6,8 +6,8 @@
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
xmi:id="_root"
name="Root">
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node1" source="Node3"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node2"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node3" destination="Node1"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node4"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node1" source="_node3" xmi:id="_node1"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node2" xmi:id="_node2"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node3" destination="_node1" xmi:id="_node3"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node4" xmi:id="_node4"/>
</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/right.nodes
index 526b3f447..4a064bc50 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/right.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c6/right.nodes
@@ -6,8 +6,8 @@
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
xmi:id="_root"
name="Root">
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node1" source="Node4"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node2"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node3"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node4" destination="Node1"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node1" source="_node4" xmi:id="_node1"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node2" xmi:id="_node2"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node3" xmi:id="_node3"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="Node4" destination="_node1" xmi:id="_node4"/>
</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes
index 518c8a03a..729b12080 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes
@@ -6,6 +6,6 @@
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
xmi:id="_root"
name="Root">
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="a" source="b"/>
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="b" destination="a"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="a" source="_b" xmi:id="_a"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="b" destination="_a" xmi:id="_b"/>
</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes
index 6bef905e6..32204319b 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes
@@ -6,5 +6,5 @@
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
xmi:id="_root"
name="Root">
- <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="a" source="a" destination="a"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="a" source="_a" destination="_a" xmi:id="_a"/>
</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/XMIMatchingTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/XMIMatchingTest.java
new file mode 100644
index 000000000..4922da139
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/XMIMatchingTest.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2015 EclipseSource Muenchen 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:
+ * Stefan Dirix - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.eclipse.emf.compare.tests.match.data.MatchInputData;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.junit.Test;
+
+/**
+ * Tests the matching behavior when combining xmi:ids and id-attributes.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ */
+public class XMIMatchingTest {
+
+ private MatchInputData input = new MatchInputData();
+
+ /**
+ * Tests a scenario in which the elements are identified via xmi:ids and an additional id-attribute is set
+ * on one side.
+ *
+ * @throws IOException
+ * if {@link MatchInputData} fails to load the test models.
+ */
+ @Test
+ public void testSetIDAttribute() throws IOException {
+ final Resource left = input.getSetIDAttributeLeft();
+ final Resource right = input.getSetIDAttributeRight();
+
+ final IComparisonScope scope = new DefaultComparisonScope(left, right, null);
+ final Comparison comparison = EMFCompare.builder().build().compare(scope);
+
+ final List<Match> matches = comparison.getMatches();
+
+ // There should be one root match
+ assertEquals(1, matches.size());
+
+ // The root match should have two submatches.
+ final Match rootMatch = matches.get(0);
+ final List<Match> subMatches = rootMatch.getSubmatches();
+ assertEquals(2, subMatches.size());
+
+ // matches should have same xmi:id
+ for (Match match : subMatches) {
+ EObject leftObject = match.getLeft();
+ EObject rightObject = match.getRight();
+
+ Resource leftResource = leftObject.eResource();
+ Resource rightResource = rightObject.eResource();
+
+ String leftID = ((XMIResource)leftResource).getID(leftObject);
+ String rightID = ((XMIResource)rightResource).getID(rightObject);
+ assertEquals(leftID, rightID);
+ }
+
+ // Based on the matches only one difference should be determined
+ final List<Diff> differences = comparison.getDifferences();
+ assertEquals(1, differences.size());
+ }
+
+ /**
+ * Tests a scenario in which the elements should be matched according to their xmi:ids although
+ * contradicting attribute ids are set.
+ *
+ * @throws IOException
+ * if {@link MatchInputData} fails to load the test models.
+ */
+ @Test
+ public void testXMIIDPriorityA1() throws IOException {
+ final Resource left = input.getXMIIDPriorityA1Left();
+ final Resource right = input.getXMIIDPriorityA1Right();
+
+ final IComparisonScope scope = new DefaultComparisonScope(left, right, null);
+ final Comparison comparison = EMFCompare.builder().build().compare(scope);
+
+ final List<Match> matches = comparison.getMatches();
+
+ // There should be one root match
+ assertEquals(1, matches.size());
+
+ // The root match should have two submatches.
+ final Match rootMatch = matches.get(0);
+ final List<Match> subMatches = rootMatch.getSubmatches();
+ assertEquals(2, subMatches.size());
+
+ // matches should have same xmi:id since they should not be matched via id-attribute
+ for (Match match : subMatches) {
+ EObject leftObject = match.getLeft();
+ EObject rightObject = match.getRight();
+
+ Resource leftResource = leftObject.eResource();
+ Resource rightResource = rightObject.eResource();
+
+ String leftID = ((XMIResource)leftResource).getID(leftObject);
+ String rightID = ((XMIResource)rightResource).getID(rightObject);
+ assertEquals(leftID, rightID);
+ }
+ }
+
+ /**
+ * Tests a scenario without xmi:ids in the model. The elements should not match since new xmi:ids are
+ * generated on the fly.
+ *
+ * @throws IOException
+ * if {@link MatchInputData} fails to load the test models.
+ */
+ @Test
+ public void testXMIIDPriorityA2() throws IOException {
+ final Resource left = input.getXMIIDPriorityA2Left();
+ final Resource right = input.getXMIIDPriorityA2Right();
+
+ final IComparisonScope scope = new DefaultComparisonScope(left, right, null);
+ final Comparison comparison = EMFCompare.builder().build().compare(scope);
+
+ final List<Match> matches = comparison.getMatches();
+
+ // There should be one root match
+ assertEquals(1, matches.size());
+
+ final Match rootMatch = matches.get(0);
+ final List<Match> subMatches = rootMatch.getSubmatches();
+
+ // Should have 4 matches since the elements can not be matched
+ assertEquals(4, subMatches.size());
+
+ for (Match match : subMatches) {
+ EObject leftObject = match.getLeft();
+ EObject rightObject = match.getRight();
+
+ final boolean leftIsNull = leftObject == null && rightObject != null;
+ final boolean rightIsNull = rightObject == null && leftObject != null;
+
+ assertTrue(leftIsNull || rightIsNull);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/MatchInputData.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/MatchInputData.java
index 7dcd0cf3d..b8350ae33 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/MatchInputData.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/MatchInputData.java
@@ -34,4 +34,28 @@ public class MatchInputData extends AbstractInputData {
public Resource getProxyMatchingA2Right() throws IOException {
return loadFromClassLoader("proxy/a2/right.nodes", new ResourceSetImpl());
}
+
+ public Resource getSetIDAttributeLeft() throws IOException {
+ return loadFromClassLoader("setidattribute/left.nodes");
+ }
+
+ public Resource getSetIDAttributeRight() throws IOException {
+ return loadFromClassLoader("setidattribute/right.nodes");
+ }
+
+ public Resource getXMIIDPriorityA1Left() throws IOException {
+ return loadFromClassLoader("xmiidpriority/a1/left.nodes");
+ }
+
+ public Resource getXMIIDPriorityA1Right() throws IOException {
+ return loadFromClassLoader("xmiidpriority/a1/right.nodes");
+ }
+
+ public Resource getXMIIDPriorityA2Left() throws IOException {
+ return loadFromClassLoader("xmiidpriority/a2/left.nodes");
+ }
+
+ public Resource getXMIIDPriorityA2Right() throws IOException {
+ return loadFromClassLoader("xmiidpriority/a2/right.nodes");
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/setidattribute/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/setidattribute/left.nodes
new file mode 100644
index 000000000..28be9437e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/setidattribute/left.nodes
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_root"
+ name="Root">
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" xmi:id="_a" source="_b"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" xmi:id="_b" destination="_a"/>
+</nodes:Node> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/setidattribute/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/setidattribute/right.nodes
new file mode 100644
index 000000000..4ce336a67
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/setidattribute/right.nodes
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_root"
+ name="Root">
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" xmi:id="_a" name="a" source="_b"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" xmi:id="_b" destination="_a"/>
+</nodes:Node> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a1/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a1/left.nodes
new file mode 100644
index 000000000..cd652bd1b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a1/left.nodes
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_root"
+ name="Root">
+ <containmentRef1 xsi:type="nodes:Node" xmi:id="_a" name="a"/>
+ <containmentRef1 xsi:type="nodes:Node" xmi:id="_b" name="b"/>
+</nodes:Node> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a1/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a1/right.nodes
new file mode 100644
index 000000000..6634b5d76
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a1/right.nodes
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_root"
+ name="Root">
+ <containmentRef1 xsi:type="nodes:Node" xmi:id="_a" name="b"/>
+ <containmentRef1 xsi:type="nodes:Node" xmi:id="_b" name="a"/>
+</nodes:Node> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a2/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a2/left.nodes
new file mode 100644
index 000000000..1e9822fe3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a2/left.nodes
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_root"
+ name="Root">
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="a"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="b"/>
+</nodes:Node> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a2/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a2/right.nodes
new file mode 100644
index 000000000..1e9822fe3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/xmiidpriority/a2/right.nodes
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_root"
+ name="Root">
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="a"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" name="b"/>
+</nodes:Node> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/left.nodes
index 1edc7374f..127500b3d 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/left.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/left.nodes
@@ -3,8 +3,9 @@
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
- name="Root">
- <containmentRef2 xsi:type="nodes:Node" name="B">
- <containmentRef1 xsi:type="nodes:Node" name="A"/>
+ name="Root"
+ xmi:id="_r">
+ <containmentRef2 xsi:type="nodes:Node" name="B" xmi:id="_b">
+ <containmentRef1 xsi:type="nodes:Node" name="A" xmi:id="_a"/>
</containmentRef2>
</nodes:NodeMultipleContainment>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/origin.nodes
index 1edc7374f..127500b3d 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/origin.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/origin.nodes
@@ -3,8 +3,9 @@
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
- name="Root">
- <containmentRef2 xsi:type="nodes:Node" name="B">
- <containmentRef1 xsi:type="nodes:Node" name="A"/>
+ name="Root"
+ xmi:id="_r">
+ <containmentRef2 xsi:type="nodes:Node" name="B" xmi:id="_b">
+ <containmentRef1 xsi:type="nodes:Node" name="A" xmi:id="_a"/>
</containmentRef2>
</nodes:NodeMultipleContainment>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/right.nodes
index 76a4f76af..cfcb1f56c 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/right.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/fullscope/differentcontainmentmove/right.nodes
@@ -3,7 +3,9 @@
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
- name="Root">
- <containmentRef2 xsi:type="nodes:Node" name="A"/>
- <containmentRef2 xsi:type="nodes:Node" name="B"/>
+ name="Root"
+ xmi:id="_r"
+ >
+ <containmentRef2 xsi:type="nodes:Node" name="A" xmi:id="_a"/>
+ <containmentRef2 xsi:type="nodes:Node" name="B" xmi:id="_b"/>
</nodes:NodeMultipleContainment>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/origin.nodes
index 5771610c5..c9ace2482 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/origin.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/origin.nodes
@@ -1,9 +1,10 @@
-<?xml version="1.0" encoding="ASCII"?>
-<nodes:NodeMultipleContainment
- xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI"
- xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
- name="Root">
- <containmentRef2 xsi:type="nodes:Node" name="A"/>
- <containmentRef2 xsi:type="nodes:Node" name="B"/>
-</nodes:NodeMultipleContainment>
+<?xml version="1.0" encoding="ASCII"?>
+<nodes:NodeMultipleContainment
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ name="Root"
+ xmi:id="_r">
+ <containmentRef2 xsi:type="nodes:Node" name="A" xmi:id="_a" />
+ <containmentRef2 xsi:type="nodes:Node" name="B" xmi:id="_b" />
+</nodes:NodeMultipleContainment>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/side-of-move.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/side-of-move.nodes
index 0ddb5e4db..9f548a7b8 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/side-of-move.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/side-of-move.nodes
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="ASCII"?>
-<nodes:NodeMultipleContainment
- xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI"
- xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
- name="Root">
- <containmentRef2 xsi:type="nodes:Node" name="B">
- <containmentRef1 xsi:type="nodes:Node" name="A"/>
- </containmentRef2>
-</nodes:NodeMultipleContainment>
+<?xml version="1.0" encoding="ASCII"?>
+<nodes:NodeMultipleContainment
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ name="Root" xmi:id="_r">
+ <containmentRef2 xsi:type="nodes:Node" name="B" xmi:id="_b">
+ <containmentRef1 xsi:type="nodes:Node" name="A" xmi:id="_a"/>
+ </containmentRef2>
+</nodes:NodeMultipleContainment>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/unchanged.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/unchanged.nodes
index 5771610c5..064d43bf7 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/unchanged.nodes
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/data/threeway/movedifferentcontainmentfeature/unchanged.nodes
@@ -1,9 +1,10 @@
-<?xml version="1.0" encoding="ASCII"?>
-<nodes:NodeMultipleContainment
- xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI"
- xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
- name="Root">
- <containmentRef2 xsi:type="nodes:Node" name="A"/>
- <containmentRef2 xsi:type="nodes:Node" name="B"/>
-</nodes:NodeMultipleContainment>
+<?xml version="1.0" encoding="ASCII"?>
+<nodes:NodeMultipleContainment
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ name="Root"
+ xmi:id="_r">
+ <containmentRef2 xsi:type="nodes:Node" name="A" xmi:id="_a"/>
+ <containmentRef2 xsi:type="nodes:Node" name="B" xmi:id="_b"/>
+</nodes:NodeMultipleContainment>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
index 37308ddd6..5e062a038 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
@@ -8,7 +8,7 @@
* Contributors:
* Obeo - initial API and implementation
* Philip Langer - Adds additional test classes
- * Stefan Dirix - Add additional test class
+ * Stefan Dirix - Adds additional test classes
*******************************************************************************/
package org.eclipse.emf.compare.tests.suite;
@@ -37,6 +37,7 @@ import org.eclipse.emf.compare.tests.fullcomparison.ProximityComparisonTest;
import org.eclipse.emf.compare.tests.match.MatchEngineFactoryRegistryTest;
import org.eclipse.emf.compare.tests.match.ProximityIndexTest;
import org.eclipse.emf.compare.tests.match.ProxyMatchingTest;
+import org.eclipse.emf.compare.tests.match.XMIMatchingTest;
import org.eclipse.emf.compare.tests.merge.ConflictMergeTest;
import org.eclipse.emf.compare.tests.merge.ExtensionMergeTest;
import org.eclipse.emf.compare.tests.merge.FeatureMaps2wayMergeTest;
@@ -78,9 +79,9 @@ import org.junit.runners.Suite.SuiteClasses;
ExtensionMergeTest.class, IndividualMergeOutOfScopeValuesTest.class, ProximityComparisonTest.class,
DynamicInstanceComparisonTest.class, URIDistanceTest.class, FragmentationTest.class,
AllEditTests.class, CommandStackTestSuite.class, MatchEngineFactoryRegistryTest.class,
- ProxyMatchingTest.class, ConflictMergeTest.class, PseudoConflictMergeTest.class,
- ProximityIndexTest.class, AllRCPTests.class, FeatureMaps2wayMergeTest.class,
- FeatureMaps3wayMergeTest.class, FeatureMapsConflictsMergeTest.class,
+ XMIMatchingTest.class, ProxyMatchingTest.class, ConflictMergeTest.class,
+ PseudoConflictMergeTest.class, ProximityIndexTest.class, AllRCPTests.class,
+ FeatureMaps2wayMergeTest.class, FeatureMaps3wayMergeTest.class, FeatureMapsConflictsMergeTest.class,
FeatureMapsPseudoConflictsMergeTest.class, TwoWayBatchMergingTest.class, EqualityHelperTest.class,
FeatureFilterTest.class, ThreeWayBatchMergingTest.class,
MultiLineAttributeConflictDetectionTest.class, ThreeWayTextDiffTest.class,

Back to the top