From issues-return-49520-archive-asf-public=cust-asf.ponee.io@camel.apache.org Fri Feb 16 07:58:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id ADDD7180647 for ; Fri, 16 Feb 2018 07:58:04 +0100 (CET) Received: (qmail 50252 invoked by uid 500); 16 Feb 2018 06:58:03 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 50243 invoked by uid 99); 16 Feb 2018 06:58:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Feb 2018 06:58:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 22176C13FF for ; Fri, 16 Feb 2018 06:58:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.511 X-Spam-Level: X-Spam-Status: No, score=-109.511 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Vf2LBWMqBZ1c for ; Fri, 16 Feb 2018 06:58:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 069835F253 for ; Fri, 16 Feb 2018 06:58:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1866BE0230 for ; Fri, 16 Feb 2018 06:58:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 6759221E60 for ; Fri, 16 Feb 2018 06:58:00 +0000 (UTC) Date: Fri, 16 Feb 2018 06:58:00 +0000 (UTC) From: "Andrea Cosentino (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (CAMEL-12269) Bindy - Support regex expression as separator MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-12269?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andrea Cosentino reassigned CAMEL-12269: ---------------------------------------- Assignee: Dmitry Volodin > Bindy - Support regex expression as separator > --------------------------------------------- > > Key: CAMEL-12269 > URL: https://issues.apache.org/jira/browse/CAMEL-12269 > Project: Camel > Issue Type: New Feature > Components: camel-bindy > Affects Versions: 2.20.2 > Reporter: Bohdan > Assignee: Dmitry Volodin > Priority: Major > Fix For: 2.21.0 > > > I try to unmarshal CSV file into the class below: > {code:java} > @CsvRecord(separator = "[,;]", skipFirstLine = true) > public class Example { > @DataField(pos = 1) > private String field1; > @DataField(pos = 2) > private String field2; > }{code} > CSV file: > {code:java} > header1,header2 > "value_1","value,2" > {code} > After unmarshalling I get the following value for field2: "value[,;]2". > However, the correct value for field2 should be "value,2". > Complete test: > {code:java} > 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.annotation.DataField; > import org.apache.camel.model.dataformat.BindyType; > import org.apache.camel.test.junit4.CamelTestSupport; > import org.junit.Test; > public class BindyTest extends CamelTestSupport { > @CsvRecord(separator = "[,;]", skipFirstLine = true) > public static class Example { > @DataField(pos = 1) > private String field1; > @DataField(pos = 2) > private String field2; > } > @Test > public void testUnmarshal() throws Exception { > MockEndpoint mock = getMockEndpoint("mock:result"); > mock.expectedMessageCount(1); > template.sendBody("direct:unmarshal", "header1,header2\n\"value1\",\"value,2\""); > assertMockEndpointsSatisfied(); > Example body = mock.getReceivedExchanges().get(0).getIn().getBody(Example.class); > assertEquals("value,2", body.field2); > } > @Override > protected RouteBuilder createRouteBuilder() throws Exception { > return new RouteBuilder() { > @Override > public void configure() throws Exception { > from("direct:unmarshal") > .unmarshal().bindy(BindyType.Csv, Example.class) > .to("mock:result"); > } > }; > } > } > {code} > *Possible workaround:* > Use separator {code}"[,;](?=(?:[^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)"{code} (regex explained in https://stackoverflow.com/a/18893443) -- This message was sent by Atlassian JIRA (v7.6.3#76005)