diff options
author | Eike Stepper | 2013-10-20 04:01:03 +0000 |
---|---|---|
committer | Eike Stepper | 2013-10-20 04:01:03 +0000 |
commit | 89401a02e4655f50121d7cc275066731621776dc (patch) | |
tree | d5b159dd4c4eb6a5e8a9da05d13d1a098627b38e /plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo | |
parent | 818bb91c31a41509583a81ebe37439c187ea5cfd (diff) | |
download | cdo-89401a02e4655f50121d7cc275066731621776dc.tar.gz cdo-89401a02e4655f50121d7cc275066731621776dc.tar.xz cdo-89401a02e4655f50121d7cc275066731621776dc.zip |
[419574] NPE in CDOMergingConflictResolver
https://bugs.eclipse.org/bugs/show_bug.cgi?id=419574
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_419574_Test.java | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_419574_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_419574_Test.java new file mode 100644 index 0000000000..d855a20443 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_419574_Test.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.bugzilla; + +import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.model1.Company; +import org.eclipse.emf.cdo.tests.model1.Customer; +import org.eclipse.emf.cdo.tests.model1.SalesOrder; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.emf.spi.cdo.CDOMergingConflictResolver; + +/** + * Bug 419574 - NPE in CDOMergingConflictResolver. + * + * @author Eike Stepper + */ +public class Bugzilla_419574_Test extends AbstractCDOTest +{ + public void testConflict() throws Exception + { + String resourcePath = getResourcePath("/res1"); + + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + + Company company = getModel1Factory().createCompany(); + company.setName("Central"); + + transaction.createResource(resourcePath).getContents().add(company); + transaction.commit(); + session.close(); + } + + CDOSession session1 = openSession(); + session1.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES); + + CDOSession session2 = openSession(); + session2.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES); + + CDOTransaction transaction1 = session1.openTransaction(); + transaction1.options().addConflictResolver(new CDOMergingConflictResolver()); + // transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL); + + CDOTransaction transaction2 = session2.openTransaction(); + transaction2.options().addConflictResolver(new CDOMergingConflictResolver()); + // transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL); + + Company company1 = (Company)transaction1.getResource(resourcePath).getContents().get(0); + Customer c1 = getModel1Factory().createCustomer(); + company1.getCustomers().add(c1); + + Company company2 = (Company)transaction2.getResource(resourcePath).getContents().get(0); + Customer c2 = getModel1Factory().createCustomer(); + company2.getCustomers().add(c2); + + commitAndSync(transaction1, transaction2); + commitAndSync(transaction2, transaction1); + + SalesOrder s1 = getModel1Factory().createSalesOrder(); + s1.setCustomer(c1); + company1.getSalesOrders().add(s1); + + SalesOrder s2 = getModel1Factory().createSalesOrder(); + s2.setCustomer(c2); + company2.getSalesOrders().add(s2); + + commitAndSync(transaction1, transaction2); + commitAndSync(transaction2, transaction1); + } +} |