SPR-5682: fixing test breakage on CI server due to strange non-determinism in the order of bean names being returned in the key set of the map of beans matching the required type.
This commit is contained in:
parent
8c5f78c0d6
commit
772a74a636
|
|
@ -17,7 +17,9 @@
|
||||||
package org.springframework.context.annotation;
|
package org.springframework.context.annotation;
|
||||||
|
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
|
import static org.junit.matchers.JUnitMatchers.*;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
@ -127,6 +129,7 @@ public class ConfigurationClassApplicationContextTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void getBeanByTypeAmbiguityRaisesException() {
|
public void getBeanByTypeAmbiguityRaisesException() {
|
||||||
ConfigurationClassApplicationContext context = new ConfigurationClassApplicationContext(TwoTestBeanConfig.class);
|
ConfigurationClassApplicationContext context = new ConfigurationClassApplicationContext(TwoTestBeanConfig.class);
|
||||||
|
|
@ -134,11 +137,15 @@ public class ConfigurationClassApplicationContextTests {
|
||||||
try {
|
try {
|
||||||
context.getBean(TestBean.class);
|
context.getBean(TestBean.class);
|
||||||
} catch (RuntimeException ex) {
|
} catch (RuntimeException ex) {
|
||||||
assertThat(ex.getMessage(), equalTo(
|
assertThat(ex.getMessage(),
|
||||||
"No unique bean of type [" + TestBean.class.getName() + "] is defined: " +
|
allOf(
|
||||||
"2 matching bean definitions found (tb1,tb2). Consider qualifying with " +
|
containsString("No unique bean of type [" + TestBean.class.getName() + "] is defined"),
|
||||||
"getBean(Class<T> beanType, String beanName) or declaring one bean definition as " +
|
containsString("2 matching bean definitions found"),
|
||||||
"@" + Primary.class.getSimpleName()));
|
containsString("tb1"),
|
||||||
|
containsString("tb2"),
|
||||||
|
containsString("Consider qualifying with")
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue