Add some missing tests.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1600868 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2014-06-06 12:33:44 +00:00
parent d96586563c
commit ba8c6f6d6f
1 changed files with 24 additions and 0 deletions

View File

@ -1045,6 +1045,30 @@ public class ValidateTest {
}
}
@Test
public void testIsInstanceOf_withMessageArgs() {
Validate.isInstanceOf(String.class, "hi", "Error %s=%s", "Name", "Value");
Validate.isInstanceOf(Integer.class, 1, "Error %s=%s", "Name", "Value");
try {
Validate.isInstanceOf(List.class, "hi", "Error %s=%s", "Name", "Value");
fail("Expecting IllegalArgumentException");
} catch(final IllegalArgumentException e) {
assertEquals("Error Name=Value", e.getMessage());
}
try {
Validate.isInstanceOf(List.class, "hi", "Error %s=%s", List.class, "Value");
fail("Expecting IllegalArgumentException");
} catch(final IllegalArgumentException e) {
assertEquals("Error interface java.util.List=Value", e.getMessage());
}
try {
Validate.isInstanceOf(List.class, "hi", "Error %s=%s", List.class, null);
fail("Expecting IllegalArgumentException");
} catch(final IllegalArgumentException e) {
assertEquals("Error interface java.util.List=null", e.getMessage());
}
}
@Test
public void testIsAssignable() {
Validate.isAssignableFrom(CharSequence.class, String.class);