|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2024 the original author or authors. |
|
|
|
|
* Copyright 2002-2025 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -67,6 +67,7 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
@@ -67,6 +67,7 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
|
|
|
|
import org.springframework.core.task.SyncTaskExecutor; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
|
|
|
|
@ -104,6 +105,7 @@ class ConfigurationClassPostProcessorTests {
@@ -104,6 +105,7 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); |
|
|
|
|
pp.postProcessBeanFactory(beanFactory); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).getBeanClass().getName()).contains(ClassUtils.CGLIB_CLASS_SEPARATOR); |
|
|
|
|
Foo foo = beanFactory.getBean("foo", Foo.class); |
|
|
|
|
Bar bar = beanFactory.getBean("bar", Bar.class); |
|
|
|
|
assertThat(bar.foo).isSameAs(foo); |
|
|
|
|
@ -118,6 +120,7 @@ class ConfigurationClassPostProcessorTests {
@@ -118,6 +120,7 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); |
|
|
|
|
pp.postProcessBeanFactory(beanFactory); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).getBeanClass().getName()).contains(ClassUtils.CGLIB_CLASS_SEPARATOR); |
|
|
|
|
Foo foo = beanFactory.getBean("foo", Foo.class); |
|
|
|
|
Bar bar = beanFactory.getBean("bar", Bar.class); |
|
|
|
|
assertThat(bar.foo).isSameAs(foo); |
|
|
|
|
@ -132,6 +135,7 @@ class ConfigurationClassPostProcessorTests {
@@ -132,6 +135,7 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); |
|
|
|
|
pp.postProcessBeanFactory(beanFactory); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).getBeanClass().getName()).doesNotContain(ClassUtils.CGLIB_CLASS_SEPARATOR); |
|
|
|
|
Foo foo = beanFactory.getBean("foo", Foo.class); |
|
|
|
|
Bar bar = beanFactory.getBean("bar", Bar.class); |
|
|
|
|
assertThat(bar.foo).isNotSameAs(foo); |
|
|
|
|
@ -143,6 +147,7 @@ class ConfigurationClassPostProcessorTests {
@@ -143,6 +147,7 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); |
|
|
|
|
pp.postProcessBeanFactory(beanFactory); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).getBeanClass().getName()).doesNotContain(ClassUtils.CGLIB_CLASS_SEPARATOR); |
|
|
|
|
Foo foo = beanFactory.getBean("foo", Foo.class); |
|
|
|
|
Bar bar = beanFactory.getBean("bar", Bar.class); |
|
|
|
|
assertThat(bar.foo).isNotSameAs(foo); |
|
|
|
|
@ -154,6 +159,7 @@ class ConfigurationClassPostProcessorTests {
@@ -154,6 +159,7 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); |
|
|
|
|
pp.postProcessBeanFactory(beanFactory); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).getBeanClass().getName()).doesNotContain(ClassUtils.CGLIB_CLASS_SEPARATOR); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("foo")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("bar")).hasBeanClass()).isTrue(); |
|
|
|
|
Foo foo = beanFactory.getBean("foo", Foo.class); |
|
|
|
|
@ -167,6 +173,7 @@ class ConfigurationClassPostProcessorTests {
@@ -167,6 +173,7 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); |
|
|
|
|
pp.postProcessBeanFactory(beanFactory); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).getBeanClass().getName()).doesNotContain(ClassUtils.CGLIB_CLASS_SEPARATOR); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("foo")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("bar")).hasBeanClass()).isTrue(); |
|
|
|
|
Foo foo = beanFactory.getBean("foo", Foo.class); |
|
|
|
|
@ -174,6 +181,15 @@ class ConfigurationClassPostProcessorTests {
@@ -174,6 +181,15 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
assertThat(bar.foo).isNotSameAs(foo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void enhancementIsNotPresentWithEmptyConfig() { |
|
|
|
|
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(EmptyConfig.class)); |
|
|
|
|
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); |
|
|
|
|
pp.postProcessBeanFactory(beanFactory); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).hasBeanClass()).isTrue(); |
|
|
|
|
assertThat(((RootBeanDefinition) beanFactory.getBeanDefinition("config")).getBeanClass().getName()).doesNotContain(ClassUtils.CGLIB_CLASS_SEPARATOR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void configurationIntrospectionOfInnerClassesWorksWithDotNameSyntax() { |
|
|
|
|
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(getClass().getName() + ".SingletonBeanConfig")); |
|
|
|
|
@ -1166,7 +1182,7 @@ class ConfigurationClassPostProcessorTests {
@@ -1166,7 +1182,7 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
static class StaticSingletonBeanConfig { |
|
|
|
|
static final class StaticSingletonBeanConfig { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
public static Foo foo() { |
|
|
|
|
@ -1179,6 +1195,10 @@ class ConfigurationClassPostProcessorTests {
@@ -1179,6 +1195,10 @@ class ConfigurationClassPostProcessorTests {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
static final class EmptyConfig { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
@Order(2) |
|
|
|
|
static class OverridingSingletonBeanConfig { |
|
|
|
|
|