Skip to main content
summaryrefslogtreecommitdiffstats
blob: bba12fbc309c7fe771db490e6ca9e192117f8afa (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
/*
 * Copyright (c) 2012, 2013 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.CDOState;
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.config.IModelConfig;
import org.eclipse.emf.cdo.tests.model6.BaseObject;
import org.eclipse.emf.cdo.tests.model6.G;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;

import org.eclipse.emf.spi.cdo.InternalCDOObject;

/**
 * Bug 397232: Load notification missing for initial load.
 *
 * @author Eike Stepper
 */
public class Bugzilla_397232_Test extends AbstractCDOTest
{
  @Skips(IModelConfig.CAPABILITY_LEGACY)
  public void testLoadNotification() throws Exception
  {
    CDOSession session = openSession();

    {
      CDOTransaction transaction = session.openTransaction();
      CDOResource resource = transaction.createResource(getResourcePath("/test1"));
      G g = getModel6Factory().createG();
      BaseObject bo = getModel6Factory().createBaseObject();
      bo.setAttributeRequired("required");
      g.setDummy("g");
      g.setReference(bo);
      resource.getContents().add(g);
      resource.getContents().add(bo);
      transaction.commit();
      transaction.close();
    }

    CDOView view = session.openView();
    view.options().setLoadNotificationEnabled(true);
    CDOResource resource2 = view.getResource(getResourcePath("/test1"));

    // Load initially
    G g = (G)resource2.getContents().get(0);
    assertEquals(3, g.getNotifications().size());

    // Simulate GC
    InternalCDOObject cdoObject = (InternalCDOObject)CDOUtil.getCDOObject(g);
    cdoObject.cdoInternalSetState(CDOState.PROXY);
    cdoObject.cdoInternalSetRevision(null);

    // Re-load
    g.getDummy();
    assertEquals(6, g.getNotifications().size());
  }
}

Back to the top