You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/11/23 09:29:59 UTC
[camel] branch master updated: CAMEL-15878 - Camel-Infinispan:
Support authentication in idempotent repository
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
The following commit(s) were added to refs/heads/master by this push:
new 659566f CAMEL-15878 - Camel-Infinispan: Support authentication in idempotent repository
659566f is described below
commit 659566f945ac8f79344d31561f90b746f2d1da38
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Nov 23 10:27:28 2020 +0100
CAMEL-15878 - Camel-Infinispan: Support authentication in idempotent repository
---
.../idempotent/InfinispanIdempotentRepository.java | 4 +-
...spanTestContainersIdempotentRepositoryTest.java | 78 ++++++++++++++++++++++
2 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
index a297714..0c04aa6 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
@@ -132,8 +132,8 @@ public class InfinispanIdempotentRepository extends ServiceSupport implements Id
if (InfinispanUtil.isRemote(cacheContainer)) {
RemoteCacheManager manager = InfinispanUtil.asRemote(cacheContainer);
cache = cacheName != null
- ? manager.getCache(cacheName, true)
- : manager.getCache(true);
+ ? manager.getCache(cacheName)
+ : manager.getCache();
} else {
cache = cacheName != null
? cacheContainer.getCache(cacheName)
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersIdempotentRepositoryTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersIdempotentRepositoryTest.java
new file mode 100644
index 0000000..d9c23db
--- /dev/null
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersIdempotentRepositoryTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.testcontainers;
+
+import java.util.UUID;
+import java.util.stream.IntStream;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.infinispan.processor.idempotent.InfinispanIdempotentRepository;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
+import org.junit.Before;
+import org.junit.jupiter.api.Test;
+
+public class InfinispanTestContainersIdempotentRepositoryTest extends InfinispanTestContainerSupport {
+
+ private RemoteCacheManager remoteCacheManager;
+
+ @EndpointInject("mock:result")
+ private MockEndpoint result;
+
+ @Before
+ public void doPreSetup() {
+ remoteCacheManager = createAndGetDefaultCache();
+ }
+
+ @Test
+ public void producerQueryOperationWithoutQueryBuilder() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+
+ final String messageId = UUID.randomUUID().toString();
+ IntStream.range(0, 10).forEach(
+ i -> template().sendBodyAndHeader("direct:start", "message-" + i, "MessageID", messageId));
+
+ mock.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .idempotentConsumer(
+ header("MessageID"),
+ new InfinispanIdempotentRepository(
+ new RemoteCacheManager(
+ new ConfigurationBuilder()
+ .addServers(getInfispanUrl())
+ .security().authentication().username("admin")
+ .password("password").realm("default")
+ .serverName("infinispan").saslMechanism("DIGEST-MD5")
+ .build(),
+ true),
+ "mycache"))
+ .skipDuplicate(true)
+ .to("mock:result");
+ }
+ };
+ }
+}