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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new f42f5a9  ✅ Add integration test module + infinispan (#433)
f42f5a9 is described below

commit f42f5a9f71e53b0de8532af637b32f4be22be79c
Author: Federico Mariani <[email protected]>
AuthorDate: Mon Feb 7 09:42:56 2022 +0100

    ✅ Add integration test module + infinispan (#433)
---
 .../infinispan/pom.xml                             |  55 ++++++++
 .../springboot/infinispan/InfinispanRoutes.java    |  49 +++++++
 .../springboot/infinispan/InfinispanTest.java      | 146 +++++++++++++++++++++
 .../integration-common}/pom.xml                    |  33 ++---
 .../camel/integration/springboot/Application.java  |  28 ++++
 .../springboot/SpringBootBaseIntegration.java      |  36 +++++
 tests/camel-spring-boot-integration-tests/pom.xml  |  68 ++++++++++
 tests/pom.xml                                      |   1 +
 8 files changed, 395 insertions(+), 21 deletions(-)

diff --git a/tests/camel-spring-boot-integration-tests/infinispan/pom.xml 
b/tests/camel-spring-boot-integration-tests/infinispan/pom.xml
new file mode 100644
index 0000000..0ee9911
--- /dev/null
+++ b/tests/camel-spring-boot-integration-tests/infinispan/pom.xml
@@ -0,0 +1,55 @@
+<?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/xsd/maven-4.0.0.xsd";>
+       <parent>
+               <artifactId>camel-spring-boot-integration-tests</artifactId>
+               <groupId>org.apache.camel.springboot</groupId>
+               <version>3.15.0-SNAPSHOT</version>
+       </parent>
+       <modelVersion>4.0.0</modelVersion>
+
+       <artifactId>infinispan</artifactId>
+       <name>Camel SB :: Integration Tests :: Infinispan</name>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.apache.camel.springboot</groupId>
+                       <artifactId>integration-common</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.apache.camel.springboot</groupId>
+                       <artifactId>camel-infinispan-starter</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.apache.camel</groupId>
+                       <artifactId>camel-test-infra-infinispan</artifactId>
+                       <version>${project.version}</version>
+                       <type>test-jar</type>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+
+</project>
diff --git 
a/tests/camel-spring-boot-integration-tests/infinispan/src/main/java/org/apache/camel/integration/springboot/infinispan/InfinispanRoutes.java
 
b/tests/camel-spring-boot-integration-tests/infinispan/src/main/java/org/apache/camel/integration/springboot/infinispan/InfinispanRoutes.java
new file mode 100644
index 0000000..4c72f3c
--- /dev/null
+++ 
b/tests/camel-spring-boot-integration-tests/infinispan/src/main/java/org/apache/camel/integration/springboot/infinispan/InfinispanRoutes.java
@@ -0,0 +1,49 @@
+/*
+ * 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.integration.springboot.infinispan;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.infinispan.InfinispanConstants;
+import org.apache.camel.component.infinispan.InfinispanOperation;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class InfinispanRoutes extends RouteBuilder {
+
+       @Override
+       public void configure() throws Exception {
+               from("direct:put")
+                       .setHeader(InfinispanConstants.OPERATION)
+                               .constant(InfinispanOperation.PUT)
+               .to("infinispanRemoteComponent://myCache");
+
+               from("direct:get")
+                       .setHeader(InfinispanConstants.OPERATION)
+                               .constant(InfinispanOperation.GET)
+               .to("infinispanRemoteComponent://myCache")
+               .to("mock:result");
+
+               from("direct:consumer")
+                       .setHeader(InfinispanConstants.OPERATION)
+                               .constant(InfinispanOperation.PUT)
+               .to("infinispanRemoteComponent://myConsumerCache");
+
+               from("infinispanRemoteComponent://myConsumerCache")
+               .to("mock:consumerResult");
+       }
+}
diff --git 
a/tests/camel-spring-boot-integration-tests/infinispan/src/test/java/org/apache/camel/integration/springboot/infinispan/InfinispanTest.java
 
b/tests/camel-spring-boot-integration-tests/infinispan/src/test/java/org/apache/camel/integration/springboot/infinispan/InfinispanTest.java
new file mode 100644
index 0000000..3c438d6
--- /dev/null
+++ 
b/tests/camel-spring-boot-integration-tests/infinispan/src/test/java/org/apache/camel/integration/springboot/infinispan/InfinispanTest.java
@@ -0,0 +1,146 @@
+/*
+ * 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.integration.springboot.infinispan;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.infinispan.InfinispanConstants;
+import org.apache.camel.component.infinispan.remote.InfinispanRemoteComponent;
+import 
org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.integration.springboot.Application;
+import org.apache.camel.integration.springboot.SpringBootBaseIntegration;
+import org.apache.camel.test.infra.infinispan.services.InfinispanService;
+import 
org.apache.camel.test.infra.infinispan.services.InfinispanServiceFactory;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
+import org.infinispan.configuration.cache.CacheMode;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Random;
+import java.util.UUID;
+
+@SpringBootTest(classes = { Application.class, 
InfinispanTest.InfinispanConfiguration.class })
+public class InfinispanTest extends SpringBootBaseIntegration {
+
+       @RegisterExtension
+       public static InfinispanService service = 
InfinispanServiceFactory.createService();
+
+       @Test
+       public void producer() throws InterruptedException {
+               final String msg = UUID.randomUUID().toString();
+               final Integer key = new Random().nextInt();
+
+               final MockEndpoint mock = 
camelContext.getEndpoint("mock:result", MockEndpoint.class);
+               mock.expectedMessageCount(1);
+               mock.expectedBodiesReceived(msg);
+
+               sendMessage("direct:put", key, msg);
+
+               sendMessage("direct:get", key, msg);
+
+               mock.assertIsSatisfied();
+       }
+
+       @Test
+       public void consumer() throws InterruptedException {
+               final String msg = UUID.randomUUID().toString();
+               final Integer key = new Random().nextInt();
+
+               MockEndpoint mock = 
camelContext.getEndpoint("mock:consumerResult", MockEndpoint.class);
+               mock.expectedMessageCount(1);
+               mock.expectedHeaderReceived("CamelInfinispanKey", key);
+
+               sendMessage("direct:consumer", key, msg);
+
+               mock.assertIsSatisfied();
+       }
+
+       private Exchange sendMessage(String endpointUri, Integer key, String 
msg) {
+               return producerTemplate.send(endpointUri, exchange -> {
+                       exchange.getIn().setHeader(InfinispanConstants.KEY, 
key);
+                       exchange.getIn().setHeader(InfinispanConstants.VALUE, 
msg);
+               });
+       }
+
+       @Configuration
+       public static class InfinispanConfiguration {
+
+               protected static ConfigurationBuilder getConfiguration() {
+                       ConfigurationBuilder clientBuilder = new 
ConfigurationBuilder();
+
+                       // for default tests, we force return value for all the
+                       // operations
+                       clientBuilder
+                                       .forceReturnValues(true);
+
+                       // add server from the test infra service
+                       clientBuilder
+                                       .addServer()
+                                       .host(service.host())
+                                       .port(service.port());
+
+                       // add security info
+                       clientBuilder
+                                       .security()
+                                       .authentication()
+                                       .username(service.username())
+                                       .password(service.password())
+                                       .serverName("infinispan")
+                                       .saslMechanism("DIGEST-MD5")
+                                       .realm("default");
+
+                       return clientBuilder;
+               }
+
+               @Bean("infinispanRemoteComponent")
+               public InfinispanRemoteComponent infinispanRemoteComponent() {
+                       InfinispanRemoteConfiguration 
infinispanRemoteConfiguration = new InfinispanRemoteConfiguration();
+
+                       infinispanRemoteConfiguration.setHosts(service.host() + 
":" + service.port());
+
+                       
infinispanRemoteConfiguration.setUsername(service.username());
+                       
infinispanRemoteConfiguration.setPassword(service.password());
+
+                       RemoteCacheManager cacheContainer = new 
RemoteCacheManager(getConfiguration().build());
+                       cacheContainer.administration()
+                                       .getOrCreateCache(
+                                                       "myCache",
+                                                       new 
org.infinispan.configuration.cache.ConfigurationBuilder()
+                                                                       
.clustering()
+                                                                       
.cacheMode(CacheMode.DIST_SYNC).build());
+
+                       cacheContainer.administration()
+                                       .getOrCreateCache(
+                                                       "myConsumerCache",
+                                                       new 
org.infinispan.configuration.cache.ConfigurationBuilder()
+                                                                       
.clustering()
+                                                                       
.cacheMode(CacheMode.DIST_SYNC).build());
+
+                       
infinispanRemoteConfiguration.setCacheContainer(cacheContainer);
+                       InfinispanRemoteComponent component = new 
InfinispanRemoteComponent();
+                       
component.setConfiguration(infinispanRemoteConfiguration);
+
+                       return component;
+               }
+       }
+}
diff --git a/tests/pom.xml 
b/tests/camel-spring-boot-integration-tests/integration-common/pom.xml
similarity index 53%
copy from tests/pom.xml
copy to tests/camel-spring-boot-integration-tests/integration-common/pom.xml
index 7ccd314..e6c12c4 100644
--- a/tests/pom.xml
+++ b/tests/camel-spring-boot-integration-tests/integration-common/pom.xml
@@ -17,25 +17,16 @@
     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.springboot</groupId>
-        <artifactId>spring-boot-parent</artifactId>
-        <version>3.16.0-SNAPSHOT</version>
-        <relativePath>../parent/pom.xml</relativePath>
-    </parent>
-
-    <groupId>org.apache.camel.springboot</groupId>
-    <artifactId>tests</artifactId>
-    <name>Camel SB :: Tests</name>
-    <description>Camel Spring Boot Tests</description>
-    <packaging>pom</packaging>
-
-    <modules>
-        <module>camel-itest-spring-boot</module>
-    </modules>
-
+<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/xsd/maven-4.0.0.xsd";>
+       <parent>
+               <artifactId>camel-spring-boot-integration-tests</artifactId>
+               <groupId>org.apache.camel.springboot</groupId>
+               <version>3.15.0-SNAPSHOT</version>
+       </parent>
+       <modelVersion>4.0.0</modelVersion>
+
+       <artifactId>integration-common</artifactId>
+       <name>Camel SB :: Integration Tests :: Common</name>
 </project>
diff --git 
a/tests/camel-spring-boot-integration-tests/integration-common/src/main/java/org/apache/camel/integration/springboot/Application.java
 
b/tests/camel-spring-boot-integration-tests/integration-common/src/main/java/org/apache/camel/integration/springboot/Application.java
new file mode 100644
index 0000000..3c05c12
--- /dev/null
+++ 
b/tests/camel-spring-boot-integration-tests/integration-common/src/main/java/org/apache/camel/integration/springboot/Application.java
@@ -0,0 +1,28 @@
+/*
+ * 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.integration.springboot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+       public static void main(String[] args) {
+               SpringApplication.run(Application.class);
+       }
+}
diff --git 
a/tests/camel-spring-boot-integration-tests/integration-common/src/main/java/org/apache/camel/integration/springboot/SpringBootBaseIntegration.java
 
b/tests/camel-spring-boot-integration-tests/integration-common/src/main/java/org/apache/camel/integration/springboot/SpringBootBaseIntegration.java
new file mode 100644
index 0000000..b35ec7e
--- /dev/null
+++ 
b/tests/camel-spring-boot-integration-tests/integration-common/src/main/java/org/apache/camel/integration/springboot/SpringBootBaseIntegration.java
@@ -0,0 +1,36 @@
+/*
+ * 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.integration.springboot;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@CamelSpringBootTest
+@SpringBootTest(classes = Application.class)
+public class SpringBootBaseIntegration {
+
+       @Autowired
+       protected CamelContext camelContext;
+
+       @Autowired
+       protected ProducerTemplate producerTemplate;
+
+}
diff --git a/tests/camel-spring-boot-integration-tests/pom.xml 
b/tests/camel-spring-boot-integration-tests/pom.xml
new file mode 100644
index 0000000..bee000a
--- /dev/null
+++ b/tests/camel-spring-boot-integration-tests/pom.xml
@@ -0,0 +1,68 @@
+<?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/xsd/maven-4.0.0.xsd";>
+       <parent>
+               <artifactId>tests</artifactId>
+               <groupId>org.apache.camel.springboot</groupId>
+               <version>3.15.0-SNAPSHOT</version>
+       </parent>
+       <modelVersion>4.0.0</modelVersion>
+
+       <artifactId>camel-spring-boot-integration-tests</artifactId>
+       <name>Camel SB :: Integration Tests</name>
+       <description>Spring-Boot Camel integration test</description>
+       <modules>
+               <module>integration-common</module>
+               <module>infinispan</module>
+       </modules>
+       <packaging>pom</packaging>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.apache.camel</groupId>
+                       <artifactId>camel-support</artifactId>
+               </dependency>
+
+               <!-- Spring Boot -->
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter</artifactId>
+                       <version>${spring-boot-version}</version>
+               </dependency>
+               <!-- Camel -->
+               <dependency>
+                       <groupId>org.apache.camel.springboot</groupId>
+                       <artifactId>camel-spring-boot-starter</artifactId>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-test</artifactId>
+                       <version>${spring-boot-version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.camel</groupId>
+                       <artifactId>camel-test-spring-junit5</artifactId>
+               </dependency>
+       </dependencies>
+
+</project>
diff --git a/tests/pom.xml b/tests/pom.xml
index 7ccd314..23b4d52 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -36,6 +36,7 @@
 
     <modules>
         <module>camel-itest-spring-boot</module>
+        <module>camel-spring-boot-integration-tests</module>
     </modules>
 
 </project>

Reply via email to