use of org.eclipse.scout.rt.platform.context.RunContext in project scout.rt by eclipse.
the class ServerRunContextTest method testRunContextsEmpty.
@Test
public void testRunContextsEmpty() {
RunContext runContext = RunContexts.empty();
assertThat(runContext, CoreMatchers.instanceOf(ServerRunContext.class));
ServerRunContext serverCtx = (ServerRunContext) runContext;
assertNull(serverCtx.getSubject());
assertNull(serverCtx.getSession());
assertNull(serverCtx.getUserAgent());
assertNull(serverCtx.getLocale());
assertEquals(TransactionScope.REQUIRES_NEW, serverCtx.getTransactionScope());
}
use of org.eclipse.scout.rt.platform.context.RunContext in project scout.rt by eclipse.
the class JaxWsRunContextLookup method lookupRunContext.
/**
* Method invoked to look up the {@link RunContext}, and must not return <code>null</code>.
*/
protected RunContext lookupRunContext(final WebServiceContext webServiceContext) {
final RunContext runContext = MessageContexts.getRunContext(webServiceContext.getMessageContext());
if (runContext != null) {
return runContext;
}
if (RunContext.CURRENT.get() != null) {
return RunContext.CURRENT.get().copy();
}
LOG.warn(RUNCONTEXT_MISSING_WARNING);
return RunContexts.empty();
}
use of org.eclipse.scout.rt.platform.context.RunContext in project scout.rt by eclipse.
the class JobCancelTest method testCancelRunContextPriorSchedulingJob.
/**
* Tests that a job is not run if the RunMonitor is already cancelled.
*/
@Test
public void testCancelRunContextPriorSchedulingJob() {
RunContext runContext = RunContexts.copyCurrent();
// 1. Cancel the RunMonitor
runContext.getRunMonitor().cancel(false);
// 2. Schedule the job (should never)
final AtomicBoolean executed = new AtomicBoolean(false);
IFuture<Void> future = Jobs.schedule(new IRunnable() {
@Override
public void run() throws Exception {
executed.set(true);
}
}, Jobs.newInput().withRunContext(runContext));
future.awaitDone();
assertFalse(executed.get());
assertTrue(future.isCancelled());
}
use of org.eclipse.scout.rt.platform.context.RunContext in project scout.rt by eclipse.
the class SessionFutureFilter method accept.
@Override
public boolean accept(final IFuture<?> future) {
final RunContext runContext = future.getJobInput().getRunContext();
if (runContext == null) {
return false;
}
final ISession session = runContext.getAdapter(ISession.class);
if (session == null) {
return false;
}
return m_session == session;
}
Aggregations