File tree 2 files changed +6
-2
lines changed
main/java/org/springframework/test/context/bean/override
test/java/org/springframework/test/context/bean/override
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -101,10 +101,12 @@ private void postProcessWithRegistry(ConfigurableListableBeanFactory beanFactory
101
101
* Copy certain details of a {@link BeanDefinition} to the definition created by
102
102
* this processor for a given {@link OverrideMetadata}.
103
103
* <p>The default implementation copies the {@linkplain BeanDefinition#isPrimary()
104
- * primary flag} and the {@linkplain BeanDefinition#getScope() scope}.
104
+ * primary flag}, @{@linkplain BeanDefinition#isFallback() fallback flag}
105
+ * and the {@linkplain BeanDefinition#getScope() scope}.
105
106
*/
106
107
protected void copyBeanDefinitionDetails (BeanDefinition from , RootBeanDefinition to ) {
107
108
to .setPrimary (from .isPrimary ());
109
+ to .setFallback (from .isFallback ());
108
110
to .setScope (from .getScope ());
109
111
}
110
112
Original file line number Diff line number Diff line change @@ -156,19 +156,21 @@ void allowReplaceDefinitionWhenSingletonDefinitionPresent() {
156
156
}
157
157
158
158
@ Test
159
- void copyDefinitionPrimaryAndScope () {
159
+ void copyDefinitionPrimaryFallbackAndScope () {
160
160
AnnotationConfigApplicationContext context = createContext (SingletonBean .class );
161
161
context .getBeanFactory ().registerScope ("customScope" , new SimpleThreadScope ());
162
162
RootBeanDefinition definition = new RootBeanDefinition (String .class , () -> "ORIGINAL" );
163
163
definition .setScope ("customScope" );
164
164
definition .setPrimary (true );
165
+ definition .setFallback (true );
165
166
context .registerBeanDefinition ("singleton" , definition );
166
167
context .register (SingletonBean .class );
167
168
168
169
assertThatNoException ().isThrownBy (context ::refresh );
169
170
assertThat (context .getBeanDefinition ("singleton" ))
170
171
.isNotSameAs (definition )
171
172
.matches (BeanDefinition ::isPrimary , "isPrimary" )
173
+ .matches (BeanDefinition ::isFallback , "isFallback" )
172
174
.satisfies (d -> assertThat (d .getScope ()).isEqualTo ("customScope" ))
173
175
.matches (Predicate .not (BeanDefinition ::isSingleton ), "!isSingleton" )
174
176
.matches (Predicate .not (BeanDefinition ::isPrototype ), "!isPrototype" );
You can’t perform that action at this time.
0 commit comments