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 2022/08/08 13:16:06 UTC
[camel] branch main updated: CAMEL-18364: Added unit test
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
The following commit(s) were added to refs/heads/main by this push:
new b09ba6cbcff CAMEL-18364: Added unit test
b09ba6cbcff is described below
commit b09ba6cbcffe7fbac1f02d6d6d6f6cde018027bb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Aug 8 15:15:24 2022 +0200
CAMEL-18364: Added unit test
---
.../jsonpath/JsonPathChoicePrimitiveTest.java | 53 ++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathChoicePrimitiveTest.java b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathChoicePrimitiveTest.java
new file mode 100644
index 00000000000..852379d9c61
--- /dev/null
+++ b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathChoicePrimitiveTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.jsonpath;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+public class JsonPathChoicePrimitiveTest extends CamelTestSupport {
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .choice()
+ .when().jsonpath("$[?(@.counter>0)]")
+ .to("mock:positive")
+ .otherwise()
+ .to("mock:zero")
+ .end();
+ }
+ };
+ }
+
+ @Test
+ public void testCounter() throws Exception {
+ getMockEndpoint("mock:positive").expectedBodiesReceived("{\"counter\": 1}", "{\"counter\": 2}");
+ getMockEndpoint("mock:zero").expectedBodiesReceived("{\"counter\": 0}");
+
+ template.sendBody("direct:start", "{\"counter\": 1}");
+ template.sendBody("direct:start", "{\"counter\": 0}");
+ template.sendBody("direct:start", "{\"counter\": 2}");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}