Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3af703b8ace35b7d0bfa8f64f900c1a180d423f9 (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
/*
 * Copyright (c) 2014 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.config.impl.ConfigTest.Requires;
import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
import org.eclipse.emf.cdo.tests.model1.Supplier;
import org.eclipse.emf.cdo.tests.model1.legacy.Model1Factory;
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.cdo.util.ConcurrentAccessException;

/**
 * @author Leonid
 */
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
public class Bugzilla_430836_Test extends AbstractCDOTest
{
  public void testXRefQueryOnBranchOtherThenMain() throws Exception
  {
    internalTestWithMaxResults();
  }

  private void internalTestWithMaxResults() throws ConcurrentAccessException, CommitException
  {
    CDOSession session = openSession();
    CDOBranch mainBranch = session.getBranchManager().getMainBranch();
    CDOTransaction transaction = session.openTransaction();

    Supplier mainBranchSupplier = Model1Factory.eINSTANCE.createSupplier();
    PurchaseOrder po = Model1Factory.eINSTANCE.createPurchaseOrder();
    po.setSupplier(mainBranchSupplier);

    CDOResource resource = transaction.createResource(getResourcePath("main_po.po"));
    resource.getContents().add(po);
    resource.getContents().add(mainBranchSupplier);

    transaction.commit();
    transaction.close();

    CDOBranch newBranch = mainBranch.createBranch("new_branch");
    transaction = session.openTransaction(newBranch);

    PurchaseOrder po2 = Model1Factory.eINSTANCE.createPurchaseOrder();
    po2.setSupplier(transaction.getObject(mainBranchSupplier));

    resource = transaction.createResource(getResourcePath("branch_po.po"));
    resource.getContents().add(po2);

    transaction.commit();
    transaction.close();

    CDOTransaction tx = session.openTransaction(newBranch);
    assertEquals(2, tx.queryXRefs(CDOUtil.getCDOObject(tx.getObject(mainBranchSupplier))).size());
  }
}

Back to the top