use of org.eclipse.scout.rt.platform.IBean 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.IBean in project scout.rt by eclipse.
the class PermissionServiceTest method testImpl.
/* ---------------------------------------------------------------------------------------------- */
/* Tests for Bug 398323 - CodeService / PermissionService: More fine-grained lookup strategies for finding classes */
/* ---------------------------------------------------------------------------------------------- */
private void testImpl(IPermissionService testService, boolean testPermission1Expected, boolean testPermission2Expected) {
List<IBean<?>> reg = TestingUtility.registerBeans(new BeanMetaData(IPermissionService.class).withInitialInstance(testService).withApplicationScoped(true));
try {
IPermissionService service = BEANS.get(IPermissionService.class);
assertSame(testService, service);
//
Set<Class<? extends Permission>> result = service.getAllPermissionClasses();
boolean testPermission1Found = false;
boolean testPermission2Found = false;
for (Class<?> b : result) {
if (ObjectUtility.equals(b.getName(), TestPermission1.class.getName())) {
testPermission1Found = true;
}
if (ObjectUtility.equals(b.getName(), TestPermission2.class.getName())) {
testPermission2Found = true;
}
}
//
if (testPermission1Expected) {
assertTrue("TestPermission1 class not found (expected: found)", testPermission1Found);
} else {
assertFalse("TestPermission1 class found (expected: not found)", testPermission1Found);
}
if (testPermission2Expected) {
assertTrue("TestPermission2 class not found (expected: found)", testPermission2Found);
} else {
assertFalse("TestPermission2 class found (expected: not found)", testPermission2Found);
}
} finally {
TestingUtility.unregisterBeans(reg);
}
}
use of org.eclipse.scout.rt.platform.IBean in project scout.rt by eclipse.
the class BeanAnnotations method init.
/**
* Initialize fields annotated with {@link BeanMock}
*/
public void init(Object testObj) {
List<IBean<?>> regs = new ArrayList<IBean<?>>();
Field[] fields = testObj.getClass().getDeclaredFields();
for (Field f : fields) {
if (isBeanMock(f)) {
regs.add(registerMock(testObj, f));
}
}
m_regs = Collections.unmodifiableList(regs);
}
use of org.eclipse.scout.rt.platform.IBean in project scout.rt by eclipse.
the class JandexTypeNameIdResolverTest method testPoJoInterfaceWithMultipleImplementation.
@Test
public void testPoJoInterfaceWithMultipleImplementation() {
List<IBean<?>> registeredBeans = new ArrayList<>();
try {
registeredBeans.add(TestingUtility.registerBean(new BeanMetaData(Person.class)));
registeredBeans.add(TestingUtility.registerBean(new BeanMetaData(ProjectPerson2.class).withReplace(true)));
registeredBeans.add(TestingUtility.registerBean(new BeanMetaData(Company.class)));
registeredBeans.add(TestingUtility.registerBean(new BeanMetaData(ProjectCompany2.class).withReplace(true)));
CustomerResponse2 customerResponse = new CustomerResponse2();
customerResponse.customers = new ArrayList<>();
customerResponse.customers.add(BEANS.get(ProjectPerson2.class));
customerResponse.customers.add(BEANS.get(ProjectCompany2.class));
marshallUnmarshall(customerResponse);
} finally {
TestingUtility.unregisterBeans(registeredBeans);
}
}
use of org.eclipse.scout.rt.platform.IBean in project scout.rt by eclipse.
the class JandexTypeNameIdResolverTest method testBeanInterfaceWithMultipleImplementation.
@Test
public void testBeanInterfaceWithMultipleImplementation() {
List<IBean<?>> registeredBeans = new ArrayList<>();
try {
registeredBeans.add(TestingUtility.registerBean(new BeanMetaData(Person.class)));
registeredBeans.add(TestingUtility.registerBean(new BeanMetaData(ProjectPerson.class).withReplace(true)));
runTestBeanInterfaceWithMultipleImplementation();
registeredBeans.add(TestingUtility.registerBean(new BeanMetaData(Company.class)));
registeredBeans.add(TestingUtility.registerBean(new BeanMetaData(ProjectCompany.class).withReplace(true)));
runTestBeanInterfaceWithMultipleImplementation();
CustomerResponse customerResponse = new CustomerResponse();
customerResponse.customers = new ArrayList<>();
customerResponse.customers.add(BEANS.get(ProjectPerson.class));
customerResponse.customers.add(BEANS.get(ProjectCompany.class));
marshallUnmarshall(customerResponse);
} finally {
TestingUtility.unregisterBeans(registeredBeans);
}
}
Aggregations