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());
}
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();
}
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());
}
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);
}
}
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));
}
Aggregations