blob: 610bd361be3469cafe26cc13a3e40f8e66df70a0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/**
* Copyright (c) 2004 - 2010 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:
* Caspar De Groot - initial API and implementation
*/
package org.eclipse.emf.cdo.tests.bugzilla;
import org.eclipse.emf.cdo.CDOObject;
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.model1.Customer;
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
/**
* Bug 321699 - CDOViewImpl.getObject(CDOID, boolean) can return wrong object for temporary IDs.
*
* @author Caspar De Groot
*/
public class Bugzilla_321699_Test extends AbstractCDOTest
{
public void test() throws CommitException
{
CDOSession session = openSession();
CDOTransaction tx = session.openTransaction();
CDOResource resource = tx.createResource("/r1");
msg("Pre-commit ID of resource = " + resource.cdoID());
CDOObject fetchedObject = tx.getObject(resource.cdoID());
assertSame(resource, fetchedObject);
tx.commit();
msg("Post-commit ID of resource = " + resource.cdoID());
Customer customer = Model1Factory.eINSTANCE.createCustomer();
resource.getContents().add(customer);
CDOID customerID = CDOUtil.getCDOObject(customer).cdoID();
msg("Pre-commit ID of customer = " + customerID);
fetchedObject = tx.getObject(customerID);
msg("Object fetched for customerID = " + fetchedObject);
assertSame(customer, fetchedObject);
tx.close();
session.close();
}
}
|