JDocCoverage Report - 21.04.2006 22:02:51

Namemethod, %comment, %TODO@see
smallsql.junit.TestDBMetaData45,5%   (113/1938)30

/* =============================================================
 * SmallSQL : a free Java DBMS library for the Java(tm) platform
 * =============================================================
 *
 * (C) Copyright 2004-2006, by Volker Berlin.
 *
 * Project Info:  http://www.smallsql.de/
 *
 * This library is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by 
 * the Free Software Foundation; either version 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 * USA.  
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 * in the United States and other countries.]
 *
 * ---------------
 * TestDBMetaData.java
 * ---------------
 * Author: Volker Berlin
 * 
 */
package smallsql.junit;

import java.sql.*;
/**
 * @author Volker Berlin
 *
 */
public class TestDBMetaData extends BasicTestCase {

	public TestDBMetaData(){
		super();
	}
	public TestDBMetaData(String arg0) {
		super(arg0);
	}

	public void testCatalogs() throws Exception{
		Connection con = AllTests.getConnection();
		try{
			con.createStatement().execute("drop database test2\n\r\t");
		}catch(SQLException e){
		}
		con.createStatement().execute("create database test2");
		DatabaseMetaData md = con.getMetaData();
		ResultSet rs = md.getCatalogs();
		//TODO assertRSMetaData( rs, new String[]{"TABLE_CAT"}, new int[]{Types.VARCHAR});
		while(rs.next()){
			System.out.println( "testCatalogs:"+rs.getObject(1) );
		}
	}
	
	public void testTableColumn() throws Exception{
		Connection con = AllTests.getConnection();
		dropTable(con,"tableColumns");
		dropView( con, "viewColumns");
		con.createStatement().execute("create table tableColumns(a int default 5)");
		DatabaseMetaData md = con.getMetaData();
		
		ResultSet rs = md.getColumns(null, null, "tableColumns", null);		
		//TODO assertRSMetaData( rs, new String[]{"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION", "IS_NULLABLE"}, new int[]{Types.VARCHAR});		
		assertTrue( "No row", rs.next() );
		assertEquals( "a", rs.getObject("COLUMN_NAME") ); 
		assertEquals( "INT", rs.getObject("TYPE_NAME") ); 
		assertEquals( "5", rs.getObject("COLUMN_Def") ); 
		
		con.createStatement().execute("create view viewColumns as Select * from tableColumns");
		
		rs = md.getColumns(null, null, "viewColumns", null);
		//TODO assertRSMetaData( rs, new String[]{"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION", "IS_NULLABLE"}, new int[]{Types.VARCHAR});		
		assertTrue( "No row", rs.next() );
		assertEquals( "a", rs.getObject("COLUMN_NAME") ); 
		assertEquals( "INT", rs.getObject("TYPE_NAME") ); 
		assertEquals( "5", rs.getObject("COLUMN_Def") ); 

		dropView( con, "viewColumns");
		dropTable( con, "tableColumns");
	}
	
}