You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ge...@apache.org on 2008/05/20 09:24:37 UTC

svn commit: r658131 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/model/ components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/ components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/

Author: gertv
Date: Tue May 20 00:24:37 2008
New Revision: 658131

URL: http://svn.apache.org/viewvc?rev=658131&view=rev
Log:
CAMEL-519: Adding stream caching to the XML syntax

Added:
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/StreamCachingInterceptorTest.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/streamCachingOnRoute.xml
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java?rev=658131&r1=658130&r2=658131&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java Tue May 20 00:24:37 2008
@@ -229,4 +229,17 @@
         intercept(new StreamCachingInterceptor());
         return this;
     }
+        
+    /**
+     * Enable stream caching on this route
+     * @param enable <code>true</code> for enabling stream caching
+     */
+    @XmlAttribute(required=false)
+    public void setStreamCaching(Boolean enable) {
+        if (enable) {
+            streamCaching();
+        } else {
+            noStreamCaching();
+        }
+    }
 }

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/StreamCachingInterceptorTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/StreamCachingInterceptorTest.java?rev=658131&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/StreamCachingInterceptorTest.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/StreamCachingInterceptorTest.java Tue May 20 00:24:37 2008
@@ -0,0 +1,36 @@
+package org.apache.camel.spring.interceptor;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+import java.io.StringReader;
+
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Route;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.stream.StreamCache;
+
+/**
+ * Test case for enabling stream caching through XML
+ */
+public class StreamCachingInterceptorTest extends ContextTestSupport {
+    
+    public void testStreamCachingInterceptorEnabled() throws Exception {
+        MockEndpoint a = getMockEndpoint("mock:a");
+        a.expectedMessageCount(1);
+
+        StreamSource message = new StreamSource(new StringReader("<hello>world!</hello>"));
+        template.sendBody("direct:a", message);
+
+        assertMockEndpointsSatisifed();
+        //assertTrue(a.assertExchangeReceived(0).getIn().getBody() instanceof StreamCache);
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/interceptor/streamCachingOnRoute.xml");
+    }
+
+}

Added: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/streamCachingOnRoute.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/streamCachingOnRoute.xml?rev=658131&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/streamCachingOnRoute.xml (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/streamCachingOnRoute.xml Tue May 20 00:24:37 2008
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd 
+    ">
+
+  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+    <!--  START SNIPPET: streamCache -->
+    <route streamCaching="true">
+      <from uri="direct:a"/>
+      <to uri="mock:a"/>
+    </route>
+    <!--  END SNIPPET: streamCache -->
+  </camelContext>  
+
+</beans>