use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.
the class GroovyMarkupViewTests method customTemplateEngine.
@Test
public void customTemplateEngine() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();
view.setTemplateEngine(new TestTemplateEngine());
view.setApplicationContext(this.webAppContext);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
assertThat(engine).isNotNull();
assertThat(engine.getClass()).isEqualTo(TestTemplateEngine.class);
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.
the class ScheduledTasksBeanDefinitionParserTests method checkScheduler.
@Test
public void checkScheduler() {
Object schedulerBean = this.context.getBean("testScheduler");
Object schedulerRef = new DirectFieldAccessor(this.registrar).getPropertyValue("taskScheduler");
assertThat(schedulerRef).isEqualTo(schedulerBean);
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.
the class ScheduledTasksBeanDefinitionParserTests method checkTarget.
@Test
public void checkTarget() {
List<IntervalTask> tasks = (List<IntervalTask>) new DirectFieldAccessor(this.registrar).getPropertyValue("fixedRateTasks");
Runnable runnable = tasks.get(0).getRunnable();
assertThat(runnable.getClass()).isEqualTo(ScheduledMethodRunnable.class);
Object targetObject = ((ScheduledMethodRunnable) runnable).getTarget();
Method targetMethod = ((ScheduledMethodRunnable) runnable).getMethod();
assertThat(targetObject).isEqualTo(this.testBean);
assertThat(targetMethod.getName()).isEqualTo("test");
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.
the class BinaryExceptionClassifierTests method testClassifySubclassMatchInCauseFalse.
@Test
public void testClassifySubclassMatchInCauseFalse() {
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
map.put(IllegalStateException.class, true);
map.put(BarException.class, false);
BinaryExceptionClassifier binaryExceptionClassifier = new BinaryExceptionClassifier(map, true);
binaryExceptionClassifier.setTraverseCauses(true);
assertTrue(binaryExceptionClassifier.classify(new RuntimeException(new FooException("Foo", new BarException()))));
assertTrue(((Map<?, ?>) new DirectFieldAccessor(binaryExceptionClassifier).getPropertyValue("classified")).containsKey(FooException.class));
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.
the class AnnotationDrivenBeanDefinitionParserTests method scheduledPostProcessorSchedulerReference.
@Test
public void scheduledPostProcessorSchedulerReference() {
Object scheduler = context.getBean("testScheduler");
Object postProcessor = context.getBean(TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME);
assertThat(new DirectFieldAccessor(postProcessor).getPropertyValue("scheduler")).isSameAs(scheduler);
}
Aggregations