1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-29 11:10:35 +02:00

Handle CSV import of empty file

This commit is contained in:
Erik Johansson
2018-02-13 19:35:33 +01:00
parent 33a6a365fe
commit 979638bc2f
2 changed files with 11 additions and 0 deletions

View File

@@ -33,6 +33,10 @@ public class CsvHelper {
}
private static String[] getOldStyleHeaders(String sampleLine) {
if (sampleLine == null) {
return null;
}
final String[] fields = sampleLine.split(",", -1);
// Return an array with header fields so that all the headers that actually are

View File

@@ -24,6 +24,7 @@ import org.junit.Test;
import java.io.BufferedReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
@@ -181,4 +182,10 @@ public class CsvHelperTest {
assertEquals(1, list.size());
validateEntry(list.get(0), 0);
}
@Test(expected = ParseException.class)
public void empty() throws Exception {
final String data = "";
CsvHelper.importFrom(new BufferedReader(new StringReader(data)));
}
}