1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package net.sf.jour.signature;
25
26 import java.util.List;
27 import java.util.Vector;
28
29
30
31
32
33 class APICompareChangeHelper {
34
35 List changes;
36
37 APICompareChangeHelper() {
38 changes = new Vector();
39 }
40
41 public void fail(String message) {
42 changes.add(message);
43 }
44
45 public boolean assertTrue(String message, boolean condition) {
46 if (!condition) {
47 fail(message);
48 return true;
49 } else {
50 return false;
51 }
52 }
53
54 public boolean assertFalse(String message, boolean condition) {
55 if (condition) {
56 fail(message);
57 return true;
58 } else {
59 return false;
60 }
61 }
62
63 public boolean assertNull(String message, Object object) {
64 return assertTrue(message, object == null);
65 }
66
67 public boolean assertNotNull(String message, Object object) {
68 return assertTrue(message, object != null);
69 }
70
71 public boolean assertEquals(String message, int expected, int actual) {
72 return assertEquals(message, new Integer(expected), new Integer(actual));
73 }
74
75 public boolean assertEquals(String message, boolean expected, boolean actual) {
76 return assertEquals(message, new Boolean(expected), new Boolean(actual));
77 }
78
79 public boolean assertEquals(String message, Object expected, Object actual) {
80 if (expected == null && actual == null) {
81 return false;
82 }
83 if (expected != null && expected.equals(actual)) {
84 return false;
85 }
86 failNotEquals(message, expected, actual);
87 return true;
88 }
89
90 private void failNotEquals(String message, Object expected, Object actual) {
91 fail(format(message, expected, actual));
92 }
93
94 String format(String message, Object expected, Object actual) {
95 String formatted = "";
96 if (message != null) {
97 formatted = message + " ";
98 }
99 return formatted + "expected:<" + expected + "> but was:<" + actual + ">";
100 }
101 }