001: /*
002: * $Id: TestAxionResultSetMetaData.java,v 1.3 2005/12/20 18:32:47 ahimanikya Exp $
003: * =======================================================================
004: * Copyright (c) 2003 Axion Development Team. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above
011: * copyright notice, this list of conditions and the following
012: * disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The names "Tigris", "Axion", nor the names of its contributors may
020: * not be used to endorse or promote products derived from this
021: * software without specific prior written permission.
022: *
023: * 4. Products derived from this software may not be called "Axion", nor
024: * may "Tigris" or "Axion" appear in their names without specific prior
025: * written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
030: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
032: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
033: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
034: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
035: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
036: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
037: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
038: * =======================================================================
039: */
040:
041: package org.axiondb.jdbc;
042:
043: import java.sql.SQLException;
044:
045: import junit.framework.Test;
046: import junit.framework.TestCase;
047: import junit.framework.TestSuite;
048:
049: import org.axiondb.ColumnIdentifier;
050: import org.axiondb.Literal;
051: import org.axiondb.Selectable;
052: import org.axiondb.TableIdentifier;
053: import org.axiondb.types.CharacterVaryingType;
054: import org.axiondb.types.IntegerType;
055:
056: /**
057: * @version $Revision: 1.3 $ $Date: 2005/12/20 18:32:47 $
058: * @author Rod Waldhoff
059: */
060: public class TestAxionResultSetMetaData extends TestCase {
061:
062: private AxionResultSetMetaData _meta = null;
063: private Selectable[] _sel = new Selectable[] {
064: new ColumnIdentifier(new TableIdentifier("TABLE"), "FOO",
065: "F", new CharacterVaryingType(10)),
066: new Literal(new Integer(17), new IntegerType()) };
067:
068: public TestAxionResultSetMetaData(String testName) {
069: super (testName);
070: }
071:
072: public static Test suite() {
073: return new TestSuite(TestAxionResultSetMetaData.class);
074: }
075:
076: public void setUp() throws Exception {
077: super .setUp();
078: _meta = new AxionResultSetMetaData(_sel);
079: }
080:
081: public void tearDown() throws Exception {
082: super .tearDown();
083: _meta = null;
084: }
085:
086: // tests
087:
088: public void testBadIndex() throws Exception {
089: try {
090: _meta.getCatalogName(0);
091: fail("Expected SQLException");
092: } catch (SQLException e) {
093: // expected
094: }
095: try {
096: _meta.getCatalogName(3);
097: fail("Expected SQLException");
098: } catch (SQLException e) {
099: // expected
100: }
101: }
102:
103: public void testGetCatalogName() throws Exception {
104: assertEquals("", _meta.getCatalogName(1));
105: }
106:
107: public void testGetSchemaName() throws Exception {
108: assertEquals("", _meta.getSchemaName(1));
109: }
110:
111: public void testGetTableName() throws Exception {
112: assertEquals("TABLE", _meta.getTableName(1));
113: assertEquals("", _meta.getTableName(2));
114: }
115:
116: public void testGetColumnCount() throws Exception {
117: assertEquals(2, _meta.getColumnCount());
118: }
119:
120: public void testGetColumDisplaySize() throws Exception {
121: assertTrue(_meta.getColumnDisplaySize(1) > 0);
122: }
123:
124: public void testGetColumnLabel() throws Exception {
125: assertNotNull(_meta.getColumnLabel(1));
126: }
127:
128: public void testGetColumnName() throws Exception {
129: assertNotNull(_meta.getColumnName(1));
130: }
131:
132: public void testGetColumnClassName() throws Exception {
133: assertNotNull(_meta.getColumnClassName(1));
134: }
135:
136: public void testIsAutoIncrement() throws Exception {
137: assertTrue(!_meta.isAutoIncrement(1));
138: }
139:
140: public void testIsCaseSensitive() throws Exception {
141: assertTrue(_meta.isCaseSensitive(1));
142: }
143:
144: public void testIsCurrency() throws Exception {
145: assertTrue(!_meta.isCurrency(1));
146: }
147:
148: public void testIsNullable() throws Exception {
149: assertEquals(1, _meta.isNullable(1));
150: }
151:
152: public void testIsSearchable() throws Exception {
153: assertTrue(_meta.isSearchable(1));
154: }
155:
156: public void testIsSigned() throws Exception {
157: assertTrue(_meta.isSigned(1)); // ???
158: }
159:
160: public void testIsReadOnly() throws Exception {
161: assertTrue(!_meta.isReadOnly(1));
162: }
163:
164: public void testIsWritable() throws Exception {
165: assertTrue(_meta.isWritable(1));
166: }
167:
168: public void testIsDefinitelyWritable() throws Exception {
169: assertTrue(!_meta.isDefinitelyWritable(1));
170: }
171: }
|