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 d51dda994ba1b5717e82b80716f15f639ab572a3 Author: Andrea Cosentino <[email protected]> AuthorDate: Fri Oct 2 16:36:46 2020 +0200 CAMEL-15603 - Camel-Infinispan: Support Authentication through URI options --- components/camel-infinispan/pom.xml | 20 ----- .../infinispan/InfinispanComponentTest.java | 61 --------------- .../InfinispanTestContainerSupport.java | 14 ++-- .../InfinispanTestContainersProducerTest.java | 20 ++--- .../camel-infinispan/src/test/resources/log4j.xml | 88 ---------------------- pom.xml | 2 +- 6 files changed, 19 insertions(+), 186 deletions(-) diff --git a/components/camel-infinispan/pom.xml b/components/camel-infinispan/pom.xml index b3f1681..f60c061 100644 --- a/components/camel-infinispan/pom.xml +++ b/components/camel-infinispan/pom.xml @@ -70,11 +70,6 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test-junit5</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> <artifactId>camel-test-spring-junit5</artifactId> <scope>test</scope> </dependency> @@ -121,21 +116,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-jcl</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-testcontainers-junit5</artifactId> <scope>test</scope> diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentTest.java deleted file mode 100644 index 9750b17..0000000 --- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentTest.java +++ /dev/null @@ -1,61 +0,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. - */ -package org.apache.camel.component.infinispan; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -public class InfinispanComponentTest extends InfinispanTestSupport { - private final String cacheName = "default"; - - @Test - public void consumerReceivedEntryCreatedEventNotifications() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(2); - - namedCache(cacheName).put(KEY_ONE, VALUE_ONE); - assertMockEndpointsSatisfied(); - } - - @Test - public void producerPublishesKeyAndValue() throws Exception { - fluentTemplate() - .to("direct:start") - .withHeader(InfinispanConstants.KEY, KEY_ONE) - .withHeader(InfinispanConstants.VALUE, VALUE_ONE) - .send(); - - assertThat(namedCache(cacheName).get(KEY_ONE).toString(), is(VALUE_ONE)); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() { - fromF("infinispan:%s?cacheContainer=#cacheContainer&eventTypes=CACHE_ENTRY_CREATED", cacheName) - .to("mock:result"); - from("direct:start") - .toF("infinispan:%s?cacheContainer=#cacheContainer", cacheName); - } - }; - } -} diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainerSupport.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainerSupport.java index c875dd1..39128a1 100644 --- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainerSupport.java +++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainerSupport.java @@ -18,6 +18,7 @@ package org.apache.camel.component.infinispan.testcontainers; import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport; import org.apache.camel.test.testcontainers.junit5.Wait; +import org.infinispan.client.hotrod.DefaultTemplate; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; @@ -39,7 +40,7 @@ public class InfinispanTestContainerSupport extends ContainerAwareTestSupport { return new GenericContainer(CONTAINER_IMAGE) .withNetworkAliases(CONTAINER_NAME) .withEnv("USER", "admin") - .withEnv("PASSWORD", "password") + .withEnv("PASS", "password") .withExposedPorts(11222) .waitingFor(Wait.forListeningPort()) .waitingFor(Wait.forLogMessageContaining("Infinispan Server 11.0.3.Final started", 1)); @@ -52,13 +53,14 @@ public class InfinispanTestContainerSupport extends ContainerAwareTestSupport { getContainerPort(CONTAINER_NAME, 11222)); } - public RemoteCache<Object, Object> getDefaultCache() { + public RemoteCacheManager createAndGetDefaultCache() { ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); - clientBuilder.addServer().host(getContainerHost(CONTAINER_NAME)).port(11222) - .security().authentication().username("user").password("password"); + clientBuilder.addServer().host(getContainerHost(CONTAINER_NAME)).port(getContainerPort(CONTAINER_NAME, 11222)) + .security().authentication().username("admin").password("password").serverName("infinispan") + .saslMechanism("DIGEST-MD5").realm("default").remoteCache("mycache").templateName(DefaultTemplate.DIST_SYNC); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(clientBuilder.build()); - RemoteCache<Object, Object> cache = remoteCacheManager.getCache("default"); - return cache; + remoteCacheManager.getCache("mycache"); + return remoteCacheManager; } } diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersProducerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersProducerTest.java index 3affdb3..f45aed28 100644 --- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersProducerTest.java +++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersProducerTest.java @@ -20,8 +20,8 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.infinispan.InfinispanConstants; -import org.infinispan.client.hotrod.RemoteCache; -import org.junit.jupiter.api.BeforeAll; +import org.infinispan.client.hotrod.RemoteCacheManager; +import org.junit.Before; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -30,11 +30,11 @@ public class InfinispanTestContainersProducerTest extends InfinispanTestContaine private static final String COMMAND_VALUE = "commandValue"; private static final String COMMAND_KEY = "commandKey1"; - private RemoteCache<Object, Object> cache; + private RemoteCacheManager remoteCacheManager; - @BeforeAll - public void init() { - cache = getDefaultCache(); + @Before + public void doPreSetup() { + remoteCacheManager = createAndGetDefaultCache(); } @Test @@ -46,8 +46,6 @@ public class InfinispanTestContainersProducerTest extends InfinispanTestContaine exchange.getIn().setHeader(InfinispanConstants.VALUE, COMMAND_VALUE); } }); - String result = (String) cache.get(COMMAND_KEY); - assertEquals(COMMAND_VALUE, result); Exchange exchange; exchange = template.send("direct:get", new Processor() { @@ -66,9 +64,11 @@ public class InfinispanTestContainersProducerTest extends InfinispanTestContaine @Override public void configure() { from("direct:put") - .to("infinispan:default?cacheContainer=#cacheContainer&operation=PUT&user=admin&password=password&secure=true"); + .to("infinispan:mycache?hosts=" + getInfispanUrl() + + "&operation=PUT&username=admin&password=password&secure=true"); from("direct:get") - .to("infinispan:default?cacheContainer=#cacheContainer&operation=GET&user=admin&password=password&secure=true"); + .to("infinispan:mycache?hosts=" + getInfispanUrl() + + "&operation=GET&username=admin&password=password&secure=true"); } }; } diff --git a/components/camel-infinispan/src/test/resources/log4j.xml b/components/camel-infinispan/src/test/resources/log4j.xml deleted file mode 100644 index e4081f2..0000000 --- a/components/camel-infinispan/src/test/resources/log4j.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?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. - ---> -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> - -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> - - <appender name="FILE" class="org.apache.log4j.FileAppender"> - <param name="File" value="target/camel-infinispan-test.log" /> - <param name="Append" value="true" /> - <param name="Threshold" value="INFO" /> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%d [%-15.15t] %-5p %-30.30c{1} - %m%n" /> - </layout> - </appender> - - <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> - <param name="Threshold" value="INFO" /> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="[%30.30t] %-30.30c{1} %-5p %m%n" /> - </layout> - </appender> - - <!-- ================ --> - <!-- Limit categories --> - <!-- ================ --> - <category name="org.jboss.arquillian"> - <priority value="INFO" /> - </category> - - <category name="org.infinispan.arquillian.core.WithRunningServerObserver"> - <priority value="INFO" /> - </category> - - <category name="org.infinispan.server.test.util.TestsuiteListener"> - <priority value="INFO" /> - </category> - - <category name="org.apache.http"> - <priority value="INFO" /> - </category> - - <category name="org.infinispan"> - <priority value="INFO" /> - </category> - - <category name="org.jgroups"> - <priority value="INFO" /> - </category> - - <category name="org.apache.commons.httpclient.auth"> - <priority value="INFO"/> - </category> - - <category name="org.apache.auth"> - <priority value="INFO"/> - </category> - - <category name="org.apache.directory"> - <priority value="WARN"/> - </category> - - <!-- ======================= --> - <!-- Setup the Root category --> - <!-- ======================= --> - - <root> - <priority value="INFO" /> - <appender-ref ref="FILE" /> - </root> - -</log4j:configuration> diff --git a/pom.xml b/pom.xml index 8c810a3..689b57e 100644 --- a/pom.xml +++ b/pom.xml @@ -113,7 +113,7 @@ <maven-compiler-plugin-version>3.8.1</maven-compiler-plugin-version> <maven-javadoc-plugin-version>3.2.0</maven-javadoc-plugin-version> - <maven-surefire-plugin-version>3.0.0-M4</maven-surefire-plugin-version> + <maven-surefire-plugin-version>3.0.0-M5</maven-surefire-plugin-version> <!-- we need to override the version inherited from Apache POM for modules that use this POM as parent --> <surefire.version>${maven-surefire-plugin-version}</surefire.version> <formatter-maven-plugin.version>2.12.1</formatter-maven-plugin.version>
