This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit ea32b1383a01914492414328ca718ec967e145e9 Author: Nicolas Filotto <essob...@users.noreply.github.com> AuthorDate: Thu Jun 8 08:42:44 2023 +0200 Ref #4220: Add the camel-swift extension (#4315) ## Motivation There is a new component (dataformat) called `camel-swift` that we would like to add to the project. ## Modifications: * Creates the new extension thanks to the maven plugin * Adds support of the JVM mode for both types of messages (MX and MT) * Adds support of the native mode to MT messages only because MX messages bring too many classes, methods, and fields to access by reflection which slows down the native image build --- docs/modules/ROOT/examples/dataformats/swiftMt.yml | 13 ++ docs/modules/ROOT/examples/dataformats/swiftMx.yml | 13 ++ docs/modules/ROOT/nav.adoc | 1 + .../ROOT/pages/reference/extensions/swift.adoc | 56 +++++++ extensions/pom.xml | 1 + extensions/swift/deployment/pom.xml | 67 ++++++++ .../component/swift/deployment/SwiftProcessor.java | 100 +++++++++++ extensions/swift/pom.xml | 39 +++++ extensions/swift/runtime/pom.xml | 104 ++++++++++++ .../swift/runtime/src/main/doc/limitations.adoc | 4 + .../main/resources/META-INF/quarkus-extension.yaml | 31 ++++ integration-tests/pom.xml | 1 + integration-tests/swift/pom.xml | 144 ++++++++++++++++ .../component/swift/mt/it/SwiftMtResource.java | 78 +++++++++ .../component/swift/mt/it/SwiftMtRoutes.java | 32 ++++ .../component/swift/mx/it/SwiftMxResource.java | 103 ++++++++++++ .../component/swift/mx/it/SwiftMxRoutes.java | 40 +++++ .../quarkus/component/swift/mt/it/SwiftMtIT.java | 24 +++ .../quarkus/component/swift/mt/it/SwiftMtTest.java | 65 ++++++++ .../quarkus/component/swift/mx/it/SwiftMxIT.java | 26 +++ .../quarkus/component/swift/mx/it/SwiftMxTest.java | 86 ++++++++++ .../swift/src/test/resources/mt/message1.txt | 55 ++++++ .../swift/src/test/resources/mt/message2.json | 128 ++++++++++++++ .../swift/src/test/resources/mt/message2.txt | 20 +++ .../swift/src/test/resources/mx/message1.xml | 38 +++++ .../swift/src/test/resources/mx/message2.json | 184 +++++++++++++++++++++ .../swift/src/test/resources/mx/message2.xml | 129 +++++++++++++++ .../swift/src/test/resources/mx/message3.xml | 43 +++++ poms/bom/pom.xml | 15 ++ poms/bom/src/main/generated/flattened-full-pom.xml | 5 + .../src/main/generated/flattened-reduced-pom.xml | 5 + .../generated/flattened-reduced-verbose-pom.xml | 5 + tooling/scripts/test-categories.yaml | 1 + 33 files changed, 1656 insertions(+) diff --git a/docs/modules/ROOT/examples/dataformats/swiftMt.yml b/docs/modules/ROOT/examples/dataformats/swiftMt.yml new file mode 100644 index 0000000000..d408659fec --- /dev/null +++ b/docs/modules/ROOT/examples/dataformats/swiftMt.yml @@ -0,0 +1,13 @@ +# Do not edit directly! +# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +cqArtifactId: camel-quarkus-swift +cqArtifactIdBase: swift +cqNativeSupported: true +cqStatus: Stable +cqDeprecated: false +cqJvmSince: 3.0.0 +cqNativeSince: 3.0.0 +cqCamelPartName: swiftMt +cqCamelPartTitle: SWIFT MT +cqCamelPartDescription: Encode and decode SWIFT MT messages. +cqExtensionPageTitle: SWIFT diff --git a/docs/modules/ROOT/examples/dataformats/swiftMx.yml b/docs/modules/ROOT/examples/dataformats/swiftMx.yml new file mode 100644 index 0000000000..35bc055967 --- /dev/null +++ b/docs/modules/ROOT/examples/dataformats/swiftMx.yml @@ -0,0 +1,13 @@ +# Do not edit directly! +# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +cqArtifactId: camel-quarkus-swift +cqArtifactIdBase: swift +cqNativeSupported: true +cqStatus: Stable +cqDeprecated: false +cqJvmSince: 3.0.0 +cqNativeSince: 3.0.0 +cqCamelPartName: swiftMx +cqCamelPartTitle: SWIFT MX +cqCamelPartDescription: Encode and decode SWIFT MX messages. +cqExtensionPageTitle: SWIFT diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 55b6f8ef01..d723a52020 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -257,6 +257,7 @@ *** xref:reference/extensions/soap.adoc[SOAP dataformat] *** xref:reference/extensions/sql.adoc[SQL] *** xref:reference/extensions/ssh.adoc[SSH] +*** xref:reference/extensions/swift.adoc[SWIFT] *** xref:reference/extensions/saga.adoc[Saga] *** xref:reference/extensions/salesforce.adoc[Salesforce] *** xref:reference/extensions/scheduler.adoc[Scheduler] diff --git a/docs/modules/ROOT/pages/reference/extensions/swift.adoc b/docs/modules/ROOT/pages/reference/extensions/swift.adoc new file mode 100644 index 0000000000..dfd5704aa3 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/swift.adoc @@ -0,0 +1,56 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +[id="extensions-swift"] += SWIFT +:linkattrs: +:cq-artifact-id: camel-quarkus-swift +:cq-native-supported: true +:cq-status: Stable +:cq-status-deprecation: Stable +:cq-description: Encode and decode SWIFT messages. +:cq-deprecated: false +:cq-jvm-since: 3.0.0 +:cq-native-since: 3.0.0 + +ifeval::[{doc-show-badges} == true] +[.badges] +[.badge-key]##JVM since##[.badge-supported]##3.0.0## [.badge-key]##Native since##[.badge-supported]##3.0.0## +endif::[] + +Encode and decode SWIFT messages. + +[id="extensions-swift-whats-inside"] +== What's inside + +* xref:{cq-camel-components}:dataformats:swiftMt-dataformat.adoc[SWIFT MT data format] +* xref:{cq-camel-components}:dataformats:swiftMx-dataformat.adoc[SWIFT MX data format] + +Please refer to the above links for usage and configuration details. + +[id="extensions-swift-maven-coordinates"] +== Maven coordinates + +https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-swift[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"] + +Or add the coordinates to your existing project: + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-swift</artifactId> +</dependency> +---- +ifeval::[{doc-show-user-guide-link} == true] +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. +endif::[] + +[id="extensions-swift-camel-quarkus-limitations"] +== Camel Quarkus limitations + +[id="extensions-swift-limitations-mx-types"] +=== MX types + +The MX message types are not supported in native mode because it drastically slows down the native image build due to an +excessive amount of classes, methods, and fields to access by reflection that need to be registered. + diff --git a/extensions/pom.xml b/extensions/pom.xml index 6c93986a3b..9a6f56baee 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -226,6 +226,7 @@ <module>stax</module> <module>stream</module> <module>stringtemplate</module> + <module>swift</module> <module>syslog</module> <module>tarfile</module> <module>telegram</module> diff --git a/extensions/swift/deployment/pom.xml b/extensions/swift/deployment/pom.xml new file mode 100644 index 0000000000..a8dcc06653 --- /dev/null +++ b/extensions/swift/deployment/pom.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-swift-parent</artifactId> + <version>3.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-swift-deployment</artifactId> + <name>Camel Quarkus :: SWIFT :: Deployment</name> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jaxb-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-swift</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/extensions/swift/deployment/src/main/java/org/apache/camel/quarkus/component/swift/deployment/SwiftProcessor.java b/extensions/swift/deployment/src/main/java/org/apache/camel/quarkus/component/swift/deployment/SwiftProcessor.java new file mode 100644 index 0000000000..af36412a9c --- /dev/null +++ b/extensions/swift/deployment/src/main/java/org/apache/camel/quarkus/component/swift/deployment/SwiftProcessor.java @@ -0,0 +1,100 @@ +/* + * 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.quarkus.component.swift.deployment; + +import com.prowidesoftware.swift.model.AbstractMessage; +import com.prowidesoftware.swift.model.MessageStandardType; +import com.prowidesoftware.swift.model.SwiftBlock; +import com.prowidesoftware.swift.model.Tag; +import com.prowidesoftware.swift.model.UnparsedTextList; +import com.prowidesoftware.swift.model.field.Field; +import com.prowidesoftware.swift.model.field.Narrative; +import com.prowidesoftware.swift.model.field.StructuredNarrative; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.IndexDependencyBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import org.jboss.jandex.DotName; +import org.jboss.jandex.IndexView; + +class SwiftProcessor { + + private static final String FEATURE = "camel-swift"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + void indexDependencies(BuildProducer<IndexDependencyBuildItem> indexedDependency) { + // The dependency for MX message types + // Adding this dependency slows down drastically the native image build since it brings a lot of reflection + // indexedDependency.produce(new IndexDependencyBuildItem("com.prowidesoftware", "pw-iso20022")); + // The dependency for MT message types + indexedDependency.produce(new IndexDependencyBuildItem("com.prowidesoftware", "pw-swift-core")); + } + + @BuildStep + void registerOtherTypesForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) { + + reflectiveClass.produce( + ReflectiveClassBuildItem + .builder(Tag.class, UnparsedTextList.class, MessageStandardType.class, Narrative.class, + StructuredNarrative.class) + .fields() + .build()); + + } + + @BuildStep + void registerMessageTypesForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, + CombinedIndexBuildItem combinedIndex) { + reflectiveClass.produce(ReflectiveClassBuildItem.builder(AbstractMessage.class) + .methods().fields().build()); + registerForReflection(combinedIndex, AbstractMessage.class.getName(), reflectiveClass); + } + + @BuildStep + void registerFieldTypesForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, + CombinedIndexBuildItem combinedIndex) { + + registerForReflection(combinedIndex, Field.class.getName(), reflectiveClass); + } + + @BuildStep + void registerSwiftBlocksForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, + CombinedIndexBuildItem combinedIndex) { + reflectiveClass.produce(ReflectiveClassBuildItem.builder(SwiftBlock.class).fields().build()); + registerForReflection(combinedIndex, SwiftBlock.class.getName(), reflectiveClass); + } + + private static void registerForReflection(CombinedIndexBuildItem combinedIndex, String className, + BuildProducer<ReflectiveClassBuildItem> reflectiveClass) { + IndexView index = combinedIndex.getIndex(); + + String[] classes = index.getAllKnownSubclasses(DotName.createSimple(className)) + .stream() + .map(classInfo -> classInfo.name().toString()) + .toArray(String[]::new); + + // Register classes for refection + reflectiveClass.produce(ReflectiveClassBuildItem.builder(classes).fields().build()); + } +} diff --git a/extensions/swift/pom.xml b/extensions/swift/pom.xml new file mode 100644 index 0000000000..289fa8cd12 --- /dev/null +++ b/extensions/swift/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-extensions</artifactId> + <version>3.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-swift-parent</artifactId> + <name>Camel Quarkus :: SWIFT</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/swift/runtime/pom.xml b/extensions/swift/runtime/pom.xml new file mode 100644 index 0000000000..9427c2d0e8 --- /dev/null +++ b/extensions/swift/runtime/pom.xml @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-swift-parent</artifactId> + <version>3.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-swift</artifactId> + <name>Camel Quarkus :: SWIFT :: Runtime</name> + <description>Encode and decode SWIFT messages.</description> + + <properties> + <camel.quarkus.jvmSince>3.0.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>3.0.0</camel.quarkus.nativeSince> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jaxb</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-swift</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>full</id> + <activation> + <property> + <name>!quickly</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>update-extension-doc-page</id> + <goals> + <goal>update-extension-doc-page</goal> + </goals> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/extensions/swift/runtime/src/main/doc/limitations.adoc b/extensions/swift/runtime/src/main/doc/limitations.adoc new file mode 100644 index 0000000000..0448a2e631 --- /dev/null +++ b/extensions/swift/runtime/src/main/doc/limitations.adoc @@ -0,0 +1,4 @@ +=== MX types + +The MX message types are not supported in native mode because it drastically slows down the native image build due to an +excessive amount of classes, methods, and fields to access by reflection that need to be registered. diff --git a/extensions/swift/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/swift/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000..8cad8b67a4 --- /dev/null +++ b/extensions/swift/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel SWIFT" +description: "Encode and decode SWIFT messages" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/swift.html" + categories: + - "integration" + status: + - "stable" diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index bb197206fa..9dc57f5c65 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -215,6 +215,7 @@ <module>ssh</module> <module>stax</module> <module>stringtemplate</module> + <module>swift</module> <!--<module>syndication</module> https://github.com/apache/camel-quarkus/issues/4515 --> <module>syslog</module> <module>tarfile</module> diff --git a/integration-tests/swift/pom.xml b/integration-tests/swift/pom.xml new file mode 100644 index 0000000000..fd7b05e972 --- /dev/null +++ b/integration-tests/swift/pom.xml @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent-it</artifactId> + <version>3.0.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent-it/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-swift</artifactId> + <name>Camel Quarkus :: Integration Tests :: SWIFT</name> + <description>Integration tests for Camel Quarkus SWIFT extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-swift</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + <scope>runtime</scope> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <argLine>--add-opens java.base/java.time=ALL-UNNAMED + </argLine> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>virtualDependencies</id> + <activation> + <property> + <name>!noVirtualDependencies</name> + </property> + </activation> + <dependencies> + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-swift-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </profile> + </profiles> + +</project> diff --git a/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtResource.java b/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtResource.java new file mode 100644 index 0000000000..612d387107 --- /dev/null +++ b/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtResource.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.quarkus.component.swift.mt.it; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import com.prowidesoftware.swift.model.mt.mt1xx.MT103; +import com.prowidesoftware.swift.model.mt.mt5xx.MT515; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import org.apache.camel.ProducerTemplate; + +@Path("/swift-mt") +@ApplicationScoped +public class SwiftMtResource { + + @Inject + ProducerTemplate producerTemplate; + + @Path("/unmarshal") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String unmarshal(byte[] message) { + final MT515 response = producerTemplate.requestBody("direct:mt.unmarshal", message, MT515.class); + return response.getMessageType(); + } + + @Path("/unmarshaldsl") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String unmarshalDsl(byte[] message) { + final MT515 response = producerTemplate.requestBody("direct:mt.unmarshaldsl", message, MT515.class); + return response.getMessageType(); + } + + @Path("/marshal") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String marshal(byte[] body) throws IOException { + MT103 message = MT103.parse(new ByteArrayInputStream(body)); + final Object response = producerTemplate.requestBody("direct:mt.marshal", message); + MT103 actual = MT103.parse((InputStream) response); + return actual.getMessageType(); + } + + @Path("/marshalJson") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public Object marshalJson(byte[] body) throws IOException { + MT103 message = MT103.parse(new ByteArrayInputStream(body)); + return producerTemplate.requestBody("direct:mt.marshalJson", message); + } +} diff --git a/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtRoutes.java b/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtRoutes.java new file mode 100644 index 0000000000..9c6ecc956e --- /dev/null +++ b/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtRoutes.java @@ -0,0 +1,32 @@ +/* + * 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.quarkus.component.swift.mt.it; + +import jakarta.enterprise.context.ApplicationScoped; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.SwiftMtDataFormat; + +@ApplicationScoped +public class SwiftMtRoutes extends RouteBuilder { + @Override + public void configure() { + from("direct:mt.unmarshal").unmarshal(new SwiftMtDataFormat()); + from("direct:mt.unmarshaldsl").unmarshal().swiftMt(); + from("direct:mt.marshal").marshal(new SwiftMtDataFormat()); + from("direct:mt.marshalJson").marshal(new SwiftMtDataFormat("true")); + } +} diff --git a/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxResource.java b/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxResource.java new file mode 100644 index 0000000000..520520429e --- /dev/null +++ b/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxResource.java @@ -0,0 +1,103 @@ +/* + * 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.quarkus.component.swift.mx.it; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; + +import com.prowidesoftware.swift.model.mx.MxCamt04800103; +import com.prowidesoftware.swift.model.mx.MxPacs00800107; +import com.prowidesoftware.swift.model.mx.sys.MxXsys01100102; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import org.apache.camel.ProducerTemplate; +import org.apache.commons.io.IOUtils; + +@Path("/swift-mx") +@ApplicationScoped +public class SwiftMxResource { + + @Inject + ProducerTemplate producerTemplate; + + @Path("/unmarshal") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String unmarshal(byte[] message) { + final MxCamt04800103 response = producerTemplate.requestBody("direct:mx.unmarshal", message, MxCamt04800103.class); + return response.getMxId().id(); + } + + @Path("/unmarshaldsl") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String unmarshalDsl(byte[] message) { + final MxCamt04800103 response = producerTemplate.requestBody("direct:mx.unmarshaldsl", message, MxCamt04800103.class); + return response.getMxId().id(); + } + + @Path("/unmarshalFull") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String unmarshalFull(byte[] message) { + final MxXsys01100102 response = producerTemplate.requestBody("direct:mx.unmarshalFull", message, MxXsys01100102.class); + return response.getMxId().id(); + } + + @Path("/marshal") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String marshal(byte[] body) throws IOException { + MxPacs00800107 message = MxPacs00800107.parse(new String(body)); + final Object response = producerTemplate.requestBody("direct:mx.marshal", message); + MxPacs00800107 actual = MxPacs00800107.parse(IOUtils.toString((InputStream) response, StandardCharsets.UTF_8)); + return actual.getMxId().id(); + } + + @Path("/marshalFull") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public boolean marshalFull(byte[] body) throws IOException { + MxPacs00800107 message = MxPacs00800107.parse(new String(body)); + final Object response = producerTemplate.requestBody("direct:mx.marshalFull", message); + BufferedReader reader = new BufferedReader(new InputStreamReader((InputStream) response, StandardCharsets.UTF_8)); + String line = reader.readLine(); + return line.contains("<?xml"); + } + + @Path("/marshalJson") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public Object marshalJson(byte[] body) throws IOException { + MxPacs00800107 message = MxPacs00800107.parse(new String(body)); + return producerTemplate.requestBody("direct:mx.marshalJson", message); + } +} diff --git a/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxRoutes.java b/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxRoutes.java new file mode 100644 index 0000000000..5939dbc7e0 --- /dev/null +++ b/integration-tests/swift/src/main/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxRoutes.java @@ -0,0 +1,40 @@ +/* + * 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.quarkus.component.swift.mx.it; + +import com.prowidesoftware.swift.model.mx.MxReadConfiguration; +import com.prowidesoftware.swift.model.mx.MxWriteConfiguration; +import jakarta.enterprise.context.ApplicationScoped; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.SwiftMxDataFormat; + +@ApplicationScoped +public class SwiftMxRoutes extends RouteBuilder { + @Override + public void configure() { + from("direct:mx.unmarshal").unmarshal(new SwiftMxDataFormat()); + from("direct:mx.unmarshaldsl").unmarshal().swiftMx(); + MxReadConfiguration readConfig = new MxReadConfiguration(); + from("direct:mx.unmarshalFull") + .unmarshal(new SwiftMxDataFormat(false, "urn:swift:xsd:xsys.011.001.02", readConfig)); + from("direct:mx.marshal").marshal(new SwiftMxDataFormat()); + MxWriteConfiguration writeConfiguration = new MxWriteConfiguration(); + writeConfiguration.includeXMLDeclaration = false; + from("direct:mx.marshalFull").marshal(new SwiftMxDataFormat(writeConfiguration, null, null)); + from("direct:mx.marshalJson").marshal(new SwiftMxDataFormat(true)); + } +} diff --git a/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtIT.java b/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtIT.java new file mode 100644 index 0000000000..0a008bf506 --- /dev/null +++ b/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtIT.java @@ -0,0 +1,24 @@ +/* + * 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.quarkus.component.swift.mt.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class SwiftMtIT extends SwiftMtTest { + +} diff --git a/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtTest.java b/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtTest.java new file mode 100644 index 0000000000..5fcb79a596 --- /dev/null +++ b/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mt/it/SwiftMtTest.java @@ -0,0 +1,65 @@ +/* + * 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.quarkus.component.swift.mt.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.hamcrest.Matchers.equalTo; + +@QuarkusTest +class SwiftMtTest { + + @ParameterizedTest + @ValueSource(strings = { "", "dsl" }) + void testUnmarshal(String mode) throws Exception { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(getClass().getResourceAsStream("/mt/message1.txt").readAllBytes()) + .post(String.format("/swift-mt/unmarshal%s", mode)) // + .then() + .body(equalTo("515")) + .statusCode(200); + } + + @Test + void testMarshal() throws Exception { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(getClass().getResourceAsStream("/mt/message2.txt").readAllBytes()) + .post("/swift-mt/marshal") // + .then() + .body(equalTo("103")) + .statusCode(200); + } + + @Test + void testMarshalJson() throws Exception { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(getClass().getResourceAsStream("/mt/message2.txt").readAllBytes()) + .post("/swift-mt/marshalJson") // + .then() + .body(equalTo(new String(getClass().getResourceAsStream("/mt/message2.json").readAllBytes()).trim())) + .statusCode(200); + } + +} diff --git a/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxIT.java b/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxIT.java new file mode 100644 index 0000000000..8f4725c768 --- /dev/null +++ b/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxIT.java @@ -0,0 +1,26 @@ +/* + * 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.quarkus.component.swift.mx.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.junit.jupiter.api.Disabled; + +@Disabled("MX types are not supported in Native mode as it drastically slows down the native image build") +@QuarkusIntegrationTest +class SwiftMxIT extends SwiftMxTest { + +} diff --git a/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxTest.java b/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxTest.java new file mode 100644 index 0000000000..ca2439d4d6 --- /dev/null +++ b/integration-tests/swift/src/test/java/org/apache/camel/quarkus/component/swift/mx/it/SwiftMxTest.java @@ -0,0 +1,86 @@ +/* + * 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.quarkus.component.swift.mx.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.hamcrest.Matchers.equalTo; + +@QuarkusTest +class SwiftMxTest { + + @ParameterizedTest + @ValueSource(strings = { "", "dsl" }) + void testUnmarshal(String mode) throws Exception { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(getClass().getResourceAsStream("/mx/message1.xml").readAllBytes()) + .post(String.format("/swift-mx/unmarshal%s", mode)) // + .then() + .body(equalTo("camt.048.001.03")) + .statusCode(200); + } + + @Test + void testUnmarshalFull() throws Exception { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(getClass().getResourceAsStream("/mx/message3.xml").readAllBytes()) + .post("/swift-mx/unmarshalFull") // + .then() + .body(equalTo("xsys.011.001.02")) + .statusCode(200); + } + + @Test + void testMarshal() throws Exception { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(getClass().getResourceAsStream("/mx/message2.xml").readAllBytes()) + .post("/swift-mx/marshal") // + .then() + .body(equalTo("pacs.008.001.07")) + .statusCode(200); + } + + @Test + void testMarshalFull() throws Exception { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(getClass().getResourceAsStream("/mx/message2.xml").readAllBytes()) + .post("/swift-mx/marshalFull") // + .then() + .body(equalTo("false")) + .statusCode(200); + } + + @Test + void testMarshalJson() throws Exception { + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(getClass().getResourceAsStream("/mx/message2.xml").readAllBytes()) + .post("/swift-mx/marshalJson") // + .then() + .body(equalTo(new String(getClass().getResourceAsStream("/mx/message2.json").readAllBytes()).trim())) + .statusCode(200); + } +} diff --git a/integration-tests/swift/src/test/resources/mt/message1.txt b/integration-tests/swift/src/test/resources/mt/message1.txt new file mode 100644 index 0000000000..a474f5c31b --- /dev/null +++ b/integration-tests/swift/src/test/resources/mt/message1.txt @@ -0,0 +1,55 @@ +{1:F01AAAAIT2TAXXX8236800622}{2:O5151648131111BBBBLULLCFND22278474801311111648N}{4: +:16R:GENL +:20C::SEME//FRTJ123456789 +:23G:NEWM +:22F::TRTR//TRAD +:16R:LINK +:13A::LINK//514 +:20C::RELA//0405D012AA +:16S:LINK +:16S:GENL +:16R:CONFDET +:98A::TRAD//20210112 +:98A::SETT//20210117 +:90A::DEAL//PRCT/101,001283 +:22F::PRIC//AVER +:22H::PAYM//APMT +:22H::BUSE//BUYI +:16R:CONFPRTY +:95P::INVE//FUNANIC1 +:16S:CONFPRTY +:16R:CONFPRTY +:95P::BUYR//MGTCDE55 +:16S:CONFPRTY +:16R:CONFPRTY +:95P::SELL//CFPIDEFF +:16S:CONFPRTY +:36B::CONF//FAMT/4000000, +:35B:ISIN GB0123412345 +:16S:CONFDET +:16R:SETDET +:22F::SETR//TRAD +:16R:SETPRTY +:95R::DEAG/CRST/111 +:16S:SETPRTY +:16R:SETPRTY +:95P::SELL//CFPIDEFF +:97A::SAFE//1234567 +:16S:SETPRTY +:16R:SETPRTY +:95P::PSET//CRSTGB22 +:16S:SETPRTY +:16R:AMT +:19A::DEAL//GBP4040051,32 +:16S:AMT +:16R:AMT +:19A::ACRU//GBP7000, +:16S:AMT +:16R:AMT +:19A::EXEC//GBP100, +:16S:AMT +:16R:AMT +:19A::SETT//GBP4047151,32 +:16S:AMT +:16S:SETDET +-} diff --git a/integration-tests/swift/src/test/resources/mt/message2.json b/integration-tests/swift/src/test/resources/mt/message2.json new file mode 100644 index 0000000000..b29edb88fb --- /dev/null +++ b/integration-tests/swift/src/test/resources/mt/message2.json @@ -0,0 +1,128 @@ +{ + "type": "MT", + "basicHeaderBlock": { + "applicationId": "F", + "serviceId": "01", + "logicalTerminal": "BICFOOYYAXXX", + "sessionNumber": "8683", + "sequenceNumber": "497519" + }, + "applicationHeaderBlock": { + "senderInputTime": "1535", + "MIRDate": "051028", + "MIRLogicalTerminal": "ESPBESMMAXXX", + "MIRSessionNumber": "5423", + "MIRSequenceNumber": "752247", + "receiverOutputDate": "051028", + "receiverOutputTime": "1535", + "messagePriority": "N", + "messageType": "103", + "blockType": "O", + "direction": "O" + }, + "userHeaderBlock": { + "fields": [ + { + "name": "113", + "bankingPriority": "ROMF" + }, + { + "name": "108", + "mUR": "0510280182794665" + }, + { + "name": "119", + "validationFlag": "STP" + } + ] + }, + "textBlock": { + "fields": [ + { + "name": "20", + "reference": "0061350113089908" + }, + { + "name": "13C", + "code": "RNCTIME", + "timeIndication": "1534", + "sign": "+", + "timeOffset": "0000" + }, + { + "name": "23B", + "type": "CRED" + }, + { + "name": "23E", + "instructionCode": "SDVA" + }, + { + "name": "32A", + "date": "061028", + "currency": "EUR", + "amount": "100000," + }, + { + "name": "33B", + "currency": "EUR", + "amount": "100000," + }, + { + "name": "50K", + "account": "12345678", + "nameAndAddress": "AGENTES DE BOLSA FOO AGENCIA", + "nameAndAddress2": "AV XXXXX 123 BIS 9 PL", + "nameAndAddress3": "12345 BARCELONA" + }, + { + "name": "52A", + "account": "2337", + "identifierCode": "FOOAESMMXXX" + }, + { + "name": "53A", + "identifierCode": "FOOAESMMXXX" + }, + { + "name": "57A", + "identifierCode": "BICFOOYYXXX" + }, + { + "name": "59", + "account": "ES0123456789012345671234", + "nameAndAddress": "FOO AGENTES DE BOLSA ASOC" + }, + { + "name": "71A", + "code": "OUR" + }, + { + "name": "72", + "narrative": "/BNF/TRANSF. BCO. FOO", + "structured": [ + { + "narrativeFragments": [ + "TRANSF. BCO. FOO" + ], + "narrativeSupplementFragments": [], + "codeword": "BNF" + } + ], + "unstructuredFragments": [] + } + ] + }, + "trailerBlock": { + "fields": [ + { + "name": "MAC", + "value": "88B4F929" + }, + { + "name": "CHK", + "value": "22EF370A4073" + } + ] + } +} diff --git a/integration-tests/swift/src/test/resources/mt/message2.txt b/integration-tests/swift/src/test/resources/mt/message2.txt new file mode 100644 index 0000000000..df5efc8303 --- /dev/null +++ b/integration-tests/swift/src/test/resources/mt/message2.txt @@ -0,0 +1,20 @@ +{1:F01BICFOOYYAXXX8683497519}{2:O1031535051028ESPBESMMAXXX54237522470510281535N}{3:{113:ROMF}{108:0510280182794665}{119:STP}}{4: +:20:0061350113089908 +:13C:/RNCTIME/1534+0000 +:23B:CRED +:23E:SDVA +:32A:061028EUR100000, +:33B:EUR100000, +:50K:/12345678 +AGENTES DE BOLSA FOO AGENCIA +AV XXXXX 123 BIS 9 PL +12345 BARCELONA +:52A:/2337 +FOOAESMMXXX +:53A:FOOAESMMXXX +:57A:BICFOOYYXXX +:59:/ES0123456789012345671234 +FOO AGENTES DE BOLSA ASOC +:71A:OUR +:72:/BNF/TRANSF. BCO. FOO +-}{5:{MAC:88B4F929}{CHK:22EF370A4073}} diff --git a/integration-tests/swift/src/test/resources/mx/message1.xml b/integration-tests/swift/src/test/resources/mx/message1.xml new file mode 100644 index 0000000000..919760d442 --- /dev/null +++ b/integration-tests/swift/src/test/resources/mx/message1.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<Doc:Document xmlns:Doc="urn:swift:xsd:camt.048.001.03" xmlns:xsi="httDoc://www.w3.org/2001/XMLSchema-instance"> + <Doc:ModfyRsvatn> + <Doc:MsgHdr> + <Doc:MsgId>001</Doc:MsgId> + </Doc:MsgHdr> + <Doc:RsvatnId> + <Doc:Cur> + <Doc:Tp> + <Doc:Cd>CARE</Doc:Cd> + </Doc:Tp> + </Doc:Cur> + </Doc:RsvatnId> + <Doc:NewRsvatnValSet> + <Doc:Amt> + <Doc:AmtWthtCcy>1234.0</Doc:AmtWthtCcy> + </Doc:Amt> + </Doc:NewRsvatnValSet> + </Doc:ModfyRsvatn> +</Doc:Document> diff --git a/integration-tests/swift/src/test/resources/mx/message2.json b/integration-tests/swift/src/test/resources/mx/message2.json new file mode 100644 index 0000000000..861256c1cf --- /dev/null +++ b/integration-tests/swift/src/test/resources/mx/message2.json @@ -0,0 +1,184 @@ +{ + "fiToFICstmrCdtTrf": { + "grpHdr": { + "msgId": "823823423", + "creDtTm": { + "dateTime": { + "date": { + "year": 2019, + "month": 10, + "day": 19 + }, + "time": { + "hour": 21, + "minute": 0, + "second": 45, + "nano": 0 + } + }, + "offset": { + "totalSeconds": 0 + } + }, + "btchBookg": false, + "nbOfTxs": "1", + "ctrlSum": 10000, + "ttlIntrBkSttlmAmt": { + "value": 10000, + "ccy": "USD" + }, + "intrBkSttlmDt": { + "year": 2019, + "month": 10, + "day": 28 + }, + "sttlmInf": { + "sttlmMtd": "INDA" + }, + "instgAgt": { + "finInstnId": { + "bicfi": "CITTGB2LPBG", + "nm": "Lionel Messi", + "othr": { + "id": "2342342342", + "issr": "FOOISSUER" + } + } + }, + "instdAgt": { + "finInstnId": { + "bicfi": "ICBCUS4CXXX", + "nm": "Manu Ginobili", + "pstlAdr": { + "adrTp": "PBOX", + "dept": "1", + "subDept": "DFGH", + "strtNm": "My Street", + "bldgNb": "1122", + "pstCd": "10002", + "twnNm": "Los Angeles", + "ctrySubDvsn": "ABCD" + } + } + } + }, + "cdtTrfTxInf": [ + { + "pmtId": { + "instrId": "2233445566", + "endToEndId": "987654321987654321", + "txId": "123456789", + "clrSysRef": "SDSDS333" + }, + "intrBkSttlmAmt": { + "value": 5000, + "ccy": "USD" + }, + "intrBkSttlmDt": { + "year": 2019, + "month": 7, + "day": 31 + }, + "sttlmPrty": "URGT", + "accptncDtTm": { + "dateTime": { + "date": { + "year": 2019, + "month": 4, + "day": 28 + }, + "time": { + "hour": 20, + "minute": 54, + "second": 39, + "nano": 0 + } + }, + "offset": { + "totalSeconds": 0 + } + }, + "poolgAdjstmntDt": { + "year": 2019, + "month": 4, + "day": 29 + }, + "instdAmt": { + "value": 5000, + "ccy": "USD" + }, + "chrgBr": "SHAR", + "dbtr": { + "nm": "Jhon Doe", + "pstlAdr": { + "adrTp": "HOME", + "dept": "ABCD", + "subDept": "1", + "strtNm": "Foo Street", + "bldgNb": "1", + "pstCd": "1234", + "twnNm": "Buenos Aires", + "ctrySubDvsn": "CABA", + "ctry": "AR" + }, + "ctryOfRes": "AR" + }, + "dbtrAgt": { + "finInstnId": { + "bicfi": "ITUSUSP1XXX", + "nm": "Foo Corp" + } + }, + "cdtrAgt": { + "finInstnId": { + "bicfi": "USTBUS31XXX" + } + }, + "cdtr": { + "nm": "Mike Smith" + } + } + ] + }, + "appHdr": { + "fr": { + "fiId": { + "finInstnId": { + "bicfi": "ABCDUS33XXX" + } + } + }, + "to": { + "fiId": { + "finInstnId": { + "bicfi": "EFGHUS33XXX" + } + } + }, + "bizMsgIdr": "12312312312", + "msgDefIdr": "pacs.008.001.07", + "creDt": { + "dateTime": { + "date": { + "year": 2019, + "month": 10, + "day": 19 + }, + "time": { + "hour": 20, + "minute": 53, + "second": 13, + "nano": 0 + } + }, + "offset": { + "totalSeconds": 0 + } + }, + "pssblDplct": false, + "namespace": "urn:iso:std:iso:20022:tech:xsd:head.001.001.01" + }, + "type": "MX", + "@xmlns": "urn:iso:std:iso:20022:tech:xsd:pacs.008.001.07", + "identifier": "pacs.008.001.07" +} diff --git a/integration-tests/swift/src/test/resources/mx/message2.xml b/integration-tests/swift/src/test/resources/mx/message2.xml new file mode 100644 index 0000000000..c2bba9db11 --- /dev/null +++ b/integration-tests/swift/src/test/resources/mx/message2.xml @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<message> + <AppHdr xmlns='urn:iso:std:iso:20022:tech:xsd:head.001.001.01' + xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> + <Fr> + <FIId> + <FinInstnId> + <BICFI>ABCDUS33XXX</BICFI> + </FinInstnId> + </FIId> + </Fr> + <To> + <FIId> + <FinInstnId> + <BICFI>EFGHUS33XXX</BICFI> + </FinInstnId> + </FIId> + </To> + <BizMsgIdr>12312312312</BizMsgIdr> + <MsgDefIdr>pacs.008.001.07</MsgDefIdr> + <CreDt>2019-10-19T20:53:13Z</CreDt> + <PssblDplct>false</PssblDplct> + </AppHdr> + <Document xmlns='urn:iso:std:iso:20022:tech:xsd:pacs.008.001.07' + xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> + <FIToFICstmrCdtTrf> + <GrpHdr> + <MsgId>823823423</MsgId> + <CreDtTm>2019-10-19T21:00:45Z</CreDtTm> + <BtchBookg>false</BtchBookg> + <NbOfTxs>1</NbOfTxs> + <CtrlSum>10000</CtrlSum> + <TtlIntrBkSttlmAmt Ccy='USD'>10000</TtlIntrBkSttlmAmt> + <IntrBkSttlmDt>2019-10-28</IntrBkSttlmDt> + <SttlmInf> + <SttlmMtd>INDA</SttlmMtd> + </SttlmInf> + <InstgAgt> + <FinInstnId> + <BICFI>CITTGB2LPBG</BICFI> + <Nm>Lionel Messi</Nm> + <Othr> + <Id>2342342342</Id> + <Issr>FOOISSUER</Issr> + </Othr> + </FinInstnId> + </InstgAgt> + <InstdAgt> + <FinInstnId> + <BICFI>ICBCUS4CXXX</BICFI> + <Nm>Manu Ginobili</Nm> + <PstlAdr> + <AdrTp>PBOX</AdrTp> + <Dept>1</Dept> + <SubDept>DFGH</SubDept> + <StrtNm>My Street</StrtNm> + <BldgNb>1122</BldgNb> + <PstCd>10002</PstCd> + <TwnNm>Los Angeles</TwnNm> + <CtrySubDvsn>ABCD</CtrySubDvsn> + </PstlAdr> + </FinInstnId> + </InstdAgt> + </GrpHdr> + <CdtTrfTxInf> + <PmtId> + <InstrId>2233445566</InstrId> + <EndToEndId>987654321987654321</EndToEndId> + <TxId>123456789</TxId> + <ClrSysRef>SDSDS333</ClrSysRef> + </PmtId> + <IntrBkSttlmAmt Ccy='USD'>5000</IntrBkSttlmAmt> + <IntrBkSttlmDt>2019-07-31</IntrBkSttlmDt> + <SttlmPrty>URGT</SttlmPrty> + <AccptncDtTm>2019-04-28T20:54:39Z</AccptncDtTm> + <PoolgAdjstmntDt>2019-04-29</PoolgAdjstmntDt> + <InstdAmt Ccy='USD'>5000</InstdAmt> + <ChrgBr>SHAR</ChrgBr> + <Dbtr> + <Nm>Jhon Doe</Nm> + <PstlAdr> + <AdrTp>HOME</AdrTp> + <Dept>ABCD</Dept> + <SubDept>1</SubDept> + <StrtNm>Foo Street</StrtNm> + <BldgNb>1</BldgNb> + <PstCd>1234</PstCd> + <TwnNm>Buenos Aires</TwnNm> + <CtrySubDvsn>CABA</CtrySubDvsn> + <Ctry>AR</Ctry> + </PstlAdr> + <CtryOfRes>AR</CtryOfRes> + </Dbtr> + <DbtrAgt> + <FinInstnId> + <BICFI>ITUSUSP1XXX</BICFI> + <Nm>Foo Corp</Nm> + </FinInstnId> + </DbtrAgt> + <CdtrAgt> + <FinInstnId> + <BICFI>USTBUS31XXX</BICFI> + </FinInstnId> + </CdtrAgt> + <Cdtr> + <Nm>Mike Smith</Nm> + </Cdtr> + </CdtTrfTxInf> + </FIToFICstmrCdtTrf> + </Document> +</message> diff --git a/integration-tests/swift/src/test/resources/mx/message3.xml b/integration-tests/swift/src/test/resources/mx/message3.xml new file mode 100644 index 0000000000..e0caa4cf69 --- /dev/null +++ b/integration-tests/swift/src/test/resources/mx/message3.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<Doc:Document xmlns:Doc="urn:swift:xsd:xsys.011.001.02" xmlns:Sw="urn:swift:snl:ns.Sw" + xmlns:SwInt="urn:swift:snl:ns.SwInt" xmlns:SwGbl="urn:swift:snl:ns.SwGbl"> + <Doc:xsys.011.001.02> + <Doc:DlvryNtfctn> + <Sw:SnFRef>swf00000-2020-07-28T15:11:11.123456Z</Sw:SnFRef> + <Sw:SnFRefType>InterAct</Sw:SnFRefType> + <Sw:AcceptStatus>Accepted</Sw:AcceptStatus> + <Sw:DeliveryTime>2020-07-28T15:11:08Z</Sw:DeliveryTime> + <Sw:AckSwiftTime>2020-07-28T15:11:08Z</Sw:AckSwiftTime> + <Sw:FileRequestHeader> + <SwInt:Requestor>cn=gtxdev,o=rtbsgb2l,o=swift</SwInt:Requestor> + <SwInt:Responder>cn=gtxdev,o=rtbsgb2l,o=swift</SwInt:Responder> + <SwInt:Service>swift.finplus!pc</SwInt:Service> + <SwInt:RequestType>seev.047.001.01</SwInt:RequestType> + <SwInt:Priority>Normal</SwInt:Priority> + <SwInt:RequestRef>FOO123456</SwInt:RequestRef> + </Sw:FileRequestHeader> + <Doc:Xtnsn> + <Doc:PlcAndNm>PlaceAndName</Doc:PlcAndNm> + <Doc:XtnsnEnvlp>XtnsnEnvlp</Doc:XtnsnEnvlp> + </Doc:Xtnsn> + </Doc:DlvryNtfctn> + </Doc:xsys.011.001.02> +</Doc:Document> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 50a053eae5..ec248f7d93 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -2375,6 +2375,11 @@ <artifactId>camel-support</artifactId> <version>${camel.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-swift</artifactId> + <version>${camel.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-syslog</artifactId> @@ -5555,6 +5560,16 @@ <artifactId>camel-quarkus-support-xalan-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-swift</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-swift-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-syslog</artifactId> diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index 4bf3430737..6cf59ae18f 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -2318,6 +2318,11 @@ <artifactId>camel-swift</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>4.0.0-RC1</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> </dependency> + <dependency> + <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-swift</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>4.0.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-syslog</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml index ae4d50ead7..b1cff09e0b 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -2318,6 +2318,11 @@ <artifactId>camel-swift</artifactId> <version>4.0.0-RC1</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-swift</artifactId> + <version>4.0.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-syslog</artifactId> diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml index adc1e1990d..f649cfc108 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -2318,6 +2318,11 @@ <artifactId>camel-swift</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>4.0.0-RC1</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> </dependency> + <dependency> + <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-swift</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>4.0.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-syslog</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index ebf510879f..7cad8f0e8e 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -162,6 +162,7 @@ group-10: - main-unknown-args-ignore - platform-http-proxy - platform-http-proxy-ssl + - swift group-11: - compression-grouped - disruptor