This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-csv. See https://gitlab.nuiton.org/nuiton/nuiton-csv.git commit 27b56f6b136b6523785dabe4559a3e4417778a78 Author: Arnaud Thimel <thimel@codelutin.com> Date: Wed May 2 15:52:21 2018 +0200 fixes #4 Add unit test to prouve that bug doesn't exist anymore --- src/test/java/org/nuiton/csv/ImportExportTest.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/java/org/nuiton/csv/ImportExportTest.java b/src/test/java/org/nuiton/csv/ImportExportTest.java index 5666c55..7f0016f 100644 --- a/src/test/java/org/nuiton/csv/ImportExportTest.java +++ b/src/test/java/org/nuiton/csv/ImportExportTest.java @@ -35,6 +35,8 @@ import java.io.Reader; import java.io.StringReader; import java.nio.charset.Charset; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Set; @@ -105,6 +107,33 @@ public class ImportExportTest { } + @Test + public void testExportImportDoubleQuotesString() throws Exception { + + RowBean one = new RowBean(new Date(), "Un singe en été", 24, RowBeanEnum.TWO); + one.setBooleans(Collections.singletonList(true)); + RowBean two = new RowBean(new Date(), "\"Amazing\" spiderman", 42, RowBeanEnum.ZERO); + two.setBooleans(Collections.singletonList(false)); + + List<RowBean> rowBeans = Arrays.asList(one, two); + + String csv = Export.exportToString(importExportModel, rowBeans, CHARSET); + + // 1 header line + one line per RowBean instance + int expectedLineCount = 1 + rowBeans.size(); + // number of '\n' in csv + int actualLineCount = csv.split("\n").length; + Assert.assertEquals("exported CSV must have all lines", + expectedLineCount, actualLineCount); + + List<RowBean> imported = importContent(importExportModel, csv); + + // Compare titles only, we want to test double quotes + Assert.assertEquals(one.getTitle(), imported.get(0).getTitle()); + Assert.assertEquals(two.getTitle(), imported.get(1).getTitle()); + + } + protected List<RowBean> importContent(ImportModel<RowBean> model, String content) throws IOException { Reader reader = new StringReader(content); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.