/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)dbMetaClient2.java	1.16 02/01/12
 */

package com.sun.cts.tests.jdbc.ee.dbMeta.dbMeta2;

import java.io.*;
import java.util.*;

import java.sql.*;
import javax.sql.*;

import com.sun.cts.util.*;
import com.sun.cts.porting.*;
import com.sun.cts.harness.*;

import java.rmi.RemoteException;

import javasoft.sqe.javatest.Status;
import com.sun.cts.tests.jdbc.ee.common.*;


// Merant DataSource class
//import com.merant.sequelink.jdbcx.datasource.*;

/**
 * The dbMetaClient2 class tests methods of DatabaseMetaData interface using 
 * Sun's J2EE Reference Implementation.
 * @author  
 * @version 1.7, 06/16/99
 */

public class dbMetaClient2 extends ServiceEETest  implements Serializable
{		  
	private static final String testName = "jdbc.ee.dbMeta.dbMeta2";
		
	//Naming specific member variables
	private CTSNamingContextInterface jc = null;

	//Harness requirements 

	private transient Connection conn = null;
	private transient DatabaseMetaData dbmd = null;	 
	private DataSource ds1 = null;
	private dbSchema dbSch=null;
	private	String dbName=null,dbUser=null,drManager=null;
	private String sCatalogName=null,sSchemaName=null,sPtable=null,sFtable=null;


	/* Run test in standalone mode */
	public static void main(String[] args) 
	{
		dbMetaClient2 theTests = new dbMetaClient2();
		Status s=theTests.run(args, System.out, System.err);
		s.exit();
	}

	/*  Test setup: */
	/*
	 *   @class.setup_props: Driver, the Driver name;
	 *                       db1, the database name with url;
	 *                       user1, the database user name;
	 *                       password1, the database password;
	 *                       db2, the database name with url;
	 *                       user2, the database user name;
	 *                       password2, the database password;
	 *                       DriverManager, flag for DriverManager;
	 *                       ptable, the primary table;
	 *                       ftable, the foreign table;
	 *                       cofSize, the initial size of the ptable;
	 *                       cofTypeSize, the initial size of the ftable;
	 *                       binarySize, size of binary data type;
	 *                       varbinarySize, size of varbinary data type;
	 *                       longvarbinarySize, size of longvarbinary data type;
	 *  @class.testArgs:     -ap ctssql.stmt
	 */
	public void setup(String[] args, Properties p) throws Fault 
	{
		try 
		{
			try
			{
				drManager = p.getProperty("DriverManager","");
				dbName = p.getProperty("db1","");
				dbUser = p.getProperty("user1","");
				sPtable = p.getProperty("ptable","CTSTABLE1");
				sFtable = p.getProperty("ftable","CTSTABLE2");
				if (dbName.length() == 0)
					throw new Fault("Invalid db1  Database Name");
				if (dbUser.length() == 0)
					throw new Fault("Invalid Login Id");
				if (sPtable.length() == 0)
					throw new Fault("Invalid Primary table");
				if (sFtable.length() == 0)
					throw new Fault("Invalid Foreign table");
				if (drManager.length() == 0)
					throw new Fault("Invalid DriverManager Name");

				int nLocdbname = dbName.indexOf('=');
				sCatalogName = dbName.substring(nLocdbname +1);
				sCatalogName = sCatalogName.trim();
				sSchemaName = dbUser;

				if(drManager.equals("yes"))
				{
					logMsg("Using DriverManager");
					DriverManagerConnection dmCon = new DriverManagerConnection();
					conn = dmCon.getConnection(p);
				}
				else 
				{
					logMsg("Using DataSource");
					DataSourceConnection dsCon = new DataSourceConnection();
					conn = dsCon.getConnection(p);
				}
				dbSch = new dbSchema();
				dbSch.createData(p,conn);
				dbmd=conn.getMetaData();
			}
			catch(SQLException ex)
			{
				logErr("SQL Exception : " + ex.getMessage());
			}
		}
		catch ( Exception e ) 
		{
			logErr("Setup Failed!");
			TestUtil.printStackTrace(e);
		}
	}


	/*
	 * @testName:         testStoresMixedCaseIdentifiers
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The storesMixedCaseIdentifiers() method must return a boolean 
	 *                    value; true if DBMS allows mixed case SQL Identifiers in SQL
	 *                    statements as case-insensitive and stores them as all mixed cases
	 *                    in its metadata tables and false otherwise. (See JDK 1.2.2 API 
	 *                    documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the storesMixedCaseIdentifiers() method
	 *                    It should return a boolean value
	 *
	 */
	public void testStoresMixedCaseIdentifiers() throws Fault
	{
		try
		{
			// invoke on the storesMixedCaseIdentifiers
			logMsg("Calling storesMixedCaseIdentifiers on DatabaseMetaData");
			boolean retValue=dbmd.storesMixedCaseIdentifiers();
			if(retValue)
			{
				logMsg("storesMixedCaseIdentifiers method returns unquoted SQL identifiers stored as mixed case");
			}
			else
			{
				logMsg("storesMixedCaseIdentifiers method returns unquoted SQL identifiers not stored as mixed case");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to storesMixedCaseIdentifiers is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to storesMixedCaseIdentifiers is Failed!", e);
		}
	}


	/*
	 * @testName:         testSupportsMixedCaseQuotedIdentifiers
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The supportsMixedCaseQuotedIdentifiers() method must return a boolean 
	 *                    value; true if DBMS allows mixed case quoted SQL Identifiers in SQL
	 *                    statements as case-insensitive and stores them as all mixed cases
	 *                    in its metadata tables and false otherwise. A JDBC Compliant 
	 *                    driver will always return true. (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the supportsMixedCaseQuotedIdentifiers() method
	 *                    It should return a boolean value
	 *
	 */
	public void testSupportsMixedCaseQuotedIdentifiers() throws Fault
	{
		try
		{
			// invoke on the supportsMixedCaseQuotedIdentifiers
			logMsg("Calling supportsMixedCaseQuotedIdentifiers on DatabaseMetaData");
			boolean retValue=dbmd.supportsMixedCaseQuotedIdentifiers();
			if(retValue)
			{
				logMsg("supportsMixedCaseQuotedIdentifiers method is supported");
			}
			else
			{
				logMsg("supportsMixedCaseQuotedIdentifiers method is not supported");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to supportsMixedCaseQuotedIdentifiers is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to supportsMixedCaseQuotedIdentifiers is Failed!", e);
		}
	}


	/*
	 * @testName:         testStoresUpperCaseQuotedIdentifiers
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The storesUpperCaseQuotedIdentifiers() method must return a boolean 
	 *                    value; true if DBMS allows mixed case quoted SQL Identifiers in SQL
	 *                    statements as case-insensitive and stores them as all upper cases
	 *                    in its metadata tables and false otherwise. (See JDK 1.2.2 API 
	 *                    documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the storesUpperCaseQuotedIdentifiers() method
	 *                    It should return a boolean value
	 *
	 */
	public void testStoresUpperCaseQuotedIdentifiers() throws Fault
	{
		try
		{
			// invoke on the storesUpperCaseQuotedIdentifiers
			logMsg("Calling storesUpperCaseQuotedIdentifiers on DatabaseMetaData");
			boolean retValue=dbmd.storesUpperCaseQuotedIdentifiers();
			if(retValue)
			{
				logMsg("storesUpperCaseQuotedIdentifiers method returns SQL identifiers stored as upper case");
			}
			else
			{
				logMsg("storesUpperCaseQuotedIdentifiers method returns SQL identifiers not stored as upper case");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to storesUpperCaseQuotedIdentifiers is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to storesUpperCaseQuotedIdentifiers is Failed!", e);
		}
	}


	/*
	 * @testName:         testStoresLowerCaseQuotedIdentifiers
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The storesLowerCaseQuotedIdentifiers() method must return a boolean 
	 *                    value; true if DBMS allows mixed case quoted SQL Identifiers 
	 *                    in SQLstatements as case-insensitive and stores them as all 
	 *                    lower cases in its metadata tables and false otherwise. 
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the storesLowerCaseQuotedIdentifiers() method
	 *                    It should return a boolean value
	 *
	 */
	public void testStoresLowerCaseQuotedIdentifiers() throws Fault
	{
		try
		{
			// invoke on the storesLowerCaseQuotedIdentifiers
			logMsg("Calling storesLowerCaseQuotedIdentifiers on DatabaseMetaData");
			boolean retValue=dbmd.storesLowerCaseQuotedIdentifiers();
			if(retValue)
			{
				logMsg("storesLowerCaseQuotedIdentifiers method returns SQL identifiers stored as lower case");
			}
			else
			{
				logMsg("storesLowerCaseQuotedIdentifiers method returns SQL identifiers not stored as lower case");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to storesLowerCaseQuotedIdentifiers is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to storesLowerCaseQuotedIdentifiers is Failed!", e);
		}
	}


	/*
	 * @testName:         testStoresMixedCaseQuotedIdentifiers
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The storesMixedCaseQuotedIdentifiers() method must return a boolean 
	 *                    value; true if DBMS allows mixed case quoted SQL Identifiers in SQL
	 *                    statements as case-insensitive and stores them as all mixed cases
	 *                    in its metadata tables and false otherwise. (See JDK 1.2.2 API 
	 *                    documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the storesMixedCaseQuotedIdentifiers() method
	 *                    It should return a boolean value
	 *
	 */
	public void testStoresMixedCaseQuotedIdentifiers() throws Fault
	{
		try
		{
			// invoke on the storesMixedCaseQuotedIdentifiers
			logMsg("Calling storesMixedCaseQuotedIdentifiers on DatabaseMetaData");
			boolean retValue=dbmd.storesMixedCaseQuotedIdentifiers();
			if(retValue)
			{
				logMsg("storesMixedCaseQuotedIdentifiers method returns SQL identifiers stored as mixed case");
			}
			else
			{
				logMsg("storesMixedCaseQuotedIdentifiers method returns SQL identifiers not stored as mixed case");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to storesMixedCaseQuotedIdentifiers is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to storesMixedCaseQuotedIdentifiers is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetIdentifierQuoteString
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The getIdentifierQuoteString() method must return a String
	 *                    object representing the quoting string or a space if the database
	 *                    does not support quoting identifiers.  A JDBC Compliant driver
	 *                    always uses a double quote character ("). (See JDK 1.2.2 API 
	 *                    documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the getIdentifierQuoteString() method
	 *                    It should return a String 
	 *
	 */
	public void testGetIdentifierQuoteString() throws Fault
	{
		try
		{
			// invoke on the getIdentifierQuoteString
			logMsg("Calling getIdentifierQuoteString on DatabaseMetaData");
			String sRetValue = dbmd.getIdentifierQuoteString();
			
			if (sRetValue.equals(""))
			{
				logMsg("The database does not support quoting identifiers");
			}
			else if (sRetValue instanceof String)
			{
				logMsg("getIdentifierQuoteString method returns " + sRetValue);
			}
			else if (sRetValue == null)
			{
				logErr("getIdentifierQuoteString returns an Invalid value");
				throw new Fault ("Call to getIdentfierQuoteString is Failed!");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to getIdentifierQuoteString is Failed!", sqle);
		}
		catch ( Exception e ) 
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getIdentifierQuoteString is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetSQLKeywords
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The getSQLKeywords() method must return a String object that is 
	 *                    comma separated list of keywords used by the database that are
	 *                    not also SQL-92 keywords.(See JDK 1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the  getSQLKeywords() method
	 *                    It should return a String 
	 *
	 */
	public void testGetSQLKeywords() throws Fault
	{
		try
		{
			// invoke on the getSQLKeywords
			logMsg("Calling getSQLKeywords on DatabaseMetaData");
			String sRetValue = dbmd.getSQLKeywords();
			
			if( sRetValue == null)
			{
				logMsg("getSQLKeywords method does not returns the list of SQLKeywords ");
			}
			else
			{
				logMsg("getSQLKeywords method returns: " + sRetValue);
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to getSQLKeywords is Failed!", sqle);
		}
		catch ( Exception e ) 
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getSQLKeywords is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetNumericFunctions
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The getNumericFunctions() method must return a String object 
	 *                    that is a comma separated list of math functions; These are 
	 *                    the X/Open CLI math function names used in the JDBC function 
	 *                    escape clause. (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the  getNumericFunctions() method
	 *                    It should return a String 
	 *
	 */
	public void testGetNumericFunctions() throws Fault
	{
		try
		{
			// invoke on the getNumericFunctions
			logMsg("Calling getNumericFunctions on DatabaseMetaData");
			String sRetValue = dbmd.getNumericFunctions();
			if( sRetValue == null)
			{
				logMsg("getNumericFunctions method does not returns the comma-separated list of math functions ");
			}
			else
			{
				logMsg("getNumericFunctions method returns: " + sRetValue);
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to getNumericFunctions is Failed!", sqle);
		}
		catch ( Exception e ) 
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getNumericFunctions is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetStringFunctions
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The getStringFunctions() method must return a String object 
	 *                    that is a comma separated list of string functions; These are 
	 *                    the X/Open CLI string function names used in the JDBC function 
	 *                    escape clause. (See JDK 1.2.2 API documentation) 
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the getStringFunctions() method
	 *                    It should return a String 
	 *
	 */
	public void testGetStringFunctions() throws Fault
	{
		try
		{
			// invoke on the getStringFunctions
			logMsg("Calling getStringFunctions on DatabaseMetaData");
			String sRetValue = dbmd.getStringFunctions();
			if( sRetValue == null)
			{
				logMsg("getStringFunctions method does not returns the comma-separated list of string functions ");
			}
			else
			{
				logMsg("getStringFunctions method returns: " + sRetValue);
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to getStringFunctions is Failed!", sqle);
		}
		catch ( Exception e ) 
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getStringFunctions is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetSystemFunctions
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The getSystemFunctions() method must return a String object 
	 *                    that is a comma separated list of string functions; These are 
	 *                    the X/Open CLI system function names used in the JDBC function 
	 *                    escape clause. (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the getSystemFunctions() method
	 *                    It should return a String 
	 *
	 */
	public void testGetSystemFunctions() throws Fault
	{
		try
		{
			// invoke on the getSystemFunctions
			logMsg("Calling getSystemFunctions on DatabaseMetaData");
			String sRetValue = dbmd.getSystemFunctions();
			if( sRetValue == null)
			{
				logMsg("getSystemFunctions methd does not returns the comma-separated list of system functions ");
			}
			else
			{
				logMsg("getSystemFunctions method returns: " + sRetValue);
			}
		}
		catch ( SQLException sqle)
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to getSystemFunctions is Failed!", sqle);
		}
		catch ( Exception e ) 
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getSystemFunctions is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetTimeDateFunctions
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The getSystemFunctions method must return a String object 
	 *                    that is a comma separated list of time and date functions; 
	 *                    These are the X/Open CLI time and date function names used 
	 *                    in the JDBC function escape clause. (See JDK 1.2.2 API 
	 *                    documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the getTimeDateFunctions() method
	 *                    It should return a String 
	 *
	 */
	public void testGetTimeDateFunctions() throws Fault
	{
		try
		{
			// invoke on the getTimeDateFunctions
			logMsg("Calling getTimeDateFunctions on DatabaseMetaData");
			String sRetValue = dbmd.getTimeDateFunctions();
			if( sRetValue == null)
			{
				logMsg("getTimeDateFunctions method does not returns the comma-separated list of time and date functions ");
			}
			else
			{
				logMsg("getTimeDateFunctions method returns: " + sRetValue);
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to getTimeDateFunctions is Failed!", sqle);
		}
		catch ( Exception e ) 
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getTimeDateFunctions is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetSearchStringEscape
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The getSystemFunctions() method must return a String object 
	 *                    used to escape wildcard characters; (See JDK 1.2.2 API 
	 *                    documentation) 
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the getSearchStringEscape() method
	 *                    It should return a String 
	 *
	 */
	public void testGetSearchStringEscape() throws Fault
	{
		try
		{
			// invoke on the getSearchStringEscape
			logMsg("Calling getSearchStringEscape on DatabaseMetaData");
			String sRetValue = dbmd.getSearchStringEscape();
			if( sRetValue == null)
			{
				logMsg("getSearchStringEscape  method does not returns the string used to escape wildcard characters ");
			}
			else
			{
				logMsg("getSearchStringEscape method returns: " + sRetValue);
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to getSearchStringEscape is Failed!", sqle);
		}
		catch ( Exception e ) 
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getSearchStringEscape is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetExtraNameCharacters
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The getExtraNameCharacters() method must return a String object 
	 *                    containing the extra characters; (See JDK 1.2.2 API 
	 *                    documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the getExtraNameCharacters() method
	 *                    It should return a String 
	 *
	 */
	public void testGetExtraNameCharacters() throws Fault
	{
		try
		{
			// invoke on the getExtraNameCharacters
			logMsg("Calling getExtraNameCharacters on DatabaseMetaData");
			String sRetValue = dbmd.getExtraNameCharacters();
			if( sRetValue == null)
			{
				logMsg("getExtraNameCharacters method does not returns the string containing the extra characters ");
			}
			else
			{
				logMsg("getExtraNameCharacters method returns: " + sRetValue);
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to getExtraNameCharacters is Failed!", sqle);
		}
		catch ( Exception e ) 
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getExtraNameCharacters is Failed!", e);
		}
	}


	/*
	 * @testName:         testSupportsAlterTableWithAddColumn
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The supportsAlterTableWithAddColumn() method must return a
	 *                    boolean value; true if the database supports ALTER TABLE
	 *                    with add Column and false otherwise (See JDK 1.2.2 API 
	 *                    documentation).
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the supportsAlterTableWithAddColumn() method
	 *                    It should return a boolean value
	 *
	 */
	public void testSupportsAlterTableWithAddColumn() throws Fault
	{
		try
		{
			// invoke on the supportsAlterTableWithAddColumn
			logMsg("Calling supportsAlterTableWithAddColumn on DatabaseMetaData");
			boolean retValue=dbmd.supportsAlterTableWithAddColumn();
			if (retValue)
			{
				logMsg("supportsAlterTableWithAddColumn is supported");
			}
			else
			{
				logMsg("supportsAlterTableWithAddColumn is not supported");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to supportsAlterTableWithAddColumn is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to supportsAlterTableWithAddColumn is Failed!", e);
		}
	}


	/*
	 * @testName:         testSupportsAlterTableWithDropColumn
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The supportsAlterTableWithDropColumn() method must return a
	 *                    boolean value; true if the database supports ALTER TABLE
	 *                    with drop column and false otherwise (See JDK 1.2.2 API 
	 *                    documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the supportsAlterTableWithDropColumn() method
	 *                    It should return a boolean value
	 *
	 */
	public void testSupportsAlterTableWithDropColumn() throws Fault
	{
		try
		{
			// invoke on the supportsAlterTableWithDropColumn
			logMsg("Calling supportsAlterTableWithDropColumn on DatabaseMetaData");
			boolean retValue=dbmd.supportsAlterTableWithDropColumn();
			if (retValue)
			{
				logMsg("supportsAlterTableWithDropColumn is supported");
			}
			else
			{
				logMsg("supportsAlterTableWithDropColumn is not supported");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to supportsAlterTableWithDropColumn is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to supportsAlterTableWithDropColumn is Failed!", e);
		}
	}


	/*
	 * @testName:         testSupportsColumnAliasing
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                    
	 *                    A driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The supportsColumnAliasing() method must return a
	 *                    boolean value; true if the database supports column aliasing
	 *                    and false otherwise.  A JDBC compliant driver must always return 
	 *                    true. (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the supportsColumnAliasing() method
	 *                    It should return a true value
	 *
	 */
	public void testSupportsColumnAliasing() throws Fault
	{
		try
		{
			// invoke on the supportsColumnAliasing
			logMsg("Calling supportsColumnAliasing on DatabaseMetaData");
			boolean retValue=dbmd.supportsColumnAliasing();
			logTrace("A JDBC CompliantTM driver always returns true");
			if (retValue)
			{
				logMsg("supportsColumnAliasing is supported");
			}
			else
			{
				logMsg("supportsColumnAliasing is not supported");
				throw new Fault("supportsColumnAliasing should always return true!");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to supportsColumnAliasing is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to supportsColumnAliasing is Failed!", e);
		}
	}


	/*
	 * @testName:         testNullPlusNonNullIsNull
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                    
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The nullPlusNonNullIsNull() method must return a boolean value;
	 *                    true if the concatenation of a NULL value and a non-NULL value
	 *                    results in a NULL value and false otherwise.  A JDBC compliant
	 *                    driver must always return true. (See JDK 1.2.2 API 
	 *                    documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the nullPlusNonNullIsNull() method
	 *                    It should return a boolean value
	 *
	 */
	public void testNullPlusNonNullIsNull() throws Fault
	{
		try
		{
			// invoke on the nullPlusNonNullIsNull
			logMsg("Calling nullPlusNonNullIsNull on DatabaseMetaData");
			boolean retValue=dbmd.nullPlusNonNullIsNull();
			logTrace("A JDBC CompliantTM driver always returns true");
			if (retValue)
			{
				logMsg("nullPlusNonNullIsNull method returns a NULL value for the concatenations between NULL and non-NULL");
			}
			else
			{
				logMsg("nullPlusNonNullIsNull method does not returns a NULL value for the concatenations between NULL and non-NULL");
				throw new Fault("nullPlusNonNullIsNull method should always return true!");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to nullPlusNonNullIsNull is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to nullPlusNonNullIsNull is Failed!", e);
		}
	}


	/*
	 * @testName:         testSupportsConvert
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The supportsConvert() method must return a boolean value; 
	 *                    true if the database supports the scalar function CONVERT for 
	 *                    for the conversion of one JDBC type to another and false
	 *                    otherwise. (See JDK 1.2.2 API documentation)	 
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the supportsConvert() method
	 *                    It should return a boolean value
	 *
	 */
	public void testSupportsConvert() throws Fault
	{
		try
		{
			// invoke on the supportsConvert
			logMsg("Calling supportsConvert on DatabaseMetaData");
			boolean retValue=dbmd.supportsConvert();
			if(retValue)
			{
				logMsg("supportsConvert method is supported");
			}
			else
			{
				logMsg("supportsConvert method is not supported");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to supportsConvert is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to supportsConvert is Failed!", e);
		}
	}


	/*
	 * @testName:         testSupportsConvert01
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The supportsConvert(int fromType, int toType) method must return 
	 *                    a boolean value; true if the database supports the scalar function
	 *                    CONVERT for conversions between the JDBC types fromType and toType
	 *                    and false otherwise. (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the supportsConvert(ARRAY, VARCHAR) method
	 *                    It should return a boolean value
	 *
	 */
	public void testSupportsConvert01() throws Fault
	{
		try
		{
			// invoke on the supportsConvert
			logMsg("Calling supportsConvert(ARRAY, VARCHAR) on DatabaseMetaData");
			boolean retValue=dbmd.supportsConvert(Types.ARRAY, Types.VARCHAR);
			if(retValue)
			{
				logMsg("supportsConvert(ARRAY, VARCHAR) method is supported");
			}
			else
			{
				logMsg("supportsConvert(ARRAY, VARCHAR) method is not supported");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to supportsConvert is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to supportsConvert is Failed!", e);
		}
	}


	/*
	 * @testName:         testSupportsConvert02
	 * @assertion:        The DatabaseMetaData provides information about the database.
	 *                    (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
	 *                     
	 *                    A  driver must provide full support for DatabaseMetaData and 
	 *                    ResultSetMetaData.  This implies that all of the methods in the 
	 *                    DatabaseMetaData interface must be implemented and must behave as 
	 *                    specified in the JDBC 1.0 and 2.0 specifications.  None of the 
	 *                    methods in DatabaseMetaData and ResultSetMetaData may throw an 
	 *                    exception because they are not implemented. (See section 6.2.2.3 
	 *                    of Java2 Platform Enterprise Edition (J2EE) Specification v1.2)
	 *                    The supportsConvert(int fromType, int toType) method must return 
	 *                    a boolean value; true if the database supports the scalar function
	 *                    CONVERT for conversions between the JDBC types fromType and toType
	 *                    and false otherwise. (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get the DataBaseMetaData object from the Connection to the DataBase
	 *                    and call the supportsConvert(BIGINT, VARCHAR) method
	 *                    It should return a boolean value
	 *
	 */
	public void testSupportsConvert02() throws Fault
	{
		try
		{
			// invoke on the supportsConvert
			logMsg("Calling supportsConvert(BIGINT, VARCHAR) on DatabaseMetaData");
			boolean retValue = dbmd.supportsConvert(Types.BIGINT, Types.VARCHAR);
			if(retValue)
			{
				logMsg("supportsConvert(BIGINT, VARCHAR) method is supported");
			}
			else
			{
				logMsg("supportsConvert(BIGINT, VARCHAR) method is not supported");
			}
		}
		catch ( SQLException sqle )
		{
			logErr("SQL exception " + sqle.getMessage() );
			throw new Fault("Call to supportsConvert is Failed!", sqle);
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to supportsConvert is Failed!", e);
		}
	}


	/* cleanup */
	public void  cleanup() throws Fault	
	{
		try
		{
			// Close the database 
			dbSch.destroyData(conn);
			dbSch.dbUnConnect(conn);
			logMsg("Cleanup ok;");
		}
		catch (Exception e)
		{
			logErr("An error occurred while closing the database connection");
		}
	}
}
