Search in sources :

Example 11 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData 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 12 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class FileUtilityMimeTypeTest method before.

@Before
public void before() {
    ServletContext servletContext = Mockito.mock(ServletContext.class);
    Mockito.when(servletContext.getMimeType("file.xml")).thenReturn("application/xml");
    Mockito.when(servletContext.getMimeType("file.XML")).thenReturn("application/xml");
    Mockito.when(servletContext.getMimeType("file.m4v")).thenReturn("video/mp4");
    beans.add(TestingUtility.registerBean(new BeanMetaData(ServletContext.class, servletContext).withApplicationScoped(true)));
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) ServletContext(javax.servlet.ServletContext) Before(org.junit.Before)

Example 13 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class BinaryServiceTunnelContentHandlerTest method after.

@After
public void after() {
    TestingUtility.unregisterBean(m_serviceReg);
    IBeanManager beanManager = BEANS.getBeanManager();
    // restore
    for (IBean<?> bean : m_oldBeans) {
        beanManager.registerBean(new BeanMetaData(bean));
    }
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBeanManager(org.eclipse.scout.rt.platform.IBeanManager) After(org.junit.After)

Example 14 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class SoapServiceTunnelContentHandlerTest method after.

@After
public void after() {
    TestingUtility.unregisterBean(m_serviceReg);
    IBeanManager beanManager = BEANS.getBeanManager();
    // restore
    for (IBean<?> bean : m_oldBeans) {
        beanManager.registerBean(new BeanMetaData(bean));
    }
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBeanManager(org.eclipse.scout.rt.platform.IBeanManager) After(org.junit.After)

Example 15 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class NotificationHandlerRegistryTest method ensureHandlerRegistryRefreshed.

private void ensureHandlerRegistryRefreshed() {
    IBeanManager beanManager = BEANS.getBeanManager();
    IBean<NotificationHandlerRegistry> bean = beanManager.getBean(NotificationHandlerRegistry.class);
    beanManager.unregisterBean(bean);
    beanManager.registerBean(new BeanMetaData(bean));
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBeanManager(org.eclipse.scout.rt.platform.IBeanManager)

Aggregations

BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)53 Test (org.junit.Test)18 Before (org.junit.Before)11 IBean (org.eclipse.scout.rt.platform.IBean)9 IBeanManager (org.eclipse.scout.rt.platform.IBeanManager)6 TestEnvironmentClientSession (org.eclipse.scout.rt.client.testenvironment.TestEnvironmentClientSession)5 Callable (java.util.concurrent.Callable)3 JobCompletionDelayOnSessionShutdown (org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown)3 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)3 After (org.junit.After)3 ArrayList (java.util.ArrayList)2 Subject (javax.security.auth.Subject)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 HttpSession (javax.servlet.http.HttpSession)2 IMomImplementor (org.eclipse.scout.rt.mom.api.IMomImplementor)2 NullMomImplementor (org.eclipse.scout.rt.mom.api.NullMomImplementor)2 PlatformException (org.eclipse.scout.rt.platform.exception.PlatformException)2 JaxWsImplementorSpecifics (org.eclipse.scout.rt.server.jaxws.implementor.JaxWsImplementorSpecifics)2 IClusterSynchronizationService (org.eclipse.scout.rt.server.services.common.clustersync.IClusterSynchronizationService)2