Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2015-02-24 15:51:05 +0000
committerLaurent Goubet2015-03-04 13:24:48 +0000
commit0cd4336875072986b52723da20b0baadf7d893b7 (patch)
tree3082ceb94d568f72f3f45643782e7640e18243be
parent3d32d091390278ccdafa12537bc7b9affb794186 (diff)
downloadorg.eclipse.emf.compare-0cd4336875072986b52723da20b0baadf7d893b7.tar.gz
org.eclipse.emf.compare-0cd4336875072986b52723da20b0baadf7d893b7.tar.xz
org.eclipse.emf.compare-0cd4336875072986b52723da20b0baadf7d893b7.zip
[458963] EMFCompare object doesn't use EMFCompareRCP registries
EMFCompareBuilderConfigurator wasn't called everywhere it should be. Add tests. Bug: 458963 Change-Id: Iff41881d47a16c9a8f6624941dd5aacd33c00fad Signed-off-by: Axel Richard <axel.richard@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java9
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/PseudoConflictsMergeActionTest.java8
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java20
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java7
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java3
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/RCPMatchEngineFactoryRegistryTest.java383
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/EcoreInputData.java33
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryLeft.ecore9
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryOrigin.ecore12
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryRight.ecore16
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemFeatureMapsTest.java8
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemPseudoConflictTest.java8
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemTest.java8
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java9
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java6
-rw-r--r--plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/EMFCompareBuilderConfigurator.java31
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/rcp/MatchEngineFactoryRegistryWrapperTest.java45
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java12
19 files changed, 588 insertions, 42 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java
index 1abe5ed08..ede49414c 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2013, 2014 Obeo and others
+ * Copyright (C) 2013, 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
@@ -29,6 +29,7 @@ import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.EMFCompare.Builder;
import org.eclipse.emf.compare.ide.ui.internal.logical.ComparisonScopeBuilder;
import org.eclipse.emf.compare.ide.ui.internal.logical.IdenticalResourceMinimizer;
import org.eclipse.emf.compare.ide.ui.internal.logical.StorageTypedElement;
@@ -39,6 +40,7 @@ import org.eclipse.emf.compare.ide.ui.logical.IStorageProviderAccessor;
import org.eclipse.emf.compare.ide.ui.tests.CompareTestCase;
import org.eclipse.emf.compare.ide.ui.tests.egit.fixture.GitTestRepository;
import org.eclipse.emf.compare.ide.ui.tests.egit.fixture.MockSystemReader;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.scope.IComparisonScope;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jgit.lib.Constants;
@@ -143,7 +145,10 @@ public class CompareGitTestCase extends CompareTestCase {
assertFalse(rightResourceSet.getResources().isEmpty());
assertFalse(originResourceSet.getResources().isEmpty());
- return EMFCompare.builder().build().compare(scope, new BasicMonitor());
+ final Builder comparisonBuilder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(comparisonBuilder);
+
+ return comparisonBuilder.build().compare(scope, new BasicMonitor());
}
protected static void assertDiffCount(List<Diff> differences, int expectedOutgoing, int expectedIncoming) {
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/PseudoConflictsMergeActionTest.java b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/PseudoConflictsMergeActionTest.java
index 109cba86f..ada7a70a7 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/PseudoConflictsMergeActionTest.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/PseudoConflictsMergeActionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2015 Obeo.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -28,12 +28,14 @@ import org.eclipse.emf.compare.DifferenceKind;
import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.DifferenceState;
import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.EMFCompare.Builder;
import org.eclipse.emf.compare.domain.ICompareEditingDomain;
import org.eclipse.emf.compare.domain.impl.EMFCompareEditingDomain;
import org.eclipse.emf.compare.internal.merge.MergeMode;
import org.eclipse.emf.compare.internal.merge.MergeOperation;
import org.eclipse.emf.compare.merge.IMerger;
import org.eclipse.emf.compare.rcp.EMFCompareRCPPlugin;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl.DefaultGroupProvider;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider.TreeNodeItemProviderSpec;
import org.eclipse.emf.compare.rcp.ui.tests.structuremergeviewer.groups.provider.AbstractTestTreeNodeItemProviderAdapter;
@@ -81,7 +83,9 @@ public class PseudoConflictsMergeActionTest extends AbstractTestTreeNodeItemProv
final IComparisonScope scope = new DefaultComparisonScope(scopeProvider
.getLeftPseudoConflictFullScope(), scopeProvider.getRightPseudoConflictFullScope(),
scopeProvider.getOriginPseudoConflictFullScope());
- final Comparison comparison = EMFCompare.builder().build().compare(scope);
+ final Builder comparisonBuilder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(comparisonBuilder);
+ final Comparison comparison = comparisonBuilder.build().compare(scope);
editingDomain = EMFCompareEditingDomain.create(scopeProvider.getLeftPseudoConflictFullScope(),
scopeProvider.getRightPseudoConflictFullScope(), scopeProvider
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java
index c8ab1d91e..67525cf66 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Obeo.
+ * Copyright (c) 2012, 2015 Obeo.
* 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
@@ -75,12 +75,20 @@ public abstract class AbstractCompareHandler extends AbstractHandler {
.getMatchEngineFactoryRegistry();
matchEngineFactoryRegistry.add(eObjectMatchEngineFactory);
- Builder builder = EMFCompare.builder().setPostProcessorRegistry(
- EMFCompareRCPPlugin.getDefault().getPostProcessorRegistry());
- if (enginePreferences != null) {
- EMFCompareBuilderConfigurator engineProvider = new EMFCompareBuilderConfigurator(
- enginePreferences, matchEngineFactoryRegistry);
+ final Builder builder = EMFCompare.builder();
+ final IEclipsePreferences preferences;
+ if (enginePreferences == null) {
+ preferences = EMFCompareRCPPlugin.getDefault().getEMFComparePreferences();
+ } else {
+ preferences = enginePreferences;
+ }
+ if (preferences != null) {
+ EMFCompareBuilderConfigurator engineProvider = new EMFCompareBuilderConfigurator(preferences,
+ matchEngineFactoryRegistry, EMFCompareRCPPlugin.getDefault().getPostProcessorRegistry());
engineProvider.configure(builder);
+ } else {
+ builder.setMatchEngineFactoryRegistry(matchEngineFactoryRegistry).setPostProcessorRegistry(
+ EMFCompareRCPPlugin.getDefault().getPostProcessorRegistry());
}
EMFCompare comparator = builder.build();
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java
index 61afc5f48..ae1b24621 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java
@@ -42,6 +42,7 @@ import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.DifferenceState;
import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.EMFCompare.Builder;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIPlugin;
import org.eclipse.emf.compare.ide.ui.logical.IModelMinimizer;
@@ -54,6 +55,7 @@ import org.eclipse.emf.compare.merge.BatchMerger;
import org.eclipse.emf.compare.merge.IBatchMerger;
import org.eclipse.emf.compare.merge.IMerger;
import org.eclipse.emf.compare.rcp.EMFCompareRCPPlugin;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.scope.IComparisonScope;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -137,7 +139,10 @@ public class EMFResourceMappingMerger implements IResourceMappingMerger {
minimizer.minimize(syncModel, subMonitor.newChild(1)); // 10%
final IComparisonScope scope = ComparisonScopeBuilder.create(syncModel, subMonitor.newChild(3)); // 40%
- final Comparison comparison = EMFCompare.builder().build().compare(scope,
+ final Builder builder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(builder);
+
+ final Comparison comparison = builder.build().compare(scope,
BasicMonitor.toMonitor(SubMonitor.convert(subMonitor.newChild(1), 10))); // 50%
final IMerger.Registry mergerRegistry = EMFCompareRCPPlugin.getDefault().getMergerRegistry();
if (hasRealConflict(comparison)) {
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
index 2aef0cbfd..2cf5d2b1b 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
@@ -973,8 +973,7 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
diagnostic.merge(((IDiagnosable)scope).getDiagnostic());
}
- final Builder comparisonBuilder = EMFCompare.builder().setPostProcessorRegistry(
- EMFCompareRCPPlugin.getDefault().getPostProcessorRegistry());
+ final Builder comparisonBuilder = EMFCompare.builder();
EMFCompareBuilderConfigurator.createDefault().configure(comparisonBuilder);
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/RCPMatchEngineFactoryRegistryTest.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/RCPMatchEngineFactoryRegistryTest.java
new file mode 100644
index 000000000..fdb1c681e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/RCPMatchEngineFactoryRegistryTest.java
@@ -0,0 +1,383 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.tests.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.match.IMatchEngine;
+import org.eclipse.emf.compare.match.IMatchEngine.Factory;
+import org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl;
+import org.eclipse.emf.compare.rcp.EMFCompareRCPPlugin;
+import org.eclipse.emf.compare.rcp.internal.extension.IItemDescriptor;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.ItemUtil;
+import org.eclipse.emf.compare.rcp.internal.match.MatchEngineFactoryRegistryWrapper;
+import org.eclipse.emf.compare.rcp.internal.preferences.EMFComparePreferences;
+import org.eclipse.emf.compare.rcp.ui.tests.match.data.EcoreInputData;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * Test class for {@link MatchEngineFactoryRegistryWrapper}.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+@SuppressWarnings({"restriction", "nls" })
+public class RCPMatchEngineFactoryRegistryTest {
+
+ private IMatchEngine.Factory.Registry registryWrapper;
+
+ private IEclipsePreferences preferences;
+
+ /**
+ * Creates a comparison scope from Ecore model.
+ *
+ * @return {@link IComparisonScope}
+ * @throws IOException
+ */
+ private IComparisonScope createComparisonScope() throws IOException {
+ EcoreInputData ecoreData = new EcoreInputData();
+ return new DefaultComparisonScope(ecoreData.getLeft(), ecoreData.getRight(), ecoreData.getOrigin());
+ }
+
+ @Before
+ public void setUp() throws BackingStoreException {
+ preferences = EMFCompareRCPPlugin.getDefault().getEMFComparePreferences();
+ registryWrapper = EMFCompareRCPPlugin.getDefault().getMatchEngineFactoryRegistry();
+ }
+
+ @After
+ public void tearDown() throws BackingStoreException {
+ preferences.clear();
+ }
+
+ /**
+ * Nominal use case: Adds {@link IMatchEngine.Factory} in the registry.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testAdd() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ factory.setRanking(50);
+ registryWrapper.add(factory);
+ IComparisonScope createComparisonScope = createComparisonScope();
+ assertSame(registryWrapper.getHighestRankingMatchEngineFactory(createComparisonScope), factory);
+ assertEquals(registryWrapper.getMatchEngineFactories(createComparisonScope).size(), 4);
+ }
+
+ /**
+ * Adds a factory with no ranking set into the registry.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testAddFactoryWithNoRanking() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ registryWrapper.add(factory);
+ IMatchEngine.Factory factory2 = new MockMatchEngineFactory2();
+ factory2.setRanking(50);
+ registryWrapper.add(factory2);
+ IComparisonScope createComparisonScope = createComparisonScope();
+ assertSame(registryWrapper.getHighestRankingMatchEngineFactory(createComparisonScope), factory2);
+ }
+
+ /**
+ * Adds null to the registry.
+ */
+ @Test(expected = NullPointerException.class)
+ public void testAddNull() {
+ registryWrapper.add(null);
+ }
+
+ /**
+ * Adds two factories with identical id in the registry.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testAddSameID() throws IOException {
+ MockMatchEngineFactory1 factory1 = new MockMatchEngineFactory1();
+ factory1.setRanking(50);
+ registryWrapper.add(factory1);
+ MockMatchEngineFactory1 factory2 = new MockMatchEngineFactory1();
+ factory2.setRanking(50);
+ Factory oldValue = registryWrapper.add(factory2);
+ assertSame(oldValue, factory1);
+ IComparisonScope createComparisonScope = createComparisonScope();
+ assertSame(registryWrapper.getHighestRankingMatchEngineFactory(createComparisonScope), factory2);
+ }
+
+ /**
+ * Nominal use case: Gets the highest ranking match engine factory.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testHighestRankingMatchEngineFactory() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ factory.setRanking(10);
+ registryWrapper.add(factory);
+ IMatchEngine.Factory factory2 = new MockMatchEngineFactory2();
+ factory2.setRanking(20);
+ registryWrapper.add(factory2);
+ IMatchEngine.Factory factory3 = new MockMatchEngineFactory3();
+ factory3.setRanking(30);
+ registryWrapper.add(factory3);
+
+ IComparisonScope scope = createComparisonScope();
+ assertSame(registryWrapper.getHighestRankingMatchEngineFactory(scope), factory3);
+ assertTrue(registryWrapper.getMatchEngineFactories(scope).containsAll(
+ Lists.newArrayList(factory, factory2, factory3)));
+ }
+
+ /**
+ * Nominal use case: Gets the highest ranking match engine factory with more complex registry.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testHighestRankingMatchEngineFactoryWithDisabledFactories() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ factory.setRanking(10);
+ registryWrapper.add(factory);
+
+ IMatchEngine.Factory factory2 = new MockMatchEngineFactory2();
+ factory2.setRanking(20);
+ registryWrapper.add(factory2);
+
+ IMatchEngine.Factory factory3 = new MockMatchEngineFactory3();
+ factory3.setRanking(30);
+ registryWrapper.add(factory3);
+
+ IMatchEngine.Factory disabledFactory1 = new MockDisabledMatchEngineFactory1();
+ disabledFactory1.setRanking(40);
+ registryWrapper.add(disabledFactory1);
+
+ IMatchEngine.Factory disabledFactory2 = new MockDisabledMatchEngineFactory2();
+ disabledFactory2.setRanking(50);
+ registryWrapper.add(disabledFactory2);
+
+ IMatchEngine.Factory disabledFactory3 = new MockDisabledMatchEngineFactory3();
+ disabledFactory2.setRanking(60);
+ registryWrapper.add(disabledFactory3);
+
+ IComparisonScope scope = createComparisonScope();
+ assertSame(registryWrapper.getHighestRankingMatchEngineFactory(scope), factory3);
+ assertTrue(registryWrapper.getMatchEngineFactories(scope).containsAll(
+ Lists.newArrayList(factory, factory2, factory3)));
+
+ }
+
+ /**
+ * Nominal use case: Removes a factory from the registry.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testRemove() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ factory.setRanking(50);
+ registryWrapper.add(factory);
+
+ Factory oldValue = registryWrapper.remove(MockMatchEngineFactory1.class.getName());
+ assertSame(oldValue, factory);
+ assertFalse(registryWrapper.getMatchEngineFactories(createComparisonScope()).contains(factory));
+ }
+
+ /**
+ * Tries to remove null from the registry.
+ */
+ @Test(expected = NullPointerException.class)
+ public void testRemoveNull() {
+ registryWrapper.remove(null);
+ }
+
+ /**
+ * Tries to remove a factory from the registry with an incoherent id.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testRemoveWrongID() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ factory.setRanking(10);
+ registryWrapper.add(factory);
+
+ Factory oldValue = registryWrapper.remove("IncohereId");
+ assertNull(oldValue);
+ assertTrue(!registryWrapper.getMatchEngineFactories(createComparisonScope()).isEmpty());
+ }
+
+ /**
+ * Nominal use case: Disables Match Engine factory from preferences. Checks that the registry to do use
+ * them anymore.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testDisablingMatchEngine() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ factory.setRanking(10);
+ registryWrapper.add(factory);
+
+ IMatchEngine.Factory factory2 = new MockMatchEngineFactory2();
+ factory2.setRanking(20);
+ registryWrapper.add(factory2);
+
+ IMatchEngine.Factory factory3 = new MockMatchEngineFactory3();
+ factory3.setRanking(30);
+ registryWrapper.add(factory3);
+
+ IComparisonScope scope = createComparisonScope();
+ assertSame(registryWrapper.getHighestRankingMatchEngineFactory(scope), factory3);
+
+ disableEngine(preferences, EMFComparePreferences.MATCH_ENGINE_DISABLE_ENGINES, Collections
+ .singleton(factory3.getClass().getName()));
+ assertSame(registryWrapper.getHighestRankingMatchEngineFactory(scope), factory2);
+ assertTrue(!registryWrapper.getMatchEngineFactories(scope).contains(factory3));
+
+ disableEngine(preferences, EMFComparePreferences.MATCH_ENGINE_DISABLE_ENGINES, Lists.newArrayList(
+ factory3.getClass().getName(), factory2.getClass().getName()));
+ assertSame(registryWrapper.getHighestRankingMatchEngineFactory(scope), factory);
+ assertTrue(!registryWrapper.getMatchEngineFactories(scope).contains(factory2));
+
+ }
+
+ @Test
+ public void testEMFCompareBuilder() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ factory.setRanking(10);
+ registryWrapper.add(factory);
+
+ IMatchEngine.Factory factory2 = new MockMatchEngineFactory2();
+ factory2.setRanking(20);
+ registryWrapper.add(factory2);
+
+ IMatchEngine.Factory factory3 = new MockMatchEngineFactory3();
+ factory3.setRanking(30);
+ registryWrapper.add(factory3);
+
+ MockBuilder mockBuilder = new MockBuilder();
+ mockBuilder.build();
+
+ IMatchEngine.Factory.Registry builderMatchEngineFactoryRegistry = mockBuilder
+ .getMatchEngineFactoryRegistry();
+
+ assertNotSame(registryWrapper, builderMatchEngineFactoryRegistry);
+
+ EMFCompareBuilderConfigurator.createDefault().configure(mockBuilder);
+ mockBuilder.build();
+ builderMatchEngineFactoryRegistry = mockBuilder.getMatchEngineFactoryRegistry();
+
+ assertSame(registryWrapper, builderMatchEngineFactoryRegistry);
+
+ }
+
+ /**
+ * Disables engine in preferences.
+ *
+ * @param preference
+ * {@link IEclipsePreferences}
+ * @param key
+ * @param toDisable
+ * {@link Collection} of {@link IItemDescriptor} to disable.
+ */
+ private void disableEngine(IEclipsePreferences preference, String key, Collection<String> toDisable) {
+ if (toDisable != null && !toDisable.isEmpty()) {
+ String newPreferenceValue = Joiner.on(ItemUtil.PREFERENCE_DELIMITER).join(toDisable);
+ preference.put(key, newPreferenceValue);
+ } else {
+ preference.remove(key);
+ }
+ }
+
+ /**
+ * Mock {@link IMatchEngine.Factory} that does not handle any {@link IComparisonScope}.
+ *
+ * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
+ */
+ private static class MockDisabledMatchEngineFactory1 extends MatchEngineFactoryImpl {
+ @Override
+ public boolean isMatchEngineFactoryFor(IComparisonScope scope) {
+ return false;
+ }
+ }
+
+ /**
+ * Mock {@link IMatchEngine.Factory} that does not handle any {@link IComparisonScope}.
+ *
+ * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
+ */
+ private static class MockDisabledMatchEngineFactory2 extends MockDisabledMatchEngineFactory1 {
+ }
+
+ /**
+ * Mock {@link IMatchEngine.Factory} that does not handle any {@link IComparisonScope}.
+ *
+ * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
+ */
+ private static class MockDisabledMatchEngineFactory3 extends MockDisabledMatchEngineFactory1 {
+ }
+
+ /**
+ * Mock {@link IMatchEngine.Factory} that can handle any {@link IComparisonScope}.
+ *
+ * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
+ */
+ private static class MockMatchEngineFactory1 extends MatchEngineFactoryImpl {
+ }
+
+ /**
+ * Mock {@link IMatchEngine.Factory} that can handle any {@link IComparisonScope}.
+ *
+ * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
+ */
+ private static class MockMatchEngineFactory2 extends MatchEngineFactoryImpl {
+ }
+
+ /**
+ * Mock {@link IMatchEngine.Factory} that can handle any {@link IComparisonScope}.
+ *
+ * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
+ */
+ private static class MockMatchEngineFactory3 extends MatchEngineFactoryImpl {
+ }
+
+ /**
+ * Mock {@link EMFCompare.Builder} in order to access matchEngineFactoryRegistry field.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+ private static class MockBuilder extends EMFCompare.Builder {
+ public IMatchEngine.Factory.Registry getMatchEngineFactoryRegistry() {
+ return this.matchEngineFactoryRegistry;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/EcoreInputData.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/EcoreInputData.java
new file mode 100644
index 000000000..4db3154e9
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/EcoreInputData.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.tests.match.data;
+
+import java.io.IOException;
+
+import org.eclipse.emf.compare.tests.edit.data.ResourceScopeProvider;
+import org.eclipse.emf.compare.tests.framework.AbstractInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+
+@SuppressWarnings("nls")
+public class EcoreInputData extends AbstractInputData implements ResourceScopeProvider {
+
+ public Resource getLeft() throws IOException {
+ return loadFromClassLoader("extlibraryLeft.ecore");
+ }
+
+ public Resource getRight() throws IOException {
+ return loadFromClassLoader("extlibraryRight.ecore");
+ }
+
+ public Resource getOrigin() throws IOException {
+ return loadFromClassLoader("extlibraryOrigin.ecore");
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryLeft.ecore b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryLeft.ecore
new file mode 100644
index 000000000..f106458be
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryLeft.ecore
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmi:id="_14sTEG60EeGkd4g88tZXfA" name="extlibrary" nsURI="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0"
+ nsPrefix="extlib">
+ <eClassifiers xsi:type="ecore:EClass" xmi:id="_146VgG60EeGkd4g88tZXfA" name="Book">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_146VgW60EeGkd4g88tZXfA"
+ name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryOrigin.ecore b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryOrigin.ecore
new file mode 100644
index 000000000..79bb60bdb
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryOrigin.ecore
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmi:id="_14sTEG60EeGkd4g88tZXfA" name="extlibrary" nsURI="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0"
+ nsPrefix="extlib">
+ <eClassifiers xsi:type="ecore:EClass" xmi:id="_146VgG60EeGkd4g88tZXfA" name="Book">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_146VgW60EeGkd4g88tZXfA"
+ name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_146Vg260EeGkd4g88tZXfA"
+ name="pages" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
+ defaultValueLiteral="100"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryRight.ecore b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryRight.ecore
new file mode 100644
index 000000000..cc5684e90
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/match/data/extlibraryRight.ecore
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmi:id="_14sTEG60EeGkd4g88tZXfA" name="extlibrary" nsURI="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0"
+ nsPrefix="extlib">
+ <eClassifiers xsi:type="ecore:EClass" xmi:id="_146VgG60EeGkd4g88tZXfA" name="Book">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_146Vg260EeGkd4g88tZXfA"
+ name="pages" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
+ defaultValueLiteral="100"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_1468kW60EeGkd4g88tZXfA"
+ name="category" unsettable="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" xmi:id="_148KsG60EeGkd4g88tZXfA"
+ name="author" lowerBound="1"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_9MlYMG9IEeGekPcBm25hwQ"
+ name="subtitle" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemFeatureMapsTest.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemFeatureMapsTest.java
index 007aadf57..d89e568b8 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemFeatureMapsTest.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemFeatureMapsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2015 Obeo.
* 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
@@ -17,6 +17,8 @@ import java.io.IOException;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.EMFCompare.Builder;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl.MergeViewerItem;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.IMergeViewerItem;
@@ -50,7 +52,9 @@ public class MergeViewerItemFeatureMapsTest {
final Resource rightResource = inputData.getNodesRight();
final IComparisonScope scope = new DefaultComparisonScope(leftResource, rightResource, null);
- comparison = EMFCompare.builder().build().compare(scope);
+ final Builder comparisonBuilder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(comparisonBuilder);
+ comparison = comparisonBuilder.build().compare(scope);
}
@Test
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemPseudoConflictTest.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemPseudoConflictTest.java
index 86c57dc73..e87b1a681 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemPseudoConflictTest.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemPseudoConflictTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2015 Obeo.
* 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,6 +22,8 @@ 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.EMFCompare.Builder;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl.MergeViewerItem;
import org.eclipse.emf.compare.rcp.ui.internal.util.MergeViewerUtil;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide;
@@ -60,7 +62,9 @@ public class MergeViewerItemPseudoConflictTest {
final Resource rightResource = inputData.getRight();
final IComparisonScope scope = new DefaultComparisonScope(leftResource, rightResource, null);
- comparison = EMFCompare.builder().build().compare(scope);
+ final Builder comparisonBuilder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(comparisonBuilder);
+ comparison = comparisonBuilder.build().compare(scope);
}
@Test
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemTest.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemTest.java
index 9b91ebe86..639cb084c 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemTest.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/mergeviewer/item/MergeViewerItemTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Obeo.
+ * Copyright (c) 2013, 2015 Obeo.
* 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,6 +22,8 @@ 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.EMFCompare.Builder;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.impl.AbstractTableOrTreeMergeViewer.ElementComparer;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl.MergeViewerItem;
import org.eclipse.emf.compare.rcp.ui.internal.util.MergeViewerUtil;
@@ -62,7 +64,9 @@ public class MergeViewerItemTest {
final Resource rightResource = inputData.getExtlibraryRight();
final IComparisonScope scope = new DefaultComparisonScope(leftResource, rightResource, null);
- comparison = EMFCompare.builder().build().compare(scope);
+ final Builder comparisonBuilder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(comparisonBuilder);
+ comparison = comparisonBuilder.build().compare(scope);
}
@Test
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
index 56bbadb6b..029930597 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 Obeo.
+ * Copyright (c) 2013, 2015 Obeo.
* 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
@@ -21,6 +21,8 @@ import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.compare.EMFCompare.Builder;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider.TreeItemProviderAdapterFactorySpec;
import org.eclipse.emf.compare.scope.DefaultComparisonScope;
import org.eclipse.emf.compare.scope.IComparisonScope;
@@ -38,6 +40,7 @@ import com.google.common.base.Predicate;
/**
* @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
*/
+@SuppressWarnings("restriction")
public class AbstractTestTreeNodeItemProviderAdapter {
protected static TreeItemProviderAdapterFactorySpec treeItemProviderAdapterFactory;
@@ -54,7 +57,9 @@ public class AbstractTestTreeNodeItemProviderAdapter {
protected static Comparison getComparison(ResourceScopeProvider scopeProvider) throws IOException {
final IComparisonScope scope = new DefaultComparisonScope(scopeProvider.getLeft(), scopeProvider
.getRight(), scopeProvider.getOrigin());
- return EMFCompare.builder().build().compare(scope);
+ final Builder builder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(builder);
+ return builder.build().compare(scope);
}
/**
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java
index 6b9664f6f..f7f7d24a8 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 Obeo.
+ * Copyright (c) 2013, 2015 Obeo.
* 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
@@ -15,6 +15,7 @@ import junit.framework.Test;
import junit.textui.TestRunner;
import org.eclipse.emf.compare.ComparePackage;
+import org.eclipse.emf.compare.rcp.ui.tests.match.RCPMatchEngineFactoryRegistryTest;
import org.eclipse.emf.compare.rcp.ui.tests.mergeviewer.item.MergeViewerItemFeatureMapsTest;
import org.eclipse.emf.compare.rcp.ui.tests.mergeviewer.item.MergeViewerItemPseudoConflictTest;
import org.eclipse.emf.compare.rcp.ui.tests.mergeviewer.item.MergeViewerItemTest;
@@ -38,7 +39,8 @@ import org.junit.runners.Suite.SuiteClasses;
TestReferenceChangeTreeNodeItemProviderSpec.class,
MergeViewerItemTest.class, MergeViewerItemPseudoConflictTest.class, MergeViewerItemFeatureMapsTest.class,
TestBasicDifferenceGroupImpl.class, BugsTestSuite.class,
- TestFeatureMapDifferencesFilter.class})
+ TestFeatureMapDifferencesFilter.class,
+ RCPMatchEngineFactoryRegistryTest.class})
public class AllTests {
/**
* Launches the test with the given arguments.
diff --git a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/EMFCompareBuilderConfigurator.java b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/EMFCompareBuilderConfigurator.java
index 83cae3b41..6ba60997e 100644
--- a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/EMFCompareBuilderConfigurator.java
+++ b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/EMFCompareBuilderConfigurator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2015 Obeo.
* 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
@@ -18,7 +18,7 @@ import org.eclipse.emf.compare.conflict.IConflictDetector;
import org.eclipse.emf.compare.diff.IDiffEngine;
import org.eclipse.emf.compare.equi.IEquiEngine;
import org.eclipse.emf.compare.match.IMatchEngine;
-import org.eclipse.emf.compare.match.IMatchEngine.Factory.Registry;
+import org.eclipse.emf.compare.postprocessor.IPostProcessor;
import org.eclipse.emf.compare.rcp.EMFCompareRCPPlugin;
import org.eclipse.emf.compare.rcp.internal.extension.IEMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.rcp.internal.preferences.EMFComparePreferences;
@@ -37,30 +37,39 @@ public class EMFCompareBuilderConfigurator implements IEMFCompareBuilderConfigur
/** Match engine factory registry. */
private final IMatchEngine.Factory.Registry matchEngineFactoryRegistry;
+ /** Post Processor registry. */
+ private final IPostProcessor.Descriptor.Registry<String> postProcessorRegistry;
+
/**
* Constructor.
*
* @param enginePreferences
* {@link EMFCompareBuilderConfigurator#enginePreferences}
* @param matchEngineFactoryRegistry
- * {@link IMatchEngine.Factory.Registry} that hold Match Engine factories.
+ * {@link IMatchEngine.Factory.Registry} that holds Match Engine factories.
+ * @param postProcessorRegistry
+ * {@link IPostProcessor.Descriptor.Registry} that holds post processors.
*/
public EMFCompareBuilderConfigurator(IEclipsePreferences enginePreferences,
- IMatchEngine.Factory.Registry matchEngineFactoryRegistry) {
+ IMatchEngine.Factory.Registry matchEngineFactoryRegistry,
+ IPostProcessor.Descriptor.Registry<String> postProcessorRegistry) {
Preconditions.checkNotNull(enginePreferences);
this.enginePreferences = enginePreferences;
this.matchEngineFactoryRegistry = matchEngineFactoryRegistry;
+ this.postProcessorRegistry = postProcessorRegistry;
}
/**
- * Get EMFCompareBuilderConfigurator with EMF Compare default values. Get the default preference store and
- * the default {@link IMatchEngine.Factory.Registry}.
+ * Get EMFCompareBuilderConfigurator with EMF Compare default values. Get the default preference store,
+ * the default {@link IMatchEngine.Factory.Registry} and the default
+ * {@link IPostProcessor.Descriptor.Registry}.
*
* @return Default EMFCompareBuilderConfigurator;
*/
public static EMFCompareBuilderConfigurator createDefault() {
return new EMFCompareBuilderConfigurator(EMFCompareRCPPlugin.getDefault().getEMFComparePreferences(),
- EMFCompareRCPPlugin.getDefault().getMatchEngineFactoryRegistry());
+ EMFCompareRCPPlugin.getDefault().getMatchEngineFactoryRegistry(), EMFCompareRCPPlugin
+ .getDefault().getPostProcessorRegistry());
}
/**
@@ -111,9 +120,11 @@ public class EMFCompareBuilderConfigurator implements IEMFCompareBuilderConfigur
* {@inheritDoc}
*/
public void configure(Builder builder) {
- Registry matchEngineRegistry = matchEngineFactoryRegistry;
- if (matchEngineRegistry != null) {
- builder.setMatchEngineFactoryRegistry(matchEngineRegistry);
+ if (matchEngineFactoryRegistry != null) {
+ builder.setMatchEngineFactoryRegistry(matchEngineFactoryRegistry);
+ }
+ if (postProcessorRegistry != null) {
+ builder.setPostProcessorRegistry(postProcessorRegistry);
}
IDiffEngine diffEngine = getDiffEngine();
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/rcp/MatchEngineFactoryRegistryWrapperTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/rcp/MatchEngineFactoryRegistryWrapperTest.java
index 46f5e6005..cb356f409 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/rcp/MatchEngineFactoryRegistryWrapperTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/rcp/MatchEngineFactoryRegistryWrapperTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2015 Obeo.
* 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
@@ -11,6 +11,7 @@
package org.eclipse.emf.compare.tests.rcp;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
@@ -24,6 +25,7 @@ import java.util.Collections;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.match.IMatchEngine;
import org.eclipse.emf.compare.match.IMatchEngine.Factory;
import org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl;
@@ -284,6 +286,36 @@ public class MatchEngineFactoryRegistryWrapperTest {
}
+ @Test
+ public void testEMFCompareBuilder() throws IOException {
+ IMatchEngine.Factory factory = new MockMatchEngineFactory1();
+ factory.setRanking(10);
+ registryWrapper.add(factory);
+
+ IMatchEngine.Factory factory2 = new MockMatchEngineFactory2();
+ factory2.setRanking(20);
+ registryWrapper.add(factory2);
+
+ IMatchEngine.Factory factory3 = new MockMatchEngineFactory3();
+ factory3.setRanking(30);
+ registryWrapper.add(factory3);
+
+ MockBuilder mockBuilder = new MockBuilder();
+ mockBuilder.build();
+
+ IMatchEngine.Factory.Registry builderMatchEngineFactoryRegistry = mockBuilder
+ .getMatchEngineFactoryRegistry();
+
+ assertNotSame(registryWrapper, builderMatchEngineFactoryRegistry);
+
+ mockBuilder.setMatchEngineFactoryRegistry(registryWrapper);
+ mockBuilder.build();
+ builderMatchEngineFactoryRegistry = mockBuilder.getMatchEngineFactoryRegistry();
+
+ assertSame(registryWrapper, builderMatchEngineFactoryRegistry);
+
+ }
+
/**
* Disables engine in preferences.
*
@@ -353,4 +385,15 @@ public class MatchEngineFactoryRegistryWrapperTest {
*/
private static class MockMatchEngineFactory3 extends MatchEngineFactoryImpl {
}
+
+ /**
+ * Mock {@link EMFCompare.Builder} in order to access matchEngineFactoryRegistry field.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+ private static class MockBuilder extends EMFCompare.Builder {
+ public IMatchEngine.Factory.Registry getMatchEngineFactoryRegistry() {
+ return this.matchEngineFactoryRegistry;
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF
index b46369da8..d963662d4 100644
--- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.uml2.uml.edit;bundle-version="5.0.0",
org.eclipse.emf.compare.uml2.rcp.ui;bundle-version="2.2.0",
org.eclipse.uml2.uml.resources,
- org.eclipse.emf.compare.uml2.tests
+ org.eclipse.emf.compare.uml2.tests,
+ org.eclipse.emf.compare.rcp
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java
index 3d0a0c493..e711a1d1a 100644
--- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java
+++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2015 Obeo.
* 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
@@ -33,7 +33,7 @@ import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.EMFCompare.Builder;
import org.eclipse.emf.compare.postprocessor.IPostProcessor;
-import org.eclipse.emf.compare.postprocessor.IPostProcessor.Descriptor.Registry;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.StructureMergeViewerFilter;
import org.eclipse.emf.compare.scope.DefaultComparisonScope;
import org.eclipse.emf.compare.scope.IComparisonScope;
@@ -59,6 +59,7 @@ import org.junit.Before;
*
* @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
*/
+@SuppressWarnings("restriction")
public abstract class AbstractDifferenceOrderTest {
/**
@@ -200,11 +201,8 @@ public abstract class AbstractDifferenceOrderTest {
private Comparison getComparison(NotifierScopeProvider scopeProvider) throws IOException {
final IComparisonScope scope = new DefaultComparisonScope(scopeProvider.getLeft(), scopeProvider
.getRight(), scopeProvider.getOrigin());
- Builder builder = EMFCompare.builder();
- Registry<?> postProcessorRegistry = getPostProcessorRegistry();
- if (postProcessorRegistry != null) {
- builder.setPostProcessorRegistry(postProcessorRegistry);
- }
+ final Builder builder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(builder);
return builder.build().compare(scope);
}

Back to the top