Search in sources :

Example 21 with DirectFieldAccessor

use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.

the class SchedulerBeanDefinitionParserTests method defaultScheduler.

@Test
public void defaultScheduler() {
    ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) this.context.getBean("defaultScheduler");
    Integer size = (Integer) new DirectFieldAccessor(scheduler).getPropertyValue("poolSize");
    assertThat(size).isEqualTo(1);
}
Also used : DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) ThreadPoolTaskScheduler(cn.taketoday.scheduling.concurrent.ThreadPoolTaskScheduler) Test(org.junit.jupiter.api.Test)

Example 22 with DirectFieldAccessor

use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.

the class SchedulerBeanDefinitionParserTests method customScheduler.

@Test
public void customScheduler() {
    ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) this.context.getBean("customScheduler");
    Integer size = (Integer) new DirectFieldAccessor(scheduler).getPropertyValue("poolSize");
    assertThat(size).isEqualTo(42);
}
Also used : DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) ThreadPoolTaskScheduler(cn.taketoday.scheduling.concurrent.ThreadPoolTaskScheduler) Test(org.junit.jupiter.api.Test)

Example 23 with DirectFieldAccessor

use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.

the class DefaultLifecycleProcessorTests method defaultLifecycleProcessorInstance.

@Test
public void defaultLifecycleProcessorInstance() {
    StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    Object lifecycleProcessor = new DirectFieldAccessor(context).getPropertyValue("lifecycleProcessor");
    assertThat(lifecycleProcessor).isNotNull();
    assertThat(lifecycleProcessor.getClass()).isEqualTo(DefaultLifecycleProcessor.class);
}
Also used : DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) Test(org.junit.jupiter.api.Test)

Example 24 with DirectFieldAccessor

use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.

the class DefaultLifecycleProcessorTests method customLifecycleProcessorInstance.

@Test
public void customLifecycleProcessorInstance() {
    BeanDefinition beanDefinition = new RootBeanDefinition(DefaultLifecycleProcessor.class);
    beanDefinition.getPropertyValues().add("timeoutPerShutdownPhase", 1000);
    StaticApplicationContext context = new StaticApplicationContext();
    context.registerBeanDefinition("lifecycleProcessor", beanDefinition);
    context.refresh();
    LifecycleProcessor bean = context.getBean("lifecycleProcessor", LifecycleProcessor.class);
    Object contextLifecycleProcessor = new DirectFieldAccessor(context).getPropertyValue("lifecycleProcessor");
    assertThat(contextLifecycleProcessor).isNotNull();
    assertThat(contextLifecycleProcessor).isSameAs(bean);
    assertThat(new DirectFieldAccessor(contextLifecycleProcessor).getPropertyValue("timeoutPerShutdownPhase")).isEqualTo(1000L);
}
Also used : DirectFieldAccessor(cn.taketoday.beans.DirectFieldAccessor) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) BeanDefinition(cn.taketoday.beans.factory.config.BeanDefinition) LifecycleProcessor(cn.taketoday.context.LifecycleProcessor) Test(org.junit.jupiter.api.Test)

Example 25 with DirectFieldAccessor

use of cn.taketoday.beans.DirectFieldAccessor in project today-framework by TAKETODAY.

the class ScriptTemplateViewResolverTests method viewClass.

@Test
public void viewClass() throws Exception {
    ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver();
    assertThat(resolver.requiredViewClass()).isEqualTo(ScriptTemplateView.class);
    DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
    Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
    assertThat(viewClass).isEqualTo(ScriptTemplateView.class);
}
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