|
Added
Link Here
|
| 1 |
package org.eclipse.emf.cdo.tests.bugzilla; |
| 2 |
|
| 3 |
import org.eclipse.emf.cdo.eresource.CDOResource; |
| 4 |
import org.eclipse.emf.cdo.session.CDOSession; |
| 5 |
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; |
| 6 |
import org.eclipse.emf.cdo.tests.AbstractCDOTest; |
| 7 |
import org.eclipse.emf.cdo.tests.model1.Company; |
| 8 |
import org.eclipse.emf.cdo.tests.model1.Model1Factory; |
| 9 |
import org.eclipse.emf.cdo.transaction.CDOTransaction; |
| 10 |
import org.eclipse.emf.cdo.util.CommitException; |
| 11 |
|
| 12 |
/** |
| 13 |
* Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. |
| 14 |
* All rights reserved. This program and the accompanying materials |
| 15 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 16 |
* which accompanies this distribution, and is available at |
| 17 |
* http://www.eclipse.org/legal/epl-v10.html |
| 18 |
* |
| 19 |
* Contributors: |
| 20 |
* Caspar De Groot - initial API and implementation |
| 21 |
*/ |
| 22 |
|
| 23 |
/** |
| 24 |
* Bugzilla 315026 - Local rollback inadvertently brings in updates from other sessions |
| 25 |
* |
| 26 |
* @author Caspar De Groot |
| 27 |
*/ |
| 28 |
public class Bugzilla_315026_Test extends AbstractCDOTest |
| 29 |
{ |
| 30 |
private final static String ORIGINAL_NAME = "AAA"; |
| 31 |
|
| 32 |
private final static String DIRTY_NAME = "BBB"; |
| 33 |
|
| 34 |
private final static String OTHER_NAME = "CCC"; |
| 35 |
|
| 36 |
public void test() throws Exception |
| 37 |
{ |
| 38 |
CDOSession session = openSession(); |
| 39 |
session.options().setPassiveUpdateEnabled(false); |
| 40 |
CDOTransaction tx = session.openTransaction(); |
| 41 |
CDOResource r1 = tx.createResource("/r1"); //$NON-NLS-1$ |
| 42 |
|
| 43 |
// Create clean content |
| 44 |
Company company = Model1Factory.eINSTANCE.createCompany(); |
| 45 |
company.setName(ORIGINAL_NAME); |
| 46 |
r1.getContents().add(company); |
| 47 |
tx.commit(); |
| 48 |
|
| 49 |
// Make it dirty in this session |
| 50 |
company.setName(DIRTY_NAME); |
| 51 |
|
| 52 |
// Update and commit in another session |
| 53 |
doSecondSession(); |
| 54 |
|
| 55 |
// Rollback this session |
| 56 |
tx.rollback(); |
| 57 |
assertProxy(company); |
| 58 |
|
| 59 |
// Clear this session's revision cache |
| 60 |
((InternalCDORevisionManager)session.getRevisionManager()).getCache().clear(); |
| 61 |
|
| 62 |
// Verify that value in this session does *not* match value assigned in 2nd session |
| 63 |
String name = company.getName(); |
| 64 |
assertFalse("Should not have the value committed by the other session", OTHER_NAME.equals(name)); |
| 65 |
|
| 66 |
// Verify that value in this session still matches value assigned in this session |
| 67 |
assertEquals("Should have the value originally loaded in this session", ORIGINAL_NAME, name); |
| 68 |
|
| 69 |
tx.close(); |
| 70 |
session.close(); |
| 71 |
} |
| 72 |
|
| 73 |
private void doSecondSession() throws CommitException |
| 74 |
{ |
| 75 |
CDOSession session = openSession(); |
| 76 |
CDOTransaction tx = session.openTransaction(); |
| 77 |
CDOResource r1 = tx.getResource("/r1"); //$NON-NLS-1$ |
| 78 |
|
| 79 |
Company company = (Company)r1.getContents().get(0); |
| 80 |
company.setName(OTHER_NAME); |
| 81 |
tx.commit(); |
| 82 |
|
| 83 |
tx.close(); |
| 84 |
session.close(); |
| 85 |
} |
| 86 |
} |