You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ra...@apache.org on 2019/12/25 15:23:01 UTC
[camel] branch master updated: CAMEL-14330:camel-aws-lambda -
Operation should invoke function by default
This is an automated email from the ASF dual-hosted git repository.
ramu12 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new c15dc14 CAMEL-14330:camel-aws-lambda - Operation should invoke function by default
c15dc14 is described below
commit c15dc14b594fdec8ed6a9480da053baba07ec1a2
Author: Kodanda Ramu Kakarla <kk...@kkakarla.pnq.csb>
AuthorDate: Wed Dec 25 20:51:41 2019 +0530
CAMEL-14330:camel-aws-lambda - Operation should invoke function by default
---
.../camel/component/aws/lambda/LambdaProducer.java | 2 +-
.../lambda/LambdaProducerDefaultFunctionTest.java | 66 ++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
index bc8f1dc..d71cd9a 100644
--- a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
+++ b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
@@ -561,7 +561,7 @@ public class LambdaProducer extends DefaultProducer {
private LambdaOperations determineOperation(Exchange exchange) {
LambdaOperations operation = exchange.getIn().getHeader(LambdaConstants.OPERATION, LambdaOperations.class);
if (operation == null) {
- operation = getConfiguration().getOperation();
+ operation = getConfiguration().getOperation() == null ? LambdaOperations.invokeFunction : getConfiguration().getOperation();
}
return operation;
}
diff --git a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaProducerDefaultFunctionTest.java b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaProducerDefaultFunctionTest.java
new file mode 100644
index 0000000..b9bf0e6
--- /dev/null
+++ b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaProducerDefaultFunctionTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.aws.lambda;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class LambdaProducerDefaultFunctionTest extends CamelTestSupport {
+
+ @BindToRegistry("awsLambdaClient")
+ AmazonLambdaClientMock clientMock = new AmazonLambdaClientMock();
+
+ @EndpointInject("mock:result")
+ private MockEndpoint mock;
+
+
+
+ @Test
+ public void lambdaInvokeFunctionTest() throws Exception {
+ Exchange exchange = template.send("direct:invokeFunction", ExchangePattern.InOut, new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody("{\"name\":\"Camel\"}");
+ }
+ });
+ assertMockEndpointsSatisfied();
+
+ assertNotNull(exchange.getOut().getBody(String.class));
+ assertEquals(exchange.getOut().getBody(String.class), "{\"Hello\":\"Camel\"}");
+ }
+
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:invokeFunction").to("aws-lambda://GetHelloWithName?awsLambdaClient=#awsLambdaClient").to("mock:result");
+
+
+ }
+ };
+ }
+}