You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/10/18 13:39:40 UTC
[camel] branch main updated (281656e -> 20c6cd1)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.
from 281656e (chores) camel-ribbon: use dynamic ports to prevent test failures
new cf2410b CAMEL-17101: Split EIP should support splitting a java.util.Map into a Set<Map.Entry> - so it works out of the box, and what you would assume Camel can do.
new 2fc2127 Polished
new 20c6cd1 CAMEL-17101: Split EIP should support splitting a java.util.Map into a Set<Map.Entry> - so it works out of the box, and what you would assume Camel can do.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
...erRegexpGroupTest.java => SplitterMapTest.java} | 27 +++++++++++++++-------
.../org/apache/camel/support/ObjectHelper.java | 11 ++++-----
.../ROOT/pages/camel-3x-upgrade-guide-3_13.adoc | 5 ++++
3 files changed, 29 insertions(+), 14 deletions(-)
copy core/camel-core/src/test/java/org/apache/camel/processor/{SplitTokenizerRegexpGroupTest.java => SplitterMapTest.java} (62%)
[camel] 01/03: CAMEL-17101: Split EIP should support splitting a
java.util.Map into a Set - so it works out of the box,
and what you would assume Camel can do.
Posted by da...@apache.org.
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.git
commit cf2410bf8a5fa898ef9dfb8e4c58c6498da72403
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Oct 18 15:21:42 2021 +0200
CAMEL-17101: Split EIP should support splitting a java.util.Map into a Set<Map.Entry> - so it works out of the box, and what you would assume Camel can do.
---
.../apache/camel/processor/SplitterMapTest.java | 59 ++++++++++++++++++++++
.../org/apache/camel/support/ObjectHelper.java | 4 ++
2 files changed, 63 insertions(+)
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterMapTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterMapTest.java
new file mode 100644
index 0000000..d6fe903
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterMapTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.processor;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+public class SplitterMapTest extends ContextTestSupport {
+
+ @Test
+ public void testSplitMap() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:line");
+ mock.message(0).body().isEqualTo("Hello World");
+ mock.message(0).header("myKey").isEqualTo("123");
+ mock.message(1).body().isEqualTo("Bye World");
+ mock.message(1).header("myKey").isEqualTo("789");
+
+ Map<String, String> map = new LinkedHashMap<>();
+ map.put("123", "Hello World");
+ map.put("789", "Bye World");
+
+ template.sendBody("direct:start", map);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .split(body())
+ .setHeader("myKey").simple("${body.key}")
+ .setBody(simple("${body.value}"))
+ .to("mock:line");
+ }
+ };
+ }
+}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
index c4f982b..11dc820 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
@@ -24,6 +24,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Locale;
+import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.Callable;
import java.util.regex.Pattern;
@@ -694,6 +695,9 @@ public final class ObjectHelper {
};
} else if (value instanceof Iterable) {
return (Iterable<Object>) value;
+ } else if (value instanceof Map) {
+ Map<?, ?> map = (Map<?, ?>) value;
+ return map.entrySet();
} else if (value.getClass().isArray()) {
if (org.apache.camel.util.ObjectHelper.isPrimitiveArrayType(value.getClass())) {
final Object array = value;
[camel] 02/03: Polished
Posted by da...@apache.org.
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.git
commit 2fc21275d62dd88972ad3d4bad9725a0ca49dd9f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Oct 18 15:35:22 2021 +0200
Polished
---
.../src/main/java/org/apache/camel/support/ObjectHelper.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
index 11dc820..3d21f38 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
@@ -687,12 +687,7 @@ public final class ObjectHelper {
return Collections.emptyList();
} else if (value instanceof Iterator) {
final Iterator<Object> iterator = (Iterator<Object>) value;
- return new Iterable<Object>() {
- @Override
- public Iterator<Object> iterator() {
- return iterator;
- }
- };
+ return (Iterable<Object>) () -> iterator;
} else if (value instanceof Iterable) {
return (Iterable<Object>) value;
} else if (value instanceof Map) {
[camel] 03/03: CAMEL-17101: Split EIP should support splitting a
java.util.Map into a Set - so it works out of the box,
and what you would assume Camel can do.
Posted by da...@apache.org.
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.git
commit 20c6cd1a7ed6bd353cf51a2842187aa6d388e1c3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Oct 18 15:37:16 2021 +0200
CAMEL-17101: Split EIP should support splitting a java.util.Map into a Set<Map.Entry> - so it works out of the box, and what you would assume Camel can do.
---
docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_13.adoc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_13.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_13.adoc
index 8908124..27d224a 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_13.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_13.adoc
@@ -12,6 +12,11 @@ Added method `getStartedEventNotifiers` to `org.apache.camel.spi.ManagementStrat
Added method `scheduleQueue` to `org.apache.camel.spi.ReactiveExecutor`.
+=== Split EIP
+
+The Split EIP now supports splitting message bodies that are of type `java.util.Map`, which
+now splits that into a `Set<Map.Entry>` - eg a set of each map entry as key/value pairs.
+
=== SimpleBuilder
The `org.apache.camel.builder.SimpleBuilder` has been deprecated. This builder