LANG-508 Fix tests broken by r885195

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@885913 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Niall Pemberton 2009-12-01 20:27:40 +00:00
parent e51cf4380e
commit ea3f8ad774
2 changed files with 74 additions and 74 deletions

View File

@ -58,7 +58,7 @@ public class Validate {
private static final String DEFAULT_NOT_EMPTY_COLLECTION_EXCEPTION_MESSAGE = "The validated collection is empty";
private static final String DEFAULT_NOT_EMPTY_MAP_EXCEPTION_MESSAGE = "The validated map is empty";
private static final String DEFAULT_VALID_INDEX_ARRAY_EXCEPTION_MESSAGE = "The validated array index is invalid: %d";
private static final String DEFAULT_VALID_INDEX_CHAR_SEQUENCE_EXCEPTION_MESSAGE = "The validated character sequence is invalid: %d";
private static final String DEFAULT_VALID_INDEX_CHAR_SEQUENCE_EXCEPTION_MESSAGE = "The validated character sequence index is invalid: %d";
private static final String DEFAULT_VALID_INDEX_COLLECTION_EXCEPTION_MESSAGE = "The validated collection index is invalid: %d";
/**

View File

@ -93,7 +93,7 @@ public void testIsTrue3() {
Validate.isTrue(false, "MSG", new Integer(6));
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("MSG6", ex.getMessage());
assertEquals("MSG", ex.getMessage());
}
}
@ -104,7 +104,7 @@ public void testIsTrue4() {
Validate.isTrue(false, "MSG", 7);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("MSG7", ex.getMessage());
assertEquals("MSG", ex.getMessage());
}
}
@ -115,7 +115,7 @@ public void testIsTrue5() {
Validate.isTrue(false, "MSG", 7.4d);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("MSG7.4", ex.getMessage());
assertEquals("MSG", ex.getMessage());
}
}
@ -125,8 +125,8 @@ public void testNotNull1() {
Validate.notNull(new Object());
try {
Validate.notNull(null);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
@ -140,8 +140,8 @@ public void testNotNull2() {
Validate.notNull(new Object(), "MSG");
try {
Validate.notNull(null, "MSG");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
@ -156,8 +156,8 @@ public void testNotEmptyArray1() {
Validate.notEmpty(new Object[] {null});
try {
Validate.notEmpty((Object[]) null);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated array is empty", ex.getMessage());
}
try {
@ -177,8 +177,8 @@ public void testNotEmptyArray2() {
Validate.notEmpty(new Object[] {null}, "MSG");
try {
Validate.notEmpty((Object[]) null, "MSG");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
@ -199,8 +199,8 @@ public void testNotEmptyCollection1() {
Collection<Integer> coll = new ArrayList<Integer>();
try {
Validate.notEmpty((Collection<?>) null);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated collection is empty", ex.getMessage());
}
try {
@ -221,8 +221,8 @@ public void testNotEmptyCollection2() {
Collection<Integer> coll = new ArrayList<Integer>();
try {
Validate.notEmpty((Collection<?>) null, "MSG");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
@ -244,8 +244,8 @@ public void testNotEmptyMap1() {
Map<String, Integer> map = new HashMap<String, Integer>();
try {
Validate.notEmpty((Map<?, ?>) null);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated map is empty", ex.getMessage());
}
try {
@ -266,8 +266,8 @@ public void testNotEmptyMap2() {
Map<String, Integer> map = new HashMap<String, Integer>();
try {
Validate.notEmpty((Map<?, ?>) null, "MSG");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
@ -289,15 +289,15 @@ public void testNotEmptyString1() {
Validate.notEmpty("hjl");
try {
Validate.notEmpty((String) null);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("The validated string is empty", ex.getMessage());
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated character sequence is empty", ex.getMessage());
}
try {
Validate.notEmpty("");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("The validated string is empty", ex.getMessage());
assertEquals("The validated character sequence is empty", ex.getMessage());
}
String str = "Hi";
@ -310,8 +310,8 @@ public void testNotEmptyString2() {
Validate.notEmpty("a", "MSG");
try {
Validate.notEmpty((String) null, "MSG");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
@ -335,10 +335,10 @@ public void testNotBlankNullStringShouldThrow() {
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
fail("Expecting NullPointerException");
} catch (NullPointerException e) {
//then
assertEquals("The validated string is blank", e.getMessage());
assertEquals("The validated character sequence is blank", e.getMessage());
}
}
@ -350,8 +350,8 @@ public void testNotBlankMsgNullStringShouldThrow() {
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
fail("Expecting NullPointerException");
} catch (NullPointerException e) {
//then
assertEquals("Message", e.getMessage());
}
@ -368,7 +368,7 @@ public void testNotBlankEmptyStringShouldThrow() {
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
//then
assertEquals("The validated string is blank", e.getMessage());
assertEquals("The validated character sequence is blank", e.getMessage());
}
}
@ -383,7 +383,7 @@ public void testNotBlankBlankStringWithWhitespacesShouldThrow() {
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
//then
assertEquals("The validated string is blank", e.getMessage());
assertEquals("The validated character sequence is blank", e.getMessage());
}
}
@ -398,7 +398,7 @@ public void testNotBlankBlankStringWithNewlinesShouldThrow() {
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
//then
assertEquals("The validated string is blank", e.getMessage());
assertEquals("The validated character sequence is blank", e.getMessage());
}
}
@ -533,8 +533,8 @@ public void testNoNullElementsArray1() {
Validate.noNullElements(array);
try {
Validate.noNullElements((Object[]) null);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
array[1] = null;
@ -556,8 +556,8 @@ public void testNoNullElementsArray2() {
Validate.noNullElements(array, "MSG");
try {
Validate.noNullElements((Object[]) null, "MSG");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
array[1] = null;
@ -582,8 +582,8 @@ public void testNoNullElementsCollection1() {
Validate.noNullElements(coll);
try {
Validate.noNullElements((Collection<?>) null);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
coll.set(1, null);
@ -607,8 +607,8 @@ public void testNoNullElementsCollection2() {
Validate.noNullElements(coll, "MSG");
try {
Validate.noNullElements((Collection<?>) null, "MSG");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting NullPointerException");
} catch (NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
coll.set(1, null);
@ -643,15 +643,15 @@ public void testValidIndex_withMessage_array() {
Validate.validIndex(array, 1, "Broken: ");
try {
Validate.validIndex(array, -1, "Broken: ");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("Broken: -1", ex.getMessage());
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(array, 2, "Broken: ");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("Broken: 2", ex.getMessage());
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
String[] strArray = new String[] {"Hi"};
@ -665,14 +665,14 @@ public void testValidIndex_array() {
Validate.validIndex(array, 1);
try {
Validate.validIndex(array, -1);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("The validated array index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(array, 2);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("The validated array index is invalid: 2", ex.getMessage());
}
@ -691,15 +691,15 @@ public void testValidIndex_withMessage_collection() {
Validate.validIndex(coll, 1, "Broken: ");
try {
Validate.validIndex(coll, -1, "Broken: ");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("Broken: -1", ex.getMessage());
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(coll, 2, "Broken: ");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("Broken: 2", ex.getMessage());
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
List<String> strColl = Arrays.asList(new String[] {"Hi"});
@ -715,14 +715,14 @@ public void testValidIndex_collection() {
Validate.validIndex(coll, 1);
try {
Validate.validIndex(coll, -1);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("The validated collection index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(coll, 2);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("The validated collection index is invalid: 2", ex.getMessage());
}
@ -739,15 +739,15 @@ public void testValidIndex_withMessage_charSequence() {
Validate.validIndex(str, 1, "Broken: ");
try {
Validate.validIndex(str, -1, "Broken: ");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("Broken: -1", ex.getMessage());
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(str, 2, "Broken: ");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("Broken: 2", ex.getMessage());
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
String input = "Hi";
@ -761,15 +761,15 @@ public void testValidIndex_charSequence() {
Validate.validIndex(str, 1);
try {
Validate.validIndex(str, -1);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("The validated string index is invalid: -1", ex.getMessage());
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("The validated character sequence index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(str, 2);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("The validated string index is invalid: 2", ex.getMessage());
fail("Expecting IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException ex) {
assertEquals("The validated character sequence index is invalid: 2", ex.getMessage());
}
String input = "Hi";