1919
2020package quickfix ;
2121
22- import junit .framework .TestCase ;
22+ import org .junit .Test ;
23+ import static org .junit .Assert .*;
2324import quickfix .field .BeginString ;
2425import quickfix .field .SenderCompID ;
2526import quickfix .field .SenderLocationID ;
2829import quickfix .field .TargetLocationID ;
2930import 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