You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dh...@apache.org on 2014/06/28 01:22:20 UTC

[2/5] git commit: Added test utility methods for generated tests in API component framework

Added test utility methods for generated tests in API component framework


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6fccf69b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6fccf69b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6fccf69b

Branch: refs/heads/master
Commit: 6fccf69b77d9f3e6a26278955437f8fe3d0aa0e7
Parents: 7ffeccf
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Fri Jun 27 15:02:23 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Fri Jun 27 16:22:04 2014 -0700

----------------------------------------------------------------------
 .../src/test/java/Abstract__name__TestSupport.java    | 12 ++++++++++++
 .../src/main/resources/api-route-test.vm              |  8 ++++----
 .../camel/component/test/AbstractTestTestSupport.java | 14 ++++++++++++++
 3 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6fccf69b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/java/Abstract__name__TestSupport.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/java/Abstract__name__TestSupport.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/java/Abstract__name__TestSupport.java
index 0ad30f9..94c1fdc 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/java/Abstract__name__TestSupport.java
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/java/Abstract__name__TestSupport.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.IntrospectionSupport;
 
@@ -68,4 +69,15 @@ public class Abstract${name}TestSupport extends CamelTestSupport {
         // only create the context once for this class
         return true;
     }
+
+    @SuppressWarnings("unchecked")
+    protected <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers)
+        throws CamelExecutionException {
+        return (T) template().requestBodyAndHeaders(endpointUri, body, headers);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <T> T requestBody(String endpoint, Object body) throws CamelExecutionException {
+        return (T) template().requestBody(endpoint, body);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/6fccf69b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm
index 18f8873..5c91def 100644
--- a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm
@@ -73,15 +73,15 @@ public class ${testName} extends Abstract${componentName}TestSupport {
 
 #end
 ## method invocation result
-        #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) )$type result = (${type})#end
+        #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) )final $type result = #end
 ## actual template call
 #if ( $args.isEmpty() )
-template().requestBody("direct://${model.UniqueName}", (Object)null);
+requestBody("direct://${model.UniqueName}", null);
 #elseif ( $args.size() == 1 )
 ## typecast body to avoid requestBody() conflict
-template().requestBody("direct://${model.UniqueName}", (${helper.getCanonicalName($argType)}) $helper.getDefaultArgValue($argType));
+requestBody("direct://${model.UniqueName}", $helper.getDefaultArgValue($argType));
 #else
-template().requestBodyAndHeaders("direct://${model.UniqueName}", null, headers);
+requestBodyAndHeaders("direct://${model.UniqueName}", null, headers);
 #end
 #if ( !$voidResult )
 

http://git-wip-us.apache.org/repos/asf/camel/blob/6fccf69b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/AbstractTestTestSupport.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/AbstractTestTestSupport.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/AbstractTestTestSupport.java
index f4de882..3b71884 100644
--- a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/AbstractTestTestSupport.java
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/AbstractTestTestSupport.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.test;
 
+import java.util.Map;
+
+import org.apache.camel.CamelExecutionException;
 import org.apache.camel.test.junit4.CamelTestSupport;
 
 /**
@@ -28,4 +31,15 @@ public class AbstractTestTestSupport extends CamelTestSupport {
         // only create the context once for this class
         return true;
     }
+
+    @SuppressWarnings("unchecked")
+    protected <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers)
+        throws CamelExecutionException {
+        return (T) template().requestBodyAndHeaders(endpointUri, body, headers);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <T> T requestBody(String endpoint, Object body) throws CamelExecutionException {
+        return (T) template().requestBody(endpoint, body);
+    }
 }