summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2010-10-28 03:11:31 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2010-10-28 03:11:31 +0000
commitb9cb058b5ac7c0f38d2752344cbd145e9d677a6a (patch)
treeecaeab3811b9a8ffe63da38ae1cd8b152e3d70a7 /test
parent965d6bab27014cd32c0fe4eb00b0eeae6df59d20 (diff)
downloadjackcess-b9cb058b5ac7c0f38d2752344cbd145e9d677a6a.tar.gz
jackcess-b9cb058b5ac7c0f38d2752344cbd145e9d677a6a.zip
add support for specifying a quote character on import
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@491 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r--test/data/sample-input.tab6
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/ImportTest.java58
2 files changed, 60 insertions, 4 deletions
diff --git a/test/data/sample-input.tab b/test/data/sample-input.tab
index 8acfea9..6a88f55 100644
--- a/test/data/sample-input.tab
+++ b/test/data/sample-input.tab
@@ -1,3 +1,7 @@
Test1 Test2 Test3
Foo Bar Ralph
-S Mouse Rocks \ No newline at end of file
+S Mouse Rocks
+ Partial line
+" Quoted Value" bazz " Really ""Crazy
+value"""
+buzz "embedded separator" long line
diff --git a/test/src/java/com/healthmarketscience/jackcess/ImportTest.java b/test/src/java/com/healthmarketscience/jackcess/ImportTest.java
index 6403077..a0de8c4 100644
--- a/test/src/java/com/healthmarketscience/jackcess/ImportTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/ImportTest.java
@@ -35,7 +35,9 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Types;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import junit.framework.TestCase;
@@ -56,7 +58,43 @@ public class ImportTest extends TestCase
{
for (final FileFormat fileFormat : JetFormatTest.SUPPORTED_FILEFORMATS) {
Database db = create(fileFormat);
- db.importFile("test", new File("test/data/sample-input.tab"), "\\t");
+ String tableName = db.importFile(
+ "test", new File("test/data/sample-input.tab"), "\\t");
+ Table t = db.getTable(tableName);
+
+ List<String> colNames = new ArrayList<String>();
+ for(Column c : t.getColumns()) {
+ colNames.add(c.getName());
+ }
+ assertEquals(Arrays.asList("Test1", "Test2", "Test3"), colNames);
+
+ List<Map<String, Object>> expectedRows =
+ createExpectedTable(
+ createExpectedRow(
+ "Test1", "Foo",
+ "Test2", "Bar",
+ "Test3", "Ralph"),
+ createExpectedRow(
+ "Test1", "S",
+ "Test2", "Mouse",
+ "Test3", "Rocks"),
+ createExpectedRow(
+ "Test1", "",
+ "Test2", "Partial line",
+ "Test3", null),
+ createExpectedRow(
+ "Test1", " Quoted Value",
+ "Test2", " bazz ",
+ "Test3", " Really \"Crazy" + ImportUtil.LINE_SEPARATOR
+ + "value\""),
+ createExpectedRow(
+ "Test1", "buzz",
+ "Test2", "embedded\tseparator",
+ "Test3", "long")
+ );
+ assertTable(expectedRows, t);
+
+ db.close();
}
}
@@ -64,8 +102,22 @@ public class ImportTest extends TestCase
{
for (final FileFormat fileFormat : JetFormatTest.SUPPORTED_FILEFORMATS) {
Database db = create(fileFormat);
- db.importFile("test", new File("test/data/sample-input-only-headers.tab"),
- "\\t");
+ String tableName = db.importFile(
+ "test", new File("test/data/sample-input-only-headers.tab"), "\\t");
+
+ Table t = db.getTable(tableName);
+
+ List<String> colNames = new ArrayList<String>();
+ for(Column c : t.getColumns()) {
+ colNames.add(c.getName());
+ }
+ assertEquals(Arrays.asList(
+ "RESULT_PHYS_ID", "FIRST", "MIDDLE", "LAST", "OUTLIER",
+ "RANK", "CLAIM_COUNT", "PROCEDURE_COUNT",
+ "WEIGHTED_CLAIM_COUNT", "WEIGHTED_PROCEDURE_COUNT"),
+ colNames);
+
+ db.close();
}
}