KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbunit > dataset > excel > XlsTableTest


1 /*
2  *
3  * The DbUnit Database Testing Framework
4  * Copyright (C)2002-2004, DbUnit.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */

21 package org.dbunit.dataset.excel;
22
23 import org.dbunit.dataset.AbstractTableTest;
24 import org.dbunit.dataset.Column;
25 import org.dbunit.dataset.IDataSet;
26 import org.dbunit.dataset.ITable;
27
28 import java.io.File JavaDoc;
29
30 /**
31  * @author Manuel Laflamme
32  * @since Feb 21, 2003
33  * @version $Revision: 1.2 $
34  */

35 public class XlsTableTest extends AbstractTableTest
36 {
37     public XlsTableTest(String JavaDoc s)
38     {
39         super(s);
40     }
41
42     protected ITable createTable() throws Exception JavaDoc
43     {
44         return createDataSet().getTable("TEST_TABLE");
45     }
46
47     protected IDataSet createDataSet() throws Exception JavaDoc
48     {
49         return new XlsDataSet(new File JavaDoc("src/xml/tableTest.xls"));
50     }
51
52     public void testGetMissingValue() throws Exception JavaDoc
53     {
54         int row = 0;
55         Object JavaDoc[] expected = {"row 0 col 0", null, "row 0 col 2"};
56
57         ITable table = createDataSet().getTable("MISSING_VALUES");
58
59         Column[] columns = table.getTableMetaData().getColumns();
60         assertEquals("column count", expected.length, columns.length);
61         assertEquals("row count", 1, table.getRowCount());
62         for (int i = 0; i < columns.length; i++)
63         {
64             assertEquals("value " + i, expected[i],
65                     table.getValue(row, columns[i].getColumnName()));
66         }
67     }
68 }
69
Popular Tags