Author: britter
Date: Tue May 3 18:28:54 2016
New Revision: 1742173
URL: http://svn.apache.org/viewvc?rev=1742173&view=rev
Log:
Move tests for specific issues to own package
Added:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv164Test.java
(with props)
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv167Test.java
(with props)
Removed:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/JiraCsv167Test.java
Modified:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
Modified:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java?rev=1742173&r1=1742172&r2=1742173&view=diff
==============================================================================
---
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
(original)
+++
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
Tue May 3 18:28:54 2016
@@ -384,32 +384,6 @@ public class CSVFormatTest {
}
@Test
- public void testJiraCsv154_withCommentMarker() throws IOException {
- final String comment = "This is a header comment";
- final CSVFormat format = CSVFormat.EXCEL.withHeader("H1",
"H2").withCommentMarker('#').withHeaderComments(comment);
- final StringBuilder out = new StringBuilder();
- final CSVPrinter printer = format.print(out);
- printer.print("A");
- printer.print("B");
- printer.close();
- final String s = out.toString();
- Assert.assertTrue(s, s.contains(comment));
- }
-
- @Test
- public void testJiraCsv154_withHeaderComments() throws IOException {
- final String comment = "This is a header comment";
- final CSVFormat format = CSVFormat.EXCEL.withHeader("H1",
"H2").withHeaderComments(comment).withCommentMarker('#');
- final StringBuilder out = new StringBuilder();
- final CSVPrinter printer = format.print(out);
- printer.print("A");
- printer.print("B");
- printer.close();
- final String s = out.toString();
- Assert.assertTrue(s, s.contains(comment));
- }
-
- @Test
public void testWithIgnoreEmptyLines() throws Exception {
assertFalse(CSVFormat.DEFAULT.withIgnoreEmptyLines(false).getIgnoreEmptyLines());
assertTrue(CSVFormat.DEFAULT.withIgnoreEmptyLines().getIgnoreEmptyLines());
Added:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv164Test.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv164Test.java?rev=1742173&view=auto
==============================================================================
---
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv164Test.java
(added)
+++
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv164Test.java
Tue May 3 18:28:54 2016
@@ -0,0 +1,39 @@
+package org.apache.commons.csv.bugs;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.commons.csv.CSVFormat;
+import org.apache.commons.csv.CSVPrinter;
+import org.junit.Test;
+
+public class JiraCsv164Test {
+
+ @Test
+ public void testJiraCsv154_withCommentMarker() throws IOException {
+ final String comment = "This is a header comment";
+ final CSVFormat format = CSVFormat.EXCEL.withHeader("H1",
"H2").withCommentMarker('#').withHeaderComments(comment);
+ final StringBuilder out = new StringBuilder();
+ final CSVPrinter printer = format.print(out);
+ printer.print("A");
+ printer.print("B");
+ printer.close();
+ final String s = out.toString();
+ assertTrue(s, s.contains(comment));
+ }
+
+ @Test
+ public void testJiraCsv154_withHeaderComments() throws IOException {
+ final String comment = "This is a header comment";
+ final CSVFormat format = CSVFormat.EXCEL.withHeader("H1",
"H2").withHeaderComments(comment).withCommentMarker('#');
+ final StringBuilder out = new StringBuilder();
+ final CSVPrinter printer = format.print(out);
+ printer.print("A");
+ printer.print("B");
+ printer.close();
+ final String s = out.toString();
+ assertTrue(s, s.contains(comment));
+ }
+
+}
Propchange:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv164Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv167Test.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv167Test.java?rev=1742173&view=auto
==============================================================================
---
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv167Test.java
(added)
+++
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv167Test.java
Tue May 3 18:28:54 2016
@@ -0,0 +1,84 @@
+/*
+ * 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.commons.csv.bugs;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+import org.apache.commons.csv.CSVFormat;
+import org.apache.commons.csv.CSVParser;
+import org.apache.commons.csv.CSVRecord;
+import org.apache.commons.csv.QuoteMode;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class JiraCsv167Test {
+
+ @Test
+ public void parse() throws IOException {
+ final File csvData = new
File("src/test/resources/csv-167/sample1.csv");
+ final BufferedReader br = new BufferedReader(new FileReader(csvData));
+ String s = null;
+ int totcomment = 0;
+ int totrecs = 0;
+ boolean lastWasComment = false;
+ while((s=br.readLine()) != null) {
+ if (s.startsWith("#")) {
+ if (!lastWasComment) { // comments are merged
+ totcomment++;
+ }
+ lastWasComment = true;
+ } else {
+ totrecs++;
+ lastWasComment = false;
+ }
+ }
+ br.close();
+ CSVFormat format = CSVFormat.DEFAULT;
+ //
+ format = format.withAllowMissingColumnNames(false);
+ format = format.withCommentMarker('#');
+ format = format.withDelimiter(',');
+ format = format.withEscape('\\');
+ format = format.withHeader("author", "title", "publishDate");
+ format = format.withHeaderComments("headerComment");
+ format = format.withNullString("NULL");
+ format = format.withIgnoreEmptyLines(true);
+ format = format.withIgnoreSurroundingSpaces(true);
+ format = format.withQuote('"');
+ format = format.withQuoteMode(QuoteMode.ALL);
+ format = format.withRecordSeparator('\n');
+ format = format.withSkipHeaderRecord(false);
+ //
+ final CSVParser parser = CSVParser.parse(csvData,
Charset.defaultCharset(), format);
+ int comments = 0;
+ int records = 0;
+ for (final CSVRecord csvRecord : parser) {
+// System.out.println(csvRecord.isComment() + "[" +
csvRecord.toString() + "]");
+ records++;
+ if (csvRecord.hasComment()) {
+ comments++;
+ }
+ }
+ // Comment lines are concatenated, in this example 4 lines become 2
comments.
+ Assert.assertEquals(totcomment, comments);
+ Assert.assertEquals(totrecs, records); // records includes the header
+ }
+}
Propchange:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/bugs/JiraCsv167Test.java
------------------------------------------------------------------------------
svn:eol-style = native