Use more efficient Integer cache: Use "Integer.valueOf(int)" instead of "new Integer(int)".

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1153484 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2011-08-03 13:39:42 +00:00
parent 9d6f32538c
commit ddeba76d0b
38 changed files with 163 additions and 163 deletions

View File

@ -288,9 +288,9 @@ public static Map<Object, Object> toMap(Object[] array) {
* <p>Note, this method makes only sense to provide arguments of the same type so that the
* compiler can deduce the type of the array itself. While it is possible to select the
* type explicitly like in
* <code>Number[] array = ArrayUtils.&lt;Number&gt;toArray(new Integer(42), new Double(Math.PI))</code>,
* <code>Number[] array = ArrayUtils.&lt;Number&gt;toArray(Integer.valueOf(42), new Double(Math.PI))</code>,
* there is no real advantage when compared to
* <code>new Number[] {new Integer(42), new Double(Math.PI)}</code>.</p>
* <code>new Number[] {Integer.valueOf(42), new Double(Math.PI)}</code>.</p>
*
* @param <T> the array's element type
* @param items the varargs array items, null allowed

View File

@ -226,9 +226,9 @@ public static Boolean toBooleanObject(int value) {
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
*
* <pre>
* BooleanUtils.toBoolean(new Integer(0)) = Boolean.FALSE
* BooleanUtils.toBoolean(new Integer(1)) = Boolean.TRUE
* BooleanUtils.toBoolean(new Integer(null)) = null
* BooleanUtils.toBoolean(Integer.valueOf(0)) = Boolean.FALSE
* BooleanUtils.toBoolean(Integer.valueOf(1)) = Boolean.TRUE
* BooleanUtils.toBoolean(Integer.valueOf(null)) = null
* </pre>
*
* @param value the Integer to convert
@ -273,11 +273,11 @@ public static boolean toBoolean(int value, int trueValue, int falseValue) {
* <p>Converts an Integer to a boolean specifying the conversion values.</p>
*
* <pre>
* BooleanUtils.toBoolean(new Integer(0), new Integer(1), new Integer(0)) = false
* BooleanUtils.toBoolean(new Integer(1), new Integer(1), new Integer(0)) = true
* BooleanUtils.toBoolean(new Integer(2), new Integer(1), new Integer(2)) = false
* BooleanUtils.toBoolean(new Integer(2), new Integer(2), new Integer(0)) = true
* BooleanUtils.toBoolean(null, null, new Integer(0)) = true
* BooleanUtils.toBoolean(Integer.valueOf(0), Integer.valueOf(1), Integer.valueOf(0)) = false
* BooleanUtils.toBoolean(Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(0)) = true
* BooleanUtils.toBoolean(Integer.valueOf(2), Integer.valueOf(1), Integer.valueOf(2)) = false
* BooleanUtils.toBoolean(Integer.valueOf(2), Integer.valueOf(2), Integer.valueOf(0)) = true
* BooleanUtils.toBoolean(null, null, Integer.valueOf(0)) = true
* </pre>
*
* @param value the Integer to convert
@ -341,9 +341,9 @@ public static Boolean toBooleanObject(int value, int trueValue, int falseValue,
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
*
* <pre>
* BooleanUtils.toBooleanObject(new Integer(0), new Integer(0), new Integer(2), new Integer(3)) = Boolean.TRUE
* BooleanUtils.toBooleanObject(new Integer(2), new Integer(1), new Integer(2), new Integer(3)) = Boolean.FALSE
* BooleanUtils.toBooleanObject(new Integer(3), new Integer(1), new Integer(2), new Integer(3)) = null
* BooleanUtils.toBooleanObject(Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(2), Integer.valueOf(3)) = Boolean.TRUE
* BooleanUtils.toBooleanObject(Integer.valueOf(2), Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)) = Boolean.FALSE
* BooleanUtils.toBooleanObject(Integer.valueOf(3), Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)) = null
* </pre>
*
* @param value the Integer to convert
@ -398,8 +398,8 @@ public static int toInteger(boolean bool) {
* {@code zero} is {@code false}.</p>
*
* <pre>
* BooleanUtils.toIntegerObject(true) = new Integer(1)
* BooleanUtils.toIntegerObject(false) = new Integer(0)
* BooleanUtils.toIntegerObject(true) = Integer.valueOf(1)
* BooleanUtils.toIntegerObject(false) = Integer.valueOf(0)
* </pre>
*
* @param bool the boolean to convert
@ -416,8 +416,8 @@ public static Integer toIntegerObject(boolean bool) {
* <p>{@code null} will be converted to {@code null}.</p>
*
* <pre>
* BooleanUtils.toIntegerObject(Boolean.TRUE) = new Integer(1)
* BooleanUtils.toIntegerObject(Boolean.FALSE) = new Integer(0)
* BooleanUtils.toIntegerObject(Boolean.TRUE) = Integer.valueOf(1)
* BooleanUtils.toIntegerObject(Boolean.FALSE) = Integer.valueOf(0)
* </pre>
*
* @param bool the Boolean to convert
@ -473,8 +473,8 @@ public static int toInteger(Boolean bool, int trueValue, int falseValue, int nul
* <p>Converts a boolean to an Integer specifying the conversion values.</p>
*
* <pre>
* BooleanUtils.toIntegerObject(true, new Integer(1), new Integer(0)) = new Integer(1)
* BooleanUtils.toIntegerObject(false, new Integer(1), new Integer(0)) = new Integer(0)
* BooleanUtils.toIntegerObject(true, Integer.valueOf(1), Integer.valueOf(0)) = Integer.valueOf(1)
* BooleanUtils.toIntegerObject(false, Integer.valueOf(1), Integer.valueOf(0)) = Integer.valueOf(0)
* </pre>
*
* @param bool the to convert
@ -490,9 +490,9 @@ public static Integer toIntegerObject(boolean bool, Integer trueValue, Integer f
* <p>Converts a Boolean to an Integer specifying the conversion values.</p>
*
* <pre>
* BooleanUtils.toIntegerObject(Boolean.TRUE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(1)
* BooleanUtils.toIntegerObject(Boolean.FALSE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(0)
* BooleanUtils.toIntegerObject(null, new Integer(1), new Integer(0), new Integer(2)) = new Integer(2)
* BooleanUtils.toIntegerObject(Boolean.TRUE, Integer.valueOf(1), Integer.valueOf(0), Integer.valueOf(2)) = Integer.valueOf(1)
* BooleanUtils.toIntegerObject(Boolean.FALSE, Integer.valueOf(1), Integer.valueOf(0), Integer.valueOf(2)) = Integer.valueOf(0)
* BooleanUtils.toIntegerObject(null, Integer.valueOf(1), Integer.valueOf(0), Integer.valueOf(2)) = Integer.valueOf(2)
* </pre>
*
* @param bool the Boolean to convert

View File

@ -36,11 +36,11 @@ public class NumberUtils {
/** Reusable Long constant for minus one. */
public static final Long LONG_MINUS_ONE = new Long(-1L);
/** Reusable Integer constant for zero. */
public static final Integer INTEGER_ZERO = new Integer(0);
public static final Integer INTEGER_ZERO = Integer.valueOf(0);
/** Reusable Integer constant for one. */
public static final Integer INTEGER_ONE = new Integer(1);
public static final Integer INTEGER_ONE = Integer.valueOf(1);
/** Reusable Integer constant for minus one. */
public static final Integer INTEGER_MINUS_ONE = new Integer(-1);
public static final Integer INTEGER_MINUS_ONE = Integer.valueOf(-1);
/** Reusable Short constant for zero. */
public static final Short SHORT_ZERO = new Short((short) 0);
/** Reusable Short constant for one. */
@ -395,7 +395,7 @@ public static short toShort(String str, short defaultValue) {
// Integer.getInteger(String)
// Integer.getInteger(String,int val)
// Integer.getInteger(String,Integer val)
// new Integer(String)
// Integer.valueOf(String)
// new Double(String)
// new Byte(String)
// new Long(String)

View File

@ -82,7 +82,7 @@ public MutableInt(String value) throws NumberFormatException {
* @return the value as a Integer, never null
*/
public Integer getValue() {
return new Integer(this.value);
return Integer.valueOf(this.value);
}
/**

View File

@ -2514,7 +2514,7 @@ public Writer asWriter() {
// size = -1;
// nullText = null;
// return (String) con.newInstance(
// new Object[] {new Integer(0), new Integer(size), buffer});
// new Object[] {Integer.valueOf(0), Integer.valueOf(size), buffer});
//
// } catch (Exception ex) {
// ex.printStackTrace();

View File

@ -122,7 +122,7 @@ protected StrLookup() {
* the underlying data, by converting it as necessary. For example:
* <pre>
* Map<String, Object> map = new HashMap<String, Object>();
* map.put("number", new Integer(2));
* map.put("number", Integer.valueOf(2));
* assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
* </pre>
* @param key the key to be looked up, may be null

View File

@ -199,9 +199,9 @@ public void testAddObjectArrayObject() {
assertTrue(Arrays.equals((new String[]{"a", "b", "c", "d"}), newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
Number[] numberArray1 = new Number[]{new Integer(1), new Double(2)};
Number[] numberArray1 = new Number[]{Integer.valueOf(1), new Double(2)};
newArray = ArrayUtils.add(numberArray1, new Float(3));
assertTrue(Arrays.equals((new Number[]{new Integer(1), new Double(2), new Float(3)}), newArray));
assertTrue(Arrays.equals((new Number[]{Integer.valueOf(1), new Double(2), new Float(3)}), newArray));
assertEquals(Number.class, newArray.getClass().getComponentType());
numberArray1 = null;

View File

@ -2491,12 +2491,12 @@ public void testToPrimitive_int() {
assertSame(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.toPrimitive(new Integer[0]));
assertTrue(Arrays.equals(
new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
ArrayUtils.toPrimitive(new Integer[] {new Integer(Integer.MIN_VALUE),
new Integer(Integer.MAX_VALUE), new Integer(9999999)}))
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE),
Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)}))
);
try {
ArrayUtils.toPrimitive(new Integer[] {new Integer(Integer.MIN_VALUE), null});
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), null});
fail();
} catch (NullPointerException ex) {}
}
@ -2508,12 +2508,12 @@ public void testToPrimitive_int_int() {
ArrayUtils.toPrimitive(new Integer[0], 1));
assertTrue(Arrays.equals(
new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
ArrayUtils.toPrimitive(new Integer[] {new Integer(Integer.MIN_VALUE),
new Integer(Integer.MAX_VALUE), new Integer(9999999)},1)));
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE),
Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)},1)));
assertTrue(Arrays.equals(
new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
ArrayUtils.toPrimitive(new Integer[] {new Integer(Integer.MIN_VALUE),
null, new Integer(9999999)}, Integer.MAX_VALUE))
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE),
null, Integer.valueOf(9999999)}, Integer.MAX_VALUE))
);
}
@ -2533,9 +2533,9 @@ public void testToObject_int() {
assertTrue(
Arrays.equals(
new Integer[] {
new Integer(Integer.MIN_VALUE),
new Integer(Integer.MAX_VALUE),
new Integer(9999999)},
Integer.valueOf(Integer.MIN_VALUE),
Integer.valueOf(Integer.MAX_VALUE),
Integer.valueOf(9999999)},
ArrayUtils.toObject(
new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999 })));
}

View File

@ -115,9 +115,9 @@ public void test_toBooleanObject_int() {
@Test
public void test_toBooleanObject_Integer() {
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(1)));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(-1)));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(0)));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(1)));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(-1)));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(0)));
assertEquals(null, BooleanUtils.toBooleanObject((Integer) null));
}
@ -135,14 +135,14 @@ public void test_toBoolean_int_int_int_noMatch() {
@Test
public void test_toBoolean_Integer_Integer_Integer() {
Integer six = new Integer(6);
Integer seven = new Integer(7);
Integer six = Integer.valueOf(6);
Integer seven = Integer.valueOf(7);
assertEquals(true, BooleanUtils.toBoolean((Integer) null, null, seven));
assertEquals(false, BooleanUtils.toBoolean((Integer) null, six, null));
assertEquals(true, BooleanUtils.toBoolean(new Integer(6), six, seven));
assertEquals(false, BooleanUtils.toBoolean(new Integer(7), six, seven));
assertEquals(true, BooleanUtils.toBoolean(Integer.valueOf(6), six, seven));
assertEquals(false, BooleanUtils.toBoolean(Integer.valueOf(7), six, seven));
}
@Test(expected = IllegalArgumentException.class)
@ -152,7 +152,7 @@ public void test_toBoolean_Integer_Integer_Integer_nullValue() {
@Test(expected = IllegalArgumentException.class)
public void test_toBoolean_Integer_Integer_Integer_noMatch() {
BooleanUtils.toBoolean(new Integer(8), Integer.valueOf(6), Integer.valueOf(7));
BooleanUtils.toBoolean(Integer.valueOf(8), Integer.valueOf(6), Integer.valueOf(7));
}
//-----------------------------------------------------------------------
@ -170,17 +170,17 @@ public void test_toBooleanObject_int_int_int_noMatch() {
@Test
public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
Integer six = new Integer(6);
Integer seven = new Integer(7);
Integer eight = new Integer(8);
Integer six = Integer.valueOf(6);
Integer seven = Integer.valueOf(7);
Integer eight = Integer.valueOf(8);
assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight));
assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight));
assertSame(null, BooleanUtils.toBooleanObject((Integer) null, six, seven, null));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(6), six, seven, eight));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(7), six, seven, eight));
assertEquals(null, BooleanUtils.toBooleanObject(new Integer(8), six, seven, eight));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(6), six, seven, eight));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(7), six, seven, eight));
assertEquals(null, BooleanUtils.toBooleanObject(Integer.valueOf(8), six, seven, eight));
}
@Test(expected = IllegalArgumentException.class)
@ -202,14 +202,14 @@ public void test_toInteger_boolean() {
@Test
public void test_toIntegerObject_boolean() {
assertEquals(new Integer(1), BooleanUtils.toIntegerObject(true));
assertEquals(new Integer(0), BooleanUtils.toIntegerObject(false));
assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(true));
assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(false));
}
@Test
public void test_toIntegerObject_Boolean() {
assertEquals(new Integer(1), BooleanUtils.toIntegerObject(Boolean.TRUE));
assertEquals(new Integer(0), BooleanUtils.toIntegerObject(Boolean.FALSE));
assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(Boolean.TRUE));
assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(Boolean.FALSE));
assertEquals(null, BooleanUtils.toIntegerObject((Boolean) null));
}
@ -229,17 +229,17 @@ public void test_toInteger_Boolean_int_int_int() {
@Test
public void test_toIntegerObject_boolean_Integer_Integer() {
Integer six = new Integer(6);
Integer seven = new Integer(7);
Integer six = Integer.valueOf(6);
Integer seven = Integer.valueOf(7);
assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven));
assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven));
}
@Test
public void test_toIntegerObject_Boolean_Integer_Integer_Integer() {
Integer six = new Integer(6);
Integer seven = new Integer(7);
Integer eight = new Integer(8);
Integer six = Integer.valueOf(6);
Integer seven = Integer.valueOf(7);
Integer eight = Integer.valueOf(8);
assertEquals(six, BooleanUtils.toIntegerObject(Boolean.TRUE, six, seven, eight));
assertEquals(seven, BooleanUtils.toIntegerObject(Boolean.FALSE, six, seven, eight));
assertEquals(eight, BooleanUtils.toIntegerObject((Boolean) null, six, seven, eight));

View File

@ -177,7 +177,7 @@ public void testIdentityToString() {
assertEquals(
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
ObjectUtils.identityToString(FOO));
Integer i = new Integer(90);
Integer i = Integer.valueOf(90);
String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));
assertEquals(expected, ObjectUtils.identityToString(i));
StringBuffer buffer = new StringBuffer();

View File

@ -53,7 +53,7 @@ protected void setUp() throws Exception {
super.setUp();
iString = "foo";
iInteger = new Integer(7);
iInteger = Integer.valueOf(7);
iMap = new HashMap<Object, Object>();
iMap.put("FOO", iString);
iMap.put("BAR", iInteger);

View File

@ -65,9 +65,9 @@ public void testIsTrue2() {
//-----------------------------------------------------------------------
public void testIsTrue3() {
Validate.isTrue(true, "MSG", new Integer(6));
Validate.isTrue(true, "MSG", Integer.valueOf(6));
try {
Validate.isTrue(false, "MSG", new Integer(6));
Validate.isTrue(false, "MSG", Integer.valueOf(6));
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
@ -186,7 +186,7 @@ public void testNotEmptyCollection1() {
} catch (IllegalArgumentException ex) {
assertEquals("The validated collection is empty", ex.getMessage());
}
coll.add(new Integer(8));
coll.add(Integer.valueOf(8));
Validate.notEmpty(coll);
Collection<Integer> test = Validate.notEmpty(coll);
@ -208,7 +208,7 @@ public void testNotEmptyCollection2() {
} catch (IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
coll.add(new Integer(8));
coll.add(Integer.valueOf(8));
Validate.notEmpty(coll, "MSG");
Collection<Integer> test = Validate.notEmpty(coll, "Message");
@ -231,7 +231,7 @@ public void testNotEmptyMap1() {
} catch (IllegalArgumentException ex) {
assertEquals("The validated map is empty", ex.getMessage());
}
map.put("ll", new Integer(8));
map.put("ll", Integer.valueOf(8));
Validate.notEmpty(map);
Map<String, Integer> test = Validate.notEmpty(map);
@ -253,7 +253,7 @@ public void testNotEmptyMap2() {
} catch (IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
map.put("ll", new Integer(8));
map.put("ll", Integer.valueOf(8));
Validate.notEmpty(map, "MSG");
Map<String, Integer> test = Validate.notEmpty(map, "Message");

View File

@ -30,7 +30,7 @@
*/
public class DefaultToStringStyleTest extends TestCase {
private final Integer base = new Integer(5);
private final Integer base = Integer.valueOf(5);
private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base));
public DefaultToStringStyleTest(String name) {
@ -65,8 +65,8 @@ public void testAppendSuper() {
}
public void testObject() {
Integer i3 = new Integer(3);
Integer i4 = new Integer(4);
Integer i3 = Integer.valueOf(3);
Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());

View File

@ -957,8 +957,8 @@ public void testUnrelatedClasses() {
* Test from http://issues.apache.org/bugzilla/show_bug.cgi?id=33067
*/
public void testNpeForNullElement() {
Object[] x1 = new Object[] { new Integer(1), null, new Integer(3) };
Object[] x2 = new Object[] { new Integer(1), new Integer(2), new Integer(3) };
Object[] x1 = new Object[] { Integer.valueOf(1), null, Integer.valueOf(3) };
Object[] x2 = new Object[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
// causes an NPE in 2.0 according to:
// http://issues.apache.org/bugzilla/show_bug.cgi?id=33067

View File

@ -38,8 +38,8 @@ public HashCodeBuilderAndEqualsBuilderTest(String name) {
//-----------------------------------------------------------------------
public void testInteger(boolean testTransients) {
Integer i1 = new Integer(12345);
Integer i2 = new Integer(12345);
Integer i1 = Integer.valueOf(12345);
Integer i2 = Integer.valueOf(12345);
assertEqualsAndHashCodeContract(i1, i2, testTransients);
}

View File

@ -31,7 +31,7 @@
*/
public class MultiLineToStringStyleTest extends TestCase {
private final Integer base = new Integer(5);
private final Integer base = Integer.valueOf(5);
private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base));
public MultiLineToStringStyleTest(String name) {
@ -66,8 +66,8 @@ public void testAppendSuper() {
}
public void testObject() {
Integer i3 = new Integer(3);
Integer i4 = new Integer(4);
Integer i3 = Integer.valueOf(3);
Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " 3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) null).toString());

View File

@ -30,7 +30,7 @@
*/
public class NoFieldNamesToStringStyleTest extends TestCase {
private final Integer base = new Integer(5);
private final Integer base = Integer.valueOf(5);
private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base));
public NoFieldNamesToStringStyleTest(String name) {
@ -65,8 +65,8 @@ public void testAppendSuper() {
}
public void testObject() {
Integer i3 = new Integer(3);
Integer i4 = new Integer(4);
Integer i3 = Integer.valueOf(3);
Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());

View File

@ -30,7 +30,7 @@
*/
public class ShortPrefixToStringStyleTest extends TestCase {
private final Integer base = new Integer(5);
private final Integer base = Integer.valueOf(5);
private final String baseStr = "Integer";
@Override
@ -61,8 +61,8 @@ public void testAppendSuper() {
}
public void testObject() {
Integer i3 = new Integer(3);
Integer i4 = new Integer(4);
Integer i3 = Integer.valueOf(3);
Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());

View File

@ -30,7 +30,7 @@
*/
public class SimpleToStringStyleTest extends TestCase {
private final Integer base = new Integer(5);
private final Integer base = Integer.valueOf(5);
public SimpleToStringStyleTest(String name) {
super(name);
@ -64,8 +64,8 @@ public void testAppendSuper() {
}
public void testObject() {
Integer i3 = new Integer(3);
Integer i4 = new Integer(4);
Integer i3 = Integer.valueOf(3);
Integer i4 = Integer.valueOf(4);
assertEquals("<null>", new ToStringBuilder(base).append((Object) null).toString());
assertEquals("3", new ToStringBuilder(base).append(i3).toString());
assertEquals("<null>", new ToStringBuilder(base).append("a", (Object) null).toString());

View File

@ -30,7 +30,7 @@
*/
public class StandardToStringStyleTest extends TestCase {
private final Integer base = new Integer(5);
private final Integer base = Integer.valueOf(5);
private final String baseStr = "Integer";
private static final StandardToStringStyle STYLE = new StandardToStringStyle();
@ -80,8 +80,8 @@ public void testAppendSuper() {
}
public void testObject() {
Integer i3 = new Integer(3);
Integer i4 = new Integer(4);
Integer i3 = Integer.valueOf(3);
Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[%NULL%]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=%NULL%]", new ToStringBuilder(base).append("a", (Object) null).toString());

View File

@ -601,8 +601,8 @@ public void testAppendToString() {
}
public void testObject() {
Integer i3 = new Integer(3);
Integer i4 = new Integer(4);
Integer i3 = Integer.valueOf(3);
Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@ -618,8 +618,8 @@ public void testObject() {
}
public void testObjectBuild() {
Integer i3 = new Integer(3);
Integer i4 = new Integer(4);
Integer i3 = Integer.valueOf(3);
Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).build());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).build());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).build());
@ -945,7 +945,7 @@ public <T> String toStringWithStatics(T object, ToStringStyle style, Class<? sup
* Tests ReflectionToStringBuilder setUpToClass().
*/
public void test_setUpToClass_valid() {
Integer val = new Integer(5);
Integer val = Integer.valueOf(5);
ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
test.setUpToClass(Number.class);
}
@ -954,7 +954,7 @@ public void test_setUpToClass_valid() {
* Tests ReflectionToStringBuilder setUpToClass().
*/
public void test_setUpToClass_invalid() {
Integer val = new Integer(5);
Integer val = Integer.valueOf(5);
ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
try {
test.setUpToClass(String.class);
@ -1003,7 +1003,7 @@ public void testReflectionNull() {
* See issue LANG-372.
*/
class MultiLineTestObject {
Integer i = new Integer(31337);
Integer i = Integer.valueOf(31337);
@Override
public String toString() {
return new ToStringBuilder(this).append("testInt", i).toString();

View File

@ -380,7 +380,7 @@ public void testInitializeUncheckedEx() throws ConcurrentException {
*/
@Test
public void testConstantFuture_Integer() throws Exception {
Integer value = new Integer(5);
Integer value = Integer.valueOf(5);
Future<Integer> test = ConcurrentUtils.constantFuture(value);
assertTrue(test.isDone());
assertSame(value, test.get());

View File

@ -81,7 +81,7 @@ public void testGet() throws ConcurrentException {
public void testEqualsTrue() {
checkEquals(init, true);
ConstantInitializer<Integer> init2 = new ConstantInitializer<Integer>(
new Integer(VALUE.intValue()));
Integer.valueOf(VALUE.intValue()));
checkEquals(init2, true);
init = new ConstantInitializer<Integer>(null);
init2 = new ConstantInitializer<Integer>(null);

View File

@ -51,7 +51,7 @@ protected void setUp() throws Exception {
.addContextValue("test1", null)
.addContextValue("test2", "some value")
.addContextValue("test Date", new Date())
.addContextValue("test Nbr", new Integer(5))
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
}

View File

@ -81,7 +81,7 @@ public void testNullExceptionPassing() {
.addContextValue("test1", null)
.addContextValue("test2", "some value")
.addContextValue("test Date", new Date())
.addContextValue("test Nbr", new Integer(5))
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
String message = exceptionContext.getMessage();

View File

@ -81,7 +81,7 @@ public void testNullExceptionPassing() {
.addContextValue("test1", null)
.addContextValue("test2", "some value")
.addContextValue("test Date", new Date())
.addContextValue("test Nbr", new Integer(5))
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
String message = exceptionContext.getMessage();

View File

@ -1220,7 +1220,7 @@ public void testEquals() {
f1 = Fraction.getFraction(3, 5);
assertEquals(false, f1.equals(null));
assertEquals(false, f1.equals(new Object()));
assertEquals(false, f1.equals(new Integer(6)));
assertEquals(false, f1.equals(Integer.valueOf(6)));
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(2, 5);

View File

@ -182,7 +182,7 @@ public void testToShortStringI() {
public void testCreateNumber() {
// a lot of things can go wrong
assertEquals("createNumber(String) 1 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5"));
assertEquals("createNumber(String) 2 failed", new Integer("12345"), NumberUtils.createNumber("12345"));
assertEquals("createNumber(String) 2 failed", Integer.valueOf("12345"), NumberUtils.createNumber("12345"));
assertEquals("createNumber(String) 3 failed", new Double("1234.5"), NumberUtils.createNumber("1234.5D"));
assertEquals("createNumber(String) 3 failed", new Double("1234.5"), NumberUtils.createNumber("1234.5d"));
assertEquals("createNumber(String) 4 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5F"));
@ -192,7 +192,7 @@ public void testCreateNumber() {
assertEquals("createNumber(String) 6 failed", new Long(12345), NumberUtils.createNumber("12345L"));
assertEquals("createNumber(String) 6 failed", new Long(12345), NumberUtils.createNumber("12345l"));
assertEquals("createNumber(String) 7 failed", new Float("-1234.5"), NumberUtils.createNumber("-1234.5"));
assertEquals("createNumber(String) 8 failed", new Integer("-12345"), NumberUtils.createNumber("-12345"));
assertEquals("createNumber(String) 8 failed", Integer.valueOf("-12345"), NumberUtils.createNumber("-12345"));
assertTrue("createNumber(String) 9 failed", 0xFADE == NumberUtils.createNumber("0xFADE").intValue());
assertTrue("createNumber(String) 10 failed", -0xFADE == NumberUtils.createNumber("-0xFADE").intValue());
assertEquals("createNumber(String) 11 failed", new Double("1.1E200"), NumberUtils.createNumber("1.1E200"));
@ -268,7 +268,7 @@ protected void testCreateDoubleFailure(String str) {
@Test
public void testCreateInteger() {
assertEquals("createInteger(String) failed", new Integer("12345"), NumberUtils.createInteger("12345"));
assertEquals("createInteger(String) failed", Integer.valueOf("12345"), NumberUtils.createInteger("12345"));
assertEquals("createInteger(null) failed", null, NumberUtils.createInteger(null));
this.testCreateIntegerFailure("");
this.testCreateIntegerFailure(" ");

View File

@ -150,7 +150,7 @@ public void testAddValuePrimitive() {
public void testAddValueObject() {
MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add(new Integer(1));
mutNum.add(Integer.valueOf(1));
assertEquals((byte) 2, mutNum.byteValue());
}
@ -164,7 +164,7 @@ public void testSubtractValuePrimitive() {
public void testSubtractValueObject() {
MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract(new Integer(1));
mutNum.subtract(Integer.valueOf(1));
assertEquals((byte) 0, mutNum.byteValue());
}

View File

@ -36,7 +36,7 @@ public void testConstructors() {
assertEquals(1, new MutableInt(1).intValue());
assertEquals(2, new MutableInt(new Integer(2)).intValue());
assertEquals(2, new MutableInt(Integer.valueOf(2)).intValue());
assertEquals(3, new MutableInt(new MutableLong(3)).intValue());
assertEquals(2, new MutableInt("2").intValue());
@ -50,19 +50,19 @@ public void testConstructors() {
public void testGetSet() {
final MutableInt mutNum = new MutableInt(0);
assertEquals(0, new MutableInt().intValue());
assertEquals(new Integer(0), new MutableInt().getValue());
assertEquals(Integer.valueOf(0), new MutableInt().getValue());
mutNum.setValue(1);
assertEquals(1, mutNum.intValue());
assertEquals(new Integer(1), mutNum.getValue());
assertEquals(Integer.valueOf(1), mutNum.getValue());
mutNum.setValue(new Integer(2));
mutNum.setValue(Integer.valueOf(2));
assertEquals(2, mutNum.intValue());
assertEquals(new Integer(2), mutNum.getValue());
assertEquals(Integer.valueOf(2), mutNum.getValue());
mutNum.setValue(new MutableLong(3));
assertEquals(3, mutNum.intValue());
assertEquals(new Integer(3), mutNum.getValue());
assertEquals(Integer.valueOf(3), mutNum.getValue());
try {
mutNum.setValue(null);
fail();
@ -72,7 +72,7 @@ public void testGetSet() {
public void testEquals() {
this.testEquals(new MutableInt(0), new MutableInt(0), new MutableInt(1));
// Should Numbers be supported? GaryG July-21-2005.
//this.testEquals(mutNumA, new Integer(0), mutNumC);
//this.testEquals(mutNumA, Integer.valueOf(0), mutNumC);
}
/**
@ -89,7 +89,7 @@ void testEquals(final Number numA, final Number numB, final Number numC) {
assertEquals(false, numB.equals(numC));
assertEquals(true, numC.equals(numC));
assertEquals(false, numA.equals(null));
assertEquals(false, numA.equals(new Integer(0)));
assertEquals(false, numA.equals(Integer.valueOf(0)));
assertEquals(false, numA.equals("0"));
}
@ -101,7 +101,7 @@ public void testHashCode() {
assertEquals(true, mutNumA.hashCode() == mutNumA.hashCode());
assertEquals(true, mutNumA.hashCode() == mutNumB.hashCode());
assertEquals(false, mutNumA.hashCode() == mutNumC.hashCode());
assertEquals(true, mutNumA.hashCode() == new Integer(0).hashCode());
assertEquals(true, mutNumA.hashCode() == Integer.valueOf(0).hashCode());
}
public void testCompareTo() {
@ -127,8 +127,8 @@ public void testPrimitiveValues() {
}
public void testToInteger() {
assertEquals(new Integer(0), new MutableInt(0).toInteger());
assertEquals(new Integer(123), new MutableInt(123).toInteger());
assertEquals(Integer.valueOf(0), new MutableInt(0).toInteger());
assertEquals(Integer.valueOf(123), new MutableInt(123).toInteger());
}
public void testIncrement() {
@ -157,7 +157,7 @@ public void testAddValuePrimitive() {
public void testAddValueObject() {
MutableInt mutNum = new MutableInt(1);
mutNum.add(new Integer(1));
mutNum.add(Integer.valueOf(1));
assertEquals(2, mutNum.intValue());
assertEquals(2L, mutNum.longValue());
@ -173,7 +173,7 @@ public void testSubtractValuePrimitive() {
public void testSubtractValueObject() {
MutableInt mutNum = new MutableInt(1);
mutNum.subtract(new Integer(1));
mutNum.subtract(Integer.valueOf(1));
assertEquals(0, mutNum.intValue());
assertEquals(0L, mutNum.longValue());

View File

@ -34,7 +34,7 @@ public MutableObjectTest(String testName) {
public void testConstructors() {
assertEquals(null, new MutableObject<String>().getValue());
Integer i = new Integer(6);
Integer i = Integer.valueOf(6);
assertSame(i, new MutableObject<Integer>(i).getValue());
assertSame("HI", new MutableObject<String>("HI").getValue());
assertSame(null, new MutableObject<Object>(null).getValue());

View File

@ -44,8 +44,8 @@ public class FieldUtilsTest {
static final String S = "s";
static final String SS = "ss";
static final Integer I0 = new Integer(0);
static final Integer I1 = new Integer(1);
static final Integer I0 = Integer.valueOf(0);
static final Integer I1 = Integer.valueOf(1);
static final Double D0 = new Double(0.0);
static final Double D1 = new Double(1.0);
@ -913,7 +913,7 @@ public void testWriteField() throws Exception {
}
field = parentClass.getDeclaredField("i");
try {
FieldUtils.writeField(field, publicChild, new Integer(Integer.MAX_VALUE));
FieldUtils.writeField(field, publicChild, Integer.valueOf(Integer.MAX_VALUE));
} catch (IllegalAccessException e) {
// pass
}
@ -934,8 +934,8 @@ public void testWriteFieldForceAccess() throws Exception {
FieldUtils.writeField(field, publicChild, Boolean.TRUE, true);
assertEquals(Boolean.TRUE, field.get(publicChild));
field = parentClass.getDeclaredField("i");
FieldUtils.writeField(field, publicChild, new Integer(Integer.MAX_VALUE), true);
assertEquals(new Integer(Integer.MAX_VALUE), field.get(publicChild));
FieldUtils.writeField(field, publicChild, Integer.valueOf(Integer.MAX_VALUE), true);
assertEquals(Integer.valueOf(Integer.MAX_VALUE), field.get(publicChild));
field = parentClass.getDeclaredField("d");
FieldUtils.writeField(field, publicChild, new Double(Double.MAX_VALUE), true);
assertEquals(new Double(Double.MAX_VALUE), field.get(publicChild));
@ -952,7 +952,7 @@ public void testWriteNamedField() throws Exception {
// pass
}
try {
FieldUtils.writeField(publicChild, "i", new Integer(1));
FieldUtils.writeField(publicChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
@ -968,8 +968,8 @@ public void testWriteNamedField() throws Exception {
assertEquals("S", FieldUtils.readField(publiclyShadowedChild, "s"));
FieldUtils.writeField(publiclyShadowedChild, "b", Boolean.FALSE);
assertEquals(Boolean.FALSE, FieldUtils.readField(publiclyShadowedChild, "b"));
FieldUtils.writeField(publiclyShadowedChild, "i", new Integer(0));
assertEquals(new Integer(0), FieldUtils.readField(publiclyShadowedChild, "i"));
FieldUtils.writeField(publiclyShadowedChild, "i", Integer.valueOf(0));
assertEquals(Integer.valueOf(0), FieldUtils.readField(publiclyShadowedChild, "i"));
FieldUtils.writeField(publiclyShadowedChild, "d", new Double(0.0));
assertEquals(new Double(0.0), FieldUtils.readField(publiclyShadowedChild, "d"));
@ -982,7 +982,7 @@ public void testWriteNamedField() throws Exception {
// pass
}
try {
FieldUtils.writeField(privatelyShadowedChild, "i", new Integer(1));
FieldUtils.writeField(privatelyShadowedChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
@ -1001,8 +1001,8 @@ public void testWriteNamedFieldForceAccess() throws Exception {
assertEquals("S", FieldUtils.readField(publicChild, "s", true));
FieldUtils.writeField(publicChild, "b", Boolean.TRUE, true);
assertEquals(Boolean.TRUE, FieldUtils.readField(publicChild, "b", true));
FieldUtils.writeField(publicChild, "i", new Integer(1), true);
assertEquals(new Integer(1), FieldUtils.readField(publicChild, "i", true));
FieldUtils.writeField(publicChild, "i", Integer.valueOf(1), true);
assertEquals(Integer.valueOf(1), FieldUtils.readField(publicChild, "i", true));
FieldUtils.writeField(publicChild, "d", new Double(1.0), true);
assertEquals(new Double(1.0), FieldUtils.readField(publicChild, "d", true));
@ -1010,8 +1010,8 @@ public void testWriteNamedFieldForceAccess() throws Exception {
assertEquals("S", FieldUtils.readField(publiclyShadowedChild, "s", true));
FieldUtils.writeField(publiclyShadowedChild, "b", Boolean.FALSE, true);
assertEquals(Boolean.FALSE, FieldUtils.readField(publiclyShadowedChild, "b", true));
FieldUtils.writeField(publiclyShadowedChild, "i", new Integer(0), true);
assertEquals(new Integer(0), FieldUtils.readField(publiclyShadowedChild, "i", true));
FieldUtils.writeField(publiclyShadowedChild, "i", Integer.valueOf(0), true);
assertEquals(Integer.valueOf(0), FieldUtils.readField(publiclyShadowedChild, "i", true));
FieldUtils.writeField(publiclyShadowedChild, "d", new Double(0.0), true);
assertEquals(new Double(0.0), FieldUtils.readField(publiclyShadowedChild, "d", true));
@ -1019,8 +1019,8 @@ public void testWriteNamedFieldForceAccess() throws Exception {
assertEquals("S", FieldUtils.readField(privatelyShadowedChild, "s", true));
FieldUtils.writeField(privatelyShadowedChild, "b", Boolean.FALSE, true);
assertEquals(Boolean.FALSE, FieldUtils.readField(privatelyShadowedChild, "b", true));
FieldUtils.writeField(privatelyShadowedChild, "i", new Integer(0), true);
assertEquals(new Integer(0), FieldUtils.readField(privatelyShadowedChild, "i", true));
FieldUtils.writeField(privatelyShadowedChild, "i", Integer.valueOf(0), true);
assertEquals(Integer.valueOf(0), FieldUtils.readField(privatelyShadowedChild, "i", true));
FieldUtils.writeField(privatelyShadowedChild, "d", new Double(0.0), true);
assertEquals(new Double(0.0), FieldUtils.readField(privatelyShadowedChild, "d", true));
}
@ -1040,7 +1040,7 @@ public void testWriteDeclaredNamedField() throws Exception {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "i", new Integer(1));
FieldUtils.writeDeclaredField(publicChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
@ -1056,8 +1056,8 @@ public void testWriteDeclaredNamedField() throws Exception {
assertEquals("S", FieldUtils.readDeclaredField(publiclyShadowedChild, "s"));
FieldUtils.writeDeclaredField(publiclyShadowedChild, "b", Boolean.FALSE);
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b"));
FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", new Integer(0));
assertEquals(new Integer(0), FieldUtils.readDeclaredField(publiclyShadowedChild, "i"));
FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", Integer.valueOf(0));
assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(publiclyShadowedChild, "i"));
FieldUtils.writeDeclaredField(publiclyShadowedChild, "d", new Double(0.0));
assertEquals(new Double(0.0), FieldUtils.readDeclaredField(publiclyShadowedChild, "d"));
@ -1074,7 +1074,7 @@ public void testWriteDeclaredNamedField() throws Exception {
// pass
}
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", new Integer(1));
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
@ -1102,7 +1102,7 @@ public void testWriteDeclaredNamedFieldForceAccess() throws Exception {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "i", new Integer(1), true);
FieldUtils.writeDeclaredField(publicChild, "i", Integer.valueOf(1), true);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
@ -1118,8 +1118,8 @@ public void testWriteDeclaredNamedFieldForceAccess() throws Exception {
assertEquals("S", FieldUtils.readDeclaredField(publiclyShadowedChild, "s", true));
FieldUtils.writeDeclaredField(publiclyShadowedChild, "b", Boolean.FALSE, true);
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b", true));
FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", new Integer(0), true);
assertEquals(new Integer(0), FieldUtils.readDeclaredField(publiclyShadowedChild, "i", true));
FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", Integer.valueOf(0), true);
assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(publiclyShadowedChild, "i", true));
FieldUtils.writeDeclaredField(publiclyShadowedChild, "d", new Double(0.0), true);
assertEquals(new Double(0.0), FieldUtils.readDeclaredField(publiclyShadowedChild, "d", true));
@ -1127,8 +1127,8 @@ public void testWriteDeclaredNamedFieldForceAccess() throws Exception {
assertEquals("S", FieldUtils.readDeclaredField(privatelyShadowedChild, "s", true));
FieldUtils.writeDeclaredField(privatelyShadowedChild, "b", Boolean.FALSE, true);
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(privatelyShadowedChild, "b", true));
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", new Integer(0), true);
assertEquals(new Integer(0), FieldUtils.readDeclaredField(privatelyShadowedChild, "i", true));
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", Integer.valueOf(0), true);
assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(privatelyShadowedChild, "i", true));
FieldUtils.writeDeclaredField(privatelyShadowedChild, "d", new Double(0.0), true);
assertEquals(new Double(0.0), FieldUtils.readDeclaredField(privatelyShadowedChild, "d", true));
}

View File

@ -374,13 +374,13 @@ public void testIsAssignable() throws SecurityException, NoSuchMethodException,
Assert.assertTrue(TypeUtils.isAssignable(float.class, double.class));
lo = in;
Assert.assertTrue(TypeUtils.isAssignable(int.class, long.class));
lo = new Integer(0);
lo = Integer.valueOf(0);
Assert.assertTrue(TypeUtils.isAssignable(Integer.class, long.class));
// Long lngW = 1;
Assert.assertFalse(TypeUtils.isAssignable(int.class, Long.class));
// lngW = new Integer( 0 );
// lngW = Integer.valueOf( 0 );
Assert.assertFalse(TypeUtils.isAssignable(Integer.class, Long.class));
in = new Integer(0);
in = Integer.valueOf(0);
Assert.assertTrue(TypeUtils.isAssignable(Integer.class, int.class));
Integer inte = in;
Assert.assertTrue(TypeUtils.isAssignable(int.class, Integer.class));
@ -395,7 +395,7 @@ public void testIsAssignable() throws SecurityException, NoSuchMethodException,
Type longComparableType = getClass().getField("longComparable").getGenericType();
// longComparable = 1;
Assert.assertFalse(TypeUtils.isAssignable(int.class, longComparableType));
// longComparable = new Integer( 0 );
// longComparable = Integer.valueOf( 0 );
Assert.assertFalse(TypeUtils.isAssignable(Integer.class, longComparableType));
// int[] ia;
// long[] la = ia;

View File

@ -139,8 +139,8 @@ public void testExtendedAndBuiltInFormats() {
// ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
// assertPatterns(null, pattern, emf.toPattern());
// try {
// assertEquals("one", emf.format(new Object[] {new Integer(1), "ONE"}));
// assertEquals("TWO", emf.format(new Object[] {new Integer(2), "two"}));
// assertEquals("one", emf.format(new Object[] {Integer.valueOf(1), "ONE"}));
// assertEquals("TWO", emf.format(new Object[] {Integer.valueOf(2), "two"}));
// } catch (IllegalArgumentException e) {
// // currently sub-formats not supported
// }
@ -153,8 +153,8 @@ public void testExtendedAndBuiltInFormats() {
// */
// public void testExtendedAndBuiltInWithChoiceFormat() {
// String pattern = "Choice: {0,choice,1.0#{0} {1,lower} {2,number}|2.0#{0} {1,upper} {2,number,currency}}";
// Object[] lowArgs = new Object[] {new Integer(1), "Low", new Double("1234.56")};
// Object[] highArgs = new Object[] {new Integer(2), "High", new Double("9876.54")};
// Object[] lowArgs = new Object[] {Integer.valueOf(1), "Low", new Double("1234.56")};
// Object[] highArgs = new Object[] {Integer.valueOf(2), "High", new Double("9876.54")};
// Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
// Locale[] testLocales = new Locale[availableLocales.length + 1];
// testLocales[0] = null;
@ -188,7 +188,7 @@ public void testExtendedAndBuiltInFormats() {
* Test the built in choice format.
*/
public void testBuiltInChoiceFormat() {
Object[] values = new Number[] {new Integer(1), new Double("2.2"), new Double("1234.5")};
Object[] values = new Number[] {Integer.valueOf(1), new Double("2.2"), new Double("1234.5")};
String choicePattern = null;
Locale[] availableLocales = ChoiceFormat.getAvailableLocales();

View File

@ -462,7 +462,7 @@ public void testAppendln_Object() {
sb.appendln(FOO);
assertEquals(SEP + "foo" + SEP, sb.toString());
sb.appendln(new Integer(6));
sb.appendln(Integer.valueOf(6));
assertEquals(SEP + "foo" + SEP + "6" + SEP, sb.toString());
}

View File

@ -1704,7 +1704,7 @@ public void testEquals() {
assertEquals(true, sb1.equals(sb2));
assertEquals(true, sb1.equals((Object) sb2));
assertEquals(false, sb1.equals(new Integer(1)));
assertEquals(false, sb1.equals(Integer.valueOf(1)));
assertEquals(false, sb1.equals("abc"));
}

View File

@ -51,7 +51,7 @@ public void testSystemProperiesLookup() {
public void testMapLookup() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("key", "value");
map.put("number", new Integer(2));
map.put("number", Integer.valueOf(2));
assertEquals("value", StrLookup.mapLookup(map).lookup("key"));
assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
assertEquals(null, StrLookup.mapLookup(map).lookup(null));

View File

@ -375,7 +375,7 @@ public void testLexx() {
new Object())));
assertFalse("Token equal to Token with different count. ", token.equals(new DurationFormatUtils.Token(
DurationFormatUtils.y, 1)));
DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(new Integer(1), 4);
DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(Integer.valueOf(1), 4);
assertTrue("Token with Number value not equal to itself. ", numToken.equals(numToken));
}