Search in sources :

Example 1 with LifecycleProcessor

use of cn.taketoday.context.LifecycleProcessor 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 2 with LifecycleProcessor

use of cn.taketoday.context.LifecycleProcessor in project today-infrastructure 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)

Aggregations

DirectFieldAccessor (cn.taketoday.beans.DirectFieldAccessor)2 BeanDefinition (cn.taketoday.beans.factory.config.BeanDefinition)2 RootBeanDefinition (cn.taketoday.beans.factory.support.RootBeanDefinition)2 LifecycleProcessor (cn.taketoday.context.LifecycleProcessor)2 Test (org.junit.jupiter.api.Test)2