Browse Source

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.

pull/23217/head
Chris Beams 17 years ago
parent
commit
772a74a636
  1. 19
      org.springframework.context/src/test/java/org/springframework/context/annotation/ConfigurationClassApplicationContextTests.java

19
org.springframework.context/src/test/java/org/springframework/context/annotation/ConfigurationClassApplicationContextTests.java

@ -17,7 +17,9 @@ @@ -17,7 +17,9 @@
package org.springframework.context.annotation;
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.assertThat;
import static org.junit.Assert.fail;
@ -127,6 +129,7 @@ public class ConfigurationClassApplicationContextTests { @@ -127,6 +129,7 @@ public class ConfigurationClassApplicationContextTests {
}
}
@SuppressWarnings("unchecked")
@Test
public void getBeanByTypeAmbiguityRaisesException() {
ConfigurationClassApplicationContext context = new ConfigurationClassApplicationContext(TwoTestBeanConfig.class);
@ -134,11 +137,15 @@ public class ConfigurationClassApplicationContextTests { @@ -134,11 +137,15 @@ public class ConfigurationClassApplicationContextTests {
try {
context.getBean(TestBean.class);
} catch (RuntimeException ex) {
assertThat(ex.getMessage(), equalTo(
"No unique bean of type [" + TestBean.class.getName() + "] is defined: " +
"2 matching bean definitions found (tb1,tb2). Consider qualifying with " +
"getBean(Class<T> beanType, String beanName) or declaring one bean definition as " +
"@" + Primary.class.getSimpleName()));
assertThat(ex.getMessage(),
allOf(
containsString("No unique bean of type [" + TestBean.class.getName() + "] is defined"),
containsString("2 matching bean definitions found"),
containsString("tb1"),
containsString("tb2"),
containsString("Consider qualifying with")
)
);
}
}

Loading…
Cancel
Save