blob: ccbe7152086ebbcec96772d5d276c2415a1ece99 (
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
|
/*
* Copyright (c) 2010-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.common.branch.CDOBranch;
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.IRepositoryConfig;
import org.eclipse.emf.cdo.tests.model4.RefSingleContained;
import org.eclipse.emf.cdo.tests.util.TestAdapter;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
/**
* NullPointerException in CDONotificationBuilder during Branch Merge
* <p>
* See bug 313326
*/
public class Bugzilla_313326_Test extends AbstractCDOTest
{
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
public void testNotificationBuilderBranch() throws Exception
{
skipStoreWithoutChangeSets();
// setup transaction.
final CDOSession session = openSession();
final CDOTransaction tr1 = session.openTransaction();
tr1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
// init model with a container.
final CDOResource resource = tr1.createResource(getResourcePath("/test1"));
RefSingleContained container = getModel4Factory().createRefSingleContained();
container.setElement(getModel4Factory().createSingleContainedElement());
// attach adapter to get notifications.
container.eAdapters().add(new TestAdapter());
resource.getContents().add(container);
tr1.commit();
// create another branch
final CDOBranch mainBranch = tr1.getBranch();
final CDOBranch otherBranch = mainBranch.createBranch("other");
final CDOTransaction tr2 = session.openTransaction(otherBranch);
// get container in other branch and remove containment.
RefSingleContained otherContainer = tr2.getObject(container);
assertNotNull(otherContainer);
otherContainer.setElement(null);
tr2.commit();
// sleep to have the merger see the changes.
sleep(500);
// tr1.waitForUpdate(tr2.getLastCommitTime(), DEFAULT_TIMEOUT);
// merge the other branch to main.
tr1.merge(tr2.getBranch().getHead(), new DefaultCDOMerger.PerFeature());
tr1.commit();
assertEquals(false, tr1.isDirty());
}
}
|