Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-18.04, macOS-latest, windows-2016]
java: [8, 11, 15]
java: [8, 11, 17]
fail-fast: false
max-parallel: 4
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
Expand Down
100 changes: 75 additions & 25 deletions quickfixj-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<artifactId>mockito-core</artifactId>
<version>3.12.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -379,29 +379,6 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx512m -Djava.net.preferIPv4Stack=true</argLine>
<trimStackTrace>false</trimStackTrace>
<includes>
<include>**/*Test.java</include>
<include>${acceptance.tests}</include>
</includes>
<excludes>
<exclude>**/*ForTest.java</exclude>
<exclude>**/Abstract*Test.java</exclude>
<exclude>**/AcceptanceTestSuite$*</exclude>
</excludes>
<systemPropertyVariables>
<atest.heartbeat>5</atest.heartbeat>
<atest.timeout>60000</atest.timeout>
<atest.reconnectDelay>5</atest.reconnectDelay>
<atest.skipslow>false</atest.skipslow>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -436,5 +413,78 @@
<acceptance.tests />
</properties>
</profile>
<!-- select different java options on JDK8 for surefire since otherwise the build will fail -->
<profile>
<id>surefire-java8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-Xmx512m -Djava.net.preferIPv4Stack=true
</argLine>
<trimStackTrace>false</trimStackTrace>
<includes>
<include>**/*Test.java</include>
<include>${acceptance.tests}</include>
</includes>
<excludes>
<exclude>**/*ForTest.java</exclude>
<exclude>**/Abstract*Test.java</exclude>
<exclude>**/AcceptanceTestSuite$*</exclude>
</excludes>
<systemPropertyVariables>
<atest.heartbeat>5</atest.heartbeat>
<atest.timeout>60000</atest.timeout>
<atest.reconnectDelay>5</atest.reconnectDelay>
<atest.skipslow>false</atest.skipslow>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- surefire for JDK9 and upwards -->
<profile>
<id>surefire</id>
<activation>
<jdk>[1.9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-Xmx512m -Djava.net.preferIPv4Stack=true
--add-opens java.base/java.lang=ALL-UNNAMED
</argLine>
<trimStackTrace>false</trimStackTrace>
<includes>
<include>**/*Test.java</include>
<include>${acceptance.tests}</include>
</includes>
<excludes>
<exclude>**/*ForTest.java</exclude>
<exclude>**/Abstract*Test.java</exclude>
<exclude>**/AcceptanceTestSuite$*</exclude>
</excludes>
<systemPropertyVariables>
<atest.heartbeat>5</atest.heartbeat>
<atest.timeout>60000</atest.timeout>
<atest.reconnectDelay>5</atest.reconnectDelay>
<atest.skipslow>false</atest.skipslow>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
13 changes: 0 additions & 13 deletions quickfixj-core/src/test/java/quickfix/MessageCrackerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.stub;

import java.io.InvalidObjectException;

import org.junit.Before;
import org.junit.Test;

import quickfix.MessageCracker.RedundantHandlerException;
Expand All @@ -41,14 +38,6 @@

public class MessageCrackerTest {
private int messageCracked;
private Session mockSession;

@Before
public void setUp() throws Exception {
mockSession = mock(Session.class);
stub(mockSession.getTargetDefaultApplicationVersionID()).toReturn(
new ApplVerID(ApplVerID.FIX50SP2));
}

@Test(expected=UnsupportedMessageType.class)
public void testInvokerException1() throws Exception {
Expand Down Expand Up @@ -241,8 +230,6 @@ public void onMessage(quickfix.fix44.Email email, SessionID sessionID) {
@Test
public void testFixtMessageCrackingWithSessionDefaultApplVerID() throws Exception {
quickfix.fix44.Email message = createFix44Email();
stub(mockSession.getTargetDefaultApplicationVersionID()).toReturn(
new ApplVerID(ApplVerID.FIX44));

MessageCracker cracker = new MessageCracker() {
@SuppressWarnings("unused")
Expand Down
50 changes: 35 additions & 15 deletions quickfixj-core/src/test/java/quickfix/MessageUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package quickfix;

import junit.framework.TestCase;
import quickfix.field.ApplVerID;
import quickfix.field.BeginString;
import quickfix.field.DefaultApplVerID;
Expand All @@ -36,14 +35,18 @@

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import org.junit.Test;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.stub;
import static org.mockito.Mockito.when;

public class MessageUtilsTest extends TestCase {
public class MessageUtilsTest {

@Test
public void testGetStringField() throws Exception {
String messageString = "8=FIX.4.2\0019=12\00135=X\001108=30\00110=049\001";
assertEquals("wrong value", "FIX.4.2", MessageUtils.getStringField(messageString,
Expand All @@ -52,6 +55,7 @@ public void testGetStringField() throws Exception {
assertNull(messageString, MessageUtils.getStringField(messageString, SenderCompID.FIELD));
}

@Test
public void testSessionIdFromMessage() throws Exception {
Message message = new Logon();
message.getHeader().setString(SenderCompID.FIELD, "TW");
Expand All @@ -62,6 +66,7 @@ public void testSessionIdFromMessage() throws Exception {
assertEquals("ISLD", sessionID.getTargetCompID());
}

@Test
public void testReverseSessionIdFromMessage() throws Exception {
Message message = new Logon();
message.getHeader().setString(SenderCompID.FIELD, "TW");
Expand All @@ -72,6 +77,7 @@ public void testReverseSessionIdFromMessage() throws Exception {
assertEquals("TW", sessionID.getTargetCompID());
}

@Test
public void testReverseSessionIdFromMessageWithMissingFields() throws Exception {
Message message = new Logon();
SessionID sessionID = MessageUtils.getReverseSessionID(message);
Expand All @@ -80,6 +86,7 @@ public void testReverseSessionIdFromMessageWithMissingFields() throws Exception
assertEquals(sessionID.getTargetCompID(), SessionID.NOT_SET);
}

@Test
public void testSessionIdFromRawMessage() throws Exception {
String messageString = "8=FIX.4.0\0019=56\00135=A\00134=1\00149=TW\001" +
"52=20060118-16:34:19\00156=ISLD\00198=0\001108=2\00110=223\001";
Expand All @@ -89,6 +96,7 @@ public void testSessionIdFromRawMessage() throws Exception {
assertEquals("ISLD", sessionID.getTargetCompID());
}

@Test
public void testReverseSessionIdFromRawMessage() throws Exception {
String messageString = "8=FIX.4.0\0019=56\00135=A\00134=1\00149=TW\00150=TWS\001" +
"142=TWL\00152=20060118-16:34:19\00156=ISLD\00198=0\001108=2\00110=223\001";
Expand All @@ -100,12 +108,14 @@ public void testReverseSessionIdFromRawMessage() throws Exception {
assertEquals("TWL", sessionID.getTargetLocationID());
}

@Test
public void testMessageType() throws Exception {
String messageString = "8=FIX.4.0\0019=56\00135=A\00134=1\00149=TW\001" +
"52=20060118-16:34:19\00156=ISLD\00198=0\001108=2\00110=223\001";
assertEquals("A", MessageUtils.getMessageType(messageString));
}

@Test
public void testMessageTypeError() throws Exception {
String messageString = "8=FIX.4.0\0019=56\00134=1\00149=TW\001" +
"52=20060118-16:34:19\00156=ISLD\00198=0\001108=2\00110=223\001";
Expand All @@ -117,6 +127,7 @@ public void testMessageTypeError() throws Exception {
}
}

@Test
public void testMessageTypeError2() throws Exception {
String messageString = "8=FIX.4.0\0019=56\00135=1";
try {
Expand All @@ -127,23 +138,26 @@ public void testMessageTypeError2() throws Exception {
}
}

@Test
public void testGetNonexistentStringField() throws Exception {
String messageString = "8=FIX.4.0\0019=56\00134=1\00149=TW\001" +
"52=20060118-16:34:19\00156=ISLD\00198=0\001108=2\00110=223\001";
assertNull(MessageUtils.getStringField(messageString, 35));
}

@Test
public void testGetStringFieldWithBadValue() throws Exception {
String messageString = "8=FIX.4.0\0019=56\00134=1\00149=TW\001" +
"52=20060118-16:34:19\00156=ISLD\00198=0\001108=2\00110=223";
assertNull(MessageUtils.getStringField(messageString, 10));
}

@Test
public void testParse() throws Exception {
Session mockSession = mock(Session.class);
DataDictionaryProvider mockDataDictionaryProvider = mock(DataDictionaryProvider.class);
stub(mockSession.getDataDictionaryProvider()).toReturn(mockDataDictionaryProvider);
stub(mockSession.getMessageFactory()).toReturn(new quickfix.fix40.MessageFactory());
when(mockSession.getDataDictionaryProvider()).thenReturn(mockDataDictionaryProvider);
when(mockSession.getMessageFactory()).thenReturn(new quickfix.fix40.MessageFactory());
String messageString = "8=FIX.4.0\0019=56\00135=A\00134=1\00149=TW\001" +
"52=20060118-16:34:19\00156=ISLD\00198=0\001108=2\00110=223\001";

Expand All @@ -152,6 +166,7 @@ public void testParse() throws Exception {
assertThat(message, is(notNullValue()));
}

@Test
public void testLegacyParse() throws Exception {
String data = "8=FIX.4.4\0019=309\00135=8\00149=ASX\00156=CL1_FIX44\00134=4\001" +
"52=20060324-01:05:58\00117=X-B-WOW-1494E9A0:58BD3F9D-1109\001150=D\001" +
Expand All @@ -164,11 +179,12 @@ public void testLegacyParse() throws Exception {
assertThat(message, is(notNullValue()));
}

@Test
public void testParseFixt() throws Exception {
Session mockSession = mock(Session.class);
DataDictionaryProvider mockDataDictionaryProvider = mock(DataDictionaryProvider.class);
stub(mockSession.getDataDictionaryProvider()).toReturn(mockDataDictionaryProvider);
stub(mockSession.getMessageFactory()).toReturn(new quickfix.fix40.MessageFactory());
when(mockSession.getDataDictionaryProvider()).thenReturn(mockDataDictionaryProvider);
when(mockSession.getMessageFactory()).thenReturn(new quickfix.fix40.MessageFactory());

Email email = new Email(new EmailThreadID("THREAD_ID"), new EmailType(EmailType.NEW), new Subject("SUBJECT"));
email.getHeader().setField(new ApplVerID(ApplVerID.FIX42));
Expand All @@ -181,11 +197,12 @@ public void testParseFixt() throws Exception {
assertThat(message, is(quickfix.fix40.Email.class));
}

@Test
public void testParseFixtLogon() throws Exception {
Session mockSession = mock(Session.class);
DataDictionaryProvider mockDataDictionaryProvider = mock(DataDictionaryProvider.class);
stub(mockSession.getDataDictionaryProvider()).toReturn(mockDataDictionaryProvider);
stub(mockSession.getMessageFactory()).toReturn(new DefaultMessageFactory());
when(mockSession.getDataDictionaryProvider()).thenReturn(mockDataDictionaryProvider);
when(mockSession.getMessageFactory()).thenReturn(new DefaultMessageFactory());

quickfix.fixt11.Logon logon = new quickfix.fixt11.Logon(new EncryptMethod(EncryptMethod.NONE_OTHER), new HeartBtInt(30),
new DefaultApplVerID(ApplVerID.FIX42));
Expand All @@ -196,11 +213,12 @@ public void testParseFixtLogon() throws Exception {
assertThat(message, is(quickfix.fixt11.Logon.class));
}

@Test
public void testParseFixtLogout() throws Exception {
Session mockSession = mock(Session.class);
DataDictionaryProvider mockDataDictionaryProvider = mock(DataDictionaryProvider.class);
stub(mockSession.getDataDictionaryProvider()).toReturn(mockDataDictionaryProvider);
stub(mockSession.getMessageFactory()).toReturn(new DefaultMessageFactory());
when(mockSession.getDataDictionaryProvider()).thenReturn(mockDataDictionaryProvider);
when(mockSession.getMessageFactory()).thenReturn(new DefaultMessageFactory());

quickfix.fixt11.Logout logout = new quickfix.fixt11.Logout();

Expand All @@ -210,11 +228,12 @@ public void testParseFixtLogout() throws Exception {
assertThat(message, is(quickfix.fixt11.Logout.class));
}

@Test
public void testParseFix50() throws Exception {
Session mockSession = mock(Session.class);
DataDictionaryProvider mockDataDictionaryProvider = mock(DataDictionaryProvider.class);
stub(mockSession.getDataDictionaryProvider()).toReturn(mockDataDictionaryProvider);
stub(mockSession.getMessageFactory()).toReturn(new DefaultMessageFactory());
when(mockSession.getDataDictionaryProvider()).thenReturn(mockDataDictionaryProvider);
when(mockSession.getMessageFactory()).thenReturn(new DefaultMessageFactory());

Email email = new Email(new EmailThreadID("THREAD_ID"), new EmailType(EmailType.NEW), new Subject("SUBJECT"));
email.getHeader().setField(new ApplVerID(ApplVerID.FIX50));
Expand All @@ -228,15 +247,16 @@ public void testParseFix50() throws Exception {
}

// QFJ-973
@Test
public void testParseMessageWithoutChecksumValidation() throws InvalidMessage {
Session mockSession = mock(Session.class);
when(mockSession.isValidateChecksum()).thenReturn(Boolean.FALSE);

DataDictionary dataDictionary = mock(DataDictionary.class);
DataDictionaryProvider mockDataDictionaryProvider = mock(DataDictionaryProvider.class);
when(mockDataDictionaryProvider.getSessionDataDictionary(any(String.class))).thenReturn(dataDictionary);
stub(mockSession.getDataDictionaryProvider()).toReturn(mockDataDictionaryProvider);
stub(mockSession.getMessageFactory()).toReturn(new quickfix.fix40.MessageFactory());
when(mockSession.getDataDictionaryProvider()).thenReturn(mockDataDictionaryProvider);
when(mockSession.getMessageFactory()).thenReturn(new quickfix.fix40.MessageFactory());

String messageString = "8=FIX.4.0\0019=56\00135=A\00134=1\00149=TW\001" +
"52=20060118-16:34:19\00156=ISLD\00198=0\001108=2\00110=283\001";
Expand Down
Loading