Search in sources :

Example 26 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class ServerTestRunnerDifferentSessionTest method afterClass.

@AfterClass
public static void afterClass() {
    ISession serverSession = IServerSession.CURRENT.get();
    assertTrue(serverSession instanceof JUnitServerSession1);
    assertEquals("anna", serverSession.getUserId());
    m_serverSessions.add(serverSession);
    ITransaction transaction = ITransaction.CURRENT.get();
    assertNotNull(transaction);
    m_transactions.add(transaction);
    assertEquals(5, m_serverSessions.size());
    // (beforeClass), (before,test1,after), (before,test2,after), (before,test3,after), (afterClass)
    assertEquals(5, m_transactions.size());
}
Also used : ISession(org.eclipse.scout.rt.shared.ISession) JUnitServerSession1(org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSessionTest.JUnitServerSession1) ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) AfterClass(org.junit.AfterClass)

Example 27 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class ServerTestRunnerDifferentSubjectTest method test1.

@Test
public void test1() {
    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);
}
Also used : ISession(org.eclipse.scout.rt.shared.ISession) ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) JUnitServerSession(org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSubjectTest.JUnitServerSession) Test(org.junit.Test)

Example 28 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class ServerTestRunnerDifferentSubjectTest method test2.

@Test
@RunWithSubject("john")
public void test2() {
    ISession serverSession = IServerSession.CURRENT.get();
    assertTrue(serverSession instanceof JUnitServerSession);
    assertEquals("john", serverSession.getUserId());
    m_serverSessions.add(serverSession);
    ITransaction transaction = ITransaction.CURRENT.get();
    assertNotNull(transaction);
    m_transactions.add(transaction);
}
Also used : ISession(org.eclipse.scout.rt.shared.ISession) ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) JUnitServerSession(org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSubjectTest.JUnitServerSession) RunWithSubject(org.eclipse.scout.rt.testing.platform.runner.RunWithSubject) Test(org.junit.Test)

Example 29 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class ServerTestRunnerSameSessionTest 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);
}
Also used : ISession(org.eclipse.scout.rt.shared.ISession) ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) JUnitServerSession(org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerSameSessionTest.JUnitServerSession) BeforeClass(org.junit.BeforeClass)

Example 30 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class ClientNotificationRegistry method putTransactional.

public void putTransactional(ClientNotificationMessage message) {
    ITransaction transaction = Assertions.assertNotNull(ITransaction.CURRENT.get(), "No transaction found on current calling context to register transactional client notification {}", message);
    try {
        ClientNotificationTransactionMember txMember = (ClientNotificationTransactionMember) transaction.getMember(ClientNotificationTransactionMember.TRANSACTION_MEMBER_ID);
        if (txMember == null) {
            txMember = new ClientNotificationTransactionMember(this);
            transaction.registerMember(txMember);
        }
        txMember.addNotification(message);
    } catch (RuntimeException e) {
        LOG.warn("Could not register transaction member. The notification will be processed immediately", e);
        publish(Collections.singleton(message));
    }
}
Also used : ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction)

Aggregations

ITransaction (org.eclipse.scout.rt.platform.transaction.ITransaction)37 Test (org.junit.Test)20 ISession (org.eclipse.scout.rt.shared.ISession)13 HashMap (java.util.HashMap)7 ITransactionMember (org.eclipse.scout.rt.platform.transaction.ITransactionMember)5 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)5 JUnitServerSession1 (org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSessionTest.JUnitServerSession1)4 JUnitServerSession (org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSubjectTest.JUnitServerSession)4 JUnitServerSession (org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerSameSessionTest.JUnitServerSession)4 AssertionException (org.eclipse.scout.rt.platform.util.Assertions.AssertionException)3 AfterClass (org.junit.AfterClass)3 BeforeClass (org.junit.BeforeClass)3 InvocationHandler (java.lang.reflect.InvocationHandler)2 Method (java.lang.reflect.Method)2 WebMethod (javax.jws.WebMethod)2 BooleanHolder (org.eclipse.scout.rt.platform.holders.BooleanHolder)2 Holder (org.eclipse.scout.rt.platform.holders.Holder)2 IServerSession (org.eclipse.scout.rt.server.IServerSession)2 AbstractSqlTransactionMember (org.eclipse.scout.rt.server.jdbc.AbstractSqlTransactionMember)2 Connection (java.sql.Connection)1