use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class BeanHierarchyTest method testReplaceOnPrimitive.
@Test(expected = AssertionException.class)
public void testReplaceOnPrimitive() {
BeanHierarchy<Integer> h = new BeanHierarchy<Integer>(int.class);
BeanMetaData withReplace = new BeanMetaData(int.class).withReplace(true);
h.addBean(new BeanImplementor<Integer>(withReplace));
h.queryAll();
Assert.fail();
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class BeanHierarchyTest method testGetRegisteredBeanWithMultipleRegistration.
@Test
public void testGetRegisteredBeanWithMultipleRegistration() {
BeanHierarchy<AbstractBaseClass> h = new BeanHierarchy<>(AbstractBaseClass.class);
h.addBean(new BeanImplementor<AbstractBaseClass>(new BeanMetaData(SubClassA.class)));
assertEquals(SubClassA.class, h.getExactBean(SubClassA.class).getBeanClazz());
SubClassA subA1 = Mockito.mock(SubClassA.class);
SubClassA subA2 = Mockito.mock(SubClassA.class);
h.addBean(new BeanImplementor<AbstractBaseClass>(new BeanMetaData(SubClassA.class, subA1).withReplace(true).withApplicationScoped(true).withOrder(100)));
h.addBean(new BeanImplementor<AbstractBaseClass>(new BeanMetaData(SubClassA.class, subA2).withReplace(true).withApplicationScoped(true).withOrder(101)));
assertEquals(SubClassA.class, h.getExactBean(SubClassA.class).getBeanClazz());
// expect to get instance of registered bean with lowest order
assertEquals(subA1, h.getExactBean(SubClassA.class).getInstance());
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class PlatformImplementorTest method doTestAwaitPlatformStartedFailsInState.
protected void doTestAwaitPlatformStartedFailsInState(final State platformStartFailsInState) throws Exception {
// create platform listener that fails in given state
BeanMetaData bean = new BeanMetaData(IPlatformListener.class).withApplicationScoped(true).withInitialInstance(new IPlatformListener() {
@Override
public void stateChanged(PlatformEvent event) {
if (event.getState() == platformStartFailsInState) {
throw new TestingPlatformStartupException();
}
}
});
// create platform instance and start it in another thread
final TestingPlatformImplementor platform = new TestingPlatformImplementor(bean);
Future<?> platformStartFuture = startPlatformInAnotherThread(platform);
// current thread is expected to be suspended
assertAwaitPlatformStarted(platform, platformStartFailsInState == null);
// wait until platform starter has been finished and either expect no failures or the intended startup exception
if (platformStartFailsInState == null) {
platformStartFuture.get();
} else {
try {
platformStartFuture.get();
fail("Platform is not expected to be started");
} catch (ExecutionException e) {
assertSame(TestingPlatformStartupException.class, e.getCause().getClass());
}
}
// again awaitPlatformStartedFails
assertAwaitPlatformStarted(platform, platformStartFailsInState == null);
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class TextKeyTextProviderService method register.
public static void register() {
LOG.info("Register TextKeyTextProviderService with high priority. ScoutTexts will return text keys instead of localized texts");
BeanMetaData beanData = new BeanMetaData(TextKeyTextProviderService.class).withOrder(Double.MIN_VALUE + 1);
Platform.get().getBeanManager().registerBean(beanData);
BEANS.get(ScoutTexts.class).reloadTextProviders();
}
use of org.eclipse.scout.rt.platform.BeanMetaData 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));
}
Aggregations