Search in sources :

Example 1 with JobCompletionDelayOnSessionShutdown

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));
}
Also used : SessionStoreMaxWaitWriteLockProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitWriteLockProperty) SessionStoreMaxWaitAllShutdownProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitAllShutdownProperty) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) SessionStoreHousekeepingMaxWaitShutdownProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingMaxWaitShutdownProperty) SessionStoreHousekeepingDelayProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingDelayProperty) JobCompletionDelayOnSessionShutdown(org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown) Before(org.junit.Before)

Example 2 with JobCompletionDelayOnSessionShutdown

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());
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBeanInstanceProducer(org.eclipse.scout.rt.platform.IBeanInstanceProducer) Coordinates(org.eclipse.scout.rt.client.ui.Coordinates) JobCompletionDelayOnSessionShutdown(org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) IBean(org.eclipse.scout.rt.platform.IBean) Callable(java.util.concurrent.Callable) TestEnvironmentClientSession(org.eclipse.scout.rt.client.testenvironment.TestEnvironmentClientSession) Test(org.junit.Test)

Example 3 with JobCompletionDelayOnSessionShutdown

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());
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBeanInstanceProducer(org.eclipse.scout.rt.platform.IBeanInstanceProducer) JobCompletionDelayOnSessionShutdown(org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown) TimedOutError(org.eclipse.scout.rt.platform.util.concurrent.TimedOutError) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) IBean(org.eclipse.scout.rt.platform.IBean) TestEnvironmentClientSession(org.eclipse.scout.rt.client.testenvironment.TestEnvironmentClientSession) Test(org.junit.Test)

Aggregations

JobCompletionDelayOnSessionShutdown (org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown)3 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)3 TestEnvironmentClientSession (org.eclipse.scout.rt.client.testenvironment.TestEnvironmentClientSession)2 IBean (org.eclipse.scout.rt.platform.IBean)2 IBeanInstanceProducer (org.eclipse.scout.rt.platform.IBeanInstanceProducer)2 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)2 Test (org.junit.Test)2 Callable (java.util.concurrent.Callable)1 Coordinates (org.eclipse.scout.rt.client.ui.Coordinates)1 TimedOutError (org.eclipse.scout.rt.platform.util.concurrent.TimedOutError)1 SessionStoreHousekeepingDelayProperty (org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingDelayProperty)1 SessionStoreHousekeepingMaxWaitShutdownProperty (org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingMaxWaitShutdownProperty)1 SessionStoreMaxWaitAllShutdownProperty (org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitAllShutdownProperty)1 SessionStoreMaxWaitWriteLockProperty (org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitWriteLockProperty)1 Before (org.junit.Before)1