Search in sources :

Example 21 with ApplicationContext

use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.

the class ConfigurationWithFactoryBeanAndParametersTests method test.

@Test
public void test() {
    ApplicationContext ctx = new StandardApplicationContext(Config.class, Bar.class);
    assertThat(ctx.getBean(Bar.class).foo).isNotNull();
}
Also used : StandardApplicationContext(cn.taketoday.context.support.StandardApplicationContext) ApplicationContext(cn.taketoday.context.ApplicationContext) StandardApplicationContext(cn.taketoday.context.support.StandardApplicationContext) Test(org.junit.jupiter.api.Test)

Example 22 with ApplicationContext

use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.

the class EnableAspectJAutoProxyTests method withJdkProxy.

@Test
public void withJdkProxy() {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithJdkProxy.class);
    aspectIsApplied(ctx);
    assertThat(AopUtils.isJdkDynamicProxy(ctx.getBean(FooService.class))).isTrue();
}
Also used : FooService(example.scannable.FooService) ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) ApplicationContext(cn.taketoday.context.ApplicationContext) Test(org.junit.jupiter.api.Test)

Example 23 with ApplicationContext

use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.

the class PrimitiveBeanLookupAndAutowiringTests method primitiveAutowiredInjection.

@Test
public void primitiveAutowiredInjection() {
    ApplicationContext ctx = new StandardApplicationContext(Config.class, AutowiredComponent.class);
    assertThat(ctx.getBean(AutowiredComponent.class).b).isEqualTo(true);
    assertThat(ctx.getBean(AutowiredComponent.class).i).isEqualTo(42);
}
Also used : StandardApplicationContext(cn.taketoday.context.support.StandardApplicationContext) ApplicationContext(cn.taketoday.context.ApplicationContext) StandardApplicationContext(cn.taketoday.context.support.StandardApplicationContext) Test(org.junit.jupiter.api.Test)

Example 24 with ApplicationContext

use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.

the class PrimitiveBeanLookupAndAutowiringTests method primitiveLookupByName.

@Test
public void primitiveLookupByName() {
    ApplicationContext ctx = new StandardApplicationContext(Config.class);
    boolean b = ctx.getBean("b", boolean.class);
    assertThat(b).isEqualTo(true);
    int i = ctx.getBean("i", int.class);
    assertThat(i).isEqualTo(42);
}
Also used : StandardApplicationContext(cn.taketoday.context.support.StandardApplicationContext) ApplicationContext(cn.taketoday.context.ApplicationContext) StandardApplicationContext(cn.taketoday.context.support.StandardApplicationContext) Test(org.junit.jupiter.api.Test)

Example 25 with ApplicationContext

use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.

the class PrimitiveBeanLookupAndAutowiringTests method primitiveResourceInjection.

@Test
public void primitiveResourceInjection() {
    ApplicationContext ctx = new StandardApplicationContext(Config.class, ResourceComponent.class);
    assertThat(ctx.getBean(ResourceComponent.class).b).isEqualTo(true);
    assertThat(ctx.getBean(ResourceComponent.class).i).isEqualTo(42);
}
Also used : StandardApplicationContext(cn.taketoday.context.support.StandardApplicationContext) ApplicationContext(cn.taketoday.context.ApplicationContext) StandardApplicationContext(cn.taketoday.context.support.StandardApplicationContext) Test(org.junit.jupiter.api.Test)

Aggregations

ApplicationContext (cn.taketoday.context.ApplicationContext)200 Test (org.junit.jupiter.api.Test)158 StandardApplicationContext (cn.taketoday.context.support.StandardApplicationContext)44 ConfigurableApplicationContext (cn.taketoday.context.ConfigurableApplicationContext)29 AnnotationConfigApplicationContext (cn.taketoday.context.annotation.AnnotationConfigApplicationContext)24 GenericWebServletApplicationContext (cn.taketoday.web.context.support.GenericWebServletApplicationContext)22 TestBean (cn.taketoday.beans.testfixture.beans.TestBean)14 ClassPathXmlApplicationContext (cn.taketoday.context.support.ClassPathXmlApplicationContext)12 ITestBean (cn.taketoday.beans.testfixture.beans.ITestBean)10 WebServletApplicationContext (cn.taketoday.web.servlet.WebServletApplicationContext)8 GenericApplicationContext (cn.taketoday.context.support.GenericApplicationContext)6 ConfigurableEnvironment (cn.taketoday.core.env.ConfigurableEnvironment)6 PropertySources (cn.taketoday.core.env.PropertySources)6 Resource (cn.taketoday.core.io.Resource)6 Nullable (cn.taketoday.lang.Nullable)6 FooService (example.scannable.FooService)6 ServletContext (jakarta.servlet.ServletContext)6 WebApplicationContext (cn.taketoday.web.WebApplicationContext)5 AutowireCapableBeanFactory (cn.taketoday.beans.factory.config.AutowireCapableBeanFactory)4 Advised (cn.taketoday.aop.framework.Advised)3