This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch camel-quarkus-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git

commit 62a509d6d60e34d9b40334d8addd660641473b3e
Author: aldettinger <[email protected]>
AuthorDate: Mon Aug 16 11:02:26 2021 +0200

    Fix aws-lambda license check issues and shrink example
---
 .github/test-categories.yaml                       |   1 +
 aws-lambda/{README.md => README.adoc}              | 108 +++++++++++++--------
 aws-lambda/pom.xml                                 |  11 ++-
 aws-lambda/src/main/docker/Dockerfile.jvm          |  17 ++++
 aws-lambda/src/main/docker/Dockerfile.native       |  17 ++++
 .../src/main/docker/Dockerfile.native-distroless   |  17 ++++
 .../apache/camel/quarkus/examples/CamelRoute.java  |   2 +-
 .../quarkus/examples/AWSLambdaHandlerTest.java     |  19 ++--
 docs/modules/ROOT/attachments/examples.json        |  10 +-
 9 files changed, 139 insertions(+), 63 deletions(-)

diff --git a/.github/test-categories.yaml b/.github/test-categories.yaml
index c6b5405..00279ed 100644
--- a/.github/test-categories.yaml
+++ b/.github/test-categories.yaml
@@ -27,6 +27,7 @@ group-03:
   - http-log
   - rest-json
 group-04:
+  - aws-lambda
   - timer-log
   - timer-log-cdi
 group-05:
diff --git a/aws-lambda/README.md b/aws-lambda/README.adoc
similarity index 68%
rename from aws-lambda/README.md
rename to aws-lambda/README.adoc
index 49673f7..835df95 100644
--- a/aws-lambda/README.md
+++ b/aws-lambda/README.adoc
@@ -1,4 +1,9 @@
-# Deploying a Camel Route in AWS Lambda : A Camel Quarkus example
+= Deploying a Camel Route in AWS Lambda : A Camel Quarkus example
+:cq-example-description: An example that shows how to deploy a Camel Quarkus 
route as an AWS Lambda function
+
+{cq-description}
+
+== Introduction
 
 This example uses the following framework 
 
@@ -12,43 +17,48 @@ If you want to learn more about
 * *Apache Camel - please visit its website: https://camel.apache.org/*
 * *AWS Lambda - please visit its website: https://aws.amazon.com/lambda/*
 
-## Provided Code
+== Provided Code
 
-### Quarkus Camel Amazon Lambda Integration example
+=== Quarkus Camel Amazon Lambda Integration example
 
 This example contains a sample Greeter service build using Quarkus & Camel 
framework implementing Dependency Injection design principle which can be 
deployed as functions into the Amazon Lambda.
 
-> :warning: **INCOMPATIBLE WITH DEV MODE**: Amazon Lambda Binding is not 
compatible with dev mode yet!
-
+[WARNING]
+====
+*INCOMPATIBLE WITH DEV MODE*: Amazon Lambda Binding is not compatible with dev 
mode yet!
+====
 
-#### Quarkus Extensions / Dependencies Used
+==== Quarkus Extensions / Dependencies Used
 
-1. **[Apache Camel](https://quarkus.io/guides/camel)**
-    * 
[camel-quarkus-core](https://camel.apache.org/camel-quarkus/latest/reference/extensions/core.html)
-    * 
[camel-quarkus-direct](https://camel.apache.org/camel-quarkus/latest/reference/extensions/direct.html)
-    * 
[camel-quarkus-log](https://camel.apache.org/camel-quarkus/latest/reference/extensions/log.html)
+1. **https://quarkus.io/guides/camel[Apache Camel]**
+    * 
https://camel.apache.org/camel-quarkus/latest/reference/extensions/core.html[camel-quarkus-core]
+    * 
https://camel.apache.org/camel-quarkus/latest/reference/extensions/direct.html[camel-quarkus-direct]
+    * 
https://camel.apache.org/camel-quarkus/latest/reference/extensions/log.html[camel-quarkus-log]
 
 2. **Amazon Lambda**
-    * [quarkus-amazon-lambda](https://quarkus.io/guides/amazon-lambda)
+    * https://quarkus.io/guides/amazon-lambda[quarkus-amazon-lambda]
     
-3. **[Context Dependency Injection](https://quarkus.io/guides/cdi)**
-    * [quarkus-arc](https://quarkus.io/guides/cdi-reference)
+3. **https://quarkus.io/guides/cdi[Context Dependency Injection]**
+    * https://quarkus.io/guides/cdi-reference[quarkus-arc]
     
-4. **[Testing](https://quarkus.io/guides/getting-started-testing)**
+4. **https://quarkus.io/guides/getting-started-testing[Testing]**
     * quarkus-junit5
-    * [quarkus-junit5-mockito](https://quarkus.io/blog/mocking/)
+    * https://quarkus.io/blog/mocking/[quarkus-junit5-mockito]
     * quarkus-test-amazon-lambda
 
-## Running the application in dev mode
+== Running the application in dev mode
 
 You can run your application in dev mode that enables live coding using:
 ```shell script
 mvn compile quarkus:dev
 ```
 
-> **_NOTE:_**  Quarkus now ships with a Dev UI, which is available in dev mode 
only at http://localhost:8080/q/dev/.
+[NOTE]
+====
+Quarkus now ships with a Dev UI, which is available in dev mode only at 
http://localhost:8080/q/dev/.
+====
 
-## Building and Packaging the Java code as Quarkus JVM application
+== Building and Packaging the Java code as Quarkus JVM jar
 
 The application can be packaged using:
 ```shell script
@@ -68,17 +78,25 @@ The application is now runnable using `java -jar 
target/quarkus-app/quarkus-run.
 
 It also generates a zip file `target/function.zip`. This zip file contains 
your java code along with the dependencies.
 
-<a name="native"> </a>
-
-## Building and Packaging the Java code as Quarkus Native executable
+[#package_native_executable]
+== Building and Packaging the Java code as Quarkus Native executable
 
 If you want a lower memory footprint and faster initialization times for your 
lambda, you can compile your Java code to a native executable. Just make sure 
to rebuild your project with the -Pnative switch.
-> :warning: **Building Native Executables will take much longer time and 
depends on the underlying system**
+
+[WARNING]
+====
+*Building Native Executables will take much longer time and depends on the 
underlying system*
+====
+
 ```shell script
 mvn package -Pnative
 ```
-> :information_source: If you are building on a non-Linux system Or, if you 
don't have GraalVM installed, you can run the native executable build using 
docker container. You need to pass in a property instructing quarkus to use a 
docker build as Amazon Lambda requires linux binaries. 
+
+[NOTE]
+====
+If you are building on a non-Linux system Or, if you don't have GraalVM 
installed, you can run the native executable build using docker container. You 
need to pass in a property instructing quarkus to use a docker build as Amazon 
Lambda requires linux binaries. 
 >You can do this by passing this property to your Maven build: 
 >`-Dquarkus.native.container-build=true`. However, This requires to have 
 >docker installed locally.
+====
 
 ```shell script
 mvn package -Pnative -Dquarkus.native.container-build=true
@@ -91,8 +109,11 @@ It also generates a zip file `target/function.zip`. This 
zip file contains your
 
 If you want to learn more about building native executables, please consult 
https://quarkus.io/guides/maven-tooling.html.
 
-## Extra Build Generated Files
- **_NOTE:_** After you run the build, there are a few extra files generated by 
the quarkus-amazon-lambda extension. These files are in the build directory: 
`target/`
+== Extra Build Generated Files
+[NOTE]
+====
+After you run the build, there are a few extra files generated by the 
quarkus-amazon-lambda extension. These files are in the build directory: 
`target/`
+====
 
 * function.zip - lambda deployment file
 
@@ -104,9 +125,12 @@ If you want to learn more about building native 
executables, please consult http
 
 * sam.native.yaml - (optional) for use with sam cli and native local testing
 
-> :information_source: [Please click here to know more on how to use these 
scripts for automated 
deployment](https://quarkus.io/guides/amazon-lambda#extra-build-generated-files)
+[NOTE]
+====
+https://quarkus.io/guides/amazon-lambda#extra-build-generated-files[Please 
click here to know more on how to use these scripts for automated deployment]
+====
 
-## Deploying the Quarkus JVM application to AWS Lambda via AWS Web Console
+== Deploying the Quarkus JVM application to AWS Lambda via AWS Web Console
 
 1. Go to AWS Web console and search for Lambda Service
  
@@ -132,23 +156,24 @@ If you want to learn more about building native 
executables, please consult http
 io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest
 ```
 
-### Testing the AWS Lamda Function
+=== Testing the AWS Lamda Function
 
 1. Now select the Test tab for executing a quick test. Copy paste the below 
json payload and hit Test 
 
-    ```shell script
     {
      "name": "Ravishankar"
     }
-    ```
+
 2. If everything goes fine you should get the below response along with the 
lambda execution logs & stats
 
-    ```shell script
     Hello Ravishankar ! How are you? from GreetService
-    ```
-## Deploying the Quarkus Native executable to AWS Lambda via AWS Web Console
 
-**_NOTE:_** [Please ensure that you have built your Java code as Quarkus 
Native executable](#native)
+== Deploying the Quarkus Native executable to AWS Lambda via AWS Web Console
+
+[NOTE]
+====
+<<package_native_executable,Please ensure that you have built your Java code 
as Quarkus Native executable>>
+====
 
 1. Go to AWS Web console and search for Lambda Service
  
@@ -170,28 +195,25 @@ 
io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest
 
 10. For the Handler details please provide the below Handler 
 
-    ```shell script
         not.used.in.provided.runtime
-    ```
 
 11. Then Select the Configuration tab and click Environment Variables 
 
 12. For Key enter `DISABLE_SIGNAL_HANDLERS`    & for Value enter `true`
 
-### Testing the AWS Lamda Function
+=== Testing the AWS Lamda Function
 
 1. Now select the Test tab for executing a quick test. Copy paste the below 
json payload and hit Test 
 
-    ```shell script
     {
      "name": "Ravishankar"
     }
-    ```
+
 2. If everything goes fine you should get the below response along with the 
lambda execution logs & stats
 
-    ```shell script
+
     Hello Ravishankar ! How are you? from GreetService
-    ```
 
-## JVM vs Native : Results based on lambda execution logs & stats
-![JVM vs Native Results](results.png?raw=true "JVM vs Native Results")
\ No newline at end of file
+
+== JVM vs Native : Results based on lambda execution logs & stats
+image::results.png[JVM vs Native Results]
\ No newline at end of file
diff --git a/aws-lambda/pom.xml b/aws-lambda/pom.xml
index 25e7072..546d80b 100644
--- a/aws-lambda/pom.xml
+++ b/aws-lambda/pom.xml
@@ -1,17 +1,21 @@
 <?xml version="1.0"?>
 <!--
+
     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.
+
 -->
 
 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd"; 
xmlns="http://maven.apache.org/POM/4.0.0";
@@ -191,8 +195,10 @@
             <mapping>
               <java>SLASHSTAR_STYLE</java>
               <properties>CAMEL_PROPERTIES_STYLE</properties>
-              <kt>SLASHSTAR_STYLE</kt>
-            </mapping>
+              <Dockerfile.jvm>CAMEL_PROPERTIES_STYLE</Dockerfile.jvm>
+              <Dockerfile.native>CAMEL_PROPERTIES_STYLE</Dockerfile.native>
+              
<Dockerfile.native-distroless>CAMEL_PROPERTIES_STYLE</Dockerfile.native-distroless>
+              </mapping>
             <headerDefinitions>
               
<headerDefinition>${maven.multiModuleProjectDirectory}/license-properties-headerdefinition.xml</headerDefinition>
             </headerDefinitions>
@@ -205,7 +211,6 @@
       <plugin>
         <groupId>io.quarkus</groupId>
         <artifactId>quarkus-maven-plugin</artifactId>
-        <version>${quarkus.version}</version>
         <extensions>true</extensions>
         <executions>
           <execution>
diff --git a/aws-lambda/src/main/docker/Dockerfile.jvm 
b/aws-lambda/src/main/docker/Dockerfile.jvm
index 90bc63f..5f05d76 100644
--- a/aws-lambda/src/main/docker/Dockerfile.jvm
+++ b/aws-lambda/src/main/docker/Dockerfile.jvm
@@ -1,3 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
 ####
 # This Dockerfile is used in order to build a container that runs the Quarkus 
application in JVM mode
 #
diff --git a/aws-lambda/src/main/docker/Dockerfile.native 
b/aws-lambda/src/main/docker/Dockerfile.native
index ab14aa2..bde9db1 100644
--- a/aws-lambda/src/main/docker/Dockerfile.native
+++ b/aws-lambda/src/main/docker/Dockerfile.native
@@ -1,3 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
 ####
 # This Dockerfile is used in order to build a container that runs the Quarkus 
application in native (no JVM) mode
 #
diff --git a/aws-lambda/src/main/docker/Dockerfile.native-distroless 
b/aws-lambda/src/main/docker/Dockerfile.native-distroless
index 08f3de7..b80011d 100644
--- a/aws-lambda/src/main/docker/Dockerfile.native-distroless
+++ b/aws-lambda/src/main/docker/Dockerfile.native-distroless
@@ -1,3 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
 ####
 # This Dockerfile is used in order to build a distroless container that runs 
the Quarkus application in native (no JVM) mode
 #
diff --git 
a/aws-lambda/src/main/java/org/apache/camel/quarkus/examples/CamelRoute.java 
b/aws-lambda/src/main/java/org/apache/camel/quarkus/examples/CamelRoute.java
index b8c569f..b9709a8 100644
--- a/aws-lambda/src/main/java/org/apache/camel/quarkus/examples/CamelRoute.java
+++ b/aws-lambda/src/main/java/org/apache/camel/quarkus/examples/CamelRoute.java
@@ -28,7 +28,7 @@ public class CamelRoute extends RouteBuilder {
     GreetService greetService;
 
     @Override
-    public void configure() throws Exception {
+    public void configure() {
         from("direct:input").routeId("Test")
                 .log("Inside Camel Route Received Payload ==> ${body}")
                 .setBody().body(Person.class, p -> 
greetService.greet(p.getName()))
diff --git 
a/aws-lambda/src/test/java/org/apache/camel/quarkus/examples/AWSLambdaHandlerTest.java
 
b/aws-lambda/src/test/java/org/apache/camel/quarkus/examples/AWSLambdaHandlerTest.java
index 4f3364f..28901dc 100644
--- 
a/aws-lambda/src/test/java/org/apache/camel/quarkus/examples/AWSLambdaHandlerTest.java
+++ 
b/aws-lambda/src/test/java/org/apache/camel/quarkus/examples/AWSLambdaHandlerTest.java
@@ -17,26 +17,23 @@
 package org.apache.camel.quarkus.examples;
 
 import io.quarkus.amazon.lambda.test.LambdaClient;
-import io.quarkus.test.junit.QuarkusMock;
 import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.mockito.InjectMock;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
+
+import static org.mockito.Mockito.when;
 
 @QuarkusTest
 public class AWSLambdaHandlerTest {
 
-    @BeforeAll
-    public static void setup() {
-
-        GreetService mock = Mockito.mock(GreetService.class);
-        Mockito.when(mock.greet("Stu")).thenReturn("Hello Stu ! How are you? 
from GreetService");
-        QuarkusMock.installMockForType(mock, GreetService.class);
-    }
+    @InjectMock
+    GreetService mockGreetingService;
 
     @Test
-    public void testSimpleLambdaSuccess() throws Exception {
+    public void testSimpleLambdaSuccess() {
+        when(mockGreetingService.greet("Stu")).thenReturn("Hello Stu ! How are 
you? from GreetService");
+
         Person in = new Person();
         in.setName("Stu");
         String out = LambdaClient.invoke(String.class, in);
diff --git a/docs/modules/ROOT/attachments/examples.json 
b/docs/modules/ROOT/attachments/examples.json
index 56bb1ae..a5ec778 100644
--- a/docs/modules/ROOT/attachments/examples.json
+++ b/docs/modules/ROOT/attachments/examples.json
@@ -10,6 +10,11 @@
     "link": 
"https://github.com/apache/camel-quarkus-examples/tree/main/timer-log-main";
   },
   {
+    "title": "Deploying a Camel Route in AWS Lambda ",
+    "description": "Shows how to deploy a Camel Quarkus route as an AWS Lambda 
function",
+    "link": 
"https://github.com/apache/camel-quarkus-examples/tree/main/aws-lambda";
+  },
+  {
     "title": "File consumer with Bindy \u0026 FTP",
     "description": "Shows how to consume CSV files, marshal \u0026 unmarshal 
the data and send it onwards via FTP",
     "link": 
"https://github.com/apache/camel-quarkus-examples/tree/main/file-bindy-ftp";
@@ -68,10 +73,5 @@
     "title": "XML Hello World",
     "description": "Shows how to define Camel routes using XML.",
     "link": 
"https://github.com/apache/camel-quarkus-examples/tree/main/timer-log-xml";
-  },
-  {
-    "title": "Deploying a Camel Route in AWS Lambda",
-    "description": "Demonstrates how to define Camel routes using CDI and 
deployed as functions into the Amazon Lambda",
-    "link": 
"https://github.com/apache/camel-quarkus-examples/tree/main/aws-lambda";
   }
 ]
\ No newline at end of file

Reply via email to