Author: bvahdat
Date: Wed May 1 04:26:26 2013
New Revision: 1477911
URL: http://svn.apache.org/r1477911
Log:
Polished.
Modified:
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjProducer.java
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutor.java
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutorComponent.java
Modified:
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java
(original)
+++
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java
Wed May 1 04:26:26 2013
@@ -65,6 +65,7 @@ public class QuickfixjEndpoint extends D
this.sessionID = sessionID;
}
+ @Override
public Consumer createConsumer(Processor processor) throws Exception {
LOG.info("Creating QuickFIX/J consumer: {}, ExchangePattern={}",
sessionID != null ? sessionID : "No Session", getExchangePattern());
QuickfixjConsumer consumer = new QuickfixjConsumer(this, processor);
@@ -73,6 +74,7 @@ public class QuickfixjEndpoint extends D
return consumer;
}
+ @Override
public Producer createProducer() throws Exception {
LOG.info("Creating QuickFIX/J producer: {}", sessionID != null ?
sessionID : "No Session");
if (isWildcarded()) {
@@ -81,10 +83,12 @@ public class QuickfixjEndpoint extends D
return new QuickfixjProducer(this);
}
+ @Override
public boolean isSingleton() {
return true;
}
+ @Override
public void onEvent(QuickfixjEventCategory eventCategory, SessionID
sessionID, Message message) throws Exception {
if (this.sessionID == null || isMatching(sessionID)) {
for (QuickfixjConsumer consumer : consumers) {
@@ -127,6 +131,7 @@ public class QuickfixjEndpoint extends D
|| sessionID.getTargetLocationID().equals("*");
}
+ @Override
public boolean isMultipleConsumersSupported() {
return true;
}
Modified:
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java
(original)
+++
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java
Wed May 1 04:26:26 2013
@@ -400,6 +400,7 @@ public class QuickfixjEngine extends Ser
}
private class Dispatcher implements Application {
+ @Override
public void fromAdmin(Message message, SessionID sessionID) throws
FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {
try {
dispatch(QuickfixjEventCategory.AdminMessageReceived,
sessionID, message);
@@ -414,6 +415,7 @@ public class QuickfixjEngine extends Ser
}
}
+ @Override
public void fromApp(Message message, SessionID sessionID) throws
FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
try {
dispatch(QuickfixjEventCategory.AppMessageReceived, sessionID,
message);
@@ -428,6 +430,7 @@ public class QuickfixjEngine extends Ser
}
}
+ @Override
public void onCreate(SessionID sessionID) {
try {
dispatch(QuickfixjEventCategory.SessionCreated, sessionID,
null);
@@ -436,6 +439,7 @@ public class QuickfixjEngine extends Ser
}
}
+ @Override
public void onLogon(SessionID sessionID) {
try {
dispatch(QuickfixjEventCategory.SessionLogon, sessionID, null);
@@ -444,6 +448,7 @@ public class QuickfixjEngine extends Ser
}
}
+ @Override
public void onLogout(SessionID sessionID) {
try {
dispatch(QuickfixjEventCategory.SessionLogoff, sessionID,
null);
@@ -452,6 +457,7 @@ public class QuickfixjEngine extends Ser
}
}
+ @Override
public void toAdmin(Message message, SessionID sessionID) {
try {
dispatch(QuickfixjEventCategory.AdminMessageSent, sessionID,
message);
@@ -460,6 +466,7 @@ public class QuickfixjEngine extends Ser
}
}
+ @Override
public void toApp(Message message, SessionID sessionID) throws
DoNotSend {
try {
dispatch(QuickfixjEventCategory.AppMessageSent, sessionID,
message);
Modified:
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjProducer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjProducer.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjProducer.java
(original)
+++
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjProducer.java
Wed May 1 04:26:26 2013
@@ -40,6 +40,7 @@ public class QuickfixjProducer extends D
return (QuickfixjEndpoint) super.getEndpoint();
}
+ @Override
public void process(Exchange exchange) throws Exception {
try {
sendMessage(exchange, exchange.getIn());
Modified:
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
(original)
+++
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
Wed May 1 04:26:26 2013
@@ -225,6 +225,7 @@ public class QuickfixjComponentTest {
final CountDownLatch latch = new CountDownLatch(1);
Consumer consumer = endpoint.createConsumer(new Processor() {
+ @Override
public void process(Exchange exchange) throws Exception {
QuickfixjEventCategory eventCategory =
(QuickfixjEventCategory)
exchange.getIn().getHeader(QuickfixjEndpoint.EVENT_CATEGORY_KEY);
@@ -280,6 +281,7 @@ public class QuickfixjComponentTest {
final CountDownLatch messageLatch = new CountDownLatch(2);
Consumer consumer = endpoint.createConsumer(new Processor() {
+ @Override
public void process(Exchange exchange) throws Exception {
QuickfixjEventCategory eventCategory =
(QuickfixjEventCategory)
exchange.getIn().getHeader(QuickfixjEndpoint.EVENT_CATEGORY_KEY);
Modified:
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java
(original)
+++
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java
Wed May 1 04:26:26 2013
@@ -20,7 +20,6 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Processor;
-import org.apache.camel.StatefulService;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Before;
@@ -64,7 +63,7 @@ public class QuickfixjConsumerTest {
QuickfixjConsumer consumer = new QuickfixjConsumer(mockEndpoint,
mockProcessor);
Assert.assertThat("Consumer should not be automatically started",
- ((StatefulService)consumer).isStarted(), CoreMatchers.is(false));
+ consumer.isStarted(), CoreMatchers.is(false));
consumer.onExchange(mockExchange);
@@ -72,7 +71,7 @@ public class QuickfixjConsumerTest {
Mockito.verifyZeroInteractions(mockProcessor);
consumer.start();
- Assert.assertThat(((StatefulService)consumer).isStarted(),
CoreMatchers.is(true));
+ Assert.assertThat(consumer.isStarted(), CoreMatchers.is(true));
consumer.onExchange(mockExchange);
@@ -104,7 +103,6 @@ public class QuickfixjConsumerTest {
Mockito.doReturn(null).when(consumer).getSession(mockSessionId);
Mockito.when(mockExchange.getPattern()).thenReturn(ExchangePattern.InOut);
- Mockito.when(mockExchange.copy()).thenReturn(mockExchange);
Mockito.when(mockExchange.hasOut()).thenReturn(true);
Mockito.when(mockExchange.getOut()).thenReturn(mockCamelOutMessage);
Message outboundFixMessage = new Message();
@@ -117,7 +115,7 @@ public class QuickfixjConsumerTest {
// Simulate a message from the FIX engine
consumer.onExchange(mockExchange);
-
Mockito.verify(mockExchange).setException(Mockito.isA(IllegalStateException.class));
+
Mockito.verify(mockExchange).setException(Matchers.isA(IllegalStateException.class));
}
@Test
@@ -129,10 +127,9 @@ public class QuickfixjConsumerTest {
QuickfixjConsumer consumer = Mockito.spy(new
QuickfixjConsumer(mockEndpoint, mockProcessor));
Mockito.doReturn(mockSession).when(consumer).getSession(mockSessionId);
-
Mockito.doReturn(true).when(mockSession).send(Mockito.isA(Message.class));
+
Mockito.doReturn(true).when(mockSession).send(Matchers.isA(Message.class));
Mockito.when(mockExchange.getPattern()).thenReturn(ExchangePattern.InOut);
- Mockito.when(mockExchange.copy()).thenReturn(mockExchange);
Mockito.when(mockExchange.hasOut()).thenReturn(true);
Mockito.when(mockExchange.getOut()).thenReturn(mockCamelOutMessage);
Message outboundFixMessage = new Message();
@@ -143,7 +140,7 @@ public class QuickfixjConsumerTest {
consumer.start();
consumer.onExchange(mockExchange);
- Mockito.verify(mockExchange,
Mockito.never()).setException(Mockito.isA(Exception.class));
+ Mockito.verify(mockExchange,
Mockito.never()).setException(Matchers.isA(Exception.class));
Mockito.verify(mockSession).send(outboundFixMessage);
}
}
Modified:
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
(original)
+++
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
Wed May 1 04:26:26 2013
@@ -57,6 +57,7 @@ public class QuickfixjConvertersTest ext
private QuickfixjEngine quickfixjEngine;
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -74,6 +75,7 @@ public class QuickfixjConvertersTest ext
settings.setString(Initiator.SETTING_SOCKET_CONNECT_PROTOCOL,
TransportType.VM_PIPE.toString());
}
+ @Override
@After
public void tearDown() throws Exception {
Thread.currentThread().setContextClassLoader(contextClassLoader);
Modified:
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java
(original)
+++
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java
Wed May 1 04:26:26 2013
@@ -417,6 +417,7 @@ public class QuickfixjEngineTest extends
final CountDownLatch logonLatch = new CountDownLatch(2);
QuickfixjEventListener logonListener = new QuickfixjEventListener() {
+ @Override
public synchronized void onEvent(QuickfixjEventCategory
eventCategory, SessionID sessionID, Message message) {
events.add(new EventRecord(eventCategory, sessionID, message));
if (eventCategory == QuickfixjEventCategory.SessionLogon) {
@@ -454,6 +455,7 @@ public class QuickfixjEngineTest extends
final CountDownLatch messageLatch = new CountDownLatch(1);
QuickfixjEventListener messageListener = new QuickfixjEventListener() {
+ @Override
public synchronized void onEvent(QuickfixjEventCategory
eventCategory, SessionID sessionID, Message message) {
EventRecord event = new EventRecord(eventCategory, sessionID,
message);
events.add(event);
@@ -489,6 +491,7 @@ public class QuickfixjEngineTest extends
final CountDownLatch logoffLatch = new CountDownLatch(2);
QuickfixjEventListener logoffListener = new QuickfixjEventListener() {
+ @Override
public synchronized void onEvent(QuickfixjEventCategory
eventCategory, SessionID sessionID, Message message) {
EventRecord event = new EventRecord(eventCategory, sessionID,
message);
events.add(event);
Modified:
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java
(original)
+++
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java
Wed May 1 04:26:26 2013
@@ -83,7 +83,7 @@ public class QuickfixjProducerTest {
public void setExceptionOnExchange() throws Exception {
Session mockSession =
Mockito.spy(TestSupport.createSession(sessionID));
Mockito.doReturn(mockSession).when(producer).getSession(MessageUtils.getSessionID(inboundFixMessage));
- Mockito.doThrow(new
TestException()).when(mockSession).send(Mockito.isA(Message.class));
+ Mockito.doThrow(new
TestException()).when(mockSession).send(Matchers.isA(Message.class));
producer.process(mockExchange);
Mockito.verify(mockExchange).setException(Matchers.isA(TestException.class));
@@ -93,7 +93,7 @@ public class QuickfixjProducerTest {
public void processInOnlyExchangeSuccess() throws Exception {
Session mockSession =
Mockito.spy(TestSupport.createSession(sessionID));
Mockito.doReturn(mockSession).when(producer).getSession(MessageUtils.getSessionID(inboundFixMessage));
-
Mockito.doReturn(true).when(mockSession).send(Mockito.isA(Message.class));
+
Mockito.doReturn(true).when(mockSession).send(Matchers.isA(Message.class));
producer.process(mockExchange);
@@ -105,7 +105,7 @@ public class QuickfixjProducerTest {
public void processInOnlyExchangeSendUnsuccessful() throws Exception {
Session mockSession =
Mockito.spy(TestSupport.createSession(sessionID));
Mockito.doReturn(mockSession).when(producer).getSession(MessageUtils.getSessionID(inboundFixMessage));
-
Mockito.doReturn(false).when(mockSession).send(Mockito.isA(Message.class));
+
Mockito.doReturn(false).when(mockSession).send(Matchers.isA(Message.class));
producer.process(mockExchange);
@@ -115,7 +115,6 @@ public class QuickfixjProducerTest {
@Test
public void processInOutExchangeSuccess() throws Exception {
- Mockito.when(mockExchange.copy()).thenReturn(mockExchange);
Mockito.when(mockExchange.getPattern()).thenReturn(ExchangePattern.InOut);
SessionID responseSessionID = new
SessionID(sessionID.getBeginString(), sessionID.getTargetCompID(),
sessionID.getSenderCompID());
Mockito.when(mockExchange.getProperty(QuickfixjProducer.CORRELATION_CRITERIA_KEY)).thenReturn(
@@ -148,7 +147,7 @@ public class QuickfixjProducerTest {
}, 10);
return true;
}
- }).when(mockSession).send(Mockito.isA(Message.class));
+ }).when(mockSession).send(Matchers.isA(Message.class));
producer.process(mockExchange);
@@ -190,11 +189,11 @@ public class QuickfixjProducerTest {
}, 10);
return false;
}
- }).when(mockSession).send(Mockito.isA(Message.class));
+ }).when(mockSession).send(Matchers.isA(Message.class));
producer.process(mockExchange);
- Mockito.verify(mockOutboundCamelMessage,
Mockito.never()).setBody(Mockito.isA(Message.class));
+ Mockito.verify(mockOutboundCamelMessage,
Mockito.never()).setBody(Matchers.isA(Message.class));
Mockito.verify(mockSession).send(inboundFixMessage);
Mockito.verify(mockExchange).setException(Matchers.isA(CannotSendException.class));
}
Modified:
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutor.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutor.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutor.java
(original)
+++
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutor.java
Wed May 1 04:26:26 2013
@@ -424,10 +424,12 @@ public class TradeExecutor {
this.defaultMarketPrice = defaultMarketPrice;
}
+ @Override
public double getAsk(String symbol) {
return defaultMarketPrice;
}
+ @Override
public double getBid(String symbol) {
return defaultMarketPrice;
}
Modified:
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutorComponent.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutorComponent.java?rev=1477911&r1=1477910&r2=1477911&view=diff
==============================================================================
---
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutorComponent.java
(original)
+++
camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/examples/trading/TradeExecutorComponent.java
Wed May 1 04:26:26 2013
@@ -66,6 +66,7 @@ public class TradeExecutorComponent exte
}
private static class TradeExecutorThreadFactory implements ThreadFactory {
+ @Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r, "Trade Executor");
thread.setDaemon(true);
@@ -98,8 +99,9 @@ public class TradeExecutorComponent exte
super(uri, TradeExecutorComponent.this);
this.tradeExecutor = tradeExecutor;
tradeExecutor.addListener(new QuickfixjMessageListener() {
+ @Override
public void onMessage(SessionID sessionID, Message message)
throws Exception {
- // Inject session ID into message so produce will know
where to send it
+ // Inject session ID into message so producer will know
where to send it
Header header = message.getHeader();
setOptionalField(header, sessionID, SenderCompID.FIELD,
sessionID.getTargetCompID());
setOptionalField(header, sessionID, SenderSubID.FIELD,
sessionID.getTargetSubID());
@@ -125,10 +127,13 @@ public class TradeExecutorComponent exte
});
}
+ @Override
public Producer createProducer() throws Exception {
return new DefaultProducer(this) {
+ @Override
public void process(final Exchange exchange) throws Exception {
executor.execute(new Runnable() {
+ @Override
public void run() {
try {
tradeExecutor.execute(exchange.getIn().getMandatoryBody(Message.class));
@@ -141,6 +146,7 @@ public class TradeExecutorComponent exte
};
}
+ @Override
public Consumer createConsumer(Processor processor) throws Exception {
return new DefaultConsumer(this, processor) {
@Override
@@ -148,12 +154,14 @@ public class TradeExecutorComponent exte
processors.add(getProcessor());
}
+ @Override
protected void doStop() throws Exception {
processors.remove(getProcessor());
}
};
}
+ @Override
public boolean isSingleton() {
return false;
}