.
| Method from org.apache.commons.lang.ObjectUtilsTest Detail: |
public static void main(String[] args) {
TestRunner.run(suite());
}
|
protected void setUp() throws Exception {
super.setUp();
}
|
public static Test suite() {
TestSuite suite = new TestSuite(ObjectUtilsTest.class);
suite.setName("ObjectUtils Tests");
return suite;
}
|
protected void tearDown() throws Exception {
super.tearDown();
}
|
public void testAppendIdentityToString() {
assertEquals(null, ObjectUtils.appendIdentityToString(null, null));
assertEquals(null, ObjectUtils.appendIdentityToString(new StringBuffer(), null));
assertEquals(
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
ObjectUtils.appendIdentityToString(null, FOO).toString());
assertEquals(
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
ObjectUtils.appendIdentityToString(new StringBuffer(), FOO).toString());
Integer val = new Integer(90);
assertEquals(
"java.lang.Integer@" + Integer.toHexString(System.identityHashCode(val)),
ObjectUtils.appendIdentityToString(null, val).toString());
assertEquals(
"java.lang.Integer@" + Integer.toHexString(System.identityHashCode(val)),
ObjectUtils.appendIdentityToString(new StringBuffer(), val).toString());
}
|
public void testConstructor() {
assertNotNull(new ObjectUtils());
Constructor[] cons = ObjectUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
assertEquals(true, Modifier.isPublic(ObjectUtils.class.getModifiers()));
assertEquals(false, Modifier.isFinal(ObjectUtils.class.getModifiers()));
}
|
public void testEquals() {
assertTrue("ObjectUtils.equals(null, null) returned false", ObjectUtils.equals(null, null));
assertTrue("ObjectUtils.equals(\"foo\", null) returned true", !ObjectUtils.equals(FOO, null));
assertTrue("ObjectUtils.equals(null, \"bar\") returned true", !ObjectUtils.equals(null, BAR));
assertTrue("ObjectUtils.equals(\"foo\", \"bar\") returned true", !ObjectUtils.equals(FOO, BAR));
assertTrue("ObjectUtils.equals(\"foo\", \"foo\") returned false", ObjectUtils.equals(FOO, FOO));
}
|
public void testHashCode() {
assertEquals(0, ObjectUtils.hashCode(null));
assertEquals("a".hashCode(), ObjectUtils.hashCode("a"));
}
|
public void testIdentityToString() {
assertEquals(null, ObjectUtils.identityToString(null));
assertEquals(
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
ObjectUtils.identityToString(FOO));
Integer i = new Integer(90);
assertEquals(
"java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i)),
ObjectUtils.identityToString(i));
}
|
public void testIsNull() {
Object o = FOO;
Object dflt = BAR;
assertSame("dflt was not returned when o was null", dflt, ObjectUtils.defaultIfNull(null, dflt));
assertSame("dflt was returned when o was not null", o, ObjectUtils.defaultIfNull(o, dflt));
}
|
public void testNull() {
assertTrue(ObjectUtils.NULL != null);
assertTrue(ObjectUtils.NULL instanceof ObjectUtils.Null);
assertSame(ObjectUtils.NULL, SerializationUtils.clone(ObjectUtils.NULL));
}
|
public void testToString_Object() {
assertEquals("", ObjectUtils.toString((Object) null) );
assertEquals(Boolean.TRUE.toString(), ObjectUtils.toString(Boolean.TRUE) );
}
|
public void testToString_ObjectString() {
assertEquals(BAR, ObjectUtils.toString((Object) null, BAR) );
assertEquals(Boolean.TRUE.toString(), ObjectUtils.toString(Boolean.TRUE, BAR) );
}
|