Refactor FIX message parser test
@@ -10,19 +10,11 @@ import org.junit.Test;
public class FIXMessageParserTest {
- private FIXMessage message;
-
- private FIXMessageParser parser;
-
private FIXMessages messages;
@Before
public void setUp() {
- message = new FIXMessage(32, 32);
-
messages = new FIXMessages();
-
- parser = new FIXMessageParser(messages, message);
}
@Test
@@ -104,7 +96,7 @@ public class FIXMessageParserTest {
public void read() throws IOException {
ByteBuffer buffer = ByteBuffers.wrap("8=FIX.4.2\u00019=5\u000135=D\u000110=181\u0001");
- assertEquals(true, parser.parse(buffer));
+ assertEquals(true, parse(buffer));
assertEquals(0, buffer.remaining());
@@ -115,7 +107,7 @@ public class FIXMessageParserTest {
public void readFixt11() throws IOException {
ByteBuffer buffer = ByteBuffers.wrap("8=FIXT.1.1\u00019=5\u000135=D\u000110=005\u0001");
- assertEquals(true, parser.parse(buffer));
+ assertEquals(true, parse(buffer));
assertEquals(0, buffer.remaining());
@@ -129,11 +121,19 @@ public class FIXMessageParserTest {
private void readGarbledOrPartial(String input, int remaining) throws IOException {
ByteBuffer buffer = ByteBuffers.wrap(input);
- assertEquals(false, parser.parse(buffer));
+ assertEquals(false, parse(buffer));
assertEquals(remaining, buffer.remaining());
assertEquals(asList(), messages.collect());
}
+ private boolean parse(ByteBuffer buffer) throws IOException {
+ FIXMessage message = new FIXMessage(32, 32);
+
+ FIXMessageParser parser = new FIXMessageParser(messages, message);
+
+ return parser.parse(buffer);
+ }
+
}
