|
35 | 35 | import java.util.HashSet;
|
36 | 36 | import java.util.Set;
|
37 | 37 |
|
38 |
| -import junit.framework.Assert; |
39 | 38 | import junit.framework.Test;
|
40 | 39 | import junit.framework.TestCase;
|
41 | 40 | import junit.framework.TestSuite;
|
@@ -99,24 +98,24 @@ public void testHashcode() {
|
99 | 98 | set.add(StandardTenor.OVERNIGHT);
|
100 | 99 | set.add(StandardTenor.T_1D);
|
101 | 100 | set.add(StandardTenor.T_15Y);
|
102 |
| - Assert.assertEquals("size", 3, set.size()); |
103 |
| - Assert.assertTrue("Contains " + StandardTenor.T_1D, set.contains(StandardTenor.T_1D)); |
104 |
| - Assert.assertTrue("Contains " + StandardTenor.OVERNIGHT, set.contains(StandardTenor.OVERNIGHT)); |
105 |
| - Assert.assertTrue("Contains " + StandardTenor.T_15Y, set.contains(StandardTenor.T_15Y)); |
106 |
| - Assert.assertEquals("Equals ", StandardTenor.T_15Y, StandardTenor.T_15Y); |
| 101 | + assertEquals("size", 3, set.size()); |
| 102 | + assertTrue("Contains " + StandardTenor.T_1D, set.contains(StandardTenor.T_1D)); |
| 103 | + assertTrue("Contains " + StandardTenor.OVERNIGHT, set.contains(StandardTenor.OVERNIGHT)); |
| 104 | + assertTrue("Contains " + StandardTenor.T_15Y, set.contains(StandardTenor.T_15Y)); |
| 105 | + assertEquals("Equals ", StandardTenor.T_15Y, StandardTenor.T_15Y); |
107 | 106 | }
|
108 | 107 |
|
109 | 108 | public void testEquals() {
|
110 |
| - Assert.assertEquals("Equals ", StandardTenor.T_15Y, StandardTenor.T_15Y); |
111 |
| - Assert.assertTrue("same", StandardTenor.OVERNIGHT.equals(StandardTenor.OVERNIGHT)); |
112 |
| - Assert.assertFalse("not same", StandardTenor.OVERNIGHT.equals(StandardTenor.SPOT)); |
113 |
| - Assert.assertFalse("Different class", StandardTenor.OVERNIGHT.equals("Hello")); |
114 |
| - Assert.assertFalse("Null", StandardTenor.OVERNIGHT.equals(null)); |
115 |
| - Assert.assertTrue("same", StandardTenor.T_10Y.equals(StandardTenor.T_10Y)); |
116 |
| - Assert.assertFalse("diff unit", StandardTenor.T_10Y.equals(StandardTenor.T_15Y)); |
117 |
| - Assert.assertTrue("same", StandardTenor.T_10Y.equals(new Tenor(10, TenorCode.YEAR))); |
118 |
| - Assert.assertFalse("same", new Tenor(10, null).equals(new Tenor(10, TenorCode.YEAR))); |
119 |
| - Assert.assertTrue("same", new Tenor(10, null).equals(new Tenor(10, null))); |
| 109 | + assertEquals("Equals ", StandardTenor.T_15Y, StandardTenor.T_15Y); |
| 110 | + assertTrue("same", StandardTenor.OVERNIGHT.equals(StandardTenor.OVERNIGHT)); |
| 111 | + assertFalse("not same", StandardTenor.OVERNIGHT.equals(StandardTenor.SPOT)); |
| 112 | + assertFalse("Different class", StandardTenor.OVERNIGHT.equals("Hello")); |
| 113 | + assertFalse("Null", StandardTenor.OVERNIGHT.equals(null)); |
| 114 | + assertTrue("same", StandardTenor.T_10Y.equals(StandardTenor.T_10Y)); |
| 115 | + assertFalse("diff unit", StandardTenor.T_10Y.equals(StandardTenor.T_15Y)); |
| 116 | + assertTrue("same", StandardTenor.T_10Y.equals(new Tenor(10, TenorCode.YEAR))); |
| 117 | + assertFalse("same", new Tenor(10, null).equals(new Tenor(10, TenorCode.YEAR))); |
| 118 | + assertTrue("same", new Tenor(10, null).equals(new Tenor(10, null))); |
120 | 119 | }
|
121 | 120 |
|
122 | 121 | // -----------------------------------------------------------------------
|
@@ -147,32 +146,32 @@ public void testInvalidTenors() {
|
147 | 146 | private void checkToString(final String string) {
|
148 | 147 | try {
|
149 | 148 | final Tenor t = Tenor.valueOf(string);
|
150 |
| - Assert.assertEquals(string, t.toString()); |
| 149 | + assertEquals(string, t.toString()); |
151 | 150 | } catch (final IllegalArgumentException e) {
|
152 |
| - Assert.fail(e.toString()); |
| 151 | + fail(e.toString()); |
153 | 152 | }
|
154 | 153 | }
|
155 | 154 |
|
156 | 155 | private void checkInvalidTenor(final String str) {
|
157 | 156 | try {
|
158 | 157 | Tenor.valueOf(str);
|
159 |
| - Assert.fail(str + " is invalid and should have thrown an exception!"); |
| 158 | + fail(str + " is invalid and should have thrown an exception!"); |
160 | 159 | } catch (final IllegalArgumentException e) {
|
161 |
| - Assert.assertTrue(true); |
| 160 | + assertTrue(true); |
162 | 161 | }
|
163 | 162 | }
|
164 | 163 |
|
165 | 164 | private Tenor checkValidTenor(final String str, final boolean acceptUnits, final TenorCode tenorCode, final int units) {
|
166 | 165 | Tenor tenor = null;
|
167 | 166 | try {
|
168 | 167 | tenor = Tenor.valueOf(str);
|
169 |
| - Assert.assertEquals(str + " Accept Units", acceptUnits, tenor.getCode().acceptUnits()); |
170 |
| - Assert.assertEquals(str + " Accept Units", acceptUnits, tenor.hasUnits()); |
171 |
| - Assert.assertSame(str + " right tenor ", tenorCode, tenor.getCode()); |
172 |
| - Assert.assertEquals(str + " Units", units, tenor.getUnits()); |
| 168 | + assertEquals(str + " Accept Units", acceptUnits, tenor.getCode().acceptUnits()); |
| 169 | + assertEquals(str + " Accept Units", acceptUnits, tenor.hasUnits()); |
| 170 | + assertSame(str + " right tenor ", tenorCode, tenor.getCode()); |
| 171 | + assertEquals(str + " Units", units, tenor.getUnits()); |
173 | 172 | } catch (final IllegalArgumentException e) {
|
174 | 173 | e.printStackTrace();
|
175 |
| - Assert.fail("[" + str + "] should be valid!"); |
| 174 | + fail("[" + str + "] should be valid!"); |
176 | 175 | }
|
177 | 176 | return tenor;
|
178 | 177 | }
|
|
0 commit comments