From b543486b187b2db0c6fad67daa12f09def6e4406 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Mon, 5 Oct 2009 03:29:20 +0000 Subject: [PATCH] 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. git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2050 50f2f4bb-b051-0410-bef5-90022cba6387 --- ...igurationClassApplicationContextTests.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/org.springframework.context/src/test/java/org/springframework/context/annotation/ConfigurationClassApplicationContextTests.java b/org.springframework.context/src/test/java/org/springframework/context/annotation/ConfigurationClassApplicationContextTests.java index 85c17b8e204..d27d3dc7579 100644 --- a/org.springframework.context/src/test/java/org/springframework/context/annotation/ConfigurationClassApplicationContextTests.java +++ b/org.springframework.context/src/test/java/org/springframework/context/annotation/ConfigurationClassApplicationContextTests.java @@ -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 { } } + @SuppressWarnings("unchecked") @Test public void getBeanByTypeAmbiguityRaisesException() { ConfigurationClassApplicationContext context = new ConfigurationClassApplicationContext(TwoTestBeanConfig.class); @@ -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 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") + ) + ); } }