Search in sources :

Example 31 with BeanMetaData

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

the class ClusterSynchronizationServiceTest method before.

@Before
public void before() throws Exception {
    m_nullMomImplementorSpy = spy(NullMomImplementor.class);
    m_beans.add(TestingUtility.registerBean(new BeanMetaData(TestClusterMom.class)));
    m_beans.add(TestingUtility.registerBean(new BeanMetaData(NullMomImplementor.class).withProducer(new IBeanInstanceProducer<IMomImplementor>() {

        @Override
        public IMomImplementor produce(IBean<IMomImplementor> bean) {
            return m_nullMomImplementorSpy;
        }
    })));
    // verify that replacement works
    assertSame("NullMomImplementor-Spy expected", m_nullMomImplementorSpy, BEANS.get(NullMomImplementor.class));
    ClusterNotificationProperties testProps = new ClusterNotificationProperties(TEST_NODE, TEST_USER);
    m_message = new ClusterNotificationMessage("notification", testProps);
    m_svc = new ClusterSynchronizationService();
    m_svc.enable();
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) ClusterNotificationMessage(org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage) IMomImplementor(org.eclipse.scout.rt.mom.api.IMomImplementor) ClusterNotificationProperties(org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationProperties) NullMomImplementor(org.eclipse.scout.rt.mom.api.NullMomImplementor) Before(org.junit.Before)

Example 32 with BeanMetaData

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

the class AccessControlServiceTest method setup.

@Before
public void setup() {
    m_accessControlService = BeanInstanceUtil.createBean(TestAccessControlService.class);
    BeanInstanceUtil.initializeBeanInstance(m_accessControlService);
    // Register this IAccessControlService with an higher priority than AllAccessControlService registered in CustomServerTestEnvironment
    m_registerServices = TestingUtility.registerBeans(new BeanMetaData(IAccessControlService.class).withInitialInstance(m_accessControlService).withApplicationScoped(true), new BeanMetaData(MaxNotificationBlockingTimeOut.class).withInitialInstance(new TestBlockingProperty()).withApplicationScoped(true));
    // register test session
    final IClientNotificationService registry = BEANS.get(IClientNotificationService.class);
    registry.registerSession("testNode", "testSession", "testuser");
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IClientNotificationService(org.eclipse.scout.rt.shared.clientnotification.IClientNotificationService) Before(org.junit.Before)

Example 33 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData 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);
    }
}
Also used : IPermissionService(org.eclipse.scout.rt.shared.services.common.security.IPermissionService) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) TestPermission1(org.eclipse.scout.rt.server.services.common.security.fixture.TestPermission1) TestPermission2(org.eclipse.scout.rt.server.services.common.security.fixture.TestPermission2) Permission(java.security.Permission) IBean(org.eclipse.scout.rt.platform.IBean)

Example 34 with BeanMetaData

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

the class BeanAnnotations method registerMock.

private IBean<?> registerMock(Object testObj, Field f) {
    Class<?> mockType = f.getType();
    BeanMetaData beanData = BEANS.get(IBeanAnnotationMetaDataProducer.class).produce(mockType);
    IBean<?> reg = Platform.get().getBeanManager().registerBean(beanData);
    Object mock = BEANS.get(mockType);
    trySetMock(f, mock, testObj);
    return reg;
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData)

Example 35 with BeanMetaData

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

the class PlatformTestRunner method interceptClassLevelStatement.

/**
 * Overwrite this method to contribute some 'class-level' behavior to this Runner.
 * <p>
 * Contributions are plugged according to the design pattern: 'chain-of-responsibility' - it is easiest to read the
 * chain from 'bottom-to-top'.
 * <p>
 * To contribute on top of the chain (meaning that you are invoked <strong>after</strong> the contributions of super
 * classes and therefore can base on their contributed functionality), you can use constructions of the following
 * form:
 * <p>
 * <code>
 *   Statement s2 = new YourInterceptor2(<strong>next</strong>); // executed 3th<br/>
 *   Statement s1 = new YourInterceptor1(s2); // executed 2nd<br/>
 *   Statement head = <i>super.interceptClassLevelStatement(s1)</i>; // executed 1st<br/>
 *   return head;
 * </code>
 * </p>
 * To be invoked <strong>before</strong> the super class contributions, you can use constructions of the following
 * form:
 * <p>
 * <code>
 *   Statement s2 = <i>super.interceptClassLevelStatement(<strong>next</strong>)</i>; // executed 3th<br/>
 *   Statement s1 = new YourInterceptor2(s2); // executed 2nd<br/>
 *   Statement head = new YourInterceptor1(s1); // executed 1st<br/>
 *   return head;
 * </code>
 *
 * @param next
 *          subsequent {@link Statement}.
 * @return the head of the chain to be invoked first.
 */
protected Statement interceptClassLevelStatement(final Statement next, final Class<?> testClass) {
    final Statement s2 = new SubjectStatement(next, testClass.getAnnotation(RunWithSubject.class));
    // exception handler to not silently swallow handled exceptions.
    final Statement s1 = new RegisterBeanStatement(s2, new BeanMetaData(JUnitExceptionHandler.class).withReplace(true).withOrder(-1000));
    return s1;
}
Also used : SubjectStatement(org.eclipse.scout.rt.testing.platform.runner.statement.SubjectStatement) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) Statement(org.junit.runners.model.Statement) SubjectStatement(org.eclipse.scout.rt.testing.platform.runner.statement.SubjectStatement) BeanAnnotationsCleanupStatement(org.eclipse.scout.rt.testing.platform.runner.statement.BeanAnnotationsCleanupStatement) AssertNoRunningJobsStatement(org.eclipse.scout.rt.testing.platform.runner.statement.AssertNoRunningJobsStatement) TimeoutRunContextStatement(org.eclipse.scout.rt.testing.platform.runner.statement.TimeoutRunContextStatement) BeanAnnotationsInitStatement(org.eclipse.scout.rt.testing.platform.runner.statement.BeanAnnotationsInitStatement) RegisterBeanStatement(org.eclipse.scout.rt.testing.platform.runner.statement.RegisterBeanStatement) ThrowHandledExceptionStatement(org.eclipse.scout.rt.testing.platform.runner.statement.ThrowHandledExceptionStatement) ClearThreadInterruptionStatusStatement(org.eclipse.scout.rt.testing.platform.runner.statement.ClearThreadInterruptionStatusStatement) RunContextStatement(org.eclipse.scout.rt.testing.platform.runner.statement.RunContextStatement) PlatformStatement(org.eclipse.scout.rt.testing.platform.runner.statement.PlatformStatement) TransactionAddFailureOnAnyExceptionStatement(org.eclipse.scout.rt.testing.platform.runner.statement.TransactionAddFailureOnAnyExceptionStatement) TimesStatement(org.eclipse.scout.rt.testing.platform.runner.statement.TimesStatement) RegisterBeanStatement(org.eclipse.scout.rt.testing.platform.runner.statement.RegisterBeanStatement)

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