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