You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2014/01/22 16:49:15 UTC
svn commit: r1560389 -
/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java
Author: ggregory
Date: Wed Jan 22 15:49:14 2014
New Revision: 1560389
URL: http://svn.apache.org/r1560389
Log:
Add @Test testRemoveAndAddColumns.
Modified:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java?rev=1560389&r1=1560388&r2=1560389&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java Wed Jan 22 15:49:14 2014
@@ -21,17 +21,21 @@ import static org.junit.Assert.assertFal
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class CSVRecordTest {
private enum EnumFixture { UNKNOWN_COLUMN }
-
+
private String[] values;
private CSVRecord record, recordWithHeader;
private Map<String, Integer> header;
@@ -132,6 +136,20 @@ public class CSVRecordTest {
}
@Test
+ public void testRemoveAndAddColumns() throws IOException {
+ // do:
+ final CSVPrinter printer = new CSVPrinter(new StringBuilder(), CSVFormat.DEFAULT);
+ final Map<String, String> map = recordWithHeader.toMap();
+ map.remove("OldColumn");
+ map.put("NewColumn", "NewValue");
+ // check:
+ final ArrayList<String> list = new ArrayList<String>(map.values());
+ Collections.sort(list);
+ printer.printRecord(list);
+ Assert.assertEquals("A,B,C,NewValue" + CSVFormat.DEFAULT.getRecordSeparator(), printer.getOut().toString());
+ }
+
+ @Test
public void testToMap() {
final Map<String, String> map = this.recordWithHeader.toMap();
this.validateMap(map, true);