Search in sources :

Example 1 with SafeStatementInvoker

use of org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker in project scout.rt by eclipse.

the class RunInModelJobStatement method evaluate.

@Override
public void evaluate() throws Throwable {
    if (ModelJobs.isModelThread()) {
        m_next.evaluate();
    } else {
        final SafeStatementInvoker invoker = new SafeStatementInvoker(m_next);
        ModelJobs.schedule(invoker, ModelJobs.newInput(ClientRunContexts.copyCurrent()).withName("Running JUnit test in model job")).awaitDone();
        invoker.throwOnError();
    }
}
Also used : SafeStatementInvoker(org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker)

Example 2 with SafeStatementInvoker

use of org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker in project scout.rt by eclipse.

the class TimeoutClientRunContextStatement method evaluate.

@Override
public void evaluate() throws Throwable {
    final SafeStatementInvoker invoker = new SafeStatementInvoker(m_next);
    final IFuture<Void> future = ModelJobs.schedule(invoker, ModelJobs.newInput(ClientRunContexts.copyCurrent()).withName("Running test with support for JUnit timeout"));
    try {
        if (m_timeoutMillis <= 0) {
            future.awaitDone();
        } else {
            future.awaitDone(m_timeoutMillis, TimeUnit.MILLISECONDS);
        }
    } catch (ThreadInterruptedError | TimedOutError e) {
        // NOSONAR
        future.cancel(true);
        // JUnit timeout exception
        throw new TestTimedOutException(m_timeoutMillis, TimeUnit.MILLISECONDS);
    }
    invoker.throwOnError();
}
Also used : SafeStatementInvoker(org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker) ThreadInterruptedError(org.eclipse.scout.rt.platform.util.concurrent.ThreadInterruptedError) TimedOutError(org.eclipse.scout.rt.platform.util.concurrent.TimedOutError) TestTimedOutException(org.junit.runners.model.TestTimedOutException)

Example 3 with SafeStatementInvoker

use of org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker in project scout.rt by eclipse.

the class RunContextStatement method evaluate.

@Override
public void evaluate() throws Throwable {
    final SafeStatementInvoker invoker = new SafeStatementInvoker(m_next);
    m_runContextProvider.create().run(invoker);
    invoker.throwOnError();
}
Also used : SafeStatementInvoker(org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker)

Example 4 with SafeStatementInvoker

use of org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker in project scout.rt by eclipse.

the class TimeoutRunContextStatement method evaluate.

@Override
public void evaluate() throws Throwable {
    final SafeStatementInvoker invoker = new SafeStatementInvoker(m_next);
    final IFuture<Void> future = Jobs.schedule(invoker, Jobs.newInput().withRunContext(// Run in new TX, because the same TX is not allowed to be used by multiple threads.
    RunContext.CURRENT.get().copy().withTransactionScope(TransactionScope.REQUIRES_NEW)).withName("Running test with support for JUnit timeout"));
    try {
        future.awaitDone(m_timeoutMillis, TimeUnit.MILLISECONDS);
    } catch (ThreadInterruptedError | TimedOutError e) {
        // NOSONAR
        future.cancel(true);
        // JUnit timeout exception
        throw new TestTimedOutException(m_timeoutMillis, TimeUnit.MILLISECONDS);
    }
    invoker.throwOnError();
}
Also used : SafeStatementInvoker(org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker) ThreadInterruptedError(org.eclipse.scout.rt.platform.util.concurrent.ThreadInterruptedError) TimedOutError(org.eclipse.scout.rt.platform.util.concurrent.TimedOutError) TestTimedOutException(org.junit.runners.model.TestTimedOutException)

Example 5 with SafeStatementInvoker

use of org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker in project scout.rt by eclipse.

the class ClientNotificationsStatement method evaluate.

@Override
public void evaluate() throws Throwable {
    final SafeStatementInvoker invoker = new SafeStatementInvoker(m_next);
    ServerRunContexts.copyCurrent().withClientNotificationCollector(m_collector).withTransactionScope(TransactionScope.REQUIRES_NEW).withClientNodeId(m_clientNodeId).run(invoker);
    invoker.throwOnError();
}
Also used : SafeStatementInvoker(org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker)

Aggregations

SafeStatementInvoker (org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker)8 Subject (javax.security.auth.Subject)2 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)2 IBean (org.eclipse.scout.rt.platform.IBean)2 ThreadInterruptedError (org.eclipse.scout.rt.platform.util.concurrent.ThreadInterruptedError)2 TimedOutError (org.eclipse.scout.rt.platform.util.concurrent.TimedOutError)2 RunWithSubject (org.eclipse.scout.rt.testing.platform.runner.RunWithSubject)2 TestTimedOutException (org.junit.runners.model.TestTimedOutException)2 IClientSession (org.eclipse.scout.rt.client.IClientSession)1 IServerSession (org.eclipse.scout.rt.server.IServerSession)1 UserAgent (org.eclipse.scout.rt.shared.ui.UserAgent)1