Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C3E714159 for ; Tue, 21 Jun 2011 09:43:24 +0000 (UTC) Received: (qmail 51169 invoked by uid 500); 21 Jun 2011 09:43:24 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 51133 invoked by uid 500); 21 Jun 2011 09:43:24 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 51118 invoked by uid 99); 21 Jun 2011 09:43:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jun 2011 09:43:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jun 2011 09:43:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D205123889C5; Tue, 21 Jun 2011 09:43:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@camel.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110621094302.D205123889C5@eris.apache.org> 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 "> - - + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + +