01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.util;
05:
06: import com.tc.test.TCTestCase;
07:
08: /**
09: * Unit test for {@link ToStringStringifier}.
10: */
11: public class ToStringStringifierTest extends TCTestCase {
12:
13: private static class MyObj {
14: private final String value;
15:
16: public MyObj(String value) {
17: this .value = value;
18: }
19:
20: public String toString() {
21: return "XXX" + this .value + "YYY";
22: }
23: }
24:
25: public void testNull() {
26: // Make sure we can disambiguate (new String("null")) and null.
27: String nullAsString = ToStringStringifier.INSTANCE
28: .toString(null);
29: assertFalse(nullAsString.equals("null"));
30: assertTrue(nullAsString.trim().length() > 0);
31: }
32:
33: public void testStringification() {
34: assertEquals("XXXYYY", ToStringStringifier.INSTANCE
35: .toString(new MyObj("")));
36: assertEquals("XXX YYY", ToStringStringifier.INSTANCE
37: .toString(new MyObj(" ")));
38: assertEquals("XXXaaabbbYYY", ToStringStringifier.INSTANCE
39: .toString(new MyObj("aaabbb")));
40: }
41:
42: }
|