use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class AnnoTestBean method autowiringIsEnabledByDefault.
@Test
void autowiringIsEnabledByDefault() {
ApplicationContext context = new AnnotationConfigApplicationContext(AutowiredConfig.class);
assertThat(context.getBean(AnnoTestBean.class).name).isEqualTo("foo");
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class AnnoTestBean method getBeanByTypeRaisesNoSuchBeanDefinitionException.
@Test
void getBeanByTypeRaisesNoSuchBeanDefinitionException() {
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
// attempt to retrieve a bean that does not exist
Class<?> targetType = Pattern.class;
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> context.getBean(targetType)).withMessageContaining(format("No qualifying bean of type '%s'", targetType.getName()));
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class AvailabilityChangeEventTests method publishPublishesEvent.
@Test
void publishPublishesEvent() {
ApplicationContext context = mock(ApplicationContext.class);
AvailabilityState state = LivenessState.CORRECT;
AvailabilityChangeEvent.publish(context, state);
ArgumentCaptor<ApplicationEvent> captor = ArgumentCaptor.forClass(ApplicationEvent.class);
then(context).should().publishEvent(captor.capture());
AvailabilityChangeEvent<?> event = (AvailabilityChangeEvent<?>) captor.getValue();
assertThat(event.getSource()).isEqualTo(context);
assertThat(event.getState()).isEqualTo(state);
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class UnsupportedInterceptor method testWithDependencyChecking.
@Test
@SuppressWarnings("resource")
public void testWithDependencyChecking() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(DEPENDENCY_CHECK_CONTEXT, getClass());
ctx.getBean("testBean");
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class ObjenesisProxyTests method appliesAspectToClassWithComplexConstructor.
@Test
public void appliesAspectToClassWithComplexConstructor() {
@SuppressWarnings("resource") ApplicationContext context = new ClassPathXmlApplicationContext("ObjenesisProxyTests-context.xml", getClass());
ClassWithComplexConstructor bean = context.getBean(ClassWithComplexConstructor.class);
bean.method();
DebugInterceptor interceptor = context.getBean(DebugInterceptor.class);
assertThat(interceptor.getCount()).isEqualTo(1L);
assertThat(bean.getDependency().getValue()).isEqualTo(1);
}
Aggregations