Skip to content

Commit 94877ce

Browse files
committed
Refactor: test to use variables for bean names
Signed-off-by: currenjin <[email protected]>
1 parent d378899 commit 94877ce

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

spring-beans/src/test/java/org/springframework/beans/factory/support/GenericTypeMatchingTests.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,26 @@ class ScopedProxyGenericTypeMatchTests {
1616
void scopedProxyBeanTypeMatching() {
1717
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
1818

19+
String targetBeanName = "scopedTarget.wordBean";
20+
String proxyBeanName = "wordBean";
21+
1922
RootBeanDefinition targetDef = new RootBeanDefinition(SomeGenericSupplier.class);
2023
targetDef.setScope("request");
21-
factory.registerBeanDefinition("scopedTarget.wordBean", targetDef);
24+
factory.registerBeanDefinition(targetBeanName, targetDef);
2225

2326
RootBeanDefinition proxyDef = new RootBeanDefinition();
2427
proxyDef.setScope("singleton");
2528
proxyDef.setTargetType(ResolvableType.forClassWithGenerics(Supplier.class, String.class));
26-
proxyDef.setAttribute("targetBeanName", "scopedTarget.wordBean");
27-
factory.registerBeanDefinition("wordBean", proxyDef);
29+
proxyDef.setAttribute("targetBeanName", targetBeanName);
30+
factory.registerBeanDefinition(proxyBeanName, proxyDef);
2831

2932
ResolvableType supplierType = ResolvableType.forClassWithGenerics(Supplier.class, String.class);
3033

31-
boolean isMatch = factory.isTypeMatch("wordBean", supplierType);
32-
33-
34+
boolean isMatch = factory.isTypeMatch(proxyBeanName, supplierType);
3435
assertThat(isMatch).isTrue();
3536

3637
String[] names = factory.getBeanNamesForType(supplierType);
37-
assertThat(names).contains("wordBean");
38+
assertThat(names).contains(proxyBeanName);
3839
}
3940

4041
static class SomeGenericSupplier implements Supplier<String> {

0 commit comments

Comments
 (0)