use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.
the class ServerTestRunnerDifferentSessionTest method beforeClass.
@BeforeClass
public static void beforeClass() {
m_serverSessions = new HashSet<>();
ISession serverSession = IServerSession.CURRENT.get();
assertTrue(serverSession instanceof JUnitServerSession1);
assertEquals("anna", serverSession.getUserId());
m_serverSessions.add(serverSession);
m_transactions = new HashSet<>();
ITransaction transaction = ITransaction.CURRENT.get();
assertNotNull(transaction);
m_transactions.add(transaction);
}
use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.
the class ServerTestRunnerDifferentSubjectTest method beforeClass.
@BeforeClass
public static void beforeClass() {
m_serverSessions = new HashSet<>();
ISession serverSession = IServerSession.CURRENT.get();
assertTrue(serverSession instanceof JUnitServerSession);
assertEquals("anna", serverSession.getUserId());
m_serverSessions.add(serverSession);
m_transactions = new HashSet<>();
ITransaction transaction = ITransaction.CURRENT.get();
assertNotNull(transaction);
m_transactions.add(transaction);
}
use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.
the class ServerTestRunnerDifferentSubjectTest method afterClass.
@AfterClass
public static void afterClass() {
ISession serverSession = IServerSession.CURRENT.get();
assertTrue(serverSession instanceof JUnitServerSession);
assertEquals("anna", serverSession.getUserId());
m_serverSessions.add(serverSession);
ITransaction transaction = ITransaction.CURRENT.get();
assertNotNull(transaction);
m_transactions.add(transaction);
assertEquals(2, m_serverSessions.size());
// (beforeClass), (before,test1,after), (before,test2,after), (afterClass)
assertEquals(4, m_transactions.size());
}
use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.
the class AbstractTransactionalMapTest method testConcurrentModifications.
@Test
public void testConcurrentModifications() {
ITransaction tr1 = createNewTransaction();
ITransaction tr2 = createNewTransaction();
Map<Integer, String> initalMap = new HashMap<Integer, String>();
initalMap.put(1, "1");
initalMap.put(2, "2");
initalMap.put(3, "3");
Map<Integer, String> map = createTransactionalMap(TRANSACTION_MEMBER_ID, false, initalMap);
// shared
ITransaction.CURRENT.set(null);
assertMapStateSimple(map, 1, "1", 2, "2", 3, "3");
// tr1
ITransaction.CURRENT.set(tr1);
map.remove(1);
map.put(1, "1.1");
map.remove(2);
map.put(2, "2.1");
assertMapStateSimple(map, 1, "1.1", 2, "2.1", 3, "3");
// shared
ITransaction.CURRENT.set(null);
assertMapStateSimple(map, 1, "1", 2, "2", 3, "3");
// tr2
ITransaction.CURRENT.set(tr2);
map.remove(2);
map.put(2, "2.2");
map.remove(3);
map.put(3, "3.2");
map.put(4, "4");
assertMapStateSimple(map, 1, "1", 2, "2.2", 3, "3.2", 4, "4");
// shared
ITransaction.CURRENT.set(null);
assertMapStateSimple(map, 1, "1", 2, "2", 3, "3");
commitTransaction(tr1);
assertMapStateSimple(map, 1, "1.1", 2, "2.1", 3, "3");
commitTransaction(tr2);
assertMapStateSimple(map, 1, "1.1", 3, "3.2", 4, "4");
}
use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.
the class AbstractTransactionalMapTest method testPutAll.
@Test
public void testPutAll() {
ITransaction tr1 = createNewTransaction();
ITransaction tr2 = createNewTransaction();
Map<Integer, String> map = createTransactionalMap(TRANSACTION_MEMBER_ID, false, new HashMap<Integer, String>());
// tr1
ITransaction.CURRENT.set(tr1);
Map<Integer, String> tr1Map = new HashMap<Integer, String>();
tr1Map.put(1, "1");
tr1Map.put(2, "2");
map.putAll(tr1Map);
assertMapState(map, tr1Map);
// tr2
ITransaction.CURRENT.set(tr2);
Map<Integer, String> tr2Map = new HashMap<Integer, String>();
// transactional concurrent modification
tr2Map.put(2, "3");
tr2Map.put(3, "3");
tr2Map.put(4, "4");
map.putAll(tr2Map);
assertMapState(map, tr2Map);
// shared
ITransaction.CURRENT.set(null);
assertMapState(map, Collections.<Integer, String>emptyMap());
commitTransaction(tr1);
assertMapState(map, tr1Map);
commitTransaction(tr2);
tr1Map.putAll(tr2Map);
// not in shared map because of concurrent modification
tr1Map.remove(2);
assertMapState(map, tr1Map);
}
Aggregations