You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/11/26 16:15:30 UTC

svn commit: r1206456 - in /camel/trunk/components/camel-quickfix: pom.xml src/test/java/org/apache/camel/component/quickfixj/QuickfixjProducerTest.java src/test/java/org/apache/camel/component/quickfixj/QuickfixjSpringTest.java

Author: davsclaus
Date: Sat Nov 26 15:15:28 2011
New Revision: 1206456

URL: http://svn.apache.org/viewvc?rev=1206456&view=rev
Log:
CAMEL-4716: Polished camel-quickfix to remove dep on Spring JAR

Modified:
    camel/trunk/components/camel-quickfix/pom.xml
    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/QuickfixjSpringTest.java

Modified: camel/trunk/components/camel-quickfix/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/pom.xml?rev=1206456&r1=1206455&r2=1206456&view=diff
==============================================================================
--- camel/trunk/components/camel-quickfix/pom.xml (original)
+++ camel/trunk/components/camel-quickfix/pom.xml Sat Nov 26 15:15:28 2011
@@ -15,83 +15,81 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
-	<modelVersion>4.0.0</modelVersion>
+  <modelVersion>4.0.0</modelVersion>
 
-        <parent>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-parent</artifactId>
-            <version>2.9-SNAPSHOT</version>
-            <relativePath>../../parent</relativePath>
-	</parent>
-
-	<artifactId>camel-quickfix</artifactId>
-	<packaging>bundle</packaging>
-	<name>Camel :: QuickFIX/J</name>
-	<description>Camel QuickFIX/J support</description>
-
-        <properties>
-	    <camel.osgi.export.pkg>org.apache.camel.component.quickfixj.*</camel.osgi.export.pkg>
-            <camel.osgi.import.additional>org.slf4j*;resolution:=optional</camel.osgi.import.additional>
-        </properties>
-
-    <repositories>
-        <repository>
-            <id>smx.m2</id>
-            <name>ServiceMix M2 Repository</name>
-            <url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
-        </repository>
-    </repositories>
-
-	<dependencies>
-		<dependency>
-			<groupId>org.apache.camel</groupId>
-			<artifactId>camel-core</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.camel</groupId>
-			<artifactId>camel-spring</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.quickfixj</groupId>
-			<artifactId>quickfixj-all</artifactId>
-			<version>${quickfix-version}</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.mina</groupId>
-			<artifactId>mina-core</artifactId>
-		</dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-
-        <dependency>
-			<groupId>org.apache.camel</groupId>
-			<artifactId>camel-jetty</artifactId>
-            <scope>test</scope>
-        </dependency>
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-log4j12</artifactId>
-			<scope>test</scope>
-		</dependency>
-	    <dependency>
-	      <groupId>org.springframework</groupId>
-	      <artifactId>spring-test</artifactId>
-	      <scope>test</scope>
-	    </dependency>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.mockito</groupId>
-			<artifactId>mockito-core</artifactId>
-			<scope>test</scope>
-		</dependency>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>2.9-SNAPSHOT</version>
+    <relativePath>../../parent</relativePath>
+  </parent>
+
+  <artifactId>camel-quickfix</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: QuickFIX/J</name>
+  <description>Camel QuickFIX/J support</description>
+
+  <properties>
+    <camel.osgi.export.pkg>org.apache.camel.component.quickfixj.*</camel.osgi.export.pkg>
+    <camel.osgi.import.additional>org.slf4j*;resolution:=optional</camel.osgi.import.additional>
+  </properties>
+
+  <repositories>
+    <repository>
+      <id>smx.m2</id>
+      <name>ServiceMix M2 Repository</name>
+      <url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
+    </repository>
+  </repositories>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.quickfixj</groupId>
+      <artifactId>quickfixj-all</artifactId>
+      <version>${quickfix-version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jetty</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.mina</groupId>
+      <artifactId>mina-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
 
-	</dependencies>
+  </dependencies>
 </project>

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=1206456&r1=1206455&r2=1206456&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 Sat Nov 26 15:15:28 2011
@@ -19,7 +19,6 @@ package org.apache.camel.component.quick
 import java.io.IOException;
 import java.util.Timer;
 import java.util.TimerTask;
-
 import javax.management.JMException;
 
 import org.apache.camel.Exchange;
@@ -30,7 +29,6 @@ import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
-
 import quickfix.ConfigError;
 import quickfix.FieldConvertError;
 import quickfix.FixVersions;
@@ -131,8 +129,7 @@ public class QuickfixjProducerTest {
                         try {
                             quickfixjEngine.getMessageCorrelator().onEvent(QuickfixjEventCategory.AppMessageReceived, sessionID, outboundFixMessage);
                         } catch (Exception e) {
-                            // TODO: probably not the best thing... use a LOG
-                            e.printStackTrace();
+                            throw new RuntimeException(e);
                         }
                     }
                 }, 10);

Modified: camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjSpringTest.java?rev=1206456&r1=1206455&r2=1206456&view=diff
==============================================================================
--- camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjSpringTest.java (original)
+++ camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjSpringTest.java Sat Nov 26 15:15:28 2011
@@ -18,13 +18,12 @@ package org.apache.camel.component.quick
 
 import java.util.Properties;
 
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
 import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
 import quickfix.DefaultMessageFactory;
 import quickfix.FixVersions;
 import quickfix.Message;
@@ -36,22 +35,22 @@ import quickfix.fix42.NewOrderSingle;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration
-public class QuickfixjSpringTest {
-    @Autowired(required = true)
-    private QuickfixjComponent component;
+public class QuickfixjSpringTest extends CamelSpringTestSupport {
 
-    @Autowired(required = true)
-    private SessionSettings springSessionSettings;
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/quickfixj/QuickfixjSpringTest-context.xml");
+    }
 
     @Test
     public void configureInSpring() throws Exception {
         SessionID sessionID = new SessionID("FIX.4.2:INITIATOR->ACCEPTOR");
+        SessionSettings springSessionSettings = context.getRegistry().lookup("quickfixjSettings", SessionSettings.class);
         Properties sessionProperties = springSessionSettings.getSessionProperties(sessionID, true);
         Assert.assertThat(sessionProperties.get("ConnectionType").toString(), CoreMatchers.is("initiator"));
         Assert.assertThat(sessionProperties.get("SocketConnectProtocol").toString(), CoreMatchers.is("VM_PIPE"));
 
+        QuickfixjComponent component = context.getComponent("quickfix", QuickfixjComponent.class);
         QuickfixjEngine engine = component.getEngines().values().iterator().next();
 
         Assert.assertThat(engine.getMessageFactory(), is(instanceOf(CustomMessageFactory.class)));