X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.core%2Fext%2Ftest%2Forg%2Fargeo%2Futil%2FCsvParserWithQuotedSeparatorTest.java;fp=org.argeo.core%2Fext%2Ftest%2Forg%2Fargeo%2Futil%2FCsvParserWithQuotedSeparatorTest.java;h=0000000000000000000000000000000000000000;hb=fba24f5ac520b99b3ac75781c95f11c48ac6252f;hp=67ba3464fb6845e2ffb8cbb7810da6e7699f1a81;hpb=3fbd05aa39ef235128e134fde8fd24167208e781;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.core/ext/test/org/argeo/util/CsvParserWithQuotedSeparatorTest.java b/org.argeo.core/ext/test/org/argeo/util/CsvParserWithQuotedSeparatorTest.java deleted file mode 100644 index 67ba3464f..000000000 --- a/org.argeo.core/ext/test/org/argeo/util/CsvParserWithQuotedSeparatorTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.argeo.util; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** Test that {@link CsvParser} deals properly with "" quotes. */ -public class CsvParserWithQuotedSeparatorTest { - public void testSimpleParse() throws Exception { - String toParse = "Header1,\"Header2\",Header3,\"Header4\"\n" - + "\"Col1, Col2\",\"Col\n2\",Col3,\"\"\"Col4\"\"\"\n"; - - InputStream in = new ByteArrayInputStream(toParse.getBytes()); - - CsvParser csvParser = new CsvParser() { - protected void processLine(Integer lineNumber, List header, List tokens) { - assert header.size() == tokens.size(); - assert 4 == tokens.size(); - assert "Col1, Col2".equals(tokens.get(0)); - } - }; - // System.out.println(toParse); - csvParser.parse(in); - in.close(); - - } - - public void testParseFile() throws Exception { - - final Map> lines = new HashMap>(); - InputStream in = getClass().getResourceAsStream("/org/argeo/util/ReferenceFile.csv"); - - CsvParserWithLinesAsMap parser = new CsvParserWithLinesAsMap() { - protected void processLine(Integer lineNumber, Map line) { - // System.out.println("processing line #" + lineNumber); - lines.put(lineNumber, line); - } - }; - - parser.parse(in); - in.close(); - - Map line = lines.get(2); - assert ",,,,".equals(line.get("Coma testing")); - line = lines.get(3); - assert ",, ,,".equals(line.get("Coma testing")); - line = lines.get(4); - assert "module1, module2".equals(line.get("Coma testing")); - line = lines.get(5); - assert "module1,module2".equals(line.get("Coma testing")); - line = lines.get(6); - assert ",module1,module2, \nmodule3, module4".equals(line.get("Coma testing")); - assert 5 == lines.size(); - - } -}