SPR-15481 Fixed AnnotationUtils.getValue() operation

- Fixed AnnotationUtils.getValue() operation to ensure it re-throws AnnotationConfigurationException instead of swallowing it (as it is done in few other operations in AnnotationUtils)
- Added test
- Removed unnecessary '@SuppressWarnings("unchecked")'
This commit is contained in:
Oleg Zhurakousky
2017-04-25 12:44:10 -04:00
committed by Juergen Hoeller
parent 2579dab209
commit 299b9d60fd
2 changed files with 18 additions and 3 deletions

View File

@@ -54,6 +54,7 @@ import static org.springframework.core.annotation.AnnotationUtils.*;
* @author Sam Brannen
* @author Chris Beams
* @author Phillip Webb
* @author Oleg Zhurakousky
*/
public class AnnotationUtilsTests {
@@ -1239,6 +1240,14 @@ public class AnnotationUtilsTests {
assertEquals("value: ", "", contextConfig.value());
assertEquals("location: ", "", contextConfig.location());
}
@ContextConfig(value="foo", location="bar")
@Test(expected=AnnotationConfigurationException.class)
public void synthesizeAnnotationWithAttributeAliasesDifferentValues() throws Exception {
Method m = AnnotationUtilsTests.class.getDeclaredMethod("synthesizeAnnotationWithAttributeAliasesDifferentValues");
Annotation a = synthesizeAnnotation(m.getDeclaredAnnotation(ContextConfig.class));
getValue(a);
}
@Test
public void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception {