01: /*
02: This source file is part of Smyle, a database library.
03: For up-to-date information, see http://www.drjava.de/smyle
04: Copyright (C) 2001 Stefan Reich (doc@drjava.de)
05:
06: This library is free software; you can redistribute it and/or
07: modify it under the terms of the GNU Lesser General Public
08: License as published by the Free Software Foundation; either
09: 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: For full license text, see doc/license/lgpl.txt in this distribution
21: */
22:
23: package drjava.smyle.tests;
24:
25: import java.io.*;
26: import junit.framework.*;
27: import java.util.*;
28: import drjava.util.*;
29: import drjava.smyle.*;
30: import drjava.smyle.testtypes.*;
31: import drjava.smyle.meta.*;
32: import drjava.smyle.core.*;
33: import org.artsProject.util.*;
34:
35: public class UntypedTableTest extends DiskStoreTestBase {
36: UntypedTable ut;
37:
38: public UntypedTableTest(String name) {
39: super (name);
40: }
41:
42: public void setUp() throws Exception {
43: super .setUp();
44: table.add(john);
45: }
46:
47: public void testTableNames() throws Exception {
48: SortedSet<String> names = snapshot.getTableNames();
49: assertEquals(1, names.size());
50: assertTrue(names.contains("person"));
51: }
52:
53: void loadUntypedTable() throws Exception {
54: commitAndGetNewSnapshot();
55: ut = snapshot.getUntypedTable("person");
56: }
57:
58: public void testUntypedTable() throws Exception {
59: loadUntypedTable();
60:
61: assertEquals(Person.getTypeInfo().typeDef, ut.getSchema());
62: assertEquals(1, ut.size());
63:
64: Object[] row = ut.untypedElementAt(0);
65: assertEquals(2, row.length);
66: assertEquals(john.name, row[0]);
67: assertEquals(new Integer(john.age), row[1]);
68: }
69:
70: /*public void testIndex() throws Exception {
71: TableImpl tableImpl = (TableImpl)(Table) table;
72: tableImpl.indexField(Person.f_age);
73:
74: // make sure getTable isn't called before getUntypedTable
75: snapshot.commit();
76: snapshot = store.snapshot();
77: ut = snapshot.getUntypedTable("person");
78:
79: assertEquals(Person.getTypeInfo().typeDef, ut.getSchema());
80: assertEquals(Person.f_age.nr(), ((Field) ut.getIndexedField()).nr());
81: }XX*/
82: }
|