blob: 367339e0f6b0169f2dcce427f50f70b78a39eb17 (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* Copyright (c) 2004 - 2011 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.revision.delta.CDOListFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
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.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
/**
* @author Egidijus Vaisnora
*/
public class Bugzilla_337587_Test extends AbstractCDOTest
{
/**
* TODO Disabled because bug 337587 has been reopened!
*/
public void _testRevisionCompare() throws CommitException
{
{
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource(getResourcePath("test1"));
Customer customer = getModel1Factory().createCustomer();
customer.setName("customer");
resource.getContents().add(customer);
for (int i = 0; i < 10; i++)
{
SalesOrder salesOrder = getModel1Factory().createSalesOrder();
salesOrder.setId(i);
salesOrder.setCustomer(customer);
resource.getContents().add(salesOrder);
}
transaction.commit();
}
clearCache(getRepository().getRevisionManager());
// ************************************************************* //
CDOSession session = openSession();
session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(1, 2));
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.getResource(getResourcePath("test1"));
Customer customer = (Customer)resource.getContents().get(0);
EList<SalesOrder> salesOrders = customer.getSalesOrders();
SalesOrder salesOrder = getModel1Factory().createSalesOrder();
resource.getContents().add(salesOrder);
salesOrders.set(5, salesOrder);
InternalCDORevision cleanRevision = ((InternalCDOTransaction)transaction).getCleanRevisions().get(resource);
CDORevisionDelta diff = resource.cdoRevision().compare(cleanRevision);
assertEquals(1, ((CDOListFeatureDelta)diff.getFeatureDeltas().get(0)).getListChanges().size());
transaction.commit();
}
}
|