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 2020/11/13 05:35:32 UTC
[camel] branch master updated: CAMEL-15769: add camel-jsonpath
tests for new 'false' tokenizer (#4601)
This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 d647743 CAMEL-15769: add camel-jsonpath tests for new 'false' tokenizer (#4601)
d647743 is described below
commit d647743150d226101a37ca6ec29d5bddd3d43b95
Author: Scott Carrier <sr...@users.noreply.github.com>
AuthorDate: Fri Nov 13 00:23:39 2020 -0500
CAMEL-15769: add camel-jsonpath tests for new 'false' tokenizer (#4601)
---
.../apache/camel/jsonpath/JsonPathSplitTest.java | 46 ++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathSplitTest.java b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathSplitTest.java
index 8dd01a8..4a63c1b 100644
--- a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathSplitTest.java
+++ b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathSplitTest.java
@@ -20,6 +20,7 @@ import java.io.File;
import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
@@ -38,6 +39,18 @@ public class JsonPathSplitTest extends CamelTestSupport {
.split().jsonpath("$.store.book[*]")
.to("mock:authors")
.convertBodyTo(String.class);
+
+ from("direct:start-1")
+ .split(jsonpath("text.div", String.class), "false")
+ .to("mock:result-1");
+
+ from("direct:start-2")
+ .split(jsonpath("text.div", String.class))
+ .to("mock:result-2");
+
+ from("direct:start-3")
+ .split(jsonpath("text.div", String.class), "#")
+ .to("mock:result-3");
}
};
}
@@ -66,4 +79,37 @@ public class JsonPathSplitTest extends CamelTestSupport {
assertTrue(out.contains("\"price\": 12.99,"));
}
+ @Test
+ public void testJsonPathSplitDelimiterDisable() throws Exception {
+ // CAMEL-15769
+ String json = "{ \"text\": { \"div\": \"some , text\" } }";
+ MockEndpoint m = getMockEndpoint("mock:result-1");
+ m.expectedPropertyReceived("CamelSplitSize", 1);
+ m.expectedBodiesReceived("some , text");
+ template.sendBody("direct:start-1", json);
+ m.assertIsSatisfied();
+ }
+
+ @Test
+ public void testJsonPathSplitDelimiterDefault() throws Exception {
+ // CAMEL-15769
+ String json = "{ \"text\": { \"div\": \"some , text\" } }";
+ MockEndpoint m = getMockEndpoint("mock:result-2");
+ m.expectedPropertyReceived("CamelSplitSize", 2);
+ m.expectedBodiesReceived("some ", " text");
+ template.sendBody("direct:start-2", json);
+ m.assertIsSatisfied();
+ }
+
+ @Test
+ public void testJsonPathSplitDelimiter() throws Exception {
+ // CAMEL-15769
+ String json = "{ \"text\": { \"div\": \"some ,# text\" } }";
+ MockEndpoint m = getMockEndpoint("mock:result-3");
+ m.expectedPropertyReceived("CamelSplitSize", 2);
+ m.expectedBodiesReceived("some ,", " text");
+ template.sendBody("direct:start-3", json);
+ m.assertIsSatisfied();
+ }
+
}