Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: dbef56b8bcd5767dc59670ec3a442593edc6c6bb (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/***************************************************************************
 * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
 * 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
 *    Eike Stepper - maintenance
 **************************************************************************/
package org.eclipse.emf.cdo.tests;

import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.Model1Factory;

import org.eclipse.net4j.util.om.OMPlatform;

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

/**
 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=213782
 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=201366
 * @author Simon McDuff
 */
public class TransactionDeadLockTest extends AbstractCDOTest
{
  @Override
  protected boolean useJVMTransport()
  {
    return false;
  }

  @Override
  protected void doSetUp() throws Exception
  {
    super.doSetUp();
    OMPlatform.INSTANCE.setDebugging(false);
  }

  public void testCreateManySession() throws Exception
  {
    {
      msg("Opening session");
      CDOSession session = openModel1Session();
      CDOTransaction transaction = session.openTransaction();
      transaction.createResource("/test2");
      transaction.commit();
      transaction.close();
      session.close();
    }

    for (int i = 0; i < 100; i++)
    {
      msg("Session " + i);
      CDOSession session = openModel1Session();
      CDOTransaction transaction = session.openTransaction();
      CDOResource resource = transaction.getResource("/test2");
      Category category = Model1Factory.eINSTANCE.createCategory();
      resource.getContents().add(category);
      transaction.commit();
      transaction.close();
      session.close();
    }
  }

  public void testCreateManyTransaction() throws Exception
  {
    msg("Opening session");
    CDOSession session = openModel1Session();
    CDOTransaction transaction = session.openTransaction(new ResourceSetImpl());
    transaction.createResource("/test2");
    transaction.commit();
    transaction.close();

    for (int i = 0; i < 1000; i++)
    {
      msg("Transaction " + i);
      transaction = session.openTransaction(new ResourceSetImpl());
      CDOResource resource = transaction.getResource("/test2");
      Category category = Model1Factory.eINSTANCE.createCategory();
      resource.getContents().add(category);
      transaction.commit();
      transaction.close();
    }

    session.close();
  }
}

Back to the top