1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.dbunit.dataset.csv;
23
24
25 import java.io.File;
26 import java.net.MalformedURLException;
27 import java.net.URL;
28
29 import junit.framework.TestCase;
30
31 import org.dbunit.dataset.DataSetException;
32 import org.dbunit.dataset.ITable;
33 import org.dbunit.testutil.TestUtils;
34
35
36
37
38
39
40
41 public class CsvURLDataSetTest extends TestCase {
42
43 public CsvURLDataSetTest(String s) {
44 super(s);
45 }
46
47 public void testNullColumns() throws DataSetException, MalformedURLException {
48 URL csvDir = TestUtils.getFile("csv/orders/").toURL();
49 CsvURLDataSet dataSet = new CsvURLDataSet(csvDir);
50
51 ITable table = dataSet.getTable("orders");
52 assertNull(table.getValue(4, "description"));
53 }
54
55 public void testSpacesInColumns() throws DataSetException, MalformedURLException {
56 URL csvDir = TestUtils.getFile("csv/accounts/").toURL();
57 CsvURLDataSet dataSet = new CsvURLDataSet(csvDir);
58
59 ITable table = dataSet.getTable("accounts");
60 assertEquals(" 123", table.getValue(0, "acctid"));
61 assertEquals(" 2", table.getValue(1, "acctid"));
62 assertEquals(" 3spaces", table.getValue(2, "acctid"));
63 assertEquals(" -4", table.getValue(3, "acctid"));
64 assertEquals(" 5 ", table.getValue(4, "acctid"));
65 }
66
67 }
68
69
70
71