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();
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations