Break up testIdentityToStringStringBuilder into multiple test methods.

This commit is contained in:
Gary Gregory 2017-11-10 11:47:35 -07:00
parent 4f928504ea
commit 22c3047156
1 changed files with 27 additions and 5 deletions

View File

@ -192,11 +192,27 @@ public class ObjectUtilsTest {
}
@Test
public void testIdentityToStringStringBuilder() {
public void testIdentityToStringObjectNull() {
assertNull(ObjectUtils.identityToString(null));
}
@Test
public void testIdentityToStringInteger() {
final Integer i = Integer.valueOf(90);
final String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));
assertEquals(expected, ObjectUtils.identityToString(i));
}
@Test
public void testIdentityToStringString() {
assertEquals(
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
ObjectUtils.identityToString(FOO));
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
ObjectUtils.identityToString(FOO));
}
@Test
public void testIdentityToStringStringBuilder() {
final Integer i = Integer.valueOf(90);
final String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));
@ -205,15 +221,21 @@ public class ObjectUtilsTest {
final StringBuilder builder = new StringBuilder();
ObjectUtils.identityToString(builder, i);
assertEquals(expected, builder.toString());
}
@Test
public void testIdentityToStringStringBuilderNullValue() {
try {
ObjectUtils.identityToString((StringBuilder)null, "tmp");
ObjectUtils.identityToString(new StringBuilder(), null);
fail("NullPointerException expected");
} catch(final NullPointerException npe) {
}
}
@Test
public void testIdentityToStringStringBuilderNullStringBuilder() {
try {
ObjectUtils.identityToString(new StringBuilder(), null);
ObjectUtils.identityToString((StringBuilder)null, "tmp");
fail("NullPointerException expected");
} catch(final NullPointerException npe) {
}