use of cn.taketoday.core.io.DescriptiveResource in project today-infrastructure by TAKETODAY.
the class FailFastProblemReporterTests method testWarn.
@Test
public void testWarn() throws Exception {
Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException());
Logger log = mock(Logger.class);
FailFastProblemReporter reporter = new FailFastProblemReporter();
reporter.setLogger(log);
reporter.warning(problem);
verify(log).warn(any(), isA(IllegalArgumentException.class));
}
use of cn.taketoday.core.io.DescriptiveResource in project today-infrastructure by TAKETODAY.
the class ConfigurationClassPostProcessorTests method postProcessorDoesNotOverrideRegularBeanDefinitionsEvenWithScopedProxy.
@Test
void postProcessorDoesNotOverrideRegularBeanDefinitionsEvenWithScopedProxy() {
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setResource(new DescriptiveResource("XML or something"));
BeanDefinitionHolder proxied = ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(rbd, "bar"), beanFactory, true);
beanFactory.registerBeanDefinition("bar", proxied.getBeanDefinition());
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class));
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
pp.postProcessBeanFactory(beanFactory);
beanFactory.getBean("foo", Foo.class);
beanFactory.getBean("bar", TestBean.class);
}
use of cn.taketoday.core.io.DescriptiveResource in project today-framework by TAKETODAY.
the class FailFastProblemReporterTests method testWarn.
@Test
public void testWarn() throws Exception {
Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException());
Logger log = mock(Logger.class);
FailFastProblemReporter reporter = new FailFastProblemReporter();
reporter.setLogger(log);
reporter.warning(problem);
verify(log).warn(any(), isA(IllegalArgumentException.class));
}
use of cn.taketoday.core.io.DescriptiveResource in project today-framework by TAKETODAY.
the class ConfigurationClassPostProcessorTests method postProcessorDoesNotOverrideRegularBeanDefinitions.
@Test
void postProcessorDoesNotOverrideRegularBeanDefinitions() {
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setResource(new DescriptiveResource("XML or something"));
beanFactory.registerBeanDefinition("bar", rbd);
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class));
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
pp.postProcessBeanFactory(beanFactory);
beanFactory.getBean("foo", Foo.class);
beanFactory.getBean("bar", TestBean.class);
}
use of cn.taketoday.core.io.DescriptiveResource in project today-framework by TAKETODAY.
the class ConfigurationClassPostProcessorTests method postProcessorFailsOnImplicitOverrideIfOverridingIsNotAllowed.
@Test
void postProcessorFailsOnImplicitOverrideIfOverridingIsNotAllowed() {
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setResource(new DescriptiveResource("XML or something"));
beanFactory.registerBeanDefinition("bar", rbd);
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class));
beanFactory.setAllowBeanDefinitionOverriding(false);
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() -> pp.postProcessBeanFactory(beanFactory)).withMessageContaining("bar").withMessageContaining("SingletonBeanConfig").withMessageContaining(TestBean.class.getName());
}
Aggregations