use of org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown in project scout.rt by eclipse.
the class UiSessionTest method before.
@Before
public void before() {
m_oldRunContext = RunContext.CURRENT.get();
// Because this test must be executed by a bare JUnit runner (see JavaDoc of test class).
RunContext.CURRENT.set(RunContexts.empty());
m_beans = TestingUtility.registerBeans(new BeanMetaData(JobCompletionDelayOnSessionShutdown.class).withProducer(new IBeanInstanceProducer<JobCompletionDelayOnSessionShutdown>() {
@Override
public JobCompletionDelayOnSessionShutdown produce(IBean<JobCompletionDelayOnSessionShutdown> bean) {
return new JobCompletionDelayOnSessionShutdown() {
@Override
protected Long getDefaultValue() {
return 0L;
}
};
}
}), new BeanMetaData(SessionStoreHousekeepingDelayProperty.class).withInitialInstance(new SessionStoreHousekeepingDelayProperty() {
@Override
protected Integer getDefaultValue() {
return 0;
}
}), new BeanMetaData(SessionStoreHousekeepingMaxWaitShutdownProperty.class).withInitialInstance(new SessionStoreHousekeepingMaxWaitShutdownProperty() {
@Override
protected Integer getDefaultValue() {
return 1;
}
}), new BeanMetaData(SessionStoreMaxWaitWriteLockProperty.class).withInitialInstance(new SessionStoreMaxWaitWriteLockProperty() {
@Override
protected Integer getDefaultValue() {
return 1;
}
}), new BeanMetaData(SessionStoreMaxWaitAllShutdownProperty.class).withInitialInstance(new SessionStoreMaxWaitAllShutdownProperty() {
@Override
protected Integer getDefaultValue() {
return 1;
}
}), new BeanMetaData(TestEnvironmentClientSession.class));
}
use of org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown in project scout.rt by eclipse.
the class ClientSessionTest method testStopWithBlockingClientCallback.
@Test
public void testStopWithBlockingClientCallback() throws Exception {
TestingUtility.registerBean(new BeanMetaData(TestEnvironmentClientSession.class));
TestingUtility.registerBean(new BeanMetaData(JobCompletionDelayOnSessionShutdown.class).withProducer(new IBeanInstanceProducer<JobCompletionDelayOnSessionShutdown>() {
@Override
public JobCompletionDelayOnSessionShutdown produce(IBean<JobCompletionDelayOnSessionShutdown> bean) {
return new JobCompletionDelayOnSessionShutdown() {
@Override
protected Long getDefaultValue() {
return 1000L;
}
};
}
}));
session = BEANS.get(ClientSessionProvider.class).provide(ClientRunContexts.empty().withUserAgent(UserAgents.createDefault()));
// request a geo location
Future<Coordinates> geo = ModelJobs.schedule(new Callable<Future<Coordinates>>() {
@Override
public Future<Coordinates> call() throws Exception {
return IDesktop.CURRENT.get().requestGeolocation();
}
}, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true))).awaitDoneAndGet();
assertFalse(geo.isDone());
// close from ui
ModelJobs.schedule(new IRunnable() {
@Override
public void run() throws Exception {
session.getDesktop().getUIFacade().closeFromUI(true);
}
}, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true))).awaitDone();
assertTrue(geo.isCancelled());
}
use of org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown in project scout.rt by eclipse.
the class ClientSessionTest method testStopWithBlockingMessageBox.
@Test
public void testStopWithBlockingMessageBox() throws Exception {
TestingUtility.registerBean(new BeanMetaData(TestEnvironmentClientSession.class));
TestingUtility.registerBean(new BeanMetaData(JobCompletionDelayOnSessionShutdown.class).withProducer(new IBeanInstanceProducer<JobCompletionDelayOnSessionShutdown>() {
@Override
public JobCompletionDelayOnSessionShutdown produce(IBean<JobCompletionDelayOnSessionShutdown> bean) {
return new JobCompletionDelayOnSessionShutdown() {
@Override
protected Long getDefaultValue() {
return 1000L;
}
};
}
}));
session = BEANS.get(ClientSessionProvider.class).provide(ClientRunContexts.empty().withUserAgent(UserAgents.createDefault()));
// show a messagebox
IFuture<Integer> f = ModelJobs.schedule(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
messageBox = MessageBoxes.createYesNo();
return messageBox.show();
}
}, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true)));
try {
f.awaitDoneAndGet(1, TimeUnit.SECONDS);
fail("must throw a " + TimedOutError.class.getName());
} catch (TimedOutError e) {
// nop
}
assertFalse(f.isDone());
// close from ui
ModelJobs.schedule(new IRunnable() {
@Override
public void run() throws Exception {
session.getDesktop().getUIFacade().closeFromUI(true);
}
}, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true))).awaitDone();
assertEquals(JobState.DONE, f.getState());
}
Aggregations