Skip to content

Commit

Permalink
Polish AnnotationAttributes[Tests]
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jul 6, 2015
1 parent 23124d1 commit 67ac675
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*
* @author Chris Beams
* @author Sam Brannen
* @author Juergen Hoeller
* @since 3.1.1
* @see AnnotationUtils#getAnnotationAttributes
* @see AnnotatedElementUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @author Chris Beams
* @author Sam Brannen
* @author Juergen Hoeller
* @since 3.1.1
*/
public class AnnotationAttributesTests {
Expand All @@ -57,7 +58,6 @@ public void typeSafeAttributeAccess() {
attributes.put("number", 42);
attributes.put("anno", nestedAttributes);
attributes.put("annoArray", new AnnotationAttributes[] { nestedAttributes });
attributes.put("unresolvableClass", new ClassNotFoundException("myclass"));

assertThat(attributes.getString("name"), equalTo("dave"));
assertThat(attributes.getStringArray("names"), equalTo(new String[] { "dave", "frank", "hal" }));
Expand All @@ -70,14 +70,14 @@ public void typeSafeAttributeAccess() {
assertThat(attributes.getAnnotation("anno").<Integer>getNumber("value"), equalTo(10));
assertThat(attributes.getAnnotationArray("annoArray")[0].getString("name"), equalTo("algernon"));

try {
attributes.getClass("unresolvableClass");
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
assertTrue(ex.getCause() instanceof ClassNotFoundException);
assertTrue(ex.getMessage().contains("myclass"));
}
}

@Test
public void unresolvableClass() throws Exception {
attributes.put("unresolvableClass", new ClassNotFoundException("myclass"));
exception.expect(IllegalArgumentException.class);
exception.expectMessage(containsString("myclass"));
attributes.getClass("unresolvableClass");
}

@Test
Expand Down

0 comments on commit 67ac675

Please sign in to comment.