Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2012-10-30 16:19:04 +0000
committercbrun2012-10-30 16:19:04 +0000
commitd4baffb304c8b7e66539916eba95cf8d7895b4b3 (patch)
tree18ab5fffe1b2757e51800c2fae42f961421bbbe7 /plugins/org.eclipse.emf.compare.tests/src
parentb272348f52e9f5ca24140a8dd09ac484e8bb8187 (diff)
downloadorg.eclipse.emf.compare-d4baffb304c8b7e66539916eba95cf8d7895b4b3.tar.gz
org.eclipse.emf.compare-d4baffb304c8b7e66539916eba95cf8d7895b4b3.tar.xz
org.eclipse.emf.compare-d4baffb304c8b7e66539916eba95cf8d7895b4b3.zip
Merge Brute Force Testing
Add a simple fuzzy test
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/FuzzyTest.java106
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java3
2 files changed, 108 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/FuzzyTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/FuzzyTest.java
new file mode 100644
index 000000000..fde3fc816
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/FuzzyTest.java
@@ -0,0 +1,106 @@
+/**
+ * Copyright (c) 2012 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.tests;
+
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.emfstore.fuzzy.Annotations.Data;
+import org.eclipse.emf.emfstore.fuzzy.Annotations.DataProvider;
+import org.eclipse.emf.emfstore.fuzzy.Annotations.Util;
+import org.eclipse.emf.emfstore.fuzzy.FuzzyRunner;
+import org.eclipse.emf.emfstore.fuzzy.emf.EMFDataProvider;
+import org.eclipse.emf.emfstore.fuzzy.emf.MutateUtil;
+import org.eclipse.emf.emfstore.modelmutator.api.ModelMutatorConfiguration;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * A brute force test using fuzzy testing.
+ *
+ * @author <a href="mailto:cedric.brun@obeo.fr">Cedric Brun</a>
+ */
+@RunWith(FuzzyRunner.class)
+@DataProvider(EMFDataProvider.class)
+public class FuzzyTest {
+
+ @Data
+ private EObject root;
+
+ @Util
+ private MutateUtil util;
+
+ /**
+ * Test to check if the {@link FuzzyRunner} is working.
+ */
+ @Test
+ public void detectingNoDifferenceOnACopy() {
+ Assert.assertNotNull(root);
+ EObject backup = EcoreUtil.copy(root);
+ Comparison result = EMFCompare.builder().build().compare(EMFCompare.createDefaultScope(root, backup));
+ Assert.assertEquals(0, result.getDifferences().size());
+ }
+
+ /**
+ * Test to check if the {@link FuzzyRunner} is working.
+ */
+ @Test
+ @Ignore
+ public void copyAllRightToLeft() {
+ Assert.assertNotNull(root);
+ EObject backup = EcoreUtil.copy(root);
+ ModelMutatorConfiguration conf = new ModelMutatorConfiguration(EcorePackage.eINSTANCE, root, 1L);
+ conf.setMaxDeleteCount(20);
+
+ util.mutate(conf);
+
+ Comparison result = EMFCompare.builder().build().compare(EMFCompare.createDefaultScope(root, backup));
+ int nbDiffs = result.getDifferences().size();
+
+ for (Diff delta : result.getDifferences()) {
+ delta.copyRightToLeft();
+ }
+
+ Comparison valid = EMFCompare.builder().build().compare(EMFCompare.createDefaultScope(root, backup));
+ Assert.assertEquals("We still have differences after merging all of them (had " + nbDiffs
+ + " to merge in the beginning)", 0, valid.getDifferences().size());
+
+ }
+
+ /**
+ * Test to check if the {@link FuzzyRunner} is working.
+ */
+ @Test
+ @Ignore
+ public void copyAllLeftToRight() {
+ Assert.assertNotNull(root);
+ EObject backup = EcoreUtil.copy(root);
+ ModelMutatorConfiguration conf = new ModelMutatorConfiguration(EcorePackage.eINSTANCE, root, 1L);
+ conf.setMaxDeleteCount(20);
+
+ util.mutate(conf);
+
+ Comparison result = EMFCompare.builder().build().compare(EMFCompare.createDefaultScope(root, backup));
+ int nbDiffs = result.getDifferences().size();
+ for (Diff delta : result.getDifferences()) {
+ delta.copyLeftToRight();
+ }
+
+ Comparison valid = EMFCompare.builder().build().compare(EMFCompare.createDefaultScope(root, backup));
+ Assert.assertEquals("We still have differences after merging all of them (had " + nbDiffs
+ + " to merge in the beginning)", 0, valid.getDifferences().size());
+ }
+}
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 c478c6fc0..f14f0ded0 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
@@ -15,6 +15,7 @@ import junit.framework.Test;
import junit.textui.TestRunner;
import org.eclipse.emf.compare.ComparePackage;
+import org.eclipse.emf.compare.tests.FuzzyTest;
import org.eclipse.emf.compare.tests.conflict.ConflictDetectionTest;
import org.eclipse.emf.compare.tests.diff.DiffUtilTest;
import org.eclipse.emf.compare.tests.diff.URIDistanceTest;
@@ -48,7 +49,7 @@ import org.junit.runners.Suite.SuiteClasses;
ConflictDetectionTest.class, ReqComputingTest.class, EquiComputingTest.class, DiffUtilTest.class,
MultipleMergeTest.class, PostProcessorTest.class, IndividualMergeTest.class,
IndividualMergeOutOfScopeValuesTest.class, ProximityComparisonTest.class,
- DynamicInstanceComparisonTest.class, URIDistanceTest.class, FragmentationTest.class })
+ DynamicInstanceComparisonTest.class, URIDistanceTest.class, FragmentationTest.class, FuzzyTest.class })
public class AllTests {
/**
* Standalone launcher for all of compare's tests.

Back to the top