Search in sources :

Example 1 with DescriptiveResource

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));
}
Also used : DescriptiveResource(cn.taketoday.core.io.DescriptiveResource) Logger(cn.taketoday.logging.Logger) Test(org.junit.jupiter.api.Test)

Example 2 with DescriptiveResource

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);
}
Also used : BeanDefinitionHolder(cn.taketoday.beans.factory.config.BeanDefinitionHolder) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) DescriptiveResource(cn.taketoday.core.io.DescriptiveResource) Test(org.junit.jupiter.api.Test)

Example 3 with DescriptiveResource

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));
}
Also used : DescriptiveResource(cn.taketoday.core.io.DescriptiveResource) Logger(cn.taketoday.logging.Logger) Test(org.junit.jupiter.api.Test)

Example 4 with DescriptiveResource

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);
}
Also used : RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) DescriptiveResource(cn.taketoday.core.io.DescriptiveResource) Test(org.junit.jupiter.api.Test)

Example 5 with DescriptiveResource

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());
}
Also used : ITestBean(cn.taketoday.beans.testfixture.beans.ITestBean) TestBean(cn.taketoday.beans.testfixture.beans.TestBean) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) DescriptiveResource(cn.taketoday.core.io.DescriptiveResource) Test(org.junit.jupiter.api.Test)

Aggregations

DescriptiveResource (cn.taketoday.core.io.DescriptiveResource)8 Test (org.junit.jupiter.api.Test)8 RootBeanDefinition (cn.taketoday.beans.factory.support.RootBeanDefinition)6 BeanDefinitionHolder (cn.taketoday.beans.factory.config.BeanDefinitionHolder)2 ITestBean (cn.taketoday.beans.testfixture.beans.ITestBean)2 TestBean (cn.taketoday.beans.testfixture.beans.TestBean)2 Logger (cn.taketoday.logging.Logger)2