Skip to content

Commit c061f7d

Browse files
committed
Improve: test with direct assertions and randomized bean names
1 parent 94877ce commit c061f7d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.junit.jupiter.api.Test;
44
import org.springframework.core.ResolvableType;
55

6+
import java.util.UUID;
67
import java.util.function.Supplier;
78

89
import static org.assertj.core.api.Assertions.assertThat;
@@ -16,8 +17,8 @@ class ScopedProxyGenericTypeMatchTests {
1617
void scopedProxyBeanTypeMatching() {
1718
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
1819

19-
String targetBeanName = "scopedTarget.wordBean";
20-
String proxyBeanName = "wordBean";
20+
String proxyBeanName = "wordBean-" + UUID.randomUUID();
21+
String targetBeanName = "scopedTarget." + proxyBeanName;
2122

2223
RootBeanDefinition targetDef = new RootBeanDefinition(SomeGenericSupplier.class);
2324
targetDef.setScope("request");
@@ -31,11 +32,9 @@ void scopedProxyBeanTypeMatching() {
3132

3233
ResolvableType supplierType = ResolvableType.forClassWithGenerics(Supplier.class, String.class);
3334

34-
boolean isMatch = factory.isTypeMatch(proxyBeanName, supplierType);
35-
assertThat(isMatch).isTrue();
35+
assertThat(factory.isTypeMatch(proxyBeanName, supplierType)).isTrue();
3636

37-
String[] names = factory.getBeanNamesForType(supplierType);
38-
assertThat(names).contains(proxyBeanName);
37+
assertThat(factory.getBeanNamesForType(supplierType)).contains(proxyBeanName);
3938
}
4039

4140
static class SomeGenericSupplier implements Supplier<String> {

0 commit comments

Comments
 (0)