Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2012-09-26 14:45:34 +0000
committerlgoubet2012-09-26 14:45:34 +0000
commit6feae2b46a2f2936a728754bec81c46ff8c7fb8e (patch)
tree0eef0a84f0fc54120a9f7faa504d4a016e831a21 /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation
parent09d79cd1bfece484f9d1990f7c7d7f109b9402ef (diff)
downloadorg.eclipse.emf.compare-6feae2b46a2f2936a728754bec81c46ff8c7fb8e.tar.gz
org.eclipse.emf.compare-6feae2b46a2f2936a728754bec81c46ff8c7fb8e.tar.xz
org.eclipse.emf.compare-6feae2b46a2f2936a728754bec81c46ff8c7fb8e.zip
Renaming AbstractInputData#loadFromClassLoader (typo).
Drafting the fragmentation tests.
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/FragmentationTest.java93
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/FragmentationInputData.java45
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/fragment.nodes2
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/left.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/origin.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/right.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/left.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/origin.nodes5
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/right.nodes5
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/left.nodes5
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/origin.nodes7
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/right.nodes7
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/fragment.nodes2
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/left.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/origin.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/right.nodes4
16 files changed, 199 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/FragmentationTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/FragmentationTest.java
new file mode 100644
index 000000000..5ac5c87c5
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/FragmentationTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.fragmentation;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertSame;
+import static junit.framework.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceKind;
+import org.eclipse.emf.compare.DifferenceSource;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.ResourceAttachmentChange;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.eclipse.emf.compare.tests.fragmentation.data.FragmentationInputData;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+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;
+
+@SuppressWarnings("nls")
+public class FragmentationTest {
+ private final FragmentationInputData input = new FragmentationInputData();
+
+ @Test
+ public void testDeletedRootResourceSet() throws IOException {
+ final Resource left = input.getDeletedRootLeft();
+ final Resource origin = input.getDeletedRootOrigin();
+ final Resource right = input.getDeletedRootRight();
+
+ final ResourceSet leftSet = left.getResourceSet();
+ final ResourceSet originSet = origin.getResourceSet();
+ final ResourceSet rightSet = right.getResourceSet();
+
+ assertNotNull(leftSet);
+ assertNotNull(originSet);
+ assertNotNull(rightSet);
+
+ EcoreUtil.resolveAll(leftSet);
+ EcoreUtil.resolveAll(originSet);
+ EcoreUtil.resolveAll(rightSet);
+
+ assertSame(Integer.valueOf(1), Integer.valueOf(leftSet.getResources().size()));
+ assertSame(Integer.valueOf(1), Integer.valueOf(originSet.getResources().size()));
+ assertSame(Integer.valueOf(1), Integer.valueOf(rightSet.getResources().size()));
+
+ final IComparisonScope scope = EMFCompare.createDefaultScope(leftSet, rightSet, originSet);
+ Comparison comparison = EMFCompare.newComparator(scope).compare();
+
+ final List<Diff> differences = comparison.getDifferences();
+ assertSame(Integer.valueOf(1), Integer.valueOf(differences.size()));
+
+ final Diff diff = differences.get(0);
+ assertTrue(diff instanceof ResourceAttachmentChange);
+ assertEquals(diff.getMatch().getRight(), getNodeNamed(right, "deletedRoot"));
+ assertEquals(diff.getMatch().getOrigin(), getNodeNamed(origin, "deletedRoot"));
+ assertNull(diff.getMatch().getLeft());
+ assertSame(diff.getSource(), DifferenceSource.LEFT);
+ assertSame(diff.getKind(), DifferenceKind.DELETE);
+
+ comparison = EMFCompare.newComparator(scope).compare();
+ assertSame(Integer.valueOf(0), Integer.valueOf(comparison.getDifferences().size()));
+ }
+
+ private EObject getNodeNamed(Resource res, String name) {
+ final Iterator<EObject> iterator = EcoreUtil.getAllProperContents(res, false);
+ while (iterator.hasNext()) {
+ final EObject next = iterator.next();
+ final EStructuralFeature nameFeature = next.eClass().getEStructuralFeature("name");
+ if (nameFeature != null && name.equals(next.eGet(nameFeature))) {
+ return next;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/FragmentationInputData.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/FragmentationInputData.java
new file mode 100644
index 000000000..83b4c4dc0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/FragmentationInputData.java
@@ -0,0 +1,45 @@
+/**
+ * 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.fragmentation.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;
+
+// We'll use a resource set for these tests
+@SuppressWarnings("nls")
+public class FragmentationInputData extends AbstractInputData {
+ public Resource getControlLeft() throws IOException {
+ return loadFromClassLoader("control/left.nodes", new ResourceSetImpl());
+ }
+
+ public Resource getControlOrigin() throws IOException {
+ return loadFromClassLoader("control/origin.nodes", new ResourceSetImpl());
+ }
+
+ public Resource getControlRight() throws IOException {
+ return loadFromClassLoader("control/right.nodes", new ResourceSetImpl());
+ }
+
+ public Resource getDeletedRootLeft() throws IOException {
+ return loadFromClassLoader("deletedroot/left.nodes", new ResourceSetImpl());
+ }
+
+ public Resource getDeletedRootOrigin() throws IOException {
+ return loadFromClassLoader("deletedroot/origin.nodes", new ResourceSetImpl());
+ }
+
+ public Resource getDeletedRootRight() throws IOException {
+ return loadFromClassLoader("deletedroot/right.nodes", new ResourceSetImpl());
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/fragment.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/fragment.nodes
new file mode 100644
index 000000000..27bbfc1a5
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/fragment.nodes
@@ -0,0 +1,2 @@
+<?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="_QE6YYAcQEeKTxJtDIb3mMw" name="fragmented"/> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/left.nodes
new file mode 100644
index 000000000..b75ab1666
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/left.nodes
@@ -0,0 +1,4 @@
+<?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="_ORexoLlNEeGmS9ESxeCLvg" name="root">
+ <containmentRef1 href="fragment.nodes#_QE6YYAcQEeKTxJtDIb3mMw"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/origin.nodes
new file mode 100644
index 000000000..3a9424aa9
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/origin.nodes
@@ -0,0 +1,4 @@
+<?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="_ORexoLlNEeGmS9ESxeCLvg" name="root">
+ <containmentRef1 xmi:id="_QE6YYAcQEeKTxJtDIb3mMw" name="fragmented"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/right.nodes
new file mode 100644
index 000000000..3a9424aa9
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/control/right.nodes
@@ -0,0 +1,4 @@
+<?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="_ORexoLlNEeGmS9ESxeCLvg" name="root">
+ <containmentRef1 xmi:id="_QE6YYAcQEeKTxJtDIb3mMw" name="fragmented"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/left.nodes
new file mode 100644
index 000000000..dcc0c4a0b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/left.nodes
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes">
+ <nodes:Node xmi:id="_ORexoLlNEeGmS9ESxeCLvg" name="root"/>
+</xmi:XMI> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/origin.nodes
new file mode 100644
index 000000000..bdd57d7dc
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/origin.nodes
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes">
+ <nodes:Node xmi:id="_ORexoLlNEeGmS9ESxeCLvg" name="root"/>
+ <nodes:Node xmi:id="_ORexoLlNEeGmS9ESxeCLvz" name="deletedRoot"/>
+</xmi:XMI>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/right.nodes
new file mode 100644
index 000000000..bdd57d7dc
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/deletedroot/right.nodes
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes">
+ <nodes:Node xmi:id="_ORexoLlNEeGmS9ESxeCLvg" name="root"/>
+ <nodes:Node xmi:id="_ORexoLlNEeGmS9ESxeCLvz" name="deletedRoot"/>
+</xmi:XMI>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/left.nodes
new file mode 100644
index 000000000..4299ba385
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/left.nodes
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes">
+ <nodes:Node xmi:id="_ORexoLlNEeGmS9ESxeCLvg" name="root"/>
+ <nodes:Node xmi:id="_ORexoLlNEeGmS9ESxeCLvz" name="newRoot"/>
+</xmi:XMI>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/origin.nodes
new file mode 100644
index 000000000..6d8762bae
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/origin.nodes
@@ -0,0 +1,7 @@
+<?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="_ORexoLlNEeGmS9ESxeCLvg"
+ name="root"/>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/right.nodes
new file mode 100644
index 000000000..6d8762bae
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/newroot/right.nodes
@@ -0,0 +1,7 @@
+<?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="_ORexoLlNEeGmS9ESxeCLvg"
+ name="root"/>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/fragment.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/fragment.nodes
new file mode 100644
index 000000000..27bbfc1a5
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/fragment.nodes
@@ -0,0 +1,2 @@
+<?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="_QE6YYAcQEeKTxJtDIb3mMw" name="fragmented"/> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/left.nodes
new file mode 100644
index 000000000..3a9424aa9
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/left.nodes
@@ -0,0 +1,4 @@
+<?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="_ORexoLlNEeGmS9ESxeCLvg" name="root">
+ <containmentRef1 xmi:id="_QE6YYAcQEeKTxJtDIb3mMw" name="fragmented"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/origin.nodes
new file mode 100644
index 000000000..b75ab1666
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/origin.nodes
@@ -0,0 +1,4 @@
+<?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="_ORexoLlNEeGmS9ESxeCLvg" name="root">
+ <containmentRef1 href="fragment.nodes#_QE6YYAcQEeKTxJtDIb3mMw"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/right.nodes
new file mode 100644
index 000000000..b75ab1666
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/data/uncontrol/right.nodes
@@ -0,0 +1,4 @@
+<?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="_ORexoLlNEeGmS9ESxeCLvg" name="root">
+ <containmentRef1 href="fragment.nodes#_QE6YYAcQEeKTxJtDIb3mMw"/>
+</nodes:Node>

Back to the top