Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d6e9d81521ca5e7ced68da9561102a50bcdfabdc (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
/*
 * Copyright (c) 2010-2012 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.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
import org.eclipse.emf.cdo.tests.model1.Supplier;
import org.eclipse.emf.cdo.tests.util.TestAdapter;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;

import java.util.Date;

/**
 * Bug 318844 - CDONotificationBuilder cannot handle mixed OID's/CDOObjects when processing CDOClearFeatureDelta</p>
 * http://bugs.eclipse.org/318844</p>
 * 
 * @author Caspar De Groot
 * @since 4.0
 */
public class Bugzilla_318844_Test extends AbstractCDOTest
{
  public void test() throws CommitException
  {
    final CDOSession session = openSession();
    session.options().setPassiveUpdateEnabled(false);
    CDOTransaction tx = session.openTransaction();
    CDOResource r1 = tx.createResource(getResourcePath("/r1")); //$NON-NLS-1$

    PurchaseOrder po1 = getModel1Factory().createPurchaseOrder();
    po1.setDate(new Date());
    r1.getContents().add(po1);

    tx.commit();

    // Create a new supplier but don't commit it
    Supplier supplier = getModel1Factory().createSupplier();
    r1.getContents().add(supplier);

    // Create a reference to po1 but don't commit it
    supplier.getPurchaseOrders().add(po1);

    // Add an adapter so that notification mechanism will be invoked
    r1.eAdapters().add(new TestAdapter());

    // Remove po2 in another session
    doSecondSession();

    // The following call wthrows a CCE if bug 318844 is not fixed
    session.refresh();

    tx.close();
    session.close();
  }

  private void doSecondSession() throws CommitException
  {
    CDOSession session = openSession();
    CDOTransaction tx = session.openTransaction();
    CDOResource r1 = tx.getResource(getResourcePath("/r1")); //$NON-NLS-1$

    // Detach the purchaseOrder
    r1.getContents().remove(0);

    tx.commit();
    tx.close();
    session.close();
  }
}

Back to the top