Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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/match/ProxyMatchingTest.java113
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/MatchInputData.java37
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a1/left.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a1/right.nodes13
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/left.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/other.nodes9
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/right.nodes13
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java7
8 files changed, 212 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/ProxyMatchingTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/ProxyMatchingTest.java
new file mode 100644
index 000000000..98ec6c334
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/ProxyMatchingTest.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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.ResourceAttachmentChange;
+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.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.junit.Test;
+
+/**
+ * Tests the matching behavior when unresolvable proxies exist.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ */
+public class ProxyMatchingTest {
+
+ private MatchInputData input = new MatchInputData();
+
+ /**
+ * Tests a scenario in which the elements are identified via xmi:ids and the left side uses an
+ * unresolvable proxy.
+ *
+ * @throws IOException
+ * if {@link MatchInputData} fails to load the test models.
+ */
+ @Test
+ public void testProxyA1() throws IOException {
+ final Resource left = input.getProxyMatchingA1Left();
+ final Resource right = input.getProxyMatchingA1Right();
+
+ final ResourceSet leftResourceSet = left.getResourceSet();
+ final ResourceSet rightResourceSet = right.getResourceSet();
+
+ EcoreUtil.resolveAll(leftResourceSet);
+ EcoreUtil.resolveAll(rightResourceSet);
+
+ final IComparisonScope scope = new DefaultComparisonScope(leftResourceSet, rightResourceSet, 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 since the proxy can not be matched to the "real" object
+ final Match rootMatch = matches.get(0);
+ final List<Match> subMatches = rootMatch.getSubmatches();
+ assertEquals(2, subMatches.size());
+
+ // Based on the matches two differences should be determined (add/delete)
+ final List<Diff> differences = comparison.getDifferences();
+ assertEquals(2, differences.size());
+ }
+
+ /**
+ * Tests a scenario in which the elements are identified via xmi:ids and the left side uses a resolvable
+ * proxy.
+ *
+ * @throws IOException
+ * if {@link MatchInputData} fails to load the test models.
+ */
+ @Test
+ public void testProxyA2() throws IOException {
+ final Resource left = input.getProxyMatchingA2Left();
+ final Resource right = input.getProxyMatchingA2Right();
+
+ final ResourceSet leftResourceSet = left.getResourceSet();
+ final ResourceSet rightResourceSet = right.getResourceSet();
+
+ EcoreUtil.resolveAll(leftResourceSet);
+ EcoreUtil.resolveAll(rightResourceSet);
+
+ final IComparisonScope scope = new DefaultComparisonScope(leftResourceSet, rightResourceSet, 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 one submatch
+ final Match rootMatch = matches.get(0);
+ final List<Match> subMatches = rootMatch.getSubmatches();
+ assertEquals(1, subMatches.size());
+
+ // There should be one ResourceAttachmentChange
+ final List<Diff> differences = comparison.getDifferences();
+ assertEquals(1, differences.size());
+ assertTrue(differences.get(0) instanceof ResourceAttachmentChange);
+ }
+}
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
new file mode 100644
index 000000000..7dcd0cf3d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/MatchInputData.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.data;
+
+import java.io.IOException;
+
+import org.eclipse.emf.compare.tests.framework.AbstractInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+@SuppressWarnings("nls")
+public class MatchInputData extends AbstractInputData {
+
+ public Resource getProxyMatchingA1Left() throws IOException {
+ return loadFromClassLoader("proxy/a1/left.nodes", new ResourceSetImpl());
+ }
+
+ public Resource getProxyMatchingA1Right() throws IOException {
+ return loadFromClassLoader("proxy/a1/right.nodes", new ResourceSetImpl());
+ }
+
+ public Resource getProxyMatchingA2Left() throws IOException {
+ return loadFromClassLoader("proxy/a2/left.nodes", new ResourceSetImpl());
+ }
+
+ public Resource getProxyMatchingA2Right() throws IOException {
+ return loadFromClassLoader("proxy/a2/right.nodes", new ResourceSetImpl());
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a1/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a1/left.nodes
new file mode 100644
index 000000000..77902c7f2
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/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
+ href="nonexisting.nodes#_a"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a1/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a1/right.nodes
new file mode 100644
index 000000000..9691e3a67
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a1/right.nodes
@@ -0,0 +1,13 @@
+<?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:NodeSingleValueAttribute"
+ xmi:id="_a"
+ singleValuedAttribute="attribute1"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/left.nodes
new file mode 100644
index 000000000..7f89b5406
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/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
+ href="other.nodes#_a"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/other.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/other.nodes
new file mode 100644
index 000000000..53a8b0b4c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/other.nodes
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:NodeSingleValueAttribute
+ 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="_a"
+ singleValuedAttribute="attribute1">
+</nodes:NodeSingleValueAttribute>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/right.nodes
new file mode 100644
index 000000000..9691e3a67
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/match/data/proxy/a2/right.nodes
@@ -0,0 +1,13 @@
+<?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:NodeSingleValueAttribute"
+ xmi:id="_a"
+ singleValuedAttribute="attribute1"/>
+</nodes:Node>
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 75261b04d..37308ddd6 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,6 +8,7 @@
* Contributors:
* Obeo - initial API and implementation
* Philip Langer - Adds additional test classes
+ * Stefan Dirix - Add additional test class
*******************************************************************************/
package org.eclipse.emf.compare.tests.suite;
@@ -35,6 +36,7 @@ import org.eclipse.emf.compare.tests.fullcomparison.IdentifierComparisonTest;
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.merge.ConflictMergeTest;
import org.eclipse.emf.compare.tests.merge.ExtensionMergeTest;
import org.eclipse.emf.compare.tests.merge.FeatureMaps2wayMergeTest;
@@ -76,8 +78,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,
- ConflictMergeTest.class, PseudoConflictMergeTest.class, ProximityIndexTest.class, AllRCPTests.class,
- FeatureMaps2wayMergeTest.class, FeatureMaps3wayMergeTest.class, FeatureMapsConflictsMergeTest.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