Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Borkowski2015-05-27 09:43:23 -0400
committerAxel RICHARD2015-05-28 10:26:02 -0400
commitdbc6bd1e36e628ea59879e91b2665e695e27dfe1 (patch)
treeb38ee1ce30d2ce0086ff203ab2d2fd258c78686c /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf
parent62d77d2ca6743b04e0d5c1b33b2591c9cbc77279 (diff)
downloadorg.eclipse.emf.compare-dbc6bd1e36e628ea59879e91b2665e695e27dfe1.tar.gz
org.eclipse.emf.compare-dbc6bd1e36e628ea59879e91b2665e695e27dfe1.tar.xz
org.eclipse.emf.compare-dbc6bd1e36e628ea59879e91b2665e695e27dfe1.zip
[467576] Correct Handling of Proxies in ReqEngine
MatchUtil so far did not handle proxy objects correctly, which led to false negatives in detecting required diffs, which was exposed in bug 467576. This change fixes this issue by comparing the objects' URIs to detect proxy matches. Bug: 467576 Change-Id: Ib390ddbd56e65145ecd554535d960e769c728a29 Signed-off-by: Michael Borkowski <mborkowski@eclipsesource.com>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java7
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java95
2 files changed, 100 insertions, 2 deletions
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 20767fe68..5ea30df1d 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2015 Obeo.
+ * Copyright (c) 2012, 2015 Obeo 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
@@ -9,6 +9,7 @@
* Obeo - initial API and implementation
* Philip Langer - Adds additional test classes
* Stefan Dirix - Adds additional test classes
+ * Michael Borkowski - Adds additional test classes
*******************************************************************************/
package org.eclipse.emf.compare.tests.suite;
@@ -60,6 +61,7 @@ import org.eclipse.emf.compare.tests.rcp.AllRCPTests;
import org.eclipse.emf.compare.tests.req.ReqComputingTest;
import org.eclipse.emf.compare.tests.scope.DefaultComparisonScopeTest;
import org.eclipse.emf.compare.tests.utils.EqualityHelperTest;
+import org.eclipse.emf.compare.tests.utils.MatchUtilFeatureContainsTest;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.junit.BeforeClass;
@@ -86,7 +88,8 @@ import org.junit.runners.Suite.SuiteClasses;
FeatureMapsPseudoConflictsMergeTest.class, TwoWayBatchMergingTest.class, EqualityHelperTest.class,
FeatureFilterTest.class, ThreeWayBatchMergingTest.class,
MultiLineAttributeConflictDetectionTest.class, ThreeWayTextDiffTest.class,
- MultiLineAttributeMergeTest.class, MonitorCancelTest.class, IdentifierEObjectMatcherTest.class })
+ MultiLineAttributeMergeTest.class, MonitorCancelTest.class, IdentifierEObjectMatcherTest.class,
+ MatchUtilFeatureContainsTest.class })
public class AllTests {
/**
* Standalone launcher for all of compare's tests.
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java
new file mode 100644
index 000000000..f46559d4d
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2015 EclipseSource Muenchen GmbH.
+ * 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:
+ * Michael Borkowski - initial tests
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.utils.MatchUtil;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.junit.Before;
+import org.junit.Test;
+
+@SuppressWarnings({"boxing", "nls" })
+public class MatchUtilFeatureContainsTest {
+
+ List<EObject> featureList;
+
+ InternalEObject value;
+
+ EObject container;
+
+ EClass eClass;
+
+ EStructuralFeature feature;
+
+ @Before
+ public void setUp() {
+ EPackage ePackage = mock(EPackage.class);
+
+ container = mock(EObject.class);
+ feature = mock(EStructuralFeature.class);
+
+ eClass = mock(EClass.class);
+ when(eClass.getEPackage()).thenReturn(ePackage);
+
+ when(container.eClass()).thenReturn(eClass);
+ when(feature.getEContainingClass()).thenReturn(eClass);
+
+ featureList = new LinkedList<EObject>();
+ when(container.eGet(feature, false)).thenReturn(featureList);
+
+ value = mockInternalObject();
+ featureList.add(value);
+ }
+
+ @Test
+ public void test_SameObject() {
+ assertTrue(MatchUtil.featureContains(container, feature, value));
+ }
+
+ @Test
+ public void test_Proxy() {
+ URI uri = URI.createFileURI("/my/path");
+
+ InternalEObject proxyValue = mockInternalObject();
+ when(proxyValue.eIsProxy()).thenReturn(true);
+ when(proxyValue.eProxyURI()).thenReturn(uri);
+
+ when(value.eIsProxy()).thenReturn(true);
+ when(value.eProxyURI()).thenReturn(uri);
+
+ assertTrue(MatchUtil.featureContains(container, feature, proxyValue));
+ }
+
+ @Test
+ public void test_DifferentObject() {
+ InternalEObject otherValue = mockInternalObject();
+
+ assertFalse(MatchUtil.featureContains(container, feature, otherValue));
+ }
+
+ private InternalEObject mockInternalObject() {
+ InternalEObject internalObject = mock(InternalEObject.class);
+ when(internalObject.eClass()).thenReturn(eClass);
+ return internalObject;
+ }
+}

Back to the top