Changeset 5948 for branches/cleanup


Ignore:
Timestamp:
02/22/10 15:16:09 (10 years ago)
Author:
melissa
Message:

Added another MDB service test.

Location:
branches/cleanup/components
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/bio-formats/test/loci/formats/utests/MDBServiceTest.java

    r5944 r5948  
    2626import static org.testng.AssertJUnit.*; 
    2727 
    28 import java.io.FileNotFoundException; 
    2928import java.io.IOException; 
     29import java.net.URL; 
     30import java.util.Vector; 
    3031 
    3132import loci.common.services.DependencyException; 
     
    4647public class MDBServiceTest { 
    4748 
     49  private static final String[] COLUMNS = new String[] { 
     50    "ID", "text column", "number column", "date column", "currency column", 
     51    "boolean column", "OLE column", "memo column" 
     52  }; 
     53 
     54  private static final String[][] ROWS = new String[][] { 
     55    {"1", "row 1, column 1", "1", "3/14/1999 0:0:0", "6.6600", "1", null, "foo"}, 
     56    {"2", "row 2, column 1", "2", "8/1/2008 0:0:0", "0.3700", "0", null, "bar"}, 
     57    {"3", "row 3, column 1", "3", "9/21/2001 0:0:0", "1000000.0000", "1", null, "baz"}, 
     58  }; 
     59 
     60  private static final String TEST_FILE = "test.mdb"; 
     61 
    4862  private MDBService service; 
    4963 
    5064  @BeforeMethod 
    51   public void setUp() throws DependencyException { 
     65  public void setUp() throws DependencyException, IOException { 
    5266    ServiceFactory sf = new ServiceFactory(); 
    5367    service = sf.getInstance(MDBService.class); 
     68    URL file = this.getClass().getResource(TEST_FILE); 
     69    service.initialize(file.getPath()); 
    5470  } 
    5571 
    56   @Test(expectedExceptions={FileNotFoundException.class}) 
    57   public void testInitialize() throws IOException { 
    58     service.initialize("."); 
     72  @Test 
     73  public void testData() throws IOException { 
     74    Vector<Vector<String[]>> data = service.parseDatabase(); 
     75 
     76    assertEquals(1, data.size()); 
     77 
     78    Vector<String[]> table = data.get(0); 
     79    assertEquals(4, table.size()); 
     80 
     81    String[] columnNames = table.get(0); 
     82    assertEquals(COLUMNS.length + 1, columnNames.length); 
     83    assertEquals("test table", columnNames[0]); 
     84 
     85    for (int i=1; i<columnNames.length; i++) { 
     86      assertEquals(columnNames[i], COLUMNS[i - 1]); 
     87    } 
     88 
     89    for (int i=1; i<table.size(); i++) { 
     90      String[] row = table.get(i); 
     91      for (int col=0; col<row.length; col++) { 
     92        assertEquals(ROWS[i - 1][col], row[col]); 
     93      } 
     94    } 
    5995  } 
    6096 
  • branches/cleanup/components/forks/mdbtools/src/mdbtools/libmdb/Data.java

    r4948 r5948  
    663663    { 
    664664      /* inline memo field */ 
    665       text = new String(mdb.pg_buf,start+Constants.MDB_MEMO_OVERHEAD,size - Constants.MDB_MEMO_OVERHEAD); 
     665      text = new String(mdb.pg_buf,start+Constants.MDB_MEMO_OVERHEAD + 2,size - Constants.MDB_MEMO_OVERHEAD - 2); 
    666666//      strncpy(text, &mdb->pg_buf[start + MDB_MEMO_OVERHEAD],size - MDB_MEMO_OVERHEAD); 
    667667//      text[size - MDB_MEMO_OVERHEAD]='\0'; 
Note: See TracChangeset for help on using the changeset viewer.