Search in sources :

Example 26 with BeanMetaData

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

Example 27 with BeanMetaData

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

the class ClientSessionTest method testStop.

@Test
public void testStop() throws Exception {
    TestingUtility.registerBean(new BeanMetaData(TestEnvironmentClientSession.class));
    session = BEANS.get(ClientSessionProvider.class).provide(ClientRunContexts.empty().withUserAgent(UserAgents.createDefault()));
    // run a job
    String jobResult = ModelJobs.schedule(new Callable<String>() {

        @Override
        public String call() throws Exception {
            return "OK";
        }
    }, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true))).awaitDoneAndGet();
    assertEquals("OK", jobResult);
    session.stop();
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) Callable(java.util.concurrent.Callable) TestEnvironmentClientSession(org.eclipse.scout.rt.client.testenvironment.TestEnvironmentClientSession) Test(org.junit.Test)

Example 28 with BeanMetaData

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

the class TunnelToServerTest method testBeanProxy.

@Test
public void testBeanProxy() {
    m_beanManager.registerBean(new BeanMetaData(IFixtureTunnelToServer.class).withApplicationScoped(true).withProducer(new TestingServiceTunnelProxyProducer<>(IFixtureTunnelToServer.class)));
    IFixtureTunnelToServer obj1 = m_beanManager.getBean(IFixtureTunnelToServer.class).getInstance();
    IFixtureTunnelToServer obj2 = m_beanManager.getBean(IFixtureTunnelToServer.class).getInstance();
    m_beanManager.registerBean(new BeanMetaData(IFixtureTunnelToServerEx1.class).withApplicationScoped(true));
    IFixtureTunnelToServerEx1 obj3 = m_beanManager.getBean(IFixtureTunnelToServerEx1.class).getInstance();
    Assert.assertNull(obj3);
    Assert.assertNotNull(obj1);
    Assert.assertSame(obj1, obj2);
    Assert.assertTrue(java.lang.reflect.Proxy.isProxyClass(obj1.getClass()));
    Assert.assertEquals("return IFixtureTunnelToServer#ping", obj1.ping());
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) Test(org.junit.Test)

Example 29 with BeanMetaData

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

the class RegisterTunnelToServerBridgePlatformListener method registerTunnelToServerProxy.

@Override
protected void registerTunnelToServerProxy(IBeanManager beanManager, Class<?> c) {
    List<? extends IBean<?>> beans = beanManager.getBeans(c);
    for (IBean<?> bean : beans) {
        BeanMetaData newMeta = new BeanMetaData(bean).withAnnotation(AnnotationFactory.createTunnelToServer());
        beanManager.unregisterBean(bean);
        beanManager.registerBean(newMeta);
    }
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData)

Example 30 with BeanMetaData

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

the class TestingUtility method mockConfigProperty.

@SuppressWarnings("unchecked")
public static <T> IBean<?> mockConfigProperty(Class<? extends IConfigProperty<T>> propertyClass, T value) {
    IConfigProperty<?> mock = Mockito.mock(IConfigProperty.class);
    Mockito.<T>when((T) mock.getValue(ArgumentMatchers.<String>any())).thenReturn(value);
    Mockito.<T>when((T) mock.getValue()).thenReturn(value);
    return TestingUtility.registerBean(new BeanMetaData(propertyClass, mock));
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData)

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