Eliminate varargs warnings

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1132389 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2011-06-05 12:44:41 +00:00
parent ffbc41e725
commit d3d4622998
4 changed files with 22 additions and 11 deletions

View File

@ -301,7 +301,8 @@ public class ClassUtilsTest extends TestCase {
assertFalse(ClassUtils.isAssignable(null, array2));
assertTrue(ClassUtils.isAssignable(null, array0));
assertTrue(ClassUtils.isAssignable(array0, array0));
assertTrue(ClassUtils.isAssignable(array0, null));
assertTrue(ClassUtils.isAssignable(array0, (Class<?>[]) null)); // test both types of ...
assertTrue(ClassUtils.isAssignable(array0, (Class<?>) null)); // ... varargs invocation
assertTrue(ClassUtils.isAssignable((Class[]) null, (Class[]) null));
assertFalse(ClassUtils.isAssignable(array1, array1s));
@ -729,8 +730,8 @@ public class ClassUtilsTest extends TestCase {
public void testPrimitivesToWrappers() {
// test null
assertNull("null -> null",
ClassUtils.primitivesToWrappers(null));
assertNull("null -> null", ClassUtils.primitivesToWrappers((Class<?>[]) null)); // test both types of ...
assertNull("null -> null", ClassUtils.primitivesToWrappers((Class<?>) null)); // ... varargs invocation
// test empty array
assertEquals("empty -> empty",
ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers(ArrayUtils.EMPTY_CLASS_ARRAY));
@ -800,7 +801,9 @@ public class ClassUtilsTest extends TestCase {
}
public void testWrappersToPrimitivesNull() {
assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives(null));
// Test both types of varargs invocation
assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives((Class<?>[]) null));
assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives((Class<?>) null));
}
public void testWrappersToPrimitivesEmpty() {
@ -955,15 +958,17 @@ public class ClassUtilsTest extends TestCase {
}
public void testToClass_object() {
assertNull(ClassUtils.toClass(null));
// Test both types of varargs invocation
assertNull(ClassUtils.toClass((Object[]) null));
assertNull(ClassUtils.toClass((Object) null));
assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY));
assertTrue(Arrays.equals(new Class[] { String.class, Integer.class, Double.class },
ClassUtils.toClass(new Object[] { "Test", 1, 99d })));
ClassUtils.toClass(new Object[] { "Test", Integer.valueOf(1), Double.valueOf(99d) })));
assertTrue(Arrays.equals(new Class[] { String.class, null, Double.class },
ClassUtils.toClass(new Object[] { "Test", null, 99d })));
ClassUtils.toClass(new Object[] { "Test", null, Double.valueOf(99d) })));
}
public void test_getShortCanonicalName_Object() {

View File

@ -730,9 +730,11 @@ public class StringUtilsEqualsIndexOfTest extends TestCase {
}
public void testLastIndexOfAny_StringStringArray() {
assertEquals(-1, StringUtils.lastIndexOfAny(null, null));
assertEquals(-1, StringUtils.lastIndexOfAny(null, (CharSequence) null)); // test both types of ...
assertEquals(-1, StringUtils.lastIndexOfAny(null, (CharSequence[]) null)); // ... varargs invocation
assertEquals(-1, StringUtils.lastIndexOfAny(null, FOOBAR_SUB_ARRAY));
assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, null));
assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, (CharSequence) null)); // test both types of ...
assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, (CharSequence[]) null)); // ... varargs invocation
assertEquals(3, StringUtils.lastIndexOfAny(FOOBAR, FOOBAR_SUB_ARRAY));
assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, new String[0]));
assertEquals(-1, StringUtils.lastIndexOfAny(null, new String[0]));

View File

@ -174,7 +174,9 @@ public class StringUtilsTest extends TestCase {
}
public void testJoin_Objectarray() {
assertEquals(null, StringUtils.join(null));
// Test both types of varargs invocation
assertEquals(null, StringUtils.join((Object[]) null));
assertEquals(null, StringUtils.join((Object) null));
assertEquals("", StringUtils.join(EMPTY_ARRAY_LIST));
assertEquals("", StringUtils.join(NULL_ARRAY_LIST));
assertEquals("abc", StringUtils.join(new String[] {"a", "b", "c"}));

View File

@ -230,7 +230,9 @@ public class StringUtilsTrimEmptyTest extends TestCase {
String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." };
String[] foo = new String[] { FOO, FOO, FOO };
assertEquals(null, StringUtils.stripAll(null));
// Test both varargs invocations
assertEquals(null, StringUtils.stripAll((String[]) null));
assertEquals(null, StringUtils.stripAll((String) null));
assertArrayEquals(empty, StringUtils.stripAll(empty));
assertArrayEquals(foo, StringUtils.stripAll(fooSpace));