Search in sources :

Example 1 with LifecycleBean

use of cn.taketoday.beans.testfixture.beans.LifecycleBean in project today-infrastructure by TAKETODAY.

the class XmlListableBeanFactoryTests method lifecycleMethods.

@Test
public void lifecycleMethods() {
    LifecycleBean bean = (LifecycleBean) getBeanFactory().getBean("lifecycle");
    bean.businessMethod();
}
Also used : LifecycleBean(cn.taketoday.beans.testfixture.beans.LifecycleBean) Test(org.junit.jupiter.api.Test)

Example 2 with LifecycleBean

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

the class AbstractApplicationContextTests method closeTriggersDestroy.

@Test
public void closeTriggersDestroy() {
    LifecycleBean lb = (LifecycleBean) applicationContext.getBean("lifecycle");
    boolean condition = !lb.isDestroyed();
    assertThat(condition).as("Not destroyed").isTrue();
    applicationContext.close();
    if (applicationContext.getParent() != null) {
        ((ConfigurableApplicationContext) applicationContext.getParent()).close();
    }
    assertThat(lb.isDestroyed()).as("Destroyed").isTrue();
    applicationContext.close();
    if (applicationContext.getParent() != null) {
        ((ConfigurableApplicationContext) applicationContext.getParent()).close();
    }
    assertThat(lb.isDestroyed()).as("Destroyed").isTrue();
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) LifecycleBean(cn.taketoday.beans.testfixture.beans.LifecycleBean) Test(org.junit.jupiter.api.Test)

Example 3 with LifecycleBean

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

the class XmlListableBeanFactoryTests method lifecycleMethods.

@Test
public void lifecycleMethods() {
    LifecycleBean bean = (LifecycleBean) getBeanFactory().getBean("lifecycle");
    bean.businessMethod();
}
Also used : LifecycleBean(cn.taketoday.beans.testfixture.beans.LifecycleBean) Test(org.junit.jupiter.api.Test)

Example 4 with LifecycleBean

use of cn.taketoday.beans.testfixture.beans.LifecycleBean in project today-infrastructure by TAKETODAY.

the class AbstractApplicationContextTests method closeTriggersDestroy.

@Test
public void closeTriggersDestroy() {
    LifecycleBean lb = (LifecycleBean) applicationContext.getBean("lifecycle");
    boolean condition = !lb.isDestroyed();
    assertThat(condition).as("Not destroyed").isTrue();
    applicationContext.close();
    if (applicationContext.getParent() != null) {
        ((ConfigurableApplicationContext) applicationContext.getParent()).close();
    }
    assertThat(lb.isDestroyed()).as("Destroyed").isTrue();
    applicationContext.close();
    if (applicationContext.getParent() != null) {
        ((ConfigurableApplicationContext) applicationContext.getParent()).close();
    }
    assertThat(lb.isDestroyed()).as("Destroyed").isTrue();
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) LifecycleBean(cn.taketoday.beans.testfixture.beans.LifecycleBean) Test(org.junit.jupiter.api.Test)

Aggregations

LifecycleBean (cn.taketoday.beans.testfixture.beans.LifecycleBean)4 Test (org.junit.jupiter.api.Test)4 ConfigurableApplicationContext (cn.taketoday.context.ConfigurableApplicationContext)2