Search in sources :

Example 6 with DescriptiveResource

use of org.springframework.core.io.DescriptiveResource in project spring-framework by spring-projects.

the class FailFastProblemReporterTests method testWarn.

@Test
public void testWarn() throws Exception {
    Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException());
    Log log = mock(Log.class);
    FailFastProblemReporter reporter = new FailFastProblemReporter();
    reporter.setLogger(log);
    reporter.warning(problem);
    verify(log).warn(any(), isA(IllegalArgumentException.class));
}
Also used : Log(org.apache.commons.logging.Log) DescriptiveResource(org.springframework.core.io.DescriptiveResource) Test(org.junit.jupiter.api.Test)

Example 7 with DescriptiveResource

use of org.springframework.core.io.DescriptiveResource in project spring-framework by spring-projects.

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(org.springframework.beans.factory.config.BeanDefinitionHolder) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) DescriptiveResource(org.springframework.core.io.DescriptiveResource) Test(org.junit.jupiter.api.Test)

Example 8 with DescriptiveResource

use of org.springframework.core.io.DescriptiveResource in project spring-framework by spring-projects.

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(org.springframework.beans.factory.support.RootBeanDefinition) DescriptiveResource(org.springframework.core.io.DescriptiveResource) Test(org.junit.jupiter.api.Test)

Aggregations

DescriptiveResource (org.springframework.core.io.DescriptiveResource)8 Test (org.junit.jupiter.api.Test)4 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)3 Map (java.util.Map)2 GString (groovy.lang.GString)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Log (org.apache.commons.logging.Log)1 Test (org.junit.Test)1 BeansException (org.springframework.beans.BeansException)1 BeanCreationNotAllowedException (org.springframework.beans.factory.BeanCreationNotAllowedException)1 BeanFactory (org.springframework.beans.factory.BeanFactory)1 BeanFactoryAware (org.springframework.beans.factory.BeanFactoryAware)1 BeanFactoryUtils (org.springframework.beans.factory.BeanFactoryUtils)1 SmartInitializingSingleton (org.springframework.beans.factory.SmartInitializingSingleton)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 BeanDefinitionCustomizer (org.springframework.beans.factory.config.BeanDefinitionCustomizer)1 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)1 BeanPostProcessor (org.springframework.beans.factory.config.BeanPostProcessor)1