1 package net.jaekl.cfb.util;
3 import static org.junit.Assert.*;
5 import java.sql.SQLException;
6 import java.util.Arrays;
11 public class UtilTest {
13 public void testListsAreEqual()
15 Object[][][] equal = {
25 { "one", "two", "three" },
26 { "one", "two", "three" }
29 { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) },
30 { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) }
33 { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) },
34 { Integer.valueOf(1), Integer.valueOf(2048), Long.valueOf(3) }
37 Object[][][] unequal = {
40 { "one", "two", "three" }
43 { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) },
60 { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) }
76 for (Object[][] lists : equal) {
77 List<?> a = (null == lists[0]) ? null : Arrays.asList(lists[0]);
78 List<?> b = (null == lists[1]) ? null : Arrays.asList(lists[1]);
79 boolean result = Util.listsAreEqual(a, b);
83 for (Object[][] lists : unequal) {
84 List<?> a = (null == lists[0]) ? null : Arrays.asList(lists[0]);
85 List<?> b = (null == lists[1]) ? null : Arrays.asList(lists[1]);
86 boolean result = Util.listsAreEqual(a, b);
92 public void testObjHashCode()
96 "arma virumque cano, Troiae qui primus ab oris",
97 new String[] { null, null, null },
103 code = Util.objHashCode(null);
104 assertEquals(1, code);
106 for (Object datum : data) {
107 code = Util.objHashCode(datum);
108 assertEquals(datum.hashCode(), code);
113 public void testStringify()
115 final String msg = "Foo bar baz bat bam";
116 SQLException exc = new SQLException(msg);
117 String actual = Util.stringify(exc);
119 assertNotNull(actual);
120 assertTrue(actual.contains(msg));
121 assertTrue(actual.contains("SQLException"));
122 assertTrue(actual.contains("testStringify"));