Search in sources :

Example 16 with DirectFieldAccessor

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);
}
Also used : MarkupTemplateEngine(groovy.text.markup.MarkupTemplateEngine) TemplateEngine(groovy.text.TemplateEngine) DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) Test(org.junit.jupiter.api.Test)

Example 17 with DirectFieldAccessor

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);
}
Also used : DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) Test(org.junit.jupiter.api.Test)

Example 18 with DirectFieldAccessor

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");
}
Also used : ScheduledMethodRunnable(cn.taketoday.scheduling.support.ScheduledMethodRunnable) DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) ScheduledMethodRunnable(cn.taketoday.scheduling.support.ScheduledMethodRunnable) List(java.util.List) Method(java.lang.reflect.Method) Test(org.junit.jupiter.api.Test)

Example 19 with DirectFieldAccessor

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));
}
Also used : HashMap(java.util.HashMap) DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 20 with DirectFieldAccessor

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);
}
Also used : DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) Test(org.junit.jupiter.api.Test)

Aggregations

DirectFieldAccessor (cn.taketoday.beans.DirectFieldAccessor)46 Test (org.junit.jupiter.api.Test)34 ScriptEngine (javax.script.ScriptEngine)6 Test (org.junit.Test)6 AnnotationConfigApplicationContext (cn.taketoday.context.annotation.AnnotationConfigApplicationContext)4 ThreadPoolTaskScheduler (cn.taketoday.scheduling.concurrent.ThreadPoolTaskScheduler)4 TemplateEngine (groovy.text.TemplateEngine)4 MarkupTemplateEngine (groovy.text.markup.MarkupTemplateEngine)4 Method (java.lang.reflect.Method)4 Map (java.util.Map)4 MethodInterceptor (org.aopalliance.intercept.MethodInterceptor)4 BeanDefinition (cn.taketoday.beans.factory.config.BeanDefinition)3 RootBeanDefinition (cn.taketoday.beans.factory.support.RootBeanDefinition)3 Advisor (cn.taketoday.aop.Advisor)2 Advised (cn.taketoday.aop.framework.Advised)2 LifecycleProcessor (cn.taketoday.context.LifecycleProcessor)2 StaticApplicationContext (cn.taketoday.context.support.StaticApplicationContext)2 MediaType (cn.taketoday.http.MediaType)2 ExponentialBackOffPolicy (cn.taketoday.retry.backoff.ExponentialBackOffPolicy)2 SimpleRetryPolicy (cn.taketoday.retry.policy.SimpleRetryPolicy)2