Skip to main content
summaryrefslogtreecommitdiffstats
blob: ba66de80c6bf3395c3f74afa2dab647c298bf048 (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
/*
 * Copyright (c) 2011, 2012, 2015, 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:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.tests.offline;

import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;

/**
 * @author Eike Stepper
 */
public class OfflineDelayed2Test extends AbstractSyncingTest
{
  @Override
  protected long getTestDelayed2CommitHandling()
  {
    return 1000L;
  }

  public void testCommitOrder() throws Exception
  {
    int nbrOfCommits = 5;

    InternalRepository master = getRepository("master");

    CDOSession masterSession = openSession(master.getName());
    CDOTransaction masterTransaction = masterSession.openTransaction();
    CDOResource masterResource = masterTransaction.createResource(getResourcePath("/my/resource"));

    Company masterCompany = getModel1Factory().createCompany();
    masterCompany.setName("Test");
    masterResource.getContents().add(masterCompany);

    masterTransaction.commit();

    CDOSession cloneSession = openSession();
    waitForOnline(cloneSession.getRepositoryInfo());

    for (int i = 0; i < nbrOfCommits; i++)
    {
      masterCompany.setName(Integer.toString(i));
      masterTransaction.commit();
    }

    sleep(1000);
    sleep(1000);
    sleep(1000);
    sleep(1000);
    sleep(1000);

    CDOTransaction cloneTransaction = cloneSession.openTransaction();
    CDOObject cloneCompany = CDOUtil.getCDOObject(cloneTransaction.getObject(CDOUtil.getCDOObject(masterCompany).cdoID()));
    assertEquals(nbrOfCommits + 1, cloneCompany.cdoRevision().getVersion());
  }
}

Back to the top