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 d8c83438459 CAMEL-21974: camel-j8583: ISO-8583 data format
d8c83438459 is described below

commit d8c83438459a1cbe3e836bf4fdf33e0cb6356a57
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Jul 20 13:36:19 2025 +0200

    CAMEL-21974: camel-j8583: ISO-8583 data format
---
 components/camel-iso8583/pom.xml                   | 10 ++++
 .../src/main/docs/iso8583-dataformat.adoc          | 24 ++++++++
 .../iso8583/Iso8583DataFormatSimpleTest.java       | 69 ++++++++++++++++++++++
 .../src/test/resources/log4j2.properties           |  2 +-
 4 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/components/camel-iso8583/pom.xml b/components/camel-iso8583/pom.xml
index bc057aa6ebd..712d0cd3f78 100644
--- a/components/camel-iso8583/pom.xml
+++ b/components/camel-iso8583/pom.xml
@@ -49,6 +49,16 @@
             <artifactId>camel-test-spring-junit5</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-jackson</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-groovy</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter</artifactId>
diff --git a/components/camel-iso8583/src/main/docs/iso8583-dataformat.adoc 
b/components/camel-iso8583/src/main/docs/iso8583-dataformat.adoc
index e5e8fac6fae..3cc400ff9af 100644
--- a/components/camel-iso8583/src/main/docs/iso8583-dataformat.adoc
+++ b/components/camel-iso8583/src/main/docs/iso8583-dataformat.adoc
@@ -65,6 +65,30 @@ from("direct:payment")
   .to("bean:payment");
 ----
 
+== Example
+
+You can use this data format to unmarshal a ISO-8853 message such as a 0210 
payment response, and then select the information
+from the message you need and covert this to JSon as shown below:
+
+[source,java]
+----
+from("jms:payment:response")
+        .unmarshal().iso8583("0210")
+        .transform().simple(
+            """
+                  {
+                    "op": "${body.getAt(3).value}",
+                    "amount": ${body.getAt(4).value.toPlainString},
+                    "ref": "${body.getAt(37).value}",
+                    "response": "${body.getAt(39).value}",
+                    "terminal": "${body.getAt(41).value}",
+                    "currency": "${body.getAt(49).value}"
+                  }
+            """)
+        .to("direct:payementResponse");
+----
+
+
 == More Information
 
 Find more information see the http://j8583.sourceforge.net/[J8583 project]
diff --git 
a/components/camel-iso8583/src/test/java/org/apache/camel/dataformat/iso8583/Iso8583DataFormatSimpleTest.java
 
b/components/camel-iso8583/src/test/java/org/apache/camel/dataformat/iso8583/Iso8583DataFormatSimpleTest.java
new file mode 100644
index 00000000000..70f42bebfb5
--- /dev/null
+++ 
b/components/camel-iso8583/src/test/java/org/apache/camel/dataformat/iso8583/Iso8583DataFormatSimpleTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.dataformat.iso8583;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.camel.RoutesBuilder;
+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;
+
+public class Iso8583DataFormatSimpleTest extends CamelTestSupport {
+
+    @Test
+    public void testUnmarshal() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        
getMockEndpoint("mock:result").message(0).body().isInstanceOf(Map.class);
+        
getMockEndpoint("mock:result").message(0).body().simple("${body[op]}").isEqualTo("650000");
+        
getMockEndpoint("mock:result").message(0).body().simple("${body[amount]}").isEqualTo("30.00");
+        
getMockEndpoint("mock:result").message(0).body().simple("${body[ref]}").isEqualTo("001234425791");
+        
getMockEndpoint("mock:result").message(0).body().simple("${body[response]}").isEqualTo("00");
+        
getMockEndpoint("mock:result").message(0).body().simple("${body[terminal]}").isEqualTo("614209027600TéST");
+        
getMockEndpoint("mock:result").message(0).body().simple("${body[currency]}").isEqualTo("484");
+
+        template.sendBody("direct:unmarshal", new 
File("src/test/resources/parse1.txt"));
+
+        MockEndpoint.assertIsSatisfied(context);
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:unmarshal").unmarshal().iso8583("0210")
+                        .transform().simple(
+                                """
+                                          {
+                                            "op": "${body.getAt(3).value}",
+                                            "amount": 
${body.getAt(4).value.toPlainString},
+                                            "ref": "${body.getAt(37).value}",
+                                            "response": 
"${body.getAt(39).value}",
+                                            "terminal": 
"${body.getAt(41).value}",
+                                            "currency": 
"${body.getAt(49).value}"
+                                          }
+                                        """)
+                        .log("${body}")
+                        .unmarshal().json()
+                        .to("mock:result");
+            }
+        };
+    }
+}
diff --git a/components/camel-iso8583/src/test/resources/log4j2.properties 
b/components/camel-iso8583/src/test/resources/log4j2.properties
index 57c81cd2890..67651f81af9 100644
--- a/components/camel-iso8583/src/test/resources/log4j2.properties
+++ b/components/camel-iso8583/src/test/resources/log4j2.properties
@@ -24,5 +24,5 @@ appender.out.type = Console
 appender.out.name = out
 appender.out.layout.type = PatternLayout
 appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-rootLogger.level = DEBUG
+rootLogger.level = INFO
 rootLogger.appenderRef.file.ref = file

Reply via email to