]> source.dussan.org Git - jackcess.git/commitdiff
added tests for reading memos and missing files
authorJames Ahlborn <jtahlborn@yahoo.com>
Tue, 13 Jun 2006 16:44:48 +0000 (16:44 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Tue, 13 Jun 2006 16:44:48 +0000 (16:44 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@55 f203690c-595d-4dc9-a70b-905162fa7fd2

test/data/test2.mdb [new file with mode: 0644]
test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java

diff --git a/test/data/test2.mdb b/test/data/test2.mdb
new file mode 100644 (file)
index 0000000..8da9633
Binary files /dev/null and b/test/data/test2.mdb differ
index f72b6c65dcc574ed23565386021bff868296bef9..a2d1ba1bef3c42bc90189d779bafaabe91f8e8bf 100644 (file)
@@ -3,6 +3,7 @@
 package com.healthmarketscience.jackcess;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -184,6 +185,29 @@ public class DatabaseTest extends TestCase {
     assertEquals(2, table.getNextRow().get("D"));
   }
 
+  public void testReadMemo() throws Exception {
+
+    Database db = Database.open(new File("test/data/test2.mdb"));
+    String tableName = "MSP_PROJECTS";
+    Table table = db.getTable(tableName);
+    Map<String, Object> row = table.getNextRow();
+    assertEquals("Jon Iles this is a a vawesrasoih aksdkl fas dlkjflkasjd flkjaslkdjflkajlksj dfl lkasjdf lkjaskldfj lkas dlk lkjsjdfkl; aslkdf lkasjkldjf lka skldf lka sdkjfl;kasjd falksjdfljaslkdjf laskjdfk jalskjd flkj aslkdjflkjkjasljdflkjas jf;lkasjd fjkas dasdf asd fasdf asdf asdmhf lksaiyudfoi jasodfj902384jsdf9 aw90se fisajldkfj lkasj dlkfslkd jflksjadf as", row.get("PROJ_PROP_AUTHOR"));
+    assertEquals("T", row.get("PROJ_PROP_COMPANY"));
+    assertEquals("Standard", row.get("PROJ_INFO_CAL_NAME"));
+    assertEquals("Project1", row.get("PROJ_PROP_TITLE"));
+  }
+
+  public void testMissingFile() throws Exception {
+    File bogusFile = new File("fooby-dooby.mdb");
+    assertTrue(!bogusFile.exists());
+    try {
+      Database db = Database.open(bogusFile);
+      fail("FileNotFoundException should have been thrown");
+    } catch(FileNotFoundException e) {
+    }
+    assertTrue(!bogusFile.exists());
+  }
+  
   private int countRows(Table table) throws Exception {
     table.reset();
     int rtn = 0;