[
https://issues.apache.org/jira/browse/CAMEL-12080?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16292178#comment-16292178
]
ASF GitHub Bot commented on CAMEL-12080:
----------------------------------------
davsclaus commented on a change in pull request #2149: CAMEL-12080: allow
creating csvcontent without last eol
URL: https://github.com/apache/camel/pull/2149#discussion_r157142554
##########
File path:
components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyMarshalEndWithLineBreakTest.java
##########
@@ -0,0 +1,87 @@
+/**
+ * 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.bindy.csv;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
+import org.apache.camel.dataformat.bindy.model.csv.MyCsvRecord;
+import org.apache.camel.dataformat.bindy.model.csv.MyCsvRecord2;
+import org.apache.camel.dataformat.bindy.util.ConverterUtils;
+import org.apache.camel.model.dataformat.BindyType;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class BindyMarshalEndWithLineBreakTest extends CamelTestSupport {
+
+ @Test
+ public void testCsvWithEndingLineBreak() throws Exception {
+ final CsvRecord record =
MyCsvRecord.class.getAnnotation(CsvRecord.class);
+ final MyCsvRecord csvRecord = new MyCsvRecord();
+ csvRecord.setAddressLine1("221b Baker Street");
+ csvRecord.setCity("London");
+ csvRecord.setCountry("England");
+ csvRecord.setAttention("1");
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+
mock.message(0).body().convertToString().endsWith(ConverterUtils.getStringCarriageReturn(record.crlf()));
+
+ template.sendBody("direct:withlb", csvRecord);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testCsvWithoutEndingLineBreak() throws Exception {
+ final CsvRecord record =
MyCsvRecord2.class.getAnnotation(CsvRecord.class);
+ final MyCsvRecord2 csvRecord2 = new MyCsvRecord2();
+ csvRecord2.setAddressLine1("221b Baker Street");
+ csvRecord2.setCity("London");
+ csvRecord2.setCountry("England");
+ csvRecord2.setAttention("1");
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.message(0).body().convertToString().endsWith(record.separator());
+
+ template.sendBody("direct:withoutlb", csvRecord2);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:withoutlb") //
Review comment:
Can you remove those trailing empty comments with //
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Allow creating csv content without last eol
> -------------------------------------------
>
> Key: CAMEL-12080
> URL: https://issues.apache.org/jira/browse/CAMEL-12080
> Project: Camel
> Issue Type: Improvement
> Components: camel-bindy
> Reporter: Marcin Domanski
> Priority: Minor
> Fix For: Future
>
>
> Hello,
> rfc4180 for CSV states:
> bq. The last record in the file may or may not have an ending line break.
> For deserialization Bindy accepts both types of files, but for serialization
> Bindy to my knowledge always creates content with last row ending with
> newline. Unfortunately some legacy systems treat last newline as one more
> empty row. Would it be possible to introduce control over this? I have this
> problem in CSV and also in fixed format for one other place. For now we need
> to strip the last char in Camel processor.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)