Skip to main content
summaryrefslogtreecommitdiffstats
blob: c641f7243ff5da929b313511e6ee9a6eb58131e6 (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
/*
 * Copyright (c) 2009-2012, 2016 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:
 *    Simon McDuff - initial API and implementation
 */
package org.eclipse.emf.cdo.tests.bugzilla;

import org.eclipse.emf.cdo.CDODeltaNotification;
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.OrderAddress;
import org.eclipse.emf.cdo.tests.model1.OrderDetail;
import org.eclipse.emf.cdo.tests.util.TestAdapter;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOAdapterPolicy;

/**
 * CDO wrong feature on notification when multiple super types
 * <p>
 * See bug 260764
 *
 * @author Simon McDuff
 */
public class Bugzilla_260764_Test extends AbstractCDOTest
{
  public void testBugzilla_260764() throws Exception
  {
    msg("Opening session");
    final CDOSession session = openSession();

    // ************************************************************* //
    msg("Opening transaction");
    final CDOTransaction transaction = session.openTransaction();
    final CDOResource resourceA = transaction.createResource(getResourcePath("/test1"));

    final OrderAddress orderAddress = getModel1Factory().createOrderAddress();
    resourceA.getContents().add(orderAddress);
    transaction.commit();

    transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
    final TestAdapter adapter = new TestAdapter();
    orderAddress.eAdapters().add(adapter);

    // ************************************************************* //

    msg("Opening view");
    final CDOSession session2 = openSession();

    final CDOTransaction transaction2 = session2.openTransaction();
    final OrderAddress orderAddress2 = (OrderAddress)CDOUtil.getEObject(transaction2.getObject(CDOUtil.getCDOObject(orderAddress).cdoID(), true));

    OrderDetail orderDetail = getModel1Factory().createOrderDetail();
    orderAddress2.getOrderDetails().add(orderDetail);

    assertEquals(0, adapter.getNotifications().length);
    transaction2.commit();

    new PollingTimeOuter()
    {
      @Override
      protected boolean successful()
      {
        return adapter.getNotifications().length == 1;
      }
    }.assertNoTimeOut();

    CDODeltaNotification cdoNotification = (CDODeltaNotification)adapter.getNotifications()[0];
    assertEquals(false, cdoNotification.hasNext());
    assertEquals(getModel1Package().getOrder_OrderDetails(), cdoNotification.getFeature());
  }
}

Back to the top