camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1100486 - in /camel/trunk/components/camel-jackson: pom.xml src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatTest.java
Date Sat, 07 May 2011 09:14:32 GMT
Author: davsclaus
Date: Sat May  7 09:14:31 2011
New Revision: 1100486

URL: http://svn.apache.org/viewvc?rev=1100486&view=rev
Log:
CAMEL-3032: Do not use test-jar in pom.xml.

Modified:
    camel/trunk/components/camel-jackson/pom.xml
    camel/trunk/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatTest.java

Modified: camel/trunk/components/camel-jackson/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jackson/pom.xml?rev=1100486&r1=1100485&r2=1100486&view=diff
==============================================================================
--- camel/trunk/components/camel-jackson/pom.xml (original)
+++ camel/trunk/components/camel-jackson/pom.xml Sat May  7 09:14:31 2011
@@ -59,12 +59,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-spring</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
             <scope>test</scope>

Modified: camel/trunk/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatTest.java?rev=1100486&r1=1100485&r2=1100486&view=diff
==============================================================================
--- camel/trunk/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatTest.java
(original)
+++ camel/trunk/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatTest.java
Sat May  7 09:14:31 2011
@@ -16,33 +16,63 @@
  */
 package org.apache.camel.component.jackson;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.Service;
-import org.apache.camel.spring.SpringCamelContext;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * @version 
  */
-public class SpringJacksonJsonDataFormatTest extends JacksonJsonDataFormatTest {
+public class SpringJacksonJsonDataFormatTest extends CamelSpringTestSupport {
+
+    @Test
+    public void testMarshalAndUnmarshalMap() throws Exception {
+
+        Map<String, Object> in = new HashMap<String, Object>();
+        in.put("name", "Camel");
 
-    protected CamelContext createCamelContext() throws Exception {
-        setUseRouteBuilder(false);
+        MockEndpoint mock = getMockEndpoint("mock:reverse");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().isInstanceOf(Map.class);
+        mock.message(0).body().equals(in);
 
-        final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/component/jackson/SpringJacksonJsonDataFormatTest.xml");
-        setCamelContextService(new Service() {
-            public void start() throws Exception {
-                applicationContext.start();
+        Object marshalled = template.requestBody("direct:in", in);
+        String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
+        assertEquals("{\"name\":\"Camel\"}", marshalledAsString);
+
+        template.sendBody("direct:back", marshalled);
+
+        mock.assertIsSatisfied();
+    }
 
-            }
+    @Test
+    public void testMarshalAndUnmarshalPojo() throws Exception {
 
-            public void stop() throws Exception {
-                applicationContext.stop();
-            }
-        });
+        TestPojo in = new TestPojo();
+        in.setName("Camel");
+
+        MockEndpoint mock = getMockEndpoint("mock:reversePojo");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().isInstanceOf(TestPojo.class);
+        mock.message(0).body().equals(in);
+
+        Object marshalled = template.requestBody("direct:inPojo", in);
+        String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
+        assertEquals("{\"name\":\"Camel\"}", marshalledAsString);
+
+        template.sendBody("direct:backPojo", marshalled);
+
+        mock.assertIsSatisfied();
+    }
 
-        return SpringCamelContext.springCamelContext(applicationContext);       
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/jackson/SpringJacksonJsonDataFormatTest.xml");
     }
 
 }



Mime
View raw message