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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d7679f8758f93399768bf12f513bb791b8e78461
Author: Raffaele Marcello <marcelloraffa...@gmail.com>
AuthorDate: Thu Feb 25 21:19:19 2021 +0100

    CAMEL-15963 Create a Google Cloud Functions component
---
 components/camel-google-functions/ReadMe.txt       |  13 ++
 components/camel-google-functions/pom.xml          | 132 +++++++++++++++++++++
 .../camel/GoogleCloudFunctionsComponent.java       |  40 +++++++
 .../apache/camel/GoogleCloudFunctionsEndpoint.java |  81 +++++++++++++
 .../apache/camel/GoogleCloudFunctionsProducer.java |  39 ++++++
 .../org/apache/camel/component/google-functions    |   1 +
 .../camel/GoogleCloudFunctionsComponentTest.java   |  28 +++++
 .../src/test/resources/log4j.properties            |  14 +++
 8 files changed, 348 insertions(+)

diff --git a/components/camel-google-functions/ReadMe.txt 
b/components/camel-google-functions/ReadMe.txt
new file mode 100644
index 0000000..f327e1e
--- /dev/null
+++ b/components/camel-google-functions/ReadMe.txt
@@ -0,0 +1,13 @@
+Camel Component Project
+=======================
+
+This project is a template of a Camel component.
+
+To build this project use
+
+    mvn install
+
+For more help see the Apache Camel documentation:
+
+    http://camel.apache.org/writing-components.html
+    
diff --git a/components/camel-google-functions/pom.xml 
b/components/camel-google-functions/pom.xml
new file mode 100644
index 0000000..311fd6e
--- /dev/null
+++ b/components/camel-google-functions/pom.xml
@@ -0,0 +1,132 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>3.9.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-google-functions</artifactId>
+  <packaging>jar</packaging>
+  <name>Camel :: Google Functions</name>
+  <description>Camel Component for Google Cloud Platform 
Functions</description>
+
+  <properties>
+    <firstVersion>3.9.0</firstVersion>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- Override the android JDK 7 guava in libraries-bom -->
+    <!--  <dependency>
+        <groupId>com.google.guava</groupId>
+        <artifactId>guava</artifactId>
+        <version>${google-cloud-guava-version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.google.cloud</groupId>
+        <artifactId>libraries-bom</artifactId>
+        <version>${google-cloud-bom-version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      -->
+    </dependencies>
+  
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-support</artifactId>
+    </dependency>
+    <!--
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.google.cloud</groupId>
+      <artifactId>google-cloud-storage</artifactId>
+    </dependency>
+  -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test-junit5</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-junit-jupiter</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <configuration>
+              <childDelegation>false</childDelegation>
+              <useFile>true</useFile>
+              <forkCount>1</forkCount>
+              <reuseForks>true</reuseForks>
+              
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
+              <includes>
+                  <include>**/unit/**/*.java</include>
+              </includes>
+          </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+        <id>google-functions-test</id>
+        <build>
+            <plugins>
+                <plugin>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <configuration>
+                        <childDelegation>false</childDelegation>
+                        <useFile>true</useFile>
+                        <forkCount>1</forkCount>
+                        <reuseForks>true</reuseForks>
+                        
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
+                        <includes>
+                            <include>**/*Test.java</include>
+                        </includes>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </build>
+    </profile>
+</profiles>
+
+</project>
diff --git 
a/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsComponent.java
 
b/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsComponent.java
new file mode 100644
index 0000000..f4defb7
--- /dev/null
+++ 
b/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsComponent.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+import java.util.Map;
+
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+
+@Component("google-functions")
+public class GoogleCloudFunctionsComponent extends DefaultComponent {
+
+    public GoogleCloudFunctionsComponent() {
+        super(GoogleCloudFunctionsEndpoint.class);
+    }
+
+    public GoogleCloudFunctionsComponent(CamelContext context) {
+        super(context, GoogleCloudFunctionsEndpoint.class);
+    }
+
+    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
+        Endpoint endpoint = new GoogleCloudFunctionsEndpoint(uri, this);
+        setProperties(endpoint, parameters);
+        return endpoint;
+    }
+}
diff --git 
a/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsEndpoint.java
 
b/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsEndpoint.java
new file mode 100644
index 0000000..1034788
--- /dev/null
+++ 
b/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsEndpoint.java
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+
+/**
+ * Represents a GoogleCloudFunctions endpoint.
+ */
+@UriEndpoint(scheme = "google-functions", title = "GoogleCloudFunctions", 
syntax = "google-functions:name",
+             category = { Category.CLOUD }, producerOnly = true)
+public class GoogleCloudFunctionsEndpoint extends DefaultEndpoint {
+    @UriPath
+    @Metadata(required = "true")
+    private String name;
+    @UriParam(defaultValue = "10")
+    private int option = 10;
+
+    public GoogleCloudFunctionsEndpoint() {
+    }
+
+    public GoogleCloudFunctionsEndpoint(String uri, 
GoogleCloudFunctionsComponent component) {
+        super(uri, component);
+    }
+
+    public GoogleCloudFunctionsEndpoint(String endpointUri) {
+        super(endpointUri);
+    }
+
+    public Producer createProducer() throws Exception {
+        return new GoogleCloudFunctionsProducer(this);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("Cannot consume from the 
google-functions endpoint: " + getEndpointUri());
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    /**
+     * Some description of this option, and what it does
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Some description of this option, and what it does
+     */
+    public void setOption(int option) {
+        this.option = option;
+    }
+
+    public int getOption() {
+        return option;
+    }
+}
diff --git 
a/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsProducer.java
 
b/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsProducer.java
new file mode 100644
index 0000000..07bc941
--- /dev/null
+++ 
b/components/camel-google-functions/src/main/java/org/apache/camel/GoogleCloudFunctionsProducer.java
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The GoogleCloudFunctions producer.
+ */
+public class GoogleCloudFunctionsProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(GoogleCloudFunctionsProducer.class);
+    private GoogleCloudFunctionsEndpoint endpoint;
+
+    public GoogleCloudFunctionsProducer(GoogleCloudFunctionsEndpoint endpoint) 
{
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        System.out.println(exchange.getIn().getBody());
+    }
+
+}
diff --git 
a/components/camel-google-functions/src/main/resources/META-INF/services/org/apache/camel/component/google-functions
 
b/components/camel-google-functions/src/main/resources/META-INF/services/org/apache/camel/component/google-functions
new file mode 100644
index 0000000..5144a7e
--- /dev/null
+++ 
b/components/camel-google-functions/src/main/resources/META-INF/services/org/apache/camel/component/google-functions
@@ -0,0 +1 @@
+class=org.apache.camel.GoogleCloudFunctionsComponent
diff --git 
a/components/camel-google-functions/src/test/java/org/apache/camel/GoogleCloudFunctionsComponentTest.java
 
b/components/camel-google-functions/src/test/java/org/apache/camel/GoogleCloudFunctionsComponentTest.java
new file mode 100644
index 0000000..b3131f2
--- /dev/null
+++ 
b/components/camel-google-functions/src/test/java/org/apache/camel/GoogleCloudFunctionsComponentTest.java
@@ -0,0 +1,28 @@
+package org.apache.camel;
+
+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 GoogleCloudFunctionsComponentTest extends CamelTestSupport {
+
+    @Test
+    public void testGoogleCloudFunctions() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(1);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("google-functions://foo")
+                        .to("google-functions://bar")
+                        .to("mock:result");
+            }
+        };
+    }
+}
diff --git 
a/components/camel-google-functions/src/test/resources/log4j.properties 
b/components/camel-google-functions/src/test/resources/log4j.properties
new file mode 100644
index 0000000..3b1bd38
--- /dev/null
+++ b/components/camel-google-functions/src/test/resources/log4j.properties
@@ -0,0 +1,14 @@
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - 
%m%n
+

Reply via email to