Skip to content

Commit 0a42170

Browse files
authored
Merge pull request #1079 from quickfix-j/jetbrains-junie-issue-1078-run-1befc922-ca79-4788-988c-f5ac0dfe5052
[Junie]: feat(tests): migrate JUnit 3 tests to JUnit 4 annotations
2 parents 3dc5d58 + 6bee034 commit 0a42170

13 files changed

Lines changed: 140 additions & 70 deletions

File tree

quickfixj-base/src/test/java/quickfix/DayConverterTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,26 @@
2121

2222
import java.util.Locale;
2323

24-
import junit.framework.TestCase;
24+
import org.junit.After;
25+
import org.junit.Before;
26+
import org.junit.Test;
27+
import static org.junit.Assert.*;
2528

26-
public class DayConverterTest extends TestCase {
29+
public class DayConverterTest {
2730
private Locale defaultLocale;
2831

29-
protected void setUp() throws Exception {
30-
super.setUp();
32+
@Before
33+
public void setUp() throws Exception {
3134
defaultLocale = Locale.getDefault();
3235
Locale.setDefault(Locale.US);
3336
}
3437

35-
protected void tearDown() throws Exception {
38+
@After
39+
public void tearDown() throws Exception {
3640
Locale.setDefault(defaultLocale);
37-
super.tearDown();
3841
}
3942

43+
@Test
4044
public void testConversionToInt() throws Exception {
4145
assertEquals(1, DayConverter.toInteger("sU"));
4246
assertEquals(4, DayConverter.toInteger("WEDnes"));
@@ -54,6 +58,7 @@ public void testConversionToInt() throws Exception {
5458
assertEquals(2, DayConverter.toInteger("Mo"));
5559
}
5660

61+
@Test
5762
public void testConversionToString() throws Exception {
5863
Locale.setDefault(Locale.US);
5964
assertEquals("sunday", DayConverter.toString(1));

quickfixj-base/src/test/java/quickfix/DictionaryTest.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@
2121

2222
import java.util.Locale;
2323

24-
import junit.framework.TestCase;
24+
import org.junit.After;
25+
import org.junit.Before;
26+
import org.junit.Test;
27+
import static org.junit.Assert.*;
2528

26-
public class DictionaryTest extends TestCase {
29+
public class DictionaryTest {
2730
private Dictionary dictionary;
2831
private Locale defaultLocale;
2932

30-
protected void setUp() throws Exception {
31-
super.setUp();
33+
@Before
34+
public void setUp() throws Exception {
3235
dictionary = new Dictionary();
3336
defaultLocale = Locale.getDefault();
3437
Locale.setDefault(Locale.US);
3538
}
3639

37-
protected void tearDown() throws Exception {
38-
super.tearDown();
40+
@After
41+
public void tearDown() throws Exception {
3942
Locale.setDefault(defaultLocale);
4043
}
4144

45+
@Test
4246
public void testDay() throws Exception {
4347
assertFalse(dictionary.has("DAY"));
4448
dictionary.setString("DAY", "monday");
@@ -52,6 +56,7 @@ public void testDay() throws Exception {
5256
assertEquals(4, dictionary.getDay("DAY"));
5357
}
5458

59+
@Test
5560
public void testDayTooShort() throws Exception {
5661
dictionary.setString("DAY", "t");
5762
try {
@@ -61,6 +66,7 @@ public void testDayTooShort() throws Exception {
6166
}
6267
}
6368

69+
@Test
6470
public void testDayTooUnknown() throws Exception {
6571
dictionary.setString("DAY", "xyz");
6672
try {
@@ -70,6 +76,7 @@ public void testDayTooUnknown() throws Exception {
7076
}
7177
}
7278

79+
@Test
7380
public void testBoolean() throws Exception {
7481
dictionary.setBool("B", true);
7582
assertTrue(dictionary.getBool("B"));
@@ -78,6 +85,7 @@ public void testBoolean() throws Exception {
7885
assertFalse(dictionary.getBool("B"));
7986
}
8087

88+
@Test
8189
public void testBooleanError() throws Exception {
8290
dictionary.setString("B", "XYZ");
8391
try {
@@ -87,6 +95,7 @@ public void testBooleanError() throws Exception {
8795
}
8896
}
8997

98+
@Test
9099
public void testBooleanMissing() throws Exception {
91100
try {
92101
dictionary.getBool("B");
@@ -95,11 +104,13 @@ public void testBooleanMissing() throws Exception {
95104
}
96105
}
97106

107+
@Test
98108
public void testString() throws Exception {
99109
dictionary.setString("B", "X");
100110
assertEquals("X", dictionary.getString("B"));
101111
}
102112

113+
@Test
103114
public void testStringMissing() throws Exception {
104115
try {
105116
dictionary.getString("X");
@@ -108,11 +119,13 @@ public void testStringMissing() throws Exception {
108119
}
109120
}
110121

122+
@Test
111123
public void testDouble() throws Exception {
112124
dictionary.setDouble("B", 1.1);
113125
assertEquals(1.1, dictionary.getDouble("B"), 0);
114126
}
115127

128+
@Test
116129
public void testDoubleError() throws Exception {
117130
dictionary.setString("B", "XYZ");
118131
try {
@@ -122,6 +135,7 @@ public void testDoubleError() throws Exception {
122135
}
123136
}
124137

138+
@Test
125139
public void testDoubleMissing() throws Exception {
126140
try {
127141
dictionary.getDouble("B");
@@ -130,11 +144,13 @@ public void testDoubleMissing() throws Exception {
130144
}
131145
}
132146

147+
@Test
133148
public void testLong() throws Exception {
134149
dictionary.setLong("B", 1);
135150
assertEquals(1, dictionary.getLong("B"));
136151
}
137152

153+
@Test
138154
public void testLongError() throws Exception {
139155
dictionary.setString("B", "XYZ");
140156
try {
@@ -144,6 +160,7 @@ public void testLongError() throws Exception {
144160
}
145161
}
146162

163+
@Test
147164
public void testLongMissing() throws Exception {
148165
try {
149166
dictionary.getLong("B");
@@ -152,6 +169,7 @@ public void testLongMissing() throws Exception {
152169
}
153170
}
154171

172+
@Test
155173
public void testMerge() throws Exception {
156174
Dictionary d2 = new Dictionary("ABC");
157175
d2.setString("XYZ", "123");
@@ -166,13 +184,15 @@ public void testMerge() throws Exception {
166184
assertEquals(1, d2.toMap().size());
167185
}
168186

187+
@Test
169188
public void testName() throws Exception {
170189
assertNull(dictionary.getName());
171190

172191
Dictionary d = new Dictionary("NAME");
173192
assertEquals("NAME", d.getName());
174193
}
175194

195+
@Test
176196
public void testConstructors() throws Exception {
177197
Dictionary dw = new Dictionary();
178198
assertNull(dw.getName());
@@ -194,6 +214,7 @@ public void testConstructors() throws Exception {
194214
}
195215

196216
// From C++ tests
217+
@Test
197218
public void testGetDay() throws Exception {
198219
Dictionary object = new Dictionary();
199220

quickfixj-base/src/test/java/quickfix/ExceptionTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,30 @@
1919

2020
package quickfix;
2121

22-
import junit.framework.TestCase;
22+
import org.junit.Test;
23+
import static org.junit.Assert.*;
2324

24-
public class ExceptionTest extends TestCase {
25+
public class ExceptionTest {
2526

27+
@Test
2628
public void testDoNotSend() {
2729
new DoNotSend();
2830
}
2931

32+
@Test
3033
public void testIncorrectDataFormat() {
3134
IncorrectDataFormat e = new IncorrectDataFormat(5, "test");
3235
assertEquals(5, e.getField());
3336
assertEquals("test", e.getData());
3437
}
3538

39+
@Test
3640
public void testIncorrectTagValue() {
3741
new IncorrectTagValue(5);
38-
IncorrectTagValue e = new IncorrectTagValue(5, "test");
42+
new IncorrectTagValue(5, "test");
3943
}
4044

45+
@Test
4146
public void testRuntimeError() {
4247
new RuntimeError();
4348
new RuntimeError("test");

quickfixj-base/src/test/java/quickfix/SessionIDTest.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
package quickfix;
2121

22-
import junit.framework.TestCase;
22+
import org.junit.Test;
23+
import static org.junit.Assert.*;
2324
import quickfix.field.BeginString;
2425
import quickfix.field.SenderCompID;
2526
import quickfix.field.SenderLocationID;
@@ -28,9 +29,8 @@
2829
import quickfix.field.TargetLocationID;
2930
import quickfix.field.TargetSubID;
3031

31-
import static org.junit.Assert.assertNotEquals;
32-
33-
public class SessionIDTest extends TestCase {
32+
public class SessionIDTest {
33+
@Test
3434
public void testAllFieldConstructor() throws Exception {
3535
SessionID sessionID = new SessionID(new BeginString("FIX.4.2"), new SenderCompID("SENDER"),
3636
new SenderSubID("SENDERSUB"), new SenderLocationID("SENDERLOC"), new TargetCompID(
@@ -39,6 +39,7 @@ public void testAllFieldConstructor() throws Exception {
3939
assertAllFields(sessionID);
4040
}
4141

42+
@Test
4243
public void testAllStringConstructor() throws Exception {
4344
SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "SENDERSUB", "SENDERLOC",
4445
"TARGET", "TARGETSUB", "TARGETLOC", "QUALIFIER");
@@ -56,13 +57,15 @@ private void assertAllFields(SessionID sessionID) {
5657
assertEquals("QUALIFIER", sessionID.getSessionQualifier());
5758
}
5859

60+
@Test
5961
public void testFieldConstructorNoLocation() throws Exception {
6062
SessionID sessionID = new SessionID(new BeginString("FIX.4.2"), new SenderCompID("SENDER"),
6163
new SenderSubID("SENDERSUB"), new TargetCompID("TARGET"), new TargetSubID(
6264
"TARGETSUB"));
6365
assertFieldsNoLocation(sessionID);
6466
}
6567

68+
@Test
6669
public void testStringConstructorNoLocation() throws Exception {
6770
SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "SENDERSUB", "TARGET", "TARGETSUB");
6871
assertFieldsNoLocation(sessionID);
@@ -79,12 +82,14 @@ private void assertFieldsNoLocation(SessionID sessionID) {
7982
assertEquals("", sessionID.getSessionQualifier());
8083
}
8184

85+
@Test
8286
public void testFieldConstructorNoLocationOrSub() throws Exception {
8387
SessionID sessionID = new SessionID(new BeginString("FIX.4.2"), new SenderCompID("SENDER"),
8488
new TargetCompID("TARGET"), "QUALIFIER");
8589
assertFieldsNoLocationOrSub(sessionID);
8690
}
8791

92+
@Test
8893
public void testStringConstructorNoLocationOrSub() throws Exception {
8994
SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET", "QUALIFIER");
9095
assertFieldsNoLocationOrSub(sessionID);
@@ -101,12 +106,14 @@ private void assertFieldsNoLocationOrSub(SessionID sessionID) {
101106
assertEquals("QUALIFIER", sessionID.getSessionQualifier());
102107
}
103108

109+
@Test
104110
public void testFieldConstructorNoLocationSubOrQualifier() throws Exception {
105111
SessionID sessionID = new SessionID(new BeginString("FIX.4.2"), new SenderCompID("SENDER"),
106112
new TargetCompID("TARGET"));
107113
assertFieldsNoLocationSubOrQualifier(sessionID);
108114
}
109115

116+
@Test
110117
public void testStringConstructorNoLocationSubOrQualifier() throws Exception {
111118
SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET");
112119
assertFieldsNoLocationSubOrQualifier(sessionID);
@@ -123,6 +130,7 @@ private void assertFieldsNoLocationSubOrQualifier(SessionID sessionID) {
123130
assertEquals("", sessionID.getSessionQualifier());
124131
}
125132

133+
@Test
126134
public void testDefaultConstructorException() throws Exception {
127135
try {
128136
new SessionID();
@@ -132,6 +140,7 @@ public void testDefaultConstructorException() throws Exception {
132140
}
133141
}
134142

143+
@Test
135144
public void testEquals() throws Exception {
136145
SessionID sessionID1 = new SessionID("FIX.4.2:SENDER->TARGET:QUALIFIER");
137146
SessionID sessionID2 = new SessionID("FIX.4.2:SENDER->TARGET:QUALIFIER");
@@ -142,18 +151,21 @@ public void testEquals() throws Exception {
142151
assertFalse(sessionID1.equals(null));
143152
}
144153

154+
@Test
145155
public void testHashCode() throws Exception {
146156
SessionID sessionID1 = new SessionID("FIX.4.2:SENDER->TARGET:QUALIFIER");
147157
SessionID sessionID2 = new SessionID("FIX.4.2:SENDER->TARGET:QUALIFIER");
148158
assertEquals(sessionID1.hashCode(), sessionID2.hashCode());
149159
}
150160

161+
@Test
151162
public void testNullInFieldConstructor() {
152163
SessionID sessionID = new SessionID((BeginString) null, null, null, null, null, null, null,
153164
null);
154165
assertEmptyStrings(sessionID);
155166
}
156167

168+
@Test
157169
public void testNullInStringConstructor() {
158170
SessionID sessionID = new SessionID((String) null, null, null, null, null, null, null, null);
159171
assertEmptyStrings(sessionID);
@@ -170,6 +182,7 @@ private void assertEmptyStrings(SessionID sessionID) {
170182
assertEquals("", sessionID.getSessionQualifier());
171183
}
172184

185+
@Test
173186
public void testStringConstructor() throws Exception {
174187
SessionID sessionID = new SessionID("FIX.4.2:SENDER/SSUB/SLOC->TARGET/TSUB/TLOC:QUALIFIER");
175188
assertEquals("FIX.4.2", sessionID.getBeginString());
@@ -183,6 +196,7 @@ public void testStringConstructor() throws Exception {
183196
assertEquals("FIX.4.2:SENDER/SSUB/SLOC->TARGET/TSUB/TLOC:QUALIFIER", sessionID.toString());
184197
}
185198

199+
@Test
186200
public void testStringConstructorNoSubOrLocation() throws Exception {
187201
SessionID sessionID = new SessionID("FIX.4.2:SENDER->TARGET:QUALIFIER");
188202
assertEquals("FIX.4.2", sessionID.getBeginString());
@@ -192,6 +206,7 @@ public void testStringConstructorNoSubOrLocation() throws Exception {
192206
assertEquals("FIX.4.2:SENDER->TARGET:QUALIFIER", sessionID.toString());
193207
}
194208

209+
@Test
195210
public void testStringConstructorNoSubLocationOrQualifier() throws Exception {
196211
SessionID sessionID = new SessionID("FIX.4.2:SENDER->TARGET");
197212
assertEquals("FIX.4.2", sessionID.getBeginString());
@@ -201,6 +216,7 @@ public void testStringConstructorNoSubLocationOrQualifier() throws Exception {
201216
assertEquals("FIX.4.2:SENDER->TARGET", sessionID.toString());
202217
}
203218

219+
@Test
204220
public void testStringConstructorInvalidID() throws Exception {
205221
try {
206222
new SessionID("FIX.4.2:SENDER");
@@ -210,6 +226,7 @@ public void testStringConstructorInvalidID() throws Exception {
210226
}
211227
}
212228

229+
@Test
213230
public void testFromStringUnsupported() {
214231
SessionID sessionID = new SessionID((String) null, (String) null, (String) null);
215232
try {

0 commit comments

Comments
 (0)