camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1137920 - in /camel/trunk: camel-core/src/test/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/resources/org/apache/camel/spring/impl/
Date Tue, 21 Jun 2011 09:43:02 GMT
Author: davsclaus
Date: Tue Jun 21 09:43:02 2011
New Revision: 1137920

URL: http://svn.apache.org/viewvc?rev=1137920&view=rev
Log:
Added wiki tags for documentation

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceCustomRefTest.java
      - copied, changed from r1137902, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java
Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RefDataFormatTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringRefDataFormatTest.xml

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RefDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RefDataFormatTest.java?rev=1137920&r1=1137919&r2=1137920&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RefDataFormatTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RefDataFormatTest.java Tue
Jun 21 09:43:02 2011
@@ -57,13 +57,20 @@ public class RefDataFormatTest extends C
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:a").marshal().custom("reverse").to("mock:a");
-
-                from("direct:b").unmarshal().custom("reverse").to("mock:b");
+                // START SNIPPET: e1
+                from("direct:a")
+                    .marshal().custom("reverse")
+                    .to("mock:a");
+
+                from("direct:b")
+                    .unmarshal().custom("reverse")
+                    .to("mock:b");
+                // END SNIPPET: e1
             }
         };
     }
 
+    // START SNIPPET: e2
     public static final class MyReverseDataFormat implements DataFormat {
 
         public void marshal(Exchange exchange, Object graph, OutputStream stream) throws
Exception {
@@ -87,5 +94,6 @@ public class RefDataFormatTest extends C
             return sb.toString();
         }
     }
+    // END SNIPPET: e2
 
 }

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceCustomRefTest.java
(from r1137902, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceCustomRefTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceCustomRefTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java&r1=1137902&r2=1137920&rev=1137920&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceCustomRefTest.java
Tue Jun 21 09:43:02 2011
@@ -16,56 +16,16 @@
  */
 package org.apache.camel.processor;
 
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.ServiceSupport;
-import org.apache.camel.spi.DataFormat;
-
-/**
- * Test that data format receives callback if its a service / CamelContextAware
- *
- * @version 
- */
-public class DataFormatServiceTest extends ContextTestSupport {
-
-    private final MyDataFormat my = new MyDataFormat();
-
-    public void testMarshal() throws Exception {
-        assertEquals(true, my.isStarted());
-        assertSame(context, my.getCamelContext());
+import org.apache.camel.impl.JndiRegistry;
 
-        getMockEndpoint("mock:a").expectedBodiesReceived("Hi Camel");
-
-        template.sendBody("direct:a", "Hello World");
-
-        assertMockEndpointsSatisfied();
-
-        context.stop();
-
-        assertEquals(true, my.isStopped());
-        assertSame(context, my.getCamelContext());
-    }
+public class DataFormatServiceCustomRefTest extends DataFormatServiceTest {
 
-    public void testUnmarshal() throws Exception {
-        assertEquals(true, my.isStarted());
-        assertSame(context, my.getCamelContext());
-
-        getMockEndpoint("mock:b").expectedBodiesReceived("Bye World");
-
-        template.sendBody("direct:b", "Hello World");
-
-        assertMockEndpointsSatisfied();
-
-        context.stop();
-
-        assertEquals(true, my.isStopped());
-        assertSame(context, my.getCamelContext());
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("myCustomDataFormat", my);
+        return jndi;
     }
 
     @Override
@@ -73,40 +33,18 @@ public class DataFormatServiceTest exten
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:a").marshal(my).to("mock:a");
-                from("direct:b").unmarshal(my).to("mock:b");
+                // START SNIPPET: e1
+                from("direct:a")
+                    // myCustomDataFormat refers to the data format from the Registry
+                    .marshal().custom("myCustomDataFormat")
+                    .to("mock:a");
+
+                from("direct:b")
+                    .unmarshal().custom("myCustomDataFormat")
+                    .to("mock:b");
+                // END SNIPPET: e1
             }
         };
     }
 
-    private class MyDataFormat extends ServiceSupport implements DataFormat, CamelContextAware
{
-
-        private CamelContext camelContext;
-
-        public CamelContext getCamelContext() {
-            return camelContext;
-        }
-
-        public void setCamelContext(CamelContext camelContext) {
-            this.camelContext = camelContext;
-        }
-
-        public void marshal(Exchange exchange, Object graph, OutputStream stream) throws
Exception {
-            stream.write("Hi Camel".getBytes());
-        }
-
-        public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
-            return "Bye World";
-        }
-
-        @Override
-        protected void doStart() throws Exception {
-            // noop
-        }
-
-        @Override
-        protected void doStop() throws Exception {
-            // noop
-        }
-    }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java?rev=1137920&r1=1137919&r2=1137920&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DataFormatServiceTest.java
Tue Jun 21 09:43:02 2011
@@ -34,7 +34,7 @@ import org.apache.camel.spi.DataFormat;
  */
 public class DataFormatServiceTest extends ContextTestSupport {
 
-    private final MyDataFormat my = new MyDataFormat();
+    protected final MyDataFormat my = new MyDataFormat();
 
     public void testMarshal() throws Exception {
         assertEquals(true, my.isStarted());
@@ -73,13 +73,19 @@ public class DataFormatServiceTest exten
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                // START SNIPPET: e1
+                // marshal using our custom data format. (my is an instance of MyDataFormat)
                 from("direct:a").marshal(my).to("mock:a");
+
+                // unmarshal using our custom data format.
                 from("direct:b").unmarshal(my).to("mock:b");
+                // END SNIPPET: e1
             }
         };
     }
 
-    private class MyDataFormat extends ServiceSupport implements DataFormat, CamelContextAware
{
+    // START SNIPPET: e2
+    public static class MyDataFormat extends ServiceSupport implements DataFormat, CamelContextAware
{
 
         private CamelContext camelContext;
 
@@ -109,4 +115,5 @@ public class DataFormatServiceTest exten
             // noop
         }
     }
+    // END SNIPPET: e2
 }

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringRefDataFormatTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringRefDataFormatTest.xml?rev=1137920&r1=1137919&r2=1137920&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringRefDataFormatTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringRefDataFormatTest.xml
Tue Jun 21 09:43:02 2011
@@ -22,27 +22,29 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <!-- this is our custom data format implementation -->
-    <bean id="reverse" class="org.apache.camel.impl.RefDataFormatTest$MyReverseDataFormat"/>
+  <!-- START SNIPPET: e1 -->
+  <!-- this is our custom data format implementation -->
+  <bean id="reverse" class="org.apache.camel.impl.RefDataFormatTest$MyReverseDataFormat"/>
 
-    <camelContext xmlns="http://camel.apache.org/schema/spring">
-        <route>
-            <from uri="direct:a"/>
-            <marshal>
-                <!-- refer to my custom data format -->
-                <custom ref="reverse"/>
-            </marshal>
-            <to uri="mock:a"/>
-        </route>
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+    <route>
+      <from uri="direct:a"/>
+      <marshal>
+        <!-- refer to my custom data format -->
+        <custom ref="reverse"/>
+      </marshal>
+      <to uri="mock:a"/>
+    </route>
 
-        <route>
-            <from uri="direct:b"/>
-            <unmarshal>
-                <!-- refer to my custom data format -->
-                <custom ref="reverse"/>
-            </unmarshal>
-            <to uri="mock:b"/>
-        </route>
-    </camelContext>
+    <route>
+      <from uri="direct:b"/>
+      <unmarshal>
+        <!-- refer to my custom data format -->
+        <custom ref="reverse"/>
+      </unmarshal>
+      <to uri="mock:b"/>
+    </route>
+  </camelContext>
+  <!-- END SNIPPET: e1 -->
 
 </beans>



Mime
View raw message