KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbunit > dataset > xml > XmlTableTest


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
22 package org.dbunit.dataset.xml;
23
24 import org.dbunit.dataset.AbstractTableTest;
25 import org.dbunit.dataset.Column;
26 import org.dbunit.dataset.IDataSet;
27 import org.dbunit.dataset.ITable;
28
29 import java.io.File JavaDoc;
30 import java.io.FileReader JavaDoc;
31 import java.io.Reader JavaDoc;
32
33 /**
34  * @author Manuel Laflamme
35  * @version $Revision: 1.9 $
36  * @since Feb 17, 2002
37  */

38 public class XmlTableTest extends AbstractTableTest
39 {
40     public XmlTableTest(String JavaDoc s)
41     {
42         super(s);
43     }
44
45     protected ITable createTable() throws Exception JavaDoc
46     {
47         return createDataSet().getTable("TEST_TABLE");
48     }
49
50     protected IDataSet createDataSet() throws Exception JavaDoc
51     {
52         Reader JavaDoc in = new FileReader JavaDoc(
53                 new File JavaDoc("src/xml/xmlTableTest.xml"));
54         return new XmlDataSet(in);
55     }
56
57     public void testGetMissingValue() throws Exception JavaDoc
58     {
59         Object JavaDoc[] expected = {null, ITable.NO_VALUE, "value", "", " ", ITable.NO_VALUE};
60
61         ITable table = createDataSet().getTable("MISSING_AND_NULL_VALUES");
62
63         Column[] columns = table.getTableMetaData().getColumns();
64         assertEquals("column count", expected.length, columns.length);
65         for (int i = 0; i < columns.length; i++)
66         {
67             assertEquals("value " + i, expected[i],
68                     table.getValue(0, columns[i].getColumnName()));
69         }
70     }
71
72 }
73
74
75
76
77
78
Popular Tags