Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2017-05-17 11:47:47 -0400
committerEike Stepper2017-05-17 11:47:47 -0400
commitc310ac782023d7ff7fe22661fe260b7f505ee810 (patch)
tree75378eaec000f2124d01015b4ebbb4b766062b4a /plugins/org.eclipse.emf.cdo.tests/src
parent2def4a8c9bafcfaa9500a0e06fdaf0e07eca154a (diff)
downloadcdo-c310ac782023d7ff7fe22661fe260b7f505ee810.tar.gz
cdo-c310ac782023d7ff7fe22661fe260b7f505ee810.tar.xz
cdo-c310ac782023d7ff7fe22661fe260b7f505ee810.zip
[516824] Multiple revision instances are loaded during branch switch
https://bugs.eclipse.org/bugs/show_bug.cgi?id=516824
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_516824_Test.java91
1 files changed, 91 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_516824_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_516824_Test.java
new file mode 100644
index 0000000000..a96b9db166
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_516824_Test.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017 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:
+ * Maxime Porhel (Obeo) - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+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.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Supplier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+
+/**
+ * Bug 516824: Multiple revision instances are loaded during branch switch.
+ *
+ * @author Maxime Porhel (Obeo)
+ */
+@CleanRepositoriesBefore(reason = "because")
+@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+public class Bugzilla_516824_Test extends AbstractCDOTest
+{
+ /**
+ * Ensure that there is no ClassCastException thrown during the branch switching.
+ */
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testSetBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.setName("s0");
+ // supplier.setPreferred(false); default value
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("c0");
+ company.getSuppliers().add(supplier);
+
+ CDOResource resource = transaction.createResource("newResource.company");
+ resource.getContents().add(company);
+
+ transaction.commit();
+
+ // Make sure invalidation will trigger delta notifications
+ resource.eAdapters().add(new EContentAdapter());
+
+ CDOBranch subBranch = transaction.getBranch().createBranch("subBranch");
+ transaction.setBranch(subBranch);
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testSetBranchLegacy() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource("newResource.ecore");
+ EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
+ EClass eClass = EcoreFactory.eINSTANCE.createEClass();
+
+ ePackage.setName("p0");
+ eClass.setName("c0");
+
+ resource.getContents().add(ePackage);
+ ePackage.getEClassifiers().add(eClass);
+
+ transaction.commit();
+
+ // Make sure invalidation will trigger delta notifications
+ resource.eAdapters().add(new EContentAdapter());
+
+ CDOBranch subBranch = transaction.getBranch().createBranch("subBranch");
+ transaction.setBranch(subBranch);
+ }
+}

Back to the top