mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-29 19:20:36 +02:00
Handle CSV import of empty file
This commit is contained in:
@@ -33,6 +33,10 @@ public class CsvHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String[] getOldStyleHeaders(String sampleLine) {
|
private static String[] getOldStyleHeaders(String sampleLine) {
|
||||||
|
if (sampleLine == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final String[] fields = sampleLine.split(",", -1);
|
final String[] fields = sampleLine.split(",", -1);
|
||||||
|
|
||||||
// Return an array with header fields so that all the headers that actually are
|
// Return an array with header fields so that all the headers that actually are
|
||||||
|
@@ -24,6 +24,7 @@ import org.junit.Test;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -181,4 +182,10 @@ public class CsvHelperTest {
|
|||||||
assertEquals(1, list.size());
|
assertEquals(1, list.size());
|
||||||
validateEntry(list.get(0), 0);
|
validateEntry(list.get(0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = ParseException.class)
|
||||||
|
public void empty() throws Exception {
|
||||||
|
final String data = "";
|
||||||
|
CsvHelper.importFrom(new BufferedReader(new StringReader(data)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user