From 3395ece085488ef5e6368bc068cf7ed4ed08026a Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Mon, 23 Apr 2018 13:14:57 +0200 Subject: [438682] eUnset Unsettable Features causes Rollback in DBStore https://bugs.eclipse.org/bugs/show_bug.cgi?id=438682--- .../cdo/tests/bugzilla/Bugzilla_438682_Test.java | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_438682_Test.java (limited to 'plugins') diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_438682_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_438682_Test.java new file mode 100644 index 0000000000..b51885df58 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_438682_Test.java @@ -0,0 +1,84 @@ +/* + * 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: + * Alex Lagarde - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.bugzilla; + +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.model4.MultiNonContainedElement; +import org.eclipse.emf.cdo.tests.model4.MultiNonContainedUnsettableElement; +import org.eclipse.emf.cdo.tests.model4.RefMultiNonContained; +import org.eclipse.emf.cdo.tests.model4.RefMultiNonContainedUnsettable; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CommitException; +import org.eclipse.emf.cdo.util.ConcurrentAccessException; + +import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; + +/** + * Tests ensuring that unsetting features works correctly. + * + * @author Alex Lagarde + */ +public class Bugzilla_438682_Test extends AbstractCDOTest +{ + private CDOTransaction transaction; + + private RefMultiNonContainedUnsettable rootUnsettable; + + private RefMultiNonContained rootNonUnsettable; + + @Override + protected void doSetUp() throws Exception + { + super.doSetUp(); + + // Initialize semantic model and commit + ResourceSet resourceSet = new ResourceSetImpl(); + Registry registry = resourceSet.getResourceFactoryRegistry(); + registry.getExtensionToFactoryMap().put("model1", new XMIResourceFactoryImpl()); + + MultiNonContainedUnsettableElement child1 = getModel4Factory().createMultiNonContainedUnsettableElement(); + rootUnsettable = getModel4Factory().createRefMultiNonContainedUnsettable(); + rootUnsettable.getElements().add(child1); + + MultiNonContainedElement child2 = getModel4Factory().createMultiNonContainedElement(); + rootNonUnsettable = getModel4Factory().createRefMultiNonContained(); + rootNonUnsettable.getElements().add(child2); + CDOSession session = openSession(); + transaction = session.openTransaction(resourceSet); + final CDOResource resource = transaction.createResource(getResourcePath("r1")); + resource.getContents().add(child1); + resource.getContents().add(child2); + resource.getContents().add(rootUnsettable); + resource.getContents().add(rootNonUnsettable); + transaction.commit(); + } + + public void testUnsetUnsettableFeatureAndCommit() throws ConcurrentAccessException, CommitException + { + // Unsets an unsettable feature: commit should succeed + rootUnsettable.eUnset(getModel4Package().getRefMultiNonContainedUnsettable_Elements()); + transaction.commit(); + } + + public void testUnsetNonUnsettableFeatureAndCommit() throws ConcurrentAccessException, CommitException + { + // Unsets an non-unsettable feature: what is expected here ? Depending on the used StoreAccessor, a + // CDOFeatureDeltaVisitor will be used and the CDOUnsetFeatureDelta will be tested if unsettable and returning an + // exception if not unsettable. + rootNonUnsettable.eUnset(getModel4Package().getRefMultiNonContained_Elements()); + transaction.commit(); + } +} -- cgit v1.2.3