Search in sources :

Example 1 with BeanMetaData

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();
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) Test(org.junit.Test)

Example 2 with BeanMetaData

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());
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) Test(org.junit.Test)

Example 3 with BeanMetaData

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);
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) PlatformEvent(org.eclipse.scout.rt.platform.PlatformEvent) ExecutionException(java.util.concurrent.ExecutionException) IPlatformListener(org.eclipse.scout.rt.platform.IPlatformListener)

Example 4 with BeanMetaData

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();
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) ScoutTexts(org.eclipse.scout.rt.shared.ScoutTexts)

Example 5 with BeanMetaData

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));
}
Also used : SessionStoreMaxWaitWriteLockProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitWriteLockProperty) SessionStoreMaxWaitAllShutdownProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitAllShutdownProperty) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) SessionStoreHousekeepingMaxWaitShutdownProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingMaxWaitShutdownProperty) SessionStoreHousekeepingDelayProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingDelayProperty) JobCompletionDelayOnSessionShutdown(org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown) Before(org.junit.Before)

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