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
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d273b74b6b3f4a87cde3d5503e6f3c2f326c2ad9
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
/client/build
/integration-tests/build
/out
/ideabuild/
/eclipse
/opt
/cache
/ivysettings.xml
/foo.txt
/foo.xml
/.idea
*.iml
/nanofix.ipr

.gradle/

/.idea/
*.iml
!.idea/codeStyleSettings.xml

nanofix-client/build/

7 changes: 0 additions & 7 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
~ limitations under the License.
-->

<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="fileExtensions" value="java, properties"/>
<property name="localeCountry" value="en"/>
<property name="localeLanguage" value="GB"/>
<module name="SeverityMatchFilter">
<property name="severity" value="info" />
<property name="acceptOnMatch" value="false" />
Expand Down Expand Up @@ -89,11 +95,14 @@
<module name="CovariantEquals" />

<module name="LeftCurly">
<property name="option" value="nl" />
<property name="option" value="eol"/>
<property name="tokens" value="INTERFACE_DEF, CLASS_DEF, ANNOTATION_DEF, ENUM_DEF, CTOR_DEF, METHOD_DEF,
ENUM_CONSTANT_DEF, LITERAL_WHILE, LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_SYNCHRONIZED,
LITERAL_SWITCH, LITERAL_DO, LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, STATIC_INIT, OBJBLOCK"/>
</module>

<module name="RightCurly">
<property name="option" value="alone" />
<property name="option" value="same" />
</module>

<module name="EmptyStatement" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@
import org.junit.Assert;
import org.junit.Test;

public class ConnectionNotificationsIntegrationTest
{
public class ConnectionNotificationsIntegrationTest {
private ReadableByteChannel readableByteChannel;
private WritableByteChannel writableByteChannel;
private ByteArrayOutputStream byteArrayOutputStream;

@Test
public void shouldNotifyOnConnectionEstablished() throws Exception
{
public void shouldNotifyOnConnectionEstablished() throws Exception {
FixClient fixClient;
final Lock lock = new ReentrantLock();

Expand All @@ -55,23 +53,19 @@ public void shouldNotifyOnConnectionEstablished() throws Exception
fixClient = FixClientFactory.createFixClient(new IntegrationSocketFactory(readableByteChannel, writableByteChannel));
fixClient.registerTransportObserver(new SignallingConnectionObserver(lock, connectionEstablishedCondition, connectionClosedCondition));

try
{
try {
//when
lock.lock();
fixClient.connect();
final boolean connectionEstablished = connectionEstablishedCondition.await(5, TimeUnit.SECONDS);
Assert.assertTrue(connectionEstablished);
}
finally
{
} finally {
lock.unlock();
}
}

@Test
public void shouldNotifyOnConnectionClosed() throws Exception
{
public void shouldNotifyOnConnectionClosed() throws Exception {
FixClient fixClient;
final Lock lock = new ReentrantLock();

Expand All @@ -84,18 +78,14 @@ public void shouldNotifyOnConnectionClosed() throws Exception
fixClient = FixClientFactory.createFixClient(new IntegrationSocketFactory(readableByteChannel, writableByteChannel));
fixClient.registerTransportObserver(new SignallingConnectionObserver(lock, connectionEstablishedCondition, connectionClosedCondition));

try
{
try {
//when
lock.lock();
fixClient.connect();
final boolean connectionClosed = connectionClosedCondition.await(5, TimeUnit.SECONDS);
Assert.assertTrue(connectionClosed);
}
finally
{
} finally {
lock.unlock();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@

import static org.junit.Assert.assertFalse;

public class FixClientLifecycleTest
{
public class FixClientLifecycleTest {
@Test
public void shouldBeAbleToStartListeningAgainAfterFirstStartingAndThenStopping() throws InterruptedException
{
public void shouldBeAbleToStartListeningAgainAfterFirstStartingAndThenStopping() throws InterruptedException {
Lock lock = new ReentrantLock();
final Condition connectionClosedCondition = lock.newCondition();
final Condition connectionEstablishedCondition = lock.newCondition();
Expand All @@ -46,8 +44,7 @@ public void shouldBeAbleToStartListeningAgainAfterFirstStartingAndThenStopping()

fixClient.listen();

try
{
try {
lock.lock();
final FixClient fixClient2 = FixClientFactory.createFixClient("localhost", 9990);
fixClient2.connect();
Expand All @@ -57,25 +54,21 @@ public void shouldBeAbleToStartListeningAgainAfterFirstStartingAndThenStopping()
final boolean connectionClosed = connectionClosedCondition.await(5, TimeUnit.SECONDS);
Assert.assertTrue(connectionClosed);
fixClient.listen();
}
finally
{
} finally {
lock.unlock();
}
}

@Test
public void shouldBeSafeToCloseAFixClientWhichHasNotLoggedOn()
{
public void shouldBeSafeToCloseAFixClientWhichHasNotLoggedOn() {
// Passes by merit of not throwing an exception

final FixClient fixClient = FixClientFactory.createFixClient(new IntegrationSocketFactory(null, null));
fixClient.close();
}

@Test
public void shouldReportAnUnconnectedFixClientAsNotConnected()
{
public void shouldReportAnUnconnectedFixClientAsNotConnected() {
final FixClient fixClient = FixClientFactory.createFixClient(new IntegrationSocketFactory(null, null));
assertFalse(fixClient.isConnected());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@

import static org.hamcrest.Matchers.is;

public class ReceivingFixMessagesTest
{
public class ReceivingFixMessagesTest {

private static final String EXPECTED_MSG_1 = "8=FIX.4.2\u00019=65\u000135=A\u000149=SERVER\u000156=CLIENT\u000134=177\u000152=20090107-18:15:16\u000198=0\u0001108=30\u000110=062\u0001";
private static final String EXPECTED_MSG_2 = "8=FIX.4.2\u00019=65\u000135=A\u000149=SERVER\u000156=CLIENT\u000134=177\u000134=178\u000152=20090107-18:15:16\u000198=0\u0001108=30" +
Expand All @@ -50,16 +49,14 @@ public class ReceivingFixMessagesTest
private ByteArrayOutputStream byteArrayOutputStream;

@Before
public void setUp() throws Exception
{
public void setUp() throws Exception {
byteArrayOutputStream = new ByteArrayOutputStream();
writableByteChannel = Channels.newChannel(byteArrayOutputStream);
countDownLatch = new CountDownLatch(1);
}

@Test
public void shouldGetFixMessages() throws Exception
{
public void shouldGetFixMessages() throws Exception {
readableByteChannel = Channels.newChannel(new ByteArrayInputStream(EXPECTED_MSG_1.getBytes()));
final FixClient fixClient = buildFixClient();
fixClient.subscribeToAllMessages(new AssertingFixMessageHandler(EXPECTED_MSG_1));
Expand All @@ -69,8 +66,7 @@ public void shouldGetFixMessages() throws Exception
}

@Test
public void shouldGetFixMessageWithDuplicateKey() throws Exception
{
public void shouldGetFixMessageWithDuplicateKey() throws Exception {
readableByteChannel = Channels.newChannel(new ByteArrayInputStream(EXPECTED_MSG_2.getBytes()));
final FixClient fixClient = buildFixClient();
fixClient.subscribeToAllMessages(new AssertingFixMessageHandler(EXPECTED_MSG_2));
Expand All @@ -80,8 +76,7 @@ public void shouldGetFixMessageWithDuplicateKey() throws Exception
}

@Test
public void shouldSendFixMessage() throws Exception
{
public void shouldSendFixMessage() throws Exception {
readableByteChannel = Channels.newChannel(new ByteArrayInputStream(new byte[0]));
final FixClient fixClient = buildFixClient();
fixClient.connect();
Expand All @@ -92,32 +87,24 @@ public void shouldSendFixMessage() throws Exception
Assert.assertThat(byteArrayOutputStream.toString(), is("8=FIX.4.4\u00019=15\u000135=W\u000145=3\u000145=7\u000110=179\u0001"));
}

private final class AssertingFixMessageHandler implements FixMessageHandler
{
private final class AssertingFixMessageHandler implements FixMessageHandler {
private final String expectedMessage;

private AssertingFixMessageHandler(final String expectedMessage)
{
private AssertingFixMessageHandler(final String expectedMessage) {
this.expectedMessage = expectedMessage;
}

@Override
public void onFixMessage(final FixMessage fixMessage)
{
if (expectedMessage.equals(fixMessage.toFixString()))
{
public void onFixMessage(final FixMessage fixMessage) {
if (expectedMessage.equals(fixMessage.toFixString())) {
countDownLatch.countDown();
}
else
{
} else {
throw new RuntimeException("Expected: '" + expectedMessage + "' message does not match actual: " + fixMessage.toFixString());
}

}
}

private FixClient buildFixClient()
{
private FixClient buildFixClient() {
return FixClientFactory.createFixClient(new IntegrationSocketFactory(readableByteChannel, writableByteChannel));
}
}
Loading
Loading