From e291b482b8a4033bf5f951995183d40ced2a1b8c Mon Sep 17 00:00:00 2001 From: Grzegorz Grzybek Date: Tue, 11 Feb 2014 16:41:17 +0100 Subject: [PATCH] CAMEL-7184 Ensure that QFJ consumers have their engines initialized --- .../quickfixj/QuickfixjConsumer.java | 6 +++ .../quickfixj/QuickfixjConsumerTest.java | 6 +-- .../quickfixj/QuickfixjSpringTest-context.xml | 38 ++++++++++++++++--- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjConsumer.java b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjConsumer.java index 5720b919cf9de..31efae81edd6d 100644 --- a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjConsumer.java +++ b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjConsumer.java @@ -31,6 +31,12 @@ public QuickfixjConsumer(Endpoint endpoint, Processor processor) { super(endpoint, processor); } + @Override + protected void doStart() throws Exception { + ((QuickfixjEndpoint)getEndpoint()).ensureInitialized(); + super.doStart(); + } + public void onExchange(Exchange exchange) throws Exception { if (isStarted()) { try { diff --git a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java index 6bad0f51d2cc9..1c7e28e49e6e8 100644 --- a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java +++ b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConsumerTest.java @@ -16,7 +16,6 @@ */ package org.apache.camel.component.quickfixj; -import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.Processor; @@ -37,7 +36,7 @@ public class QuickfixjConsumerTest { private Exchange mockExchange; private Processor mockProcessor; - private Endpoint mockEndpoint; + private QuickfixjEndpoint mockEndpoint; private Message inboundFixMessage; @Before @@ -54,7 +53,7 @@ public void setUp() { Mockito.when(mockCamelMessage.getBody(quickfix.Message.class)).thenReturn(inboundFixMessage); mockProcessor = Mockito.mock(Processor.class); - mockEndpoint = Mockito.mock(Endpoint.class); + mockEndpoint = Mockito.mock(QuickfixjEndpoint.class); Mockito.when(mockEndpoint.createExchange(ExchangePattern.InOnly)).thenReturn(mockExchange); } @@ -71,6 +70,7 @@ public void processExchangeOnlyWhenStarted() throws Exception { Mockito.verifyZeroInteractions(mockProcessor); consumer.start(); + Mockito.verify(mockEndpoint).ensureInitialized(); Assert.assertThat(consumer.isStarted(), CoreMatchers.is(true)); consumer.onExchange(mockExchange); diff --git a/components/camel-quickfix/src/test/resources/org/apache/camel/component/quickfixj/QuickfixjSpringTest-context.xml b/components/camel-quickfix/src/test/resources/org/apache/camel/component/quickfixj/QuickfixjSpringTest-context.xml index 10f9d580d7a37..62710f59deb15 100644 --- a/components/camel-quickfix/src/test/resources/org/apache/camel/component/quickfixj/QuickfixjSpringTest-context.xml +++ b/components/camel-quickfix/src/test/resources/org/apache/camel/component/quickfixj/QuickfixjSpringTest-context.xml @@ -35,11 +35,8 @@ - - - ${in.header.EventCategory} == 'AppMessageReceived' - - + + @@ -60,7 +57,7 @@ - + @@ -97,4 +94,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file