This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3cf4982e1dfe55d58b51584e41f16333b0b50e28 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Fri Apr 1 12:10:45 2022 +0200 CAMEL-17879: removed the deprecated camel-beanio component --- bom/camel-bom/pom.xml | 5 - camel-dependencies/pom.xml | 1 - catalog/camel-allcomponents/pom.xml | 4 - .../apache/camel/catalog/dataformats.properties | 1 - .../apache/camel/catalog/dataformats/beanio.json | 29 -- .../ahc/ws/WsProducerUsingStreamingTest.java | 2 - components/camel-beanio/pom.xml | 60 ----- .../beanio/BeanIODataFormatConfigurer.java | 26 -- .../org/apache/camel/configurer/beanio-dataformat | 2 - .../org/apache/camel/dataformat.properties | 7 - .../services/org/apache/camel/dataformat/beanio | 2 - .../org/apache/camel/dataformat/beanio/beanio.json | 29 -- .../src/main/docs/beanio-dataformat.adoc | 77 ------ .../dataformat/beanio/BeanIOConfiguration.java | 123 --------- .../camel/dataformat/beanio/BeanIODataFormat.java | 298 --------------------- .../dataformat/beanio/BeanIOErrorHandler.java | 126 --------- .../camel/dataformat/beanio/BeanIOHeader.java | 25 -- .../camel/dataformat/beanio/BeanIOHelper.java | 66 ----- .../camel/dataformat/beanio/BeanIOIterator.java | 81 ------ .../camel/dataformat/beanio/BeanIOSplitter.java | 211 --------------- .../apache/camel/dataformat/beanio/A1Record.java | 59 ---- .../apache/camel/dataformat/beanio/B1Record.java | 59 ---- .../beanio/BeanIODataFormatComplexTest.java | 239 ----------------- ...rmatSimpleCustomBeanReaderErrorHandlerTest.java | 142 ---------- .../beanio/BeanIODataFormatSimpleTest.java | 117 -------- ...IOSplitterCustomBeanReaderErrorHandlerTest.java | 122 --------- .../dataformat/beanio/BeanIOSplitterTest.java | 99 ------- .../beanio/BeanIOUnmarshalSingleObjectTest.java | 68 ----- .../apache/camel/dataformat/beanio/Constants.java | 26 -- .../apache/camel/dataformat/beanio/Employee.java | 111 -------- .../org/apache/camel/dataformat/beanio/Header.java | 111 -------- .../apache/camel/dataformat/beanio/MyErrorDto.java | 36 --- .../camel/dataformat/beanio/MyErrorHandler.java | 38 --- .../org/apache/camel/dataformat/beanio/Record.java | 65 ----- .../apache/camel/dataformat/beanio/Separator.java | 59 ---- .../beanio/SpringBeanIODataFormatSimpleTest.java | 92 ------- .../apache/camel/dataformat/beanio/Trailer.java | 59 ---- .../camel/dataformat/beanio/csv/CsvTest.java | 126 --------- .../beanio/csv/CsvTestWithProperties.java | 59 ---- .../src/test/resources/log4j2.properties | 28 -- .../beanio/SpringBeanIODataFormatSimpleTest.xml | 52 ---- .../camel/dataformat/beanio/csv/mappings.xml | 32 --- .../beanio/csv/mappingsWithProperties.xml | 32 --- .../apache/camel/dataformat/beanio/mappings.xml | 116 -------- .../dataformat/beanio/single-object-mapping.xml | 29 -- components/pom.xml | 1 - .../org/apache/camel/main/dataformats.properties | 1 - .../modules/dataformats/examples/json/beanio.json | 1 - docs/components/modules/dataformats/nav.adoc | 1 - .../dataformats/pages/beanio-dataformat.adoc | 1 - parent/pom.xml | 6 - 51 files changed, 3162 deletions(-) diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index 8880ab5..95c899e 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -333,11 +333,6 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-beanio</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> <artifactId>camel-beanstalk</artifactId> <version>${project.version}</version> </dependency> diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml index e7c2142..7655c19 100644 --- a/camel-dependencies/pom.xml +++ b/camel-dependencies/pom.xml @@ -77,7 +77,6 @@ <azure-storage-blob-version>12.14.4</azure-storage-blob-version> <azure-storage-datalake-version>12.7.1</azure-storage-datalake-version> <azure-storage-queue-version>12.11.4</azure-storage-queue-version> - <beanio-version>2.1.0</beanio-version> <bouncycastle-version>1.70</bouncycastle-version> <box-java-sdk-version>2.58.0</box-java-sdk-version> <braintree-gateway-version>3.14.0</braintree-gateway-version> diff --git a/catalog/camel-allcomponents/pom.xml b/catalog/camel-allcomponents/pom.xml index 4267a18..d89393d 100644 --- a/catalog/camel-allcomponents/pom.xml +++ b/catalog/camel-allcomponents/pom.xml @@ -239,10 +239,6 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-beanio</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> <artifactId>camel-beanstalk</artifactId> </dependency> <dependency> diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats.properties index 0f43262..e5d337d 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats.properties +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats.properties @@ -4,7 +4,6 @@ avro avroJackson barcode base64 -beanio bindyCsv bindyFixed bindyKvp diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/beanio.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/beanio.json deleted file mode 100644 index f293333..0000000 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/beanio.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "dataformat": { - "kind": "dataformat", - "name": "beanio", - "title": "BeanIO", - "description": "Marshal and unmarshal Java beans to and from flat files (such as CSV, delimited, or fixed length formats).", - "deprecated": true, - "firstVersion": "2.10.0", - "label": "dataformat,transformation,csv", - "javaType": "org.apache.camel.dataformat.beanio.BeanIODataFormat", - "supportLevel": "Stable", - "groupId": "org.apache.camel", - "artifactId": "camel-beanio", - "version": "3.17.0-SNAPSHOT", - "modelName": "beanio", - "modelJavaType": "org.apache.camel.model.dataformat.BeanioDataFormat" - }, - "properties": { - "mapping": { "kind": "attribute", "displayName": "Mapping", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The BeanIO mapping file. Is by default loaded from the classpath. You can prefix with file:, http:, or classpath: to denote from where to load the mapping file." }, - "streamName": { "kind": "attribute", "displayName": "Stream Name", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the stream to use." }, - "ignoreUnidentifiedRecords": { "kind": "attribute", "displayName": "Ignore Unidentified Records", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore unidentified records." }, - "ignoreUnexpectedRecords": { "kind": "attribute", "displayName": "Ignore Unexpected Records", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore unexpected records." }, - "ignoreInvalidRecords": { "kind": "attribute", "displayName": "Ignore Invalid Records", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore invalid records." }, - "encoding": { "kind": "attribute", "displayName": "Encoding", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The charset to use. Is by default the JVM platform default charset." }, - "beanReaderErrorHandlerType": { "kind": "attribute", "displayName": "Bean Reader Error Handler Type", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.dataformat.beanio.BeanIOErrorHandler as error handler while parsing. Configure the fully qualified class name of the error handler. Notice the options ignoreUnidentifiedRecords, ignoreUnexp [...] - "unmarshalSingleObject": { "kind": "attribute", "displayName": "Unmarshal Single Object", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "This options controls whether to unmarshal as a list of objects or as a single object only. The former is the default mode, and the latter is only intended in special use-cases where beanio maps the Camel mess [...] - "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" } - } -} diff --git a/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerUsingStreamingTest.java b/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerUsingStreamingTest.java index 329435b..f5391cf 100644 --- a/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerUsingStreamingTest.java +++ b/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerUsingStreamingTest.java @@ -16,8 +16,6 @@ */ package org.apache.camel.component.ahc.ws; -import java.io.UnsupportedEncodingException; - import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.ServerConnector; diff --git a/components/camel-beanio/pom.xml b/components/camel-beanio/pom.xml deleted file mode 100644 index ae5019b..0000000 --- a/components/camel-beanio/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel</groupId> - <artifactId>components</artifactId> - <version>3.17.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-beanio</artifactId> - <packaging>jar</packaging> - - <name>Camel :: BeanIO (deprecated)</name> - <description>Camel BeanIO data format support</description> - - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-support</artifactId> - </dependency> - <dependency> - <groupId>org.beanio</groupId> - <artifactId>beanio</artifactId> - <version>${beanio-version}</version> - </dependency> - - <!-- testing --> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring-junit5</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - - </dependencies> - -</project> diff --git a/components/camel-beanio/src/generated/java/org/apache/camel/dataformat/beanio/BeanIODataFormatConfigurer.java b/components/camel-beanio/src/generated/java/org/apache/camel/dataformat/beanio/BeanIODataFormatConfigurer.java deleted file mode 100644 index 46b4f2a..0000000 --- a/components/camel-beanio/src/generated/java/org/apache/camel/dataformat/beanio/BeanIODataFormatConfigurer.java +++ /dev/null @@ -1,26 +0,0 @@ -/* Generated by camel build tools - do NOT edit this file! */ -package org.apache.camel.dataformat.beanio; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.spi.GeneratedPropertyConfigurer; -import org.apache.camel.support.component.PropertyConfigurerSupport; - -/** - * Generated by camel build tools - do NOT edit this file! - */ -@SuppressWarnings("unchecked") -public class BeanIODataFormatConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer { - - @Override - public boolean configure(CamelContext camelContext, Object target, String name, Object value, boolean ignoreCase) { - BeanIODataFormat dataformat = (BeanIODataFormat) target; - switch (ignoreCase ? name.toLowerCase() : name) { - default: return false; - } - } - -} - diff --git a/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/configurer/beanio-dataformat b/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/configurer/beanio-dataformat deleted file mode 100644 index 2575c10..0000000 --- a/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/configurer/beanio-dataformat +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.dataformat.beanio.BeanIODataFormatConfigurer diff --git a/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/dataformat.properties b/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/dataformat.properties deleted file mode 100644 index dae2e18..0000000 --- a/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/dataformat.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -dataFormats=beanio -groupId=org.apache.camel -artifactId=camel-beanio -version=3.17.0-SNAPSHOT -projectName=Camel :: BeanIO (deprecated) -projectDescription=Camel BeanIO data format support diff --git a/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/dataformat/beanio b/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/dataformat/beanio deleted file mode 100644 index a2c24ff..0000000 --- a/components/camel-beanio/src/generated/resources/META-INF/services/org/apache/camel/dataformat/beanio +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.dataformat.beanio.BeanIODataFormat diff --git a/components/camel-beanio/src/generated/resources/org/apache/camel/dataformat/beanio/beanio.json b/components/camel-beanio/src/generated/resources/org/apache/camel/dataformat/beanio/beanio.json deleted file mode 100644 index f293333..0000000 --- a/components/camel-beanio/src/generated/resources/org/apache/camel/dataformat/beanio/beanio.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "dataformat": { - "kind": "dataformat", - "name": "beanio", - "title": "BeanIO", - "description": "Marshal and unmarshal Java beans to and from flat files (such as CSV, delimited, or fixed length formats).", - "deprecated": true, - "firstVersion": "2.10.0", - "label": "dataformat,transformation,csv", - "javaType": "org.apache.camel.dataformat.beanio.BeanIODataFormat", - "supportLevel": "Stable", - "groupId": "org.apache.camel", - "artifactId": "camel-beanio", - "version": "3.17.0-SNAPSHOT", - "modelName": "beanio", - "modelJavaType": "org.apache.camel.model.dataformat.BeanioDataFormat" - }, - "properties": { - "mapping": { "kind": "attribute", "displayName": "Mapping", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The BeanIO mapping file. Is by default loaded from the classpath. You can prefix with file:, http:, or classpath: to denote from where to load the mapping file." }, - "streamName": { "kind": "attribute", "displayName": "Stream Name", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the stream to use." }, - "ignoreUnidentifiedRecords": { "kind": "attribute", "displayName": "Ignore Unidentified Records", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore unidentified records." }, - "ignoreUnexpectedRecords": { "kind": "attribute", "displayName": "Ignore Unexpected Records", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore unexpected records." }, - "ignoreInvalidRecords": { "kind": "attribute", "displayName": "Ignore Invalid Records", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore invalid records." }, - "encoding": { "kind": "attribute", "displayName": "Encoding", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The charset to use. Is by default the JVM platform default charset." }, - "beanReaderErrorHandlerType": { "kind": "attribute", "displayName": "Bean Reader Error Handler Type", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.dataformat.beanio.BeanIOErrorHandler as error handler while parsing. Configure the fully qualified class name of the error handler. Notice the options ignoreUnidentifiedRecords, ignoreUnexp [...] - "unmarshalSingleObject": { "kind": "attribute", "displayName": "Unmarshal Single Object", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "This options controls whether to unmarshal as a list of objects or as a single object only. The former is the default mode, and the latter is only intended in special use-cases where beanio maps the Camel mess [...] - "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" } - } -} diff --git a/components/camel-beanio/src/main/docs/beanio-dataformat.adoc b/components/camel-beanio/src/main/docs/beanio-dataformat.adoc deleted file mode 100644 index 30352b7..0000000 --- a/components/camel-beanio/src/main/docs/beanio-dataformat.adoc +++ /dev/null @@ -1,77 +0,0 @@ -= BeanIO DataFormat (deprecated) -:doctitle: BeanIO -:shortname: beanio -:artifactid: camel-beanio -:description: Marshal and unmarshal Java beans to and from flat files (such as CSV, delimited, or fixed length formats). -:since: 2.10 -:supportlevel: Stable-deprecated -:deprecated: *deprecated* -//Manually maintained attributes -:camel-spring-boot-name: beanio - -*Since Camel {since}* - -The BeanIO Data Format uses -http://beanio.org/[BeanIO] to handle flat payloads (such as XML, CSV, -delimited, or fixed length formats). - -BeanIO is configured using a -http://beanio.org/2.0/docs/reference/index.html#TheMappingFile[mappings -XML] file where you define the mapping from the flat format to Objects -(POJOs). This mapping file is mandatory to use. - -== Options - -// dataformat options: START -include::partial$dataformat-options.adoc[] -// dataformat options: END - -== Usage - -An example of a -https://svn.apache.org/repos/asf/camel/trunk/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/mappings.xml[mapping -file is here]. - -=== Using Java DSL - -To use the `BeanIODataFormat` you need to configure the data format with -the mapping file, as well the name of the stream. + - In Java DSL this can be done as shown below. The streamName is -"employeeFile". - -Then we have two routes. The first route is for transforming CSV data -into a List<Employee> Java objects. Which we then -split, so the mock endpoint + - receives a message for each row. - -The 2nd route is for the reverse operation, to transform a -List<Employee> into a stream of CSV data. - -The CSV data could for example be as below: - -=== Using XML DSL - -To use the BeanIO data format in XML, you need to configure it using the -<beanio> XML tag as shown below. The routes is similar to the example -above. - -== Dependencies - -To use BeanIO in your Camel routes you need to add a dependency on -*camel-beanio* which implements this data format. - -If you use Maven you can just add the following to your pom.xml, -substituting the version number for the latest & greatest release (see -the download page for the latest versions). - -[source,xml] ---------------------------------------- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-beanio</artifactId> - <version>2.10.0</version> -</dependency> ---------------------------------------- - - -include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOConfiguration.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOConfiguration.java deleted file mode 100644 index 081975d..0000000 --- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOConfiguration.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.beanio; - -import java.nio.charset.Charset; -import java.util.Properties; - -import org.beanio.BeanReaderErrorHandler; - -/** - * To configure the BeanIO data format, or BeanIO splitter. - */ -public class BeanIOConfiguration { - - private String streamName; - private String mapping; - private boolean ignoreUnidentifiedRecords; - private boolean ignoreUnexpectedRecords; - private boolean ignoreInvalidRecords; - private Charset encoding = Charset.defaultCharset(); - private Properties properties; - private BeanReaderErrorHandler beanReaderErrorHandler; - private String beanReaderErrorHandlerType; - private boolean unmarshalSingleObject; - - public String getMapping() { - return mapping; - } - - public void setMapping(String mapping) { - this.mapping = mapping; - } - - public String getStreamName() { - return streamName; - } - - public void setStreamName(String streamName) { - this.streamName = streamName; - } - - public boolean isIgnoreUnidentifiedRecords() { - return ignoreUnidentifiedRecords; - } - - public void setIgnoreUnidentifiedRecords(boolean ignoreUnidentifiedRecords) { - this.ignoreUnidentifiedRecords = ignoreUnidentifiedRecords; - } - - public boolean isIgnoreUnexpectedRecords() { - return ignoreUnexpectedRecords; - } - - public void setIgnoreUnexpectedRecords(boolean ignoreUnexpectedRecords) { - this.ignoreUnexpectedRecords = ignoreUnexpectedRecords; - } - - public boolean isIgnoreInvalidRecords() { - return ignoreInvalidRecords; - } - - public void setIgnoreInvalidRecords(boolean ignoreInvalidRecords) { - this.ignoreInvalidRecords = ignoreInvalidRecords; - } - - public Charset getEncoding() { - return encoding; - } - - public void setEncoding(Charset encoding) { - this.encoding = encoding; - } - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } - - public BeanReaderErrorHandler getBeanReaderErrorHandler() { - return beanReaderErrorHandler; - } - - public void setBeanReaderErrorHandler(BeanReaderErrorHandler beanReaderErrorHandler) { - this.beanReaderErrorHandler = beanReaderErrorHandler; - } - - public String getBeanReaderErrorHandlerType() { - return beanReaderErrorHandlerType; - } - - public void setBeanReaderErrorHandlerType(String beanReaderErrorHandlerType) { - this.beanReaderErrorHandlerType = beanReaderErrorHandlerType; - } - - public void setBeanReaderErrorHandlerType(Class<?> beanReaderErrorHandlerType) { - this.beanReaderErrorHandlerType = beanReaderErrorHandlerType.getName(); - } - - public boolean isUnmarshalSingleObject() { - return unmarshalSingleObject; - } - - public void setUnmarshalSingleObject(boolean unmarshalSingleObject) { - this.unmarshalSingleObject = unmarshalSingleObject; - } -} diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java deleted file mode 100644 index 1ff1892..0000000 --- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIODataFormat.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * 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.beanio; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.Exchange; -import org.apache.camel.NoTypeConversionAvailableException; -import org.apache.camel.spi.DataFormat; -import org.apache.camel.spi.DataFormatName; -import org.apache.camel.spi.annotations.Dataformat; -import org.apache.camel.support.ObjectHelper; -import org.apache.camel.support.ResourceHelper; -import org.apache.camel.support.service.ServiceSupport; -import org.apache.camel.util.IOHelper; -import org.beanio.BeanReader; -import org.beanio.BeanReaderErrorHandler; -import org.beanio.BeanWriter; -import org.beanio.StreamFactory; -import org.beanio.Unmarshaller; - -import static org.apache.camel.dataformat.beanio.BeanIOHelper.getOrCreateBeanReaderErrorHandler; - -/** - * A <a href="http://camel.apache.org/data-format.html">data format</a> ( {@link DataFormat}) for beanio data. - */ -@Dataformat("beanio") -public class BeanIODataFormat extends ServiceSupport implements DataFormat, DataFormatName, CamelContextAware { - - private transient CamelContext camelContext; - private transient StreamFactory factory; - private BeanIOConfiguration configuration = new BeanIOConfiguration(); - - public BeanIODataFormat() { - } - - public BeanIODataFormat(String mapping, String streamName) { - setMapping(mapping); - setStreamName(streamName); - } - - @Override - public String getDataFormatName() { - return "beanio"; - } - - @Override - protected void doInit() throws Exception { - super.doInit(); - - org.apache.camel.util.ObjectHelper.notNull(getStreamName(), "Stream name not configured."); - if (factory == null) { - // Create the stream factory that will be used to read/write objects. - factory = StreamFactory.newInstance(); - if (ResourceHelper.isClasspathUri(getMapping())) { - loadMappingResource(); - } - } - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - - if (!ResourceHelper.isClasspathUri(getMapping())) { - loadMappingResource(); - } - } - - @Override - protected void doStop() throws Exception { - factory = null; - } - - @Override - public CamelContext getCamelContext() { - return camelContext; - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - StreamFactory getFactory() { - return factory; - } - - @Override - public void marshal(Exchange exchange, Object body, OutputStream stream) throws Exception { - List<Object> models = getModels(exchange, body); - writeModels(stream, models); - } - - @Override - public Object unmarshal(Exchange exchange, InputStream stream) throws Exception { - if (isUnmarshalSingleObject()) { - return readSingleModel(exchange, stream); - } else { - return readModels(exchange, stream); - } - } - - private void loadMappingResource() throws Exception { - // Load the mapping file using the resource helper to ensure it can be loaded in OSGi and other environments - InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), getMapping()); - try { - if (getProperties() != null) { - factory.load(is, getProperties()); - } else { - factory.load(is); - } - } finally { - IOHelper.close(is); - } - } - - @SuppressWarnings("unchecked") - private List<Object> getModels(Exchange exchange, Object body) { - List<Object> models; - - if (body instanceof Map && isUnmarshalSingleObject()) { - models = new ArrayList<>(); - models.add(body); - } else if ((models = exchange.getContext().getTypeConverter().convertTo(List.class, body)) == null) { - models = new ArrayList<>(); - for (Object model : ObjectHelper.createIterable(body)) { - models.add(model); - } - } - return models; - } - - private void writeModels(OutputStream stream, List<Object> models) { - BufferedWriter streamWriter = IOHelper.buffered(new OutputStreamWriter(stream, getEncoding())); - BeanWriter out = factory.createWriter(getStreamName(), streamWriter); - - for (Object obj : models) { - out.write(obj); - } - - out.flush(); - out.close(); - } - - private List<Object> readModels(Exchange exchange, InputStream stream) throws Exception { - List<Object> results = new ArrayList<>(); - BufferedReader streamReader = IOHelper.buffered(new InputStreamReader(stream, getEncoding())); - - BeanReader in = factory.createReader(getStreamName(), streamReader); - - BeanReaderErrorHandler errorHandler = getOrCreateBeanReaderErrorHandler(configuration, exchange, results, null); - in.setErrorHandler(errorHandler); - - try { - Object readObject; - while ((readObject = in.read()) != null) { - if (readObject instanceof BeanIOHeader) { - exchange.getOut().getHeaders().putAll(((BeanIOHeader) readObject).getHeaders()); - } - results.add(readObject); - } - } finally { - in.close(); - } - - return results; - } - - private Object readSingleModel(Exchange exchange, InputStream stream) throws NoTypeConversionAvailableException { - BufferedReader streamReader = IOHelper.buffered(new InputStreamReader(stream, getEncoding())); - try { - String data = exchange.getContext().getTypeConverter().mandatoryConvertTo(String.class, exchange, streamReader); - Unmarshaller unmarshaller = factory.createUnmarshaller(getStreamName()); - return unmarshaller.unmarshal(data); - } finally { - IOHelper.close(stream); - } - } - - public String getMapping() { - return configuration.getMapping(); - } - - public void setIgnoreUnexpectedRecords(boolean ignoreUnexpectedRecords) { - configuration.setIgnoreUnexpectedRecords(ignoreUnexpectedRecords); - } - - public void setProperties(Properties properties) { - configuration.setProperties(properties); - } - - public void setStreamName(String streamName) { - configuration.setStreamName(streamName); - } - - public boolean isIgnoreUnidentifiedRecords() { - return configuration.isIgnoreUnidentifiedRecords(); - } - - public boolean isIgnoreInvalidRecords() { - return configuration.isIgnoreInvalidRecords(); - } - - public void setIgnoreInvalidRecords(boolean ignoreInvalidRecords) { - configuration.setIgnoreInvalidRecords(ignoreInvalidRecords); - } - - public void setEncoding(String encoding) { - setEncoding(Charset.forName(encoding)); - } - - public void setEncoding(Charset encoding) { - if (encoding == null) { - throw new IllegalArgumentException("Charset encoding is null"); - } - configuration.setEncoding(encoding); - } - - public boolean isIgnoreUnexpectedRecords() { - return configuration.isIgnoreUnexpectedRecords(); - } - - public Properties getProperties() { - return configuration.getProperties(); - } - - public String getStreamName() { - return configuration.getStreamName(); - } - - public void setMapping(String mapping) { - configuration.setMapping(mapping); - } - - public void setIgnoreUnidentifiedRecords(boolean ignoreUnidentifiedRecords) { - configuration.setIgnoreUnidentifiedRecords(ignoreUnidentifiedRecords); - } - - public Charset getEncoding() { - return configuration.getEncoding(); - } - - public BeanReaderErrorHandler getBeanReaderErrorHandler() { - return configuration.getBeanReaderErrorHandler(); - } - - public void setBeanReaderErrorHandler(BeanReaderErrorHandler beanReaderErrorHandler) { - configuration.setBeanReaderErrorHandler(beanReaderErrorHandler); - } - - public String getBeanReaderErrorHandlerType() { - return configuration.getBeanReaderErrorHandlerType(); - } - - public void setBeanReaderErrorHandlerType(String beanReaderErrorHandlerType) { - configuration.setBeanReaderErrorHandlerType(beanReaderErrorHandlerType); - } - - public void setBeanReaderErrorHandlerType(Class<?> beanReaderErrorHandlerType) { - configuration.setBeanReaderErrorHandlerType(beanReaderErrorHandlerType); - } - - public boolean isUnmarshalSingleObject() { - return configuration.isUnmarshalSingleObject(); - } - - public void setUnmarshalSingleObject(boolean unmarshalSingleObject) { - configuration.setUnmarshalSingleObject(unmarshalSingleObject); - } - -} diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOErrorHandler.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOErrorHandler.java deleted file mode 100644 index 5764316..0000000 --- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOErrorHandler.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.beanio; - -import java.util.List; - -import org.apache.camel.Exchange; -import org.beanio.BeanReaderErrorHandler; -import org.beanio.BeanReaderErrorHandlerSupport; -import org.beanio.InvalidRecordException; -import org.beanio.UnexpectedRecordException; -import org.beanio.UnidentifiedRecordException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A {@link BeanReaderErrorHandler} to handle errors during parsing. This error handler is prototype scoped and provides - * access to the current {@link Exchange}. You can perform any custom initialization logic in the {@link #init()} - * method. - */ -public class BeanIOErrorHandler extends BeanReaderErrorHandlerSupport { - - static final String LOG_PREFIX = "BeanIO: "; - static final Logger LOG = LoggerFactory.getLogger(BeanIOErrorHandler.class); - - private BeanIOConfiguration configuration; - private Exchange exchange; - private List<Object> results; - private BeanIOIterator iterator; - - public BeanIOErrorHandler() { - } - - public void init() { - // any custom init code here - } - - /** - * The configuration - */ - public BeanIOConfiguration getConfiguration() { - return configuration; - } - - public void setConfiguration(BeanIOConfiguration configuration) { - this.configuration = configuration; - } - - /** - * The current exchange - */ - public Exchange getExchange() { - return exchange; - } - - public void setExchange(Exchange exchange) { - this.exchange = exchange; - } - - void setResults(List<Object> results) { - this.results = results; - } - - void setIterator(BeanIOIterator iterator) { - this.iterator = iterator; - } - - /** - * Sets a custom POJO as the result from handling an beanio error. - */ - public void handleErrorAndAddAsResult(Object result) { - if (results != null) { - results.add(result); - } else if (iterator != null) { - iterator.setNext(result); - } - } - - @Override - public void invalidRecord(InvalidRecordException ex) throws Exception { - String msg = LOG_PREFIX + "InvalidRecord: " + ex.getMessage() + ": " + ex.getRecordContext().getRecordText(); - if (getConfiguration().isIgnoreInvalidRecords()) { - LOG.debug(msg); - } else { - LOG.warn(msg); - throw ex; - } - } - - @Override - public void unexpectedRecord(UnexpectedRecordException ex) throws Exception { - String msg = LOG_PREFIX + "UnexpectedRecord: " + ex.getMessage() + ": " + ex.getRecordContext().getRecordText(); - if (getConfiguration().isIgnoreUnexpectedRecords()) { - LOG.debug(msg); - } else { - LOG.warn(msg); - throw ex; - } - } - - @Override - public void unidentifiedRecord(UnidentifiedRecordException ex) throws Exception { - String msg = LOG_PREFIX + "UnidentifiedRecord: " + ex.getMessage() + ": " + ex.getRecordContext().getRecordText(); - if (getConfiguration().isIgnoreUnidentifiedRecords()) { - LOG.debug(msg); - } else { - LOG.warn(msg); - throw ex; - } - } - -} diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHeader.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHeader.java deleted file mode 100644 index c29e14a..0000000 --- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHeader.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.beanio; - -import java.util.Map; - -public interface BeanIOHeader { - - Map<String, Object> getHeaders(); - -} diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHelper.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHelper.java deleted file mode 100644 index 2273ef9..0000000 --- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOHelper.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.beanio; - -import java.util.List; - -import org.apache.camel.Exchange; -import org.apache.camel.util.ObjectHelper; -import org.beanio.BeanReaderErrorHandler; - -/** - * Helper class - */ -public final class BeanIOHelper { - - private BeanIOHelper() { - // utility class - } - - public static BeanReaderErrorHandler getOrCreateBeanReaderErrorHandler( - BeanIOConfiguration configuration, Exchange exchange, - List<Object> results, BeanIOIterator iterator) - throws Exception { - BeanReaderErrorHandler answer = null; - - if (ObjectHelper.isNotEmpty(configuration.getBeanReaderErrorHandlerType())) { - Class<?> clazz = exchange.getContext().getClassResolver() - .resolveMandatoryClass(configuration.getBeanReaderErrorHandlerType()); - Object instance = exchange.getContext().getInjector().newInstance(clazz); - answer = (BeanReaderErrorHandler) instance; - } - if (answer == null && ObjectHelper.isNotEmpty(configuration.getBeanReaderErrorHandler())) { - answer = configuration.getBeanReaderErrorHandler(); - } - if (answer == null) { - answer = new BeanIOErrorHandler(); - } - // if the error handler extends BeanIOErrorHandler then its prototype scoped - // and then inject the current exchange and init - if (answer instanceof BeanIOErrorHandler) { - BeanIOErrorHandler eh = (BeanIOErrorHandler) answer; - eh.setConfiguration(configuration); - eh.setExchange(exchange); - eh.setResults(results); - eh.setIterator(iterator); - eh.init(); - } - - return answer; - } - -} diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOIterator.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOIterator.java deleted file mode 100644 index dd1829a..0000000 --- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOIterator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.beanio; - -import java.io.Closeable; -import java.io.IOException; -import java.util.Iterator; - -import org.beanio.BeanReader; - -public class BeanIOIterator implements Iterator<Object>, Closeable { - - private BeanReader reader; - private transient Object next; - private transient Object forceNext; - - public BeanIOIterator(BeanReader reader) { - this.reader = reader; - this.next = next(); - } - - @Override - public void close() throws IOException { - if (reader != null) { - reader.close(); - reader = null; - } - } - - @Override - public boolean hasNext() { - return next != null; - } - - @Override - public Object next() { - Object answer = next; - if (answer == null) { - answer = reader.read(); - // after read we may force a next - if (forceNext != null) { - answer = forceNext; - forceNext = null; - } - } else { - next = reader.read(); - // after read we may force a next - if (forceNext != null) { - next = forceNext; - forceNext = null; - } - } - return answer; - } - - @Override - public void remove() { - // noop - } - - /** - * Sets a custom object as the next, such as from a custom error handler - */ - public void setNext(Object next) { - this.forceNext = next; - } -} diff --git a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOSplitter.java b/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOSplitter.java deleted file mode 100644 index 5ef9e1f..0000000 --- a/components/camel-beanio/src/main/java/org/apache/camel/dataformat/beanio/BeanIOSplitter.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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.beanio; - -import java.io.File; -import java.io.InputStream; -import java.io.Reader; -import java.nio.charset.Charset; -import java.util.Properties; - -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.Expression; -import org.apache.camel.Message; -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.WrappedFile; -import org.apache.camel.support.ResourceHelper; -import org.apache.camel.util.IOHelper; -import org.apache.camel.util.ObjectHelper; -import org.beanio.BeanReader; -import org.beanio.BeanReaderErrorHandler; -import org.beanio.StreamFactory; - -import static org.apache.camel.dataformat.beanio.BeanIOHelper.getOrCreateBeanReaderErrorHandler; - -/** - * You can use {@link BeanIOSplitter} with the Camel Splitter EIP to split big payloads using a stream mode to avoid - * reading the entire content into memory. - */ -public class BeanIOSplitter implements Expression { - - private BeanIOConfiguration configuration = new BeanIOConfiguration(); - private StreamFactory factory; - - public BeanIOSplitter() throws Exception { - } - - public BeanIOSplitter(BeanIOConfiguration configuration) { - this.configuration = configuration; - } - - public BeanIOSplitter(String mapping, String streamName) { - setMapping(mapping); - setStreamName(streamName); - } - - protected StreamFactory createStreamFactory(CamelContext camelContext) throws Exception { - ObjectHelper.notNull(getStreamName(), "Stream name not configured."); - // Create the stream factory that will be used to read/write objects. - StreamFactory answer = StreamFactory.newInstance(); - - // Load the mapping file using the resource helper to ensure it can be loaded in OSGi and other environments - InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, getMapping()); - try { - if (getProperties() != null) { - answer.load(is, getProperties()); - } else { - answer.load(is); - } - } finally { - IOHelper.close(is); - } - - return answer; - } - - public Object evaluate(Exchange exchange) throws Exception { - Message msg = exchange.getIn(); - Object body = msg.getBody(); - - if (factory == null) { - factory = createStreamFactory(exchange.getContext()); - } - - BeanReader beanReader = null; - if (body instanceof WrappedFile) { - body = ((WrappedFile) body).getFile(); - } - if (body instanceof File) { - File file = (File) body; - beanReader = factory.createReader(getStreamName(), file); - } - if (beanReader == null) { - Reader reader = msg.getMandatoryBody(Reader.class); - beanReader = factory.createReader(getStreamName(), reader); - } - - BeanIOIterator iterator = new BeanIOIterator(beanReader); - - BeanReaderErrorHandler errorHandler = getOrCreateBeanReaderErrorHandler(configuration, exchange, null, iterator); - beanReader.setErrorHandler(errorHandler); - - return iterator; - } - - @Override - public <T> T evaluate(Exchange exchange, Class<T> type) { - try { - Object result = evaluate(exchange); - return exchange.getContext().getTypeConverter().convertTo(type, exchange, result); - } catch (Exception e) { - throw RuntimeCamelException.wrapRuntimeCamelException(e); - } - } - - public BeanIOConfiguration getConfiguration() { - return configuration; - } - - public void setConfiguration(BeanIOConfiguration configuration) { - this.configuration = configuration; - } - - public StreamFactory getFactory() { - return factory; - } - - public void setFactory(StreamFactory factory) { - this.factory = factory; - } - - public String getMapping() { - return configuration.getMapping(); - } - - public void setIgnoreUnexpectedRecords(boolean ignoreUnexpectedRecords) { - configuration.setIgnoreUnexpectedRecords(ignoreUnexpectedRecords); - } - - public void setProperties(Properties properties) { - configuration.setProperties(properties); - } - - public void setStreamName(String streamName) { - configuration.setStreamName(streamName); - } - - public boolean isIgnoreUnidentifiedRecords() { - return configuration.isIgnoreUnidentifiedRecords(); - } - - public boolean isIgnoreInvalidRecords() { - return configuration.isIgnoreInvalidRecords(); - } - - public void setIgnoreInvalidRecords(boolean ignoreInvalidRecords) { - configuration.setIgnoreInvalidRecords(ignoreInvalidRecords); - } - - public void setEncoding(Charset encoding) { - configuration.setEncoding(encoding); - } - - public boolean isIgnoreUnexpectedRecords() { - return configuration.isIgnoreUnexpectedRecords(); - } - - public Properties getProperties() { - return configuration.getProperties(); - } - - public String getStreamName() { - return configuration.getStreamName(); - } - - public void setMapping(String mapping) { - configuration.setMapping(mapping); - } - - public void setIgnoreUnidentifiedRecords(boolean ignoreUnidentifiedRecords) { - configuration.setIgnoreUnidentifiedRecords(ignoreUnidentifiedRecords); - } - - public Charset getEncoding() { - return configuration.getEncoding(); - } - - public BeanReaderErrorHandler getBeanReaderErrorHandler() { - return configuration.getBeanReaderErrorHandler(); - } - - public void setBeanReaderErrorHandler(BeanReaderErrorHandler beanReaderErrorHandler) { - configuration.setBeanReaderErrorHandler(beanReaderErrorHandler); - } - - public String getBeanReaderErrorHandlerType() { - return configuration.getBeanReaderErrorHandlerType(); - } - - public void setBeanReaderErrorHandlerType(String beanReaderErrorHandlerType) { - configuration.setBeanReaderErrorHandlerType(beanReaderErrorHandlerType); - } - - public void setBeanReaderErrorHandlerType(Class<?> beanReaderErrorHandlerType) { - configuration.setBeanReaderErrorHandlerType(beanReaderErrorHandlerType); - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/A1Record.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/A1Record.java deleted file mode 100644 index 39346a8..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/A1Record.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.beanio; - -public class A1Record extends Record { - Double currentPrice; - - public A1Record() { - } - - public A1Record(String sedol, String source, Double currentPrice) { - super(sedol, source); - this.currentPrice = currentPrice; - } - - public Double getCurrentPrice() { - return currentPrice; - } - - public void setCurrentPrice(Double currentPrice) { - this.currentPrice = currentPrice; - } - - @Override - public int hashCode() { - return currentPrice != null ? currentPrice.hashCode() : 0; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } else if (obj == this) { - return true; - } else { - A1Record record = (A1Record) obj; - return super.equals(record) && this.currentPrice.doubleValue() == record.getCurrentPrice().doubleValue(); - } - } - - @Override - public String toString() { - return "SEDOL[" + this.sedol + "], SOURCE[" + this.source + "], PRICE[" + this.currentPrice + "]"; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/B1Record.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/B1Record.java deleted file mode 100644 index 93f496d..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/B1Record.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.beanio; - -public class B1Record extends Record { - String securityName; - - public B1Record() { - } - - public B1Record(String sedol, String source, String securityName) { - super(sedol, source); - this.securityName = securityName; - } - - public String getSecurityName() { - return securityName; - } - - public void setSecurityName(String securityName) { - this.securityName = securityName; - } - - @Override - public int hashCode() { - return securityName != null ? securityName.hashCode() : 0; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } else if (obj == this) { - return true; - } else { - B1Record record = (B1Record) obj; - return super.equals(record) && this.securityName.equals(record.getSecurityName()); - } - } - - @Override - public String toString() { - return "SEDOL[" + this.sedol + "], SOURCE[" + this.source + "], NAME[" + this.securityName + "]"; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatComplexTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatComplexTest.java deleted file mode 100644 index 20956eb..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatComplexTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * 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.beanio; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.beanio.InvalidRecordException; -import org.beanio.UnexpectedRecordException; -import org.beanio.UnidentifiedRecordException; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; - -public class BeanIODataFormatComplexTest extends CamelTestSupport { - - private static Locale defaultLocale; - - private final String recordData = "0001917A112345.678900 " + Constants.LS - + "0002374A159303290.020 " + Constants.LS - + "0015219B1SECURITY ONE " + Constants.LS - + "END OF SECTION 1 " + Constants.LS - + "0076647A10.0000000001 " + Constants.LS - + "0135515A1999999999999 " + Constants.LS - + "2000815B1SECURITY TWO " + Constants.LS - + "2207122B1SECURITY THR " + Constants.LS - + "END OF FILE 000007 " + Constants.LS; - - private final String data = "0000000A1030808PRICE " + Constants.LS - + "0000000B1030808SECURITY " + Constants.LS - + "HEADER END " + Constants.LS - + recordData; - - private final String unExpectedData = "0000000A1030808PRICE " + Constants.LS - + "0000000B1030808SECURITY " + Constants.LS - + "0000000B1030808SECURITY " + Constants.LS - + "HEADER END " + Constants.LS - + recordData; - - private final String invalidData = "0000000A1030808PRICE " + Constants.LS - + "0000000B1030808SECURITY EXTRA DATA" + Constants.LS - + "0000000B1030808SECURITY " + Constants.LS - + "HEADER END " + Constants.LS - + recordData; - - private final String unidentifiedData = "0000000A1030808PRICE " + Constants.LS - + "0000000C1030808SECURITY " + Constants.LS - + "0000000B1030808SECURITY " + Constants.LS - + "HEADER END " + Constants.LS - + recordData; - - @BeforeAll - public static void setLocale() { - if (!Locale.getDefault().equals(Locale.ENGLISH)) { - - // the Locale used for the number formatting of the above data is - // english which could be other than the default locale - defaultLocale = Locale.getDefault(); - Locale.setDefault(Locale.ENGLISH); - } - } - - @AfterAll - public static void resetLocale() { - if (defaultLocale != null) { - Locale.setDefault(defaultLocale); - } - } - - @Test - void testMarshal() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:beanio-marshal"); - mock.expectedBodiesReceived(data); - - template.sendBody("direct:marshal", createTestData(false)); - - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshal() throws Exception { - context.setTracing(true); - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(createTestData(false)); - - template.sendBody("direct:unmarshal", data); - - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshalUnexpected() throws Exception { - Throwable ex = null; - - try { - template.sendBody("direct:unmarshal", unExpectedData); - } catch (Exception e) { - ex = e.getCause(); - } - - assertIsInstanceOf(UnexpectedRecordException.class, ex); - } - - @Test - void testUnmarshalInvalid() throws Exception { - Throwable ex = null; - - try { - template.sendBody("direct:unmarshal", invalidData); - } catch (Exception e) { - ex = e.getCause(); - } - - assertIsInstanceOf(InvalidRecordException.class, ex); - } - - @Test - void testUnmarshalUnidentifiedIgnore() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(createTestData(false)); - template.sendBody("direct:unmarshal-forgiving", unidentifiedData); - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshalUnexpectedIgnore() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(createTestData(false)); - template.sendBody("direct:unmarshal-forgiving", unExpectedData); - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshalInvalidIgnore() throws Exception { - context.setTracing(true); - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(createTestData(true)); - template.sendBody("direct:unmarshal-forgiving", invalidData); - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshalUnidentified() { - Throwable ex = null; - - try { - template.sendBody("direct:unmarshal", unidentifiedData); - } catch (Exception e) { - ex = e.getCause(); - } - - assertIsInstanceOf(UnidentifiedRecordException.class, ex); - } - - private List<Object> createTestData(boolean skipB1header) throws ParseException { - String source = "camel-beanio"; - List<Object> body = new ArrayList<>(); - - Date date = new SimpleDateFormat("ddMMyy").parse("030808"); - Header hFirst = new Header("A1", date, "PRICE"); - Header hSecond = new Header("B1", date, "SECURITY"); - Separator headerEnd = new Separator("HEADER END"); - - A1Record first = new A1Record("0001917", source, 12345.678900); - A1Record second = new A1Record("0002374", source, 59303290.020); - B1Record third = new B1Record("0015219", source, "SECURITY ONE"); - Separator sectionEnd = new Separator("END OF SECTION 1"); - A1Record fourth = new A1Record("0076647", source, 0.0000000001); - A1Record fifth = new A1Record("0135515", source, 999999999999d); - B1Record sixth = new B1Record("2000815", source, "SECURITY TWO"); - B1Record seventh = new B1Record("2207122", source, "SECURITY THR"); - - body.add(hFirst); - if (!skipB1header) { - body.add(hSecond); - } - body.add(headerEnd); - body.add(first); - body.add(second); - body.add(third); - body.add(sectionEnd); - body.add(fourth); - body.add(fifth); - body.add(sixth); - body.add(seventh); - - Trailer trailer = new Trailer(7); - body.add(trailer); - - return body; - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - BeanIODataFormat format - = new BeanIODataFormat("org/apache/camel/dataformat/beanio/mappings.xml", "securityData"); - - BeanIODataFormat forgivingFormat - = new BeanIODataFormat("org/apache/camel/dataformat/beanio/mappings.xml", "securityData"); - forgivingFormat.setIgnoreInvalidRecords(true); - forgivingFormat.setIgnoreUnexpectedRecords(true); - forgivingFormat.setIgnoreUnidentifiedRecords(true); - - from("direct:unmarshal").unmarshal(format).split(simple("${body}")).to("mock:beanio-unmarshal"); - - from("direct:unmarshal-forgiving").unmarshal(forgivingFormat).split(simple("${body}")) - .to("mock:beanio-unmarshal"); - - from("direct:marshal").marshal(format).to("mock:beanio-marshal"); - } - }; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest.java deleted file mode 100644 index dc278aa..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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.beanio; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -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; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest extends CamelTestSupport { - - // START SNIPPET: e2 - private static final String FIXED_DATA = "Joe,Smith,Developer,75000,10012009" + Constants.LS - + "Jane,Doe,Architect,80000,01152008" + Constants.LS - + "Jon,Anderson,Manager,85000,03182007" + Constants.LS; - // END SNIPPET: e2 - - private static final String FIXED_FAIL_DATA = "Joe,Smith,Developer,75000,10012009" + Constants.LS - + "Jane,Doe,Architect,80000,01152008" + Constants.LS - + "Jon,Anderson,Manager,XXX,03182007" + Constants.LS; - - @Test - void testMarshal() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-marshal"); - mock.expectedBodiesReceived(FIXED_DATA); - - template.sendBody("direct:marshal", employees); - - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshal() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(employees); - - template.sendBody("direct:unmarshal", FIXED_DATA); - - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshalFail() throws Exception { - // there should be 1 splitted that failed we get also - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedMessageCount(3); - mock.message(0).body().isInstanceOf(Employee.class); - mock.message(1).body().isInstanceOf(Employee.class); - mock.message(2).body().isInstanceOf(MyErrorDto.class); - - template.sendBody("direct:unmarshal", FIXED_FAIL_DATA); - - mock.assertIsSatisfied(); - - assertEquals("employee", mock.getReceivedExchanges().get(2).getIn().getBody(MyErrorDto.class).getRecord()); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - // START SNIPPET: e1 - // setup beanio data format using the mapping file, loaded from the classpath - BeanIODataFormat format = new BeanIODataFormat( - "org/apache/camel/dataformat/beanio/mappings.xml", - "employeeFile"); - - // use our custom error handler - format.setBeanReaderErrorHandlerType(MyErrorHandler.class); - - // a route which uses the bean io data format to format a CSV data - // to java objects - from("direct:unmarshal") - .unmarshal(format) - // and then split the message body so we get a message for each row - .split(body()) - .to("mock:beanio-unmarshal"); - - // convert list of java objects back to flat format - from("direct:marshal") - .marshal(format) - .to("mock:beanio-marshal"); - // END SNIPPET: e1 - } - }; - } - - private List<Employee> getEmployees() throws ParseException { - List<Employee> employees = new ArrayList<>(); - Employee one = new Employee(); - one.setFirstName("Joe"); - one.setLastName("Smith"); - one.setTitle("Developer"); - one.setSalary(75000); - one.setHireDate(new SimpleDateFormat("MMddyyyy").parse("10012009")); - employees.add(one); - - Employee two = new Employee(); - two.setFirstName("Jane"); - two.setLastName("Doe"); - two.setTitle("Architect"); - two.setSalary(80000); - two.setHireDate(new SimpleDateFormat("MMddyyyy").parse("01152008")); - employees.add(two); - - Employee three = new Employee(); - three.setFirstName("Jon"); - three.setLastName("Anderson"); - three.setTitle("Manager"); - three.setSalary(85000); - three.setHireDate(new SimpleDateFormat("MMddyyyy").parse("03182007")); - employees.add(three); - return employees; - } - -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java deleted file mode 100644 index 52ca0f7..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.beanio; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.spi.DataFormat; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; - -public class BeanIODataFormatSimpleTest extends CamelTestSupport { - - // START SNIPPET: e2 - private static final String FIXED_DATA = "Joe,Smith,Developer,75000,10012009" + Constants.LS - + "Jane,Doe,Architect,80000,01152008" + Constants.LS - + "Jon,Anderson,Manager,85000,03182007" + Constants.LS; - // END SNIPPET: e2 - - @Test - void testMarshal() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-marshal"); - mock.expectedBodiesReceived(FIXED_DATA); - - template.sendBody("direct:marshal", employees); - - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshal() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(employees); - - template.sendBody("direct:unmarshal", FIXED_DATA); - - mock.assertIsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - // START SNIPPET: e1 - // setup beanio data format using the mapping file, loaded from the classpath - DataFormat format = new BeanIODataFormat( - "org/apache/camel/dataformat/beanio/mappings.xml", - "employeeFile"); - - // a route which uses the bean io data format to format a CSV data - // to java objects - from("direct:unmarshal") - .unmarshal(format) - // and then split the message body so we get a message for each row - .split(body()) - .to("mock:beanio-unmarshal"); - - // convert list of java objects back to flat format - from("direct:marshal") - .marshal(format) - .to("mock:beanio-marshal"); - // END SNIPPET: e1 - } - }; - } - - private List<Employee> getEmployees() throws ParseException { - List<Employee> employees = new ArrayList<>(); - Employee one = new Employee(); - one.setFirstName("Joe"); - one.setLastName("Smith"); - one.setTitle("Developer"); - one.setSalary(75000); - one.setHireDate(new SimpleDateFormat("MMddyyyy").parse("10012009")); - employees.add(one); - - Employee two = new Employee(); - two.setFirstName("Jane"); - two.setLastName("Doe"); - two.setTitle("Architect"); - two.setSalary(80000); - two.setHireDate(new SimpleDateFormat("MMddyyyy").parse("01152008")); - employees.add(two); - - Employee three = new Employee(); - three.setFirstName("Jon"); - three.setLastName("Anderson"); - three.setTitle("Manager"); - three.setSalary(85000); - three.setHireDate(new SimpleDateFormat("MMddyyyy").parse("03182007")); - employees.add(three); - return employees; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterCustomBeanReaderErrorHandlerTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterCustomBeanReaderErrorHandlerTest.java deleted file mode 100644 index 00150fb..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterCustomBeanReaderErrorHandlerTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.beanio; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -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; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class BeanIOSplitterCustomBeanReaderErrorHandlerTest extends CamelTestSupport { - - // START SNIPPET: e2 - private static final String FIXED_DATA = "Joe,Smith,Developer,75000,10012009" + Constants.LS - + "Jane,Doe,Architect,80000,01152008" + Constants.LS - + "Jon,Anderson,Manager,85000,03182007" + Constants.LS; - // END SNIPPET: e2 - - private static final String FIXED_FAIL_DATA = "Joe,Smith,Developer,75000,10012009" + Constants.LS - + "Jane,Doe,Architect,80000,01152008" + Constants.LS - + "Jon,Anderson,Manager,XXX,03182007" + Constants.LS; - - @Test - void testSplit() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(employees); - - template.sendBody("direct:unmarshal", FIXED_DATA); - - mock.assertIsSatisfied(); - } - - @Test - void testSplitFail() throws Exception { - // there should be 1 splitted that failed we get also - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedMessageCount(3); - mock.message(0).body().isInstanceOf(Employee.class); - mock.message(1).body().isInstanceOf(Employee.class); - mock.message(2).body().isInstanceOf(MyErrorDto.class); - - template.sendBody("direct:unmarshal", FIXED_FAIL_DATA); - - mock.assertIsSatisfied(); - - assertEquals("employee", mock.getReceivedExchanges().get(2).getIn().getBody(MyErrorDto.class).getRecord()); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - // START SNIPPET: e1 - // setup beanio splitter using the mapping file, loaded from the classpath - BeanIOSplitter splitter = new BeanIOSplitter(); - splitter.setMapping("org/apache/camel/dataformat/beanio/mappings.xml"); - splitter.setStreamName("employeeFile"); - splitter.setBeanReaderErrorHandlerType(MyErrorHandler.class); - - // a route which uses the bean io data format to format a CSV data - // to java objects - from("direct:unmarshal") - // and then split the message body so we get a message for each row - .split(splitter).streaming() - .to("log:line") - .to("mock:beanio-unmarshal"); - // END SNIPPET: e1 - } - }; - } - - private List<Employee> getEmployees() throws ParseException { - List<Employee> employees = new ArrayList<>(); - Employee one = new Employee(); - one.setFirstName("Joe"); - one.setLastName("Smith"); - one.setTitle("Developer"); - one.setSalary(75000); - one.setHireDate(new SimpleDateFormat("MMddyyyy").parse("10012009")); - employees.add(one); - - Employee two = new Employee(); - two.setFirstName("Jane"); - two.setLastName("Doe"); - two.setTitle("Architect"); - two.setSalary(80000); - two.setHireDate(new SimpleDateFormat("MMddyyyy").parse("01152008")); - employees.add(two); - - Employee three = new Employee(); - three.setFirstName("Jon"); - three.setLastName("Anderson"); - three.setTitle("Manager"); - three.setSalary(85000); - three.setHireDate(new SimpleDateFormat("MMddyyyy").parse("03182007")); - employees.add(three); - return employees; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterTest.java deleted file mode 100644 index 68d5a37..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.beanio; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -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 BeanIOSplitterTest extends CamelTestSupport { - - // START SNIPPET: e2 - private static final String FIXED_DATA = "Joe,Smith,Developer,75000,10012009" + Constants.LS - + "Jane,Doe,Architect,80000,01152008" + Constants.LS - + "Jon,Anderson,Manager,85000,03182007" + Constants.LS; - // END SNIPPET: e2 - - @Test - void testSplit() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(employees); - - template.sendBody("direct:unmarshal", FIXED_DATA); - - mock.assertIsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - // START SNIPPET: e1 - // setup beanio splitter using the mapping file, loaded from the classpath - BeanIOSplitter splitter = new BeanIOSplitter(); - splitter.setMapping("org/apache/camel/dataformat/beanio/mappings.xml"); - splitter.setStreamName("employeeFile"); - - // a route which uses the bean io data format to format a CSV data - // to java objects - from("direct:unmarshal") - // and then split the message body so we get a message for each row - .split(splitter).streaming() - .to("log:line") - .to("mock:beanio-unmarshal"); - // END SNIPPET: e1 - } - }; - } - - private List<Employee> getEmployees() throws ParseException { - List<Employee> employees = new ArrayList<>(); - Employee one = new Employee(); - one.setFirstName("Joe"); - one.setLastName("Smith"); - one.setTitle("Developer"); - one.setSalary(75000); - one.setHireDate(new SimpleDateFormat("MMddyyyy").parse("10012009")); - employees.add(one); - - Employee two = new Employee(); - two.setFirstName("Jane"); - two.setLastName("Doe"); - two.setTitle("Architect"); - two.setSalary(80000); - two.setHireDate(new SimpleDateFormat("MMddyyyy").parse("01152008")); - employees.add(two); - - Employee three = new Employee(); - three.setFirstName("Jon"); - three.setLastName("Anderson"); - three.setTitle("Manager"); - three.setSalary(85000); - three.setHireDate(new SimpleDateFormat("MMddyyyy").parse("03182007")); - employees.add(three); - return employees; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOUnmarshalSingleObjectTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOUnmarshalSingleObjectTest.java deleted file mode 100644 index a61f7e7..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOUnmarshalSingleObjectTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.beanio; - -import java.util.Map; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -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; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class BeanIOUnmarshalSingleObjectTest extends CamelTestSupport { - - private static final String NEW_LINE = "\n"; - private static final String INPUT - = "1234:Content starts from here" + NEW_LINE + "then continues" + NEW_LINE + "and ends here."; - - @Test - void testMultiLineContentUnmarshal() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMessageCount(1); - - template.sendBody("direct:unmarshal", INPUT); - - mock.assertIsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - BeanIODataFormat format = new BeanIODataFormat( - "org/apache/camel/dataformat/beanio/single-object-mapping.xml", "keyValueStream"); - // turn on single mode - format.setUnmarshalSingleObject(true); - - from("direct:unmarshal").unmarshal(format).process(new Processor() { - public void process(Exchange exchange) throws Exception { - Map body = (Map) exchange.getIn().getBody(); - assertEquals(":", body.get("separator")); - assertEquals("1234", body.get("key")); - assertEquals(INPUT.substring(5), body.get("value")); - } - }).marshal(format).to("mock:result"); - } - }; - } - -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Constants.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Constants.java deleted file mode 100644 index 2382d36..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Constants.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.beanio; - -public final class Constants { - - public static final String LS = System.lineSeparator(); - - private Constants() { - } - -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Employee.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Employee.java deleted file mode 100644 index 312d244..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Employee.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.beanio; - -import java.util.Date; - -public class Employee { - - private String firstName; - private String lastName; - private String title; - private int salary; - private Date hireDate; - - public Employee() { - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getSalary() { - return salary; - } - - public void setSalary(int salary) { - this.salary = salary; - } - - public Date getHireDate() { - return hireDate; - } - - public void setHireDate(Date hireDate) { - this.hireDate = hireDate; - } - - @Override - public int hashCode() { - int result = firstName != null ? firstName.hashCode() : 0; - result = 31 * result + (lastName != null ? lastName.hashCode() : 0); - result = 31 * result + (title != null ? title.hashCode() : 0); - result = 31 * result + salary; - result = 31 * result + (hireDate != null ? hireDate.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object object) { - if (object == null) { - return false; - } else if (object == this) { - return true; - } else if (!(object instanceof Employee)) { - return false; - } - - Employee e = (Employee) object; - - return this.getFirstName().equals(e.getFirstName()) - && this.getLastName().equals(e.getLastName()) - && this.getTitle().equals(e.getTitle()) - && this.getSalary() == e.getSalary() - && this.getHireDate().equals(e.getHireDate()); - } - - @Override - public String toString() { - return "Employee{" - + "firstName='" + firstName + '\'' - + ", lastName='" + lastName + '\'' - + ", title='" + title + '\'' - + ", salary=" + salary - + ", hireDate=" + hireDate - + '}'; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Header.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Header.java deleted file mode 100644 index 38bfd2d..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Header.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.beanio; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -public class Header implements BeanIOHeader { - - String identifier; - String recordType; - Date headerDate; - - public Header() { - } - - public Header(String identifier, Date headerDate, String recordType) { - this.identifier = identifier; - this.headerDate = headerDate; - this.recordType = recordType; - } - - @Override - public int hashCode() { - int result = identifier != null ? identifier.hashCode() : 0; - result = 31 * result + (recordType != null ? recordType.hashCode() : 0); - result = 31 * result + (headerDate != null ? headerDate.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } else if (obj == this) { - return true; - } else { - Header record = (Header) obj; - return identifier.equals(record.getIdentifier()) && recordType.equals(record.getRecordType()); - } - } - - @Override - public String toString() { - return "TYPE[" + this.recordType + "], IDENTIFIER[" + this.identifier + "]"; - } - - /** - * @return the identifier - */ - public String getIdentifier() { - return identifier; - } - - /** - * @param identifier the identifier to set - */ - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - /** - * @return the headerDate - */ - public Date getHeaderDate() { - return headerDate; - } - - /** - * @param headerDate the headerDate to set - */ - public void setHeaderDate(Date headerDate) { - this.headerDate = headerDate; - } - - /** - * @return the recordType - */ - public String getRecordType() { - return recordType; - } - - /** - * @param recordType the recordType to set - */ - public void setRecordType(String recordType) { - this.recordType = recordType; - } - - @Override - public Map<String, Object> getHeaders() { - Map<String, Object> headers = new HashMap<>(); - headers.put(recordType + "Date", headerDate); - return headers; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/MyErrorDto.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/MyErrorDto.java deleted file mode 100644 index e4ae0e7..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/MyErrorDto.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.beanio; - -public class MyErrorDto { - - private String record; - private String message; - - public MyErrorDto(String record, String message) { - this.record = record; - this.message = message; - } - - public String getRecord() { - return record; - } - - public String getMessage() { - return message; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/MyErrorHandler.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/MyErrorHandler.java deleted file mode 100644 index a3b0503..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/MyErrorHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.beanio; - -import org.beanio.InvalidRecordException; - -public class MyErrorHandler extends BeanIOErrorHandler { - - public MyErrorHandler() { - } - - @Override - public void invalidRecord(InvalidRecordException ex) throws Exception { - String id = getExchange().getExchangeId(); - String line - = "ExchangeId: " + id + " Invalid record: " + ex.getMessage() + ": " + ex.getRecordContext().getRecordText(); - LOG.warn(line); - - // lets handle the error and store to the results a dummy error DTO - MyErrorDto dto = new MyErrorDto(ex.getRecordName(), ex.getMessage()); - handleErrorAndAddAsResult(dto); - } - -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Record.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Record.java deleted file mode 100644 index 95e0d8c..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Record.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.beanio; - -public abstract class Record { - String sedol; - String source; - - public Record() { - } - - public Record(String sedol, String source) { - this.sedol = sedol; - this.source = source; - } - - public String getSedol() { - return sedol; - } - - public void setSedol(String sedol) { - this.sedol = sedol; - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - @Override - public int hashCode() { - int result = sedol != null ? sedol.hashCode() : 0; - result = 31 * result + (source != null ? source.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } else if (obj == this) { - return true; - } else { - Record record = (Record) obj; - return sedol.equals(record.getSedol()) && source.equals(record.getSource()); - } - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Separator.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Separator.java deleted file mode 100644 index b871adc..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Separator.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.beanio; - -public class Separator { - String value; - - public Separator() { - } - - public Separator(String value) { - this.value = value; - } - - @Override - public int hashCode() { - return value != null ? value.hashCode() : 0; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } else if (obj == this) { - return true; - } else { - Separator record = (Separator) obj; - return this.value.equals(record.getValue()); - } - } - - /** - * @return the value - */ - public String getValue() { - return value; - } - - /** - * @param value the value to set - */ - public void setValue(String value) { - this.value = value; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.java deleted file mode 100644 index ac3c9d7..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.beanio; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.spring.junit5.CamelSpringTestSupport; -import org.junit.jupiter.api.Test; -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class SpringBeanIODataFormatSimpleTest extends CamelSpringTestSupport { - - private static final String FIXED_DATA = "Joe,Smith,Developer,75000,10012009" + Constants.LS - + "Jane,Doe,Architect,80000,01152008" + Constants.LS - + "Jon,Anderson,Manager,85000,03182007" + Constants.LS; - - @Override - protected AbstractApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.xml"); - } - - @Test - void testMarshal() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-marshal"); - mock.expectedBodiesReceived(FIXED_DATA); - - template.sendBody("direct:marshal", employees); - - mock.assertIsSatisfied(); - } - - @Test - void testUnmarshal() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedBodiesReceived(employees); - - template.sendBody("direct:unmarshal", FIXED_DATA); - - mock.assertIsSatisfied(); - } - - private List<Employee> getEmployees() throws ParseException { - List<Employee> employees = new ArrayList<>(); - Employee one = new Employee(); - one.setFirstName("Joe"); - one.setLastName("Smith"); - one.setTitle("Developer"); - one.setSalary(75000); - one.setHireDate(new SimpleDateFormat("MMddyyyy").parse("10012009")); - employees.add(one); - - Employee two = new Employee(); - two.setFirstName("Jane"); - two.setLastName("Doe"); - two.setTitle("Architect"); - two.setSalary(80000); - two.setHireDate(new SimpleDateFormat("MMddyyyy").parse("01152008")); - employees.add(two); - - Employee three = new Employee(); - three.setFirstName("Jon"); - three.setLastName("Anderson"); - three.setTitle("Manager"); - three.setSalary(85000); - three.setHireDate(new SimpleDateFormat("MMddyyyy").parse("03182007")); - employees.add(three); - return employees; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Trailer.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Trailer.java deleted file mode 100644 index aaf8768..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Trailer.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.beanio; - -public class Trailer { - int numberOfRecords; - - public Trailer() { - } - - public Trailer(int numberOfRecords) { - this.numberOfRecords = numberOfRecords; - } - - @Override - public int hashCode() { - return numberOfRecords; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } else if (obj == this) { - return true; - } else { - Trailer record = (Trailer) obj; - return this.numberOfRecords == record.getNumberOfRecords(); - } - } - - /** - * @return the numberOfRecords - */ - public int getNumberOfRecords() { - return numberOfRecords; - } - - /** - * @param numberOfRecords the numberOfRecords to set - */ - public void setNumberOfRecords(int numberOfRecords) { - this.numberOfRecords = numberOfRecords; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTest.java deleted file mode 100644 index acbfaa4..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.beanio.csv; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.dataformat.beanio.BeanIODataFormat; -import org.apache.camel.dataformat.beanio.Constants; -import org.apache.camel.spi.DataFormat; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class CsvTest extends CamelTestSupport { - - static final Logger LOG = LoggerFactory.getLogger(CsvTest.class); - - private static final String FIXED_DATA = "James,Strachan,22" + Constants.LS + "Claus,Ibsen,21" + Constants.LS; - - private boolean verbose; - - /* - @Test - void testMarshal() throws Exception { - List<Employee> employees = getEmployees(); - - MockEndpoint mock = getMockEndpoint("mock:beanio-marshal"); - mock.expectedBodiesReceived(FIXED_DATA); - - template.sendBody("direct:marshal", employees); - - mock.assertIsSatisfied(); - } - */ - - @Test - void testUnmarshal() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal"); - mock.expectedMessageCount(2); - - template.sendBody("direct:unmarshal", FIXED_DATA); - - mock.assertIsSatisfied(); - - List<Exchange> exchanges = mock.getExchanges(); - if (verbose) { - for (Exchange exchange : exchanges) { - Object body = exchange.getIn().getBody(); - LOG.info("received message {} of class {}", body, body.getClass().getName()); - } - } - List<Map> results = new ArrayList<>(); - for (Exchange exchange : exchanges) { - Map body = exchange.getIn().getBody(Map.class); - if (body != null) { - results.add(body); - } - } - assertRecord(results, 0, "James", "Strachan", 22); - assertRecord(results, 1, "Claus", "Ibsen", 21); - } - - protected static void assertRecord( - List<Map> results, int index, String expectedFirstName, String expectedLastName, int expectedAge) { - assertTrue(results.size() > index, "Not enough Map messages received: " + results.size()); - Map map = results.get(index); - assertNotNull(map, "No map result found for index " + index); - - String text = "bodyAsMap(" + index + ") "; - assertEquals(expectedFirstName, map.get("firstName"), text + "firstName"); - assertEquals(expectedLastName, map.get("lastName"), text + "lastName"); - assertEquals(expectedAge, map.get("age"), text + "age"); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - // START SNIPPET: e1 - // setup beanio data format using the mapping file, loaded from the classpath - DataFormat format = new BeanIODataFormat( - "org/apache/camel/dataformat/beanio/csv/mappings.xml", - "stream1"); - - // a route which uses the bean io data format to format a CSV data - // to java objects - from("direct:unmarshal") - .unmarshal(format) - // and then split the message body so we get a message for each row - .split(body()) - .to("mock:beanio-unmarshal"); - - // convert list of java objects back to flat format - from("direct:marshal") - .marshal(format) - .to("mock:beanio-marshal"); - // END SNIPPET: e1 - } - }; - } -} diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTestWithProperties.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTestWithProperties.java deleted file mode 100644 index 9e846df1..0000000 --- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTestWithProperties.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.beanio.csv; - -import java.util.Properties; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.dataformat.beanio.BeanIODataFormat; - -public class CsvTestWithProperties extends CsvTest { - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - // START SNIPPET: e1 - // setup beanio data format using the mapping file, loaded from the classpath - BeanIODataFormat format = new BeanIODataFormat( - "org/apache/camel/dataformat/beanio/csv/mappingsWithProperties.xml", - "stream1"); - Properties properties = new Properties(); - properties.setProperty("field1", "firstName"); - properties.setProperty("field2", "lastName"); - - format.setProperties(properties); - - // a route which uses the bean io data format to format a CSV data - // to java objects - from("direct:unmarshal") - .unmarshal(format) - // and then split the message body so we get a message for each row - .split(body()) - .to("mock:beanio-unmarshal"); - - // convert list of java objects back to flat format - from("direct:marshal") - .marshal(format) - .to("mock:beanio-marshal"); - // END SNIPPET: e1 - } - }; - } - -} diff --git a/components/camel-beanio/src/test/resources/log4j2.properties b/components/camel-beanio/src/test/resources/log4j2.properties deleted file mode 100644 index d2d50a4..0000000 --- a/components/camel-beanio/src/test/resources/log4j2.properties +++ /dev/null @@ -1,28 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -appender.console.type = Console -appender.console.name = console -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = %d %-5p %c{1} - %m %n -appender.file.type = File -appender.file.name = file -appender.file.fileName = target/camel-beanio-test.log -appender.file.layout.type = PatternLayout -appender.file.layout.pattern = %d %-5p %c{1} - %m %n -rootLogger.level = INFO -rootLogger.appenderRef.file.ref = file diff --git a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.xml b/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.xml deleted file mode 100644 index 07ba9c2..0000000 --- a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?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. - ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://camel.apache.org/schema/spring - http://camel.apache.org/schema/spring/camel-spring.xsd"> - -<!-- START SNIPPET: e1 --> - <camelContext xmlns="http://camel.apache.org/schema/spring"> - <!-- setup beanio data format --> - <dataFormats> - <beanio id="myBeanio" mapping="org/apache/camel/dataformat/beanio/mappings.xml" streamName="employeeFile" encoding="UTF-8"/> - </dataFormats> - - <route> - <from uri="direct:unmarshal"/> - <unmarshal><custom ref="myBeanio"/></unmarshal> - <split> - <simple>${body}</simple> - <to uri="mock:beanio-unmarshal"/> - </split> - </route> - - <route> - <from uri="direct:marshal"/> - <marshal><custom ref="myBeanio"/></marshal> - <to uri="mock:beanio-marshal"/> - </route> - </camelContext> - <!-- END SNIPPET: e1 --> - -</beans> diff --git a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/csv/mappings.xml b/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/csv/mappings.xml deleted file mode 100644 index 4cf9b2f..0000000 --- a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/csv/mappings.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?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. - ---> -<beanio xmlns="http://www.beanio.org/2012/03" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.beanio.org/2011/01 http://www.beanio.org/2011/01/mapping.xsd"> - - <stream name="stream1" format="csv"> - <!-- TODO warning - if class is ommitted then this test case just does nothing; no messages consumed and no warnings! :) --> - <record name="record1" class="map"> - <field name="firstName" /> - <field name="lastName" /> - <field name="age" type="int"/> - </record> - </stream> -</beanio> \ No newline at end of file diff --git a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/csv/mappingsWithProperties.xml b/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/csv/mappingsWithProperties.xml deleted file mode 100644 index 456d945..0000000 --- a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/csv/mappingsWithProperties.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?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. - ---> -<beanio xmlns="http://www.beanio.org/2012/03" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.beanio.org/2011/01 http://www.beanio.org/2011/01/mapping.xsd"> - - <stream name="stream1" format="csv"> - <!-- TODO warning - if class is ommitted then this test case just does nothing; no messages consumed and no warnings! :) --> - <record name="record1" class="map"> - <field name="${field1}" /> - <field name="${field2}" /> - <field name="age" type="int"/> - </record> - </stream> -</beanio> \ No newline at end of file diff --git a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/mappings.xml b/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/mappings.xml deleted file mode 100644 index dc994f9..0000000 --- a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/mappings.xml +++ /dev/null @@ -1,116 +0,0 @@ -<?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. - ---> -<beanio xmlns="http://www.beanio.org/2012/03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd"> - - <template name="A1Record"> - <field name="sedol" type="string" length="7"/> - <field name="identifier" rid="true" literal="A1" ignore="true"/> - <field name="currentPrice" type="double" length="12" format="0.000000####"/> - <field name="padding" type="string" length="11" ignore="true"/> - <property name="source" value="camel-beanio"/> - </template> - - <template name="B1Record"> - <field name="sedol" type="string" length="7"/> - <field name="identifier" rid="true" literal="B1" ignore="true"/> - <field name="securityName" type="string" length="12"/> - <field name="padding" type="string" length="11" ignore="true"/> - <property name="source" value="camel-beanio"/> - </template> - - <stream name="employeeFile" format="csv"> - <record name="employee" class="org.apache.camel.dataformat.beanio.Employee"> - <field name="firstName"/> - <field name="lastName"/> - <field name="title"/> - <field name="salary"/> - <field name="hireDate" format="MMddyyyy"/> - </record> - </stream> - - <stream name="securityData" format="fixedlength" strict="true"> - - <group name="headerGroup" minOccurs="1" maxOccurs="1" order="1"> - - <record name="headerA1" class="org.apache.camel.dataformat.beanio.Header" order="1" minLength="32" maxLength="32" - minOccurs="1" maxOccurs="1"> - <field name="zeros" type="string" length="7" literal="0000000" ignore="true"/> - <field name="identifier" type="string" length="2" rid="true" literal="A1"/> - <field name="headerDate" type="date" length="6" format="ddMMyy"/> - <field name="recordType" type="string" length="17"/> - </record> - - <record name="headerB1" class="org.apache.camel.dataformat.beanio.Header" order="2" minLength="32" maxLength="32" - minOccurs="1" maxOccurs="1"> - <field name="zeros" type="string" length="7" literal="0000000" ignore="true"/> - <field name="identifier" type="string" length="2" rid="true" literal="B1"/> - <field name="headerDate" type="date" length="6" format="ddMMyy"/> - <field name="recordType" type="string" length="17"/> - </record> - - <!-- Ignore the HEADER END by not setting a class --> - <record name="headerEnd" class="org.apache.camel.dataformat.beanio.Separator" order="3" minLength="32" - maxLength="32" minOccurs="1" maxOccurs="1"> - <field name="value" rid="true" literal="HEADER END" default="HEADER END" required="true"/> - <field name="padding" length="22" ignore="true"/> - </record> - - </group> - - <group name="section1" minOccurs="1" maxOccurs="1" order="2"> - - <record name="A1" template="A1Record" - class="org.apache.camel.dataformat.beanio.A1Record" minOccurs="0" - maxOccurs="unbounded" minLength="32" maxLength="32"/> - <record name="B1" template="B1Record" - class="org.apache.camel.dataformat.beanio.B1Record" minOccurs="0" - maxOccurs="unbounded" minLength="32" maxLength="32"/> - - <record name="endOfUk" class="org.apache.camel.dataformat.beanio.Separator" minOccurs="1" maxOccurs="1" - minLength="32" maxLength="32"> - <field name="value" rid="true" literal="END OF SECTION 1"/> - <field name="padding" length="16" ignore="true"/> - </record> - - </group> - - <group name="section2" minOccurs="1" maxOccurs="1" order="3"> - - <record name="A1" template="A1Record" - class="org.apache.camel.dataformat.beanio.A1Record" minOccurs="0" - maxOccurs="unbounded" minLength="32" maxLength="32"/> - <record name="B1" template="B1Record" - class="org.apache.camel.dataformat.beanio.B1Record" minOccurs="0" - maxOccurs="unbounded" minLength="32" maxLength="32"/> - - <record name="endOfFile" class="org.apache.camel.dataformat.beanio.Trailer" minOccurs="1" maxOccurs="1" - minLength="32" maxLength="32"> - <field name="endOfFile" rid="true" literal="END OF FILE" ignore="true"/> - <field name="spacer" literal=" " length="1" ignore="true"/> - <field name="numberOfRecords" type="integer" length="6" format="000000"/> - <field name="padding" length="14" ignore="true"/> - </record> - - </group> - - </stream> - -</beanio> diff --git a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/single-object-mapping.xml b/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/single-object-mapping.xml deleted file mode 100644 index 8434cb8c..0000000 --- a/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/single-object-mapping.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?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. - ---> -<beanio xmlns="http://www.beanio.org/2012/03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd"> - <stream name="keyValueStream" format="fixedlength"> - <record name="entry" class="map" minOccurs="1"> - <field name="key" length="4" required="true" justify="left" /> - <field name="separator" length="1" required="true" justify="left" /> - <field name="value" required="true" length="unbounded" justify="left" /> - </record> - </stream> -</beanio> \ No newline at end of file diff --git a/components/pom.xml b/components/pom.xml index 5875d72..3b1c028 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -102,7 +102,6 @@ <module>camel-barcode</module> <module>camel-base64</module> <module>camel-bean-validator</module> - <module>camel-beanio</module> <module>camel-bindy</module> <module>camel-bonita</module> <module>camel-box</module> diff --git a/core/camel-main/src/generated/resources/org/apache/camel/main/dataformats.properties b/core/camel-main/src/generated/resources/org/apache/camel/main/dataformats.properties index 0f43262..e5d337d 100644 --- a/core/camel-main/src/generated/resources/org/apache/camel/main/dataformats.properties +++ b/core/camel-main/src/generated/resources/org/apache/camel/main/dataformats.properties @@ -4,7 +4,6 @@ avro avroJackson barcode base64 -beanio bindyCsv bindyFixed bindyKvp diff --git a/docs/components/modules/dataformats/examples/json/beanio.json b/docs/components/modules/dataformats/examples/json/beanio.json deleted file mode 120000 index 9a8e425..0000000 --- a/docs/components/modules/dataformats/examples/json/beanio.json +++ /dev/null @@ -1 +0,0 @@ -../../../../../../components/camel-beanio/src/generated/resources/org/apache/camel/dataformat/beanio/beanio.json \ No newline at end of file diff --git a/docs/components/modules/dataformats/nav.adoc b/docs/components/modules/dataformats/nav.adoc index f4eab9d..8d0372e 100644 --- a/docs/components/modules/dataformats/nav.adoc +++ b/docs/components/modules/dataformats/nav.adoc @@ -8,7 +8,6 @@ ** xref:avroJackson-dataformat.adoc[Avro Jackson] ** xref:barcode-dataformat.adoc[Barcode] ** xref:base64-dataformat.adoc[Base64] -** xref:beanio-dataformat.adoc[BeanIO] ** xref:bindy-dataformat.adoc[Bindy] ** xref:cbor-dataformat.adoc[CBOR] ** xref:crypto-dataformat.adoc[Crypto (Java Cryptographic Extension)] diff --git a/docs/components/modules/dataformats/pages/beanio-dataformat.adoc b/docs/components/modules/dataformats/pages/beanio-dataformat.adoc deleted file mode 120000 index a6a06a0..0000000 --- a/docs/components/modules/dataformats/pages/beanio-dataformat.adoc +++ /dev/null @@ -1 +0,0 @@ -../../../../../components/camel-beanio/src/main/docs/beanio-dataformat.adoc \ No newline at end of file diff --git a/parent/pom.xml b/parent/pom.xml index 319d2b5..0a0ffce 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -94,7 +94,6 @@ <azure-storage-blob-changedfeed-version>12.0.0-beta.10</azure-storage-blob-changedfeed-version> <azure-storage-datalake-version>12.7.1</azure-storage-datalake-version> <azure-storage-queue-version>12.11.4</azure-storage-queue-version> - <beanio-version>2.1.0</beanio-version> <bouncycastle-version>1.70</bouncycastle-version> <box-java-sdk-version>2.58.0</box-java-sdk-version> <braintree-gateway-version>3.14.0</braintree-gateway-version> @@ -1058,11 +1057,6 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-beanio</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> <artifactId>camel-beanstalk</artifactId> <version>${project.version}</version> </dependency>
