use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class PlatformTestRunner method interceptMethodLevelStatement.
/**
* Overwrite this method to contribute some 'method-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.interceptMethodLevelStatement(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.interceptMethodLevelStatement(<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 interceptMethodLevelStatement(final Statement next, final Class<?> testClass, final Method testMethod) {
final Statement s5 = new ClearThreadInterruptionStatusStatement(next);
final Statement s4 = new SubjectStatement(s5, ReflectionUtility.getAnnotation(RunWithSubject.class, testMethod, testClass));
// exception handler to not silently swallow handled exceptions.
final Statement s3 = new RegisterBeanStatement(s4, new BeanMetaData(JUnitExceptionHandler.class).withReplace(true).withOrder(-1000));
final Statement s2 = new AssertNoRunningJobsStatement(s3, "Test method");
final Statement s1 = new TimesStatement(s2, ReflectionUtility.getAnnotation(Times.class, testMethod, testClass));
return s1;
}
use of org.eclipse.scout.rt.platform.BeanMetaData 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.BeanMetaData in project scout.rt by eclipse.
the class JandexTypeNameIdResolverTest method testPoJoClassWithMultipleImplementation.
/**
* Test-case with a base class and two subclasses which do not specify an own JSON type identifier.
* <p>
* This example is a completeness test for JandexTypeNameIdResolver, in a normal case this scenario is not
* reproducible due to a check for duplicated replaced classes within bean manager. This test case should fail, since
* JandexTypeNameIdResolver cannot find the correct matching class if more than one matching subclass is available.
*/
@Test(expected = InvalidTypeIdException.class)
public void testPoJoClassWithMultipleImplementation() throws Exception {
IBean<?> personBean = TestingUtility.registerBean(new BeanMetaData(ProjectPerson.class));
IBean<?> person2Bean = TestingUtility.registerBean(new BeanMetaData(ProjectPerson2.class));
try {
String json = "{\"persons\":[{\"type\":\"Person\"},{\"type\":\"Person\"}]}";
ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(BEANS.get(JandexJacksonAnnotationIntrospector.class));
mapper.readValue(json, PersonResponse.class);
} finally {
TestingUtility.unregisterBean(personBean);
TestingUtility.unregisterBean(person2Bean);
}
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class JandexTypeNameIdResolverTest method beforeClass.
@BeforeClass
public static void beforeClass() {
s_beans.add(TestingUtility.registerBean(new BeanMetaData(CoreBean.class)));
s_beans.add(TestingUtility.registerBean(new BeanMetaData(ProjectTemplateBean.class).withReplace(true)));
}
use of org.eclipse.scout.rt.platform.BeanMetaData 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