Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Lagarde2014-05-31 16:44:46 +0000
committerEsteban Dugueperoux2014-09-03 07:30:01 +0000
commite3e8d94e474188b763fcdb40a5c06ab7a8d9c227 (patch)
tree931fb3819f33ee38979e40b541b19184fea99853
parenta9c4ebc430092b4bd902167ad57e0d958d2e5082 (diff)
downloadcdo-e3e8d94e474188b763fcdb40a5c06ab7a8d9c227.tar.gz
cdo-e3e8d94e474188b763fcdb40a5c06ab7a8d9c227.tar.xz
cdo-e3e8d94e474188b763fcdb40a5c06ab7a8d9c227.zip
[435532] Reordering elements in a containment feature causes DBException
when audit mode is activated https://bugs.eclipse.org/bugs/show_bug.cgi?id=435532 - added test case Change-Id: I4e5b5ab66e3f5d542b86e2af28695bda9aa3d4b7 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=435532
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.all/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.all/src/org/eclipse/emf/cdo/tests/all/GerritTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java130
3 files changed, 134 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.all/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests.all/META-INF/MANIFEST.MF
index 55395a53f3..afff98aa00 100644
--- a/plugins/org.eclipse.emf.cdo.tests.all/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests.all/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.tests.all;singleton:=true
-Bundle-Version: 4.1.200.qualifier
+Bundle-Version: 4.1.300.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,5 +12,5 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.net4j.tests;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests.db;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.tests.all;version="4.1.200";x-internal:=true,
- org.eclipse.emf.cdo.tests.all.bundle;version="4.1.200";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.tests.all;version="4.1.300";x-internal:=true,
+ org.eclipse.emf.cdo.tests.all.bundle;version="4.1.300";x-internal:=true
diff --git a/plugins/org.eclipse.emf.cdo.tests.all/src/org/eclipse/emf/cdo/tests/all/GerritTests.java b/plugins/org.eclipse.emf.cdo.tests.all/src/org/eclipse/emf/cdo/tests/all/GerritTests.java
index e0ee9a23c4..10aad4bfb8 100644
--- a/plugins/org.eclipse.emf.cdo.tests.all/src/org/eclipse/emf/cdo/tests/all/GerritTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests.all/src/org/eclipse/emf/cdo/tests/all/GerritTests.java
@@ -31,6 +31,7 @@ public class GerritTests extends DBConfigs
@Override
protected void initConfigSuites(TestSuite parent)
{
+ addScenario(parent, new H2Config(false, false, true, false, IDGenerationLocation.STORE), JVM, NATIVE);
addScenario(parent, new H2Config(true, true, true, false, IDGenerationLocation.STORE), JVM, NATIVE);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java
new file mode 100644
index 0000000000..c24809437b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2014 Eike Stepper (Berlin, Germany) 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:
+ * Alex Lagarde - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ConcurrentAccessException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests ensuring that moving elements inside the same containment list does not cause any issue when committing.
+ *
+ * @author Alex Lagarde
+ */
+@Skips({ IRepositoryConfig.CAPABILITY_AUDITING, IRepositoryConfig.CAPABILITY_BRANCHING })
+public class Bugzilla_435532_Test extends AbstractCDOTest
+{
+ private static final int CHILDREN_NUMBER = 100;
+
+ private static final int CHILDREN_TO_MOVE_NUMBER = 50;
+
+ private Company root;
+
+ private CDOSession cdoSession;
+
+ private CDOTransaction cdoTransaction;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+
+ // Initialize semantic model
+ cdoSession = openSession();
+ cdoTransaction = cdoSession.openTransaction();
+ CDOResource resource = cdoTransaction.createResource(getResourcePath("resource"));
+
+ // Create a root with CHILDREN_NUMBER children
+ root = getModel1Factory().createCompany();
+ for (int i = 0; i < CHILDREN_NUMBER; i++)
+ {
+ root.getCategories().add(getModel1Factory().createCategory());
+ }
+ resource.getContents().add(root);
+ cdoTransaction.commit();
+ }
+
+ /**
+ * Ensures that moving elements at the end of the same containment list does not cause any issue when committing.
+ */
+ public void testDragChildrenAtListEnd() throws ConcurrentAccessException, CommitException
+ {
+ doTestDragChildren(CHILDREN_NUMBER - 1);
+ }
+
+ /**
+ * Ensures that moving elements at the beginning of the same containment list does not cause any issue when committing.
+ */
+ public void testDragChildrenAtListBegin() throws ConcurrentAccessException, CommitException
+ {
+ doTestDragChildren(0);
+ }
+
+ private void doTestDragChildren(int newPosition) throws ConcurrentAccessException, CommitException
+ {
+ // Step 1: get children to move
+ List<Category> childrenToMove = new ArrayList<Category>(root.getCategories().subList(20,
+ 20 + CHILDREN_TO_MOVE_NUMBER));
+ List<CDOID> childrenToMoveIds = new ArrayList<CDOID>();
+ for (Category child : childrenToMove)
+ {
+ childrenToMoveIds.add(CDOUtil.getCDOObject(child).cdoID());
+ }
+
+ // Step 2: move each child through a command
+ for (int i = 0; i < childrenToMove.size(); i++)
+ {
+ Category childToMove = childrenToMove.get(i);
+ root.getCategories().move(newPosition, childToMove);
+ }
+
+ // Step 3: commit
+ cdoTransaction.commit();
+
+ // Step 4: check that move correctly occured
+ cdoTransaction.close();
+ cdoSession.close();
+ cdoSession = openSession();
+ cdoTransaction = cdoSession.openTransaction();
+ root = (Company)cdoTransaction.getResource(getResourcePath("resource")).getContents().get(0);
+ childrenToMove = new ArrayList<Category>();
+ for (CDOID childID : childrenToMoveIds)
+ {
+ childrenToMove.add((Category)CDOUtil.getEObject(cdoTransaction.getObject(childID)));
+ }
+ for (int i = 0; i < childrenToMove.size(); i++)
+ {
+ int expectedPosition = Math.abs(newPosition - i);
+ Category child = childrenToMove.get(childrenToMove.size() - 1 - i);
+ assertEquals(expectedPosition, root.getCategories().indexOf(child));
+ }
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ cdoTransaction.close();
+ cdoSession.close();
+ super.doTearDown();
+ }
+}

Back to the top