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

/*
 * @(#)dateTimeClient1.java	1.7 02/01/12
 */

package com.sun.cts.tests.jdbc.ee.dateTime.dateTime1;

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 dateTimeClient1 class tests methods of Timestamp class using 
 * Sun's J2EE Reference Implementation.
 * @author  
 * @version 1.7, 06/16/99
 */

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

	//Harness requirements 
	private String sqlStmt=null;
	private Properties sqlp=null;
	private int valToGeneralize = 0;
	private Calendar cal = null;
	private java.sql.Timestamp inTimeVal=null;
	private java.sql.Timestamp inTimeVal1=null;

	/* Run test in standalone mode */
	public static void main(String[] args) 
	{
		dateTimeClient1 theTests = new dateTimeClient1();
		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 
		{
			TimeZone tz = null;
			tz = TimeZone.getDefault();
			boolean b1 = tz.useDaylightTime();
			if(!b1)
			{
				cal = Calendar.getInstance(tz);
				valToGeneralize = tz.getOffset(cal.get(Calendar.ERA),cal.get(Calendar.YEAR),cal.get(Calendar.MONTH),cal.get(Calendar.DAY_OF_MONTH),cal.get(Calendar.DAY_OF_WEEK),cal.get(Calendar.MILLISECOND));
			}
			else
			{
				valToGeneralize = tz.getRawOffset();
			}
			
			/*sqlp=new Properties();
			sqlStmt= p.getProperty("rsQuery","");
			InputStream istr= new FileInputStream(sqlStmt);
			sqlp.load(istr);*/
			sqlp=p;
		} 
		catch( Exception e ) 
		{
			logErr("Setup Failed!");
		}
	
	}


	/*
	 * @testName:         testTimestamp01
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The constructor Timestamp(long milliseconds) constructs 
	 *                    a java.sql.Timestamp object from milliseconds,a 
	 *                    milliseconds time value.
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tuorial Section 43.1)
	 *                    
	 * @ test_Strategy:   Create a Timestamp Object with a long value as an argument.
	 *                    Then get the String representation of that Timestamp object.
	 *                    Check whether it is same as equivalent String Value in the 
	 *                    property file. 
	 */
	public void testTimestamp01() throws Fault
	{
		String sTimestampVal = null;
		String sLongTstampVal = null;
		String sInTimeVal=null;
		boolean booRetVal;
		try
		{
			sTimestampVal = sqlp.getProperty("DateTime_Str_Val1","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			tstampVal=tstampVal-valToGeneralize;

			inTimeVal= new Timestamp(tstampVal);
			logMsg("Timestamp Value  " + inTimeVal);

			sInTimeVal = inTimeVal.toString().trim();
			logMsg("the string after timestamp creation is " + sInTimeVal);

			booRetVal=sTimestampVal.equals(sInTimeVal);
			if(booRetVal)
			{
				logMsg("Timestamp Constructor constructs Timestamp object");
			}
			else
			{
				logErr("Timestamp Constructor does not construct the expected Timestamp object");
				throw new Fault("Call to Timestamp Constructor is Failed!");
			}
		}
		catch ( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to Timestamp Constructor is Failed!"+ e);
		}
	}


	/*
	 * @testName:         testTimestamp02
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The constructor Timestamp(long milliseconds) constructs 
	 *                    a java.sql.Timestamp object from milliseconds,a 
	 *                    milliseconds time value.
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tuorial Section 43.1)
	 *                    
	 @ test_Strategy:     Create a Timestamp Object with a long value as an argument.
	 *                    Then get the String representation of that Timestamp object.
	 *                    Check whether it is same as equivalent String Value in the 
	 *                    property file. 
	 */
	 
	public void testTimestamp02() throws Fault
	{
		String sTimestampVal = null;
		String sInTimeVal=null;
		String sLongTstampVal = null;
		boolean booRetVal;
		try
		{
			
			sTimestampVal = sqlp.getProperty("DateTime_Str_Val2","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val2","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			tstampVal=tstampVal-valToGeneralize;

			inTimeVal= new Timestamp(tstampVal);
			sInTimeVal = inTimeVal.toString().trim();
			logMsg("the string after timestamp creation is" + sInTimeVal);

			booRetVal=sTimestampVal.equals(sInTimeVal);
			if(booRetVal)
			{
				logMsg("Timestamp Constructor constructs the Timestamp object");
			}
			else
			{
				logErr("Timestamp Constructor does not construct the expected Timestamp object");
				throw new Fault("Call to Timestamp Constructor is Failed!");
			}
		}
		catch( Exception e )
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to Timestamp Constructor is Failed!"+ e);
		}
	}


	/*
	 * @testName:         testSetNanos01
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The setNanos(int n) method sets the nanos field of 
	 *                    Timestamp Object to n 
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the setNanos(int n) method 
	 *                    and call getNanos() to check and it should return an Integer
	 *                    value that is been set
	 */
	public void testSetNanos01() throws Fault
	{
		String sLongTstampVal = null;
		int nanoVal=0;
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			inTimeVal= new Timestamp(tstampVal-valToGeneralize);
			inTimeVal.setNanos(0);

			nanoVal = inTimeVal.getNanos();
			if(nanoVal==0)
			{
				logMsg("setNanos method sets the Nano seconds to Timestamp object");
			}	
			else 
			{
				logErr("setNanos method does not set the Nano seconds to Timestamp object");
				throw new Fault("Call to setNanos is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setNanos is Failed!" + e);
		}
	}


	/*
	 * @testName:         testSetNanos02
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The setNanos(int n) method sets the nanos field of 
	 *                    Timestamp Object to n 
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the setNanos(int n) method 
	 *                    and call getNanos() to check and it should return an Integer
	 *                    value that is been set
	 */
	 
	public void testSetNanos02() throws Fault
	{
		String sLongTstampVal = null;
		int nanoVal=0;
		
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			tstampVal=tstampVal-valToGeneralize;

			inTimeVal= new Timestamp(tstampVal);
			inTimeVal.setNanos(999999999);

			nanoVal=inTimeVal.getNanos();
			if(nanoVal==999999999)
			{
				logMsg("setNanos method sets the Nano seconds for Timestamp object");
			}
			else 
			{
				logErr("setNanos method does not set the Nano seconds for Timestamp object");
				throw new Fault("Call to setNanos is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setNanos is Failed!" + e);
		}
	}


	/*
	 * @testName:         testSetNanos03 
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The setNanos(int n) method sets the nanos field of 
	 *                    Timestamp Object to n 
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the setNanos(int n) method 
	 *                    with the invalid value of argument and it should throw 
	 *                    IllegalArgumentException
	 */
	 
	public void testSetNanos03() throws Fault
	{
		boolean illArgExceptFlag=false;
		String sLongTstampVal = null;
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			inTimeVal= new Timestamp(tstampVal-valToGeneralize);

			try
			{
				inTimeVal.setNanos(-1);
			}
			catch(IllegalArgumentException e)
			{
				illArgExceptFlag=true;
			}

			if (illArgExceptFlag)
			{
				logMsg("setNanos Method does not set the out of range value");
			}
			else
			{
				logErr("setNanos Method sets the value which is exceeding limit");
				throw new Fault("Call to setNanos is Failed !");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setNanos is Failed" + e);
		}
	}


	/*
	 * @testName:         testSetNanos04
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The setNanos(int n) method sets the nanos field of 
	 *                    Timestamp Object to n 
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the setNanos(int n) method 
	 *                    with an invalid value as argument and it should throw 
	 *                    IllegalArgumentException 
	 */
	public void testSetNanos04() throws Fault
	{
		boolean illArgExceptFlag=false;
		String sLongTstampVal = null;
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			inTimeVal= new Timestamp(tstampVal-valToGeneralize);

			try
			{
				inTimeVal.setNanos(1000000000);
			}
			catch(IllegalArgumentException e)
			{
				illArgExceptFlag=true;
			}

			if (illArgExceptFlag)
			{
				logMsg("setNanos Method does not set the exceeding limit");
			}
			else
			{
				logErr("setNanos Method sets the value which is exceeding limit");
				throw new Fault("Call to setNanos is Failed !");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("call to setNanos failed" + e);
		}
	}


	/*
	 * @testName:         testGetNanos 
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method getNanos() retrieves the number of nanoseconds stored 
	 *                    in the nanos field of the Timestamp Object .Returns an integer
	 *                    equivalent to number of nanoseconds in the nanos field of the 
	 *                    Timestamp Object
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the setNanos(int n) method 
	 *                    and call getNanos() to check and it should return an Integer
	 *                    value that is been set
	 */
	public void testGetNanos() throws Fault
	{
		String sLongTstampVal = null;
		int nanoVal=0;
		
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			inTimeVal= new Timestamp(tstampVal-valToGeneralize);

			nanoVal= inTimeVal.getNanos();
			if(nanoVal>=0 || nanoVal<=999999999)
			{
				logMsg("getNanos method returns the Nano seconds of Timestamp object"+ nanoVal);
			}
			else 
			{
				logErr("getNanos() does not return the Nano seconds of Timestamp object");
				throw new Fault("Call to getNanos is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getNanos is Failed!" + e);
		}
	}


	/*
	 * @testName:         testToString01
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The Method toString() formats the Timestamp Object as a
	 *                    a String with the format yyyy-mm-dd hh:mm:ss.f .
	 *                    The driver uses a default Timezone in its conversion from
	 *                    milliseconds to String Object
	 *                    
	 @ test_Strategy:     Create a Timestamp Object with a long value as an argument.
	 *                    Then get the String representation of that Timestamp object.
	 *                    using the toString() method.Check whether it is same as 
	 *                    equivalent String Value in property file. 
	 */
	public void testToString01() throws Fault
	{
		String sTimestampVal =null;
		String sLongTstampVal = null;
		String sInTimeVal=null;
		try
		{
			sTimestampVal = sqlp.getProperty("DateTime_Str_Val1","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			tstampVal=tstampVal-valToGeneralize;

			inTimeVal= new Timestamp(tstampVal);
			sInTimeVal = inTimeVal.toString();
			logMsg("sInTimeVal = " + sInTimeVal);

			if (sInTimeVal.equals(sTimestampVal))
				logMsg("toString method returns a String object");
			else 
			{
				logErr("toString method does not return the String object");
				throw new Fault("Call to toString is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to toString is Failed!" + e);
		}
	}


	/*
	 * @testName:         testToString02
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The Method toString() formats the Timestamp Object as a
	 *                    a String with the format yyyy-mm-dd hh:mm:ss.f .
	 *                    The driver uses a default Timezone in its conversion from
	 *                    milliseconds to String Object
	 *                    
	 @ test_Strategy:     Create a Timestamp Object with a long value as an argument.
	 *                    Then get the String representation of that Timestamp object.
	 *                    using the toString() method.Check whether it is same as 
	 *                    equivalent String Value in property file. 
	 
	 */
	public void testToString02() throws Fault
	{
		String sLongTstampVal = null;
		String sTimestampVal = null;
		String retTstampVal = null;
		try
		{
			sTimestampVal = sqlp.getProperty("DateTime_Str_Val2","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val2","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			tstampVal = tstampVal-valToGeneralize;

			inTimeVal= new Timestamp(tstampVal);
			retTstampVal=inTimeVal.toString().trim();

			if (retTstampVal.equals(sTimestampVal))
				logMsg("toString method returns a String object");
			else 
			{
				logErr("toString method does not return a String object");
				throw new Fault("Call to toString is Failed");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to toString is Failed" + e);
		}
	}


	/*
	 * @testName:         testAfter01
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method after(Timestamp ts) checks whether this Timestamp
	 *                    object is after Timestamp ts or not . True if this Timestamp
	 *                    object is after Timestamp ts ; False if they are equal or if
	 *                    this Timestamp Object is before Timestamp ts .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the after(Timestamp ts) method 
	 *                    with the value of ts is after than the Timestamp
	 *                    It should return a boolean value and the value should be equal 
	 *                    to true
	 */
	public void testAfter01() throws Fault
	{
		String sLongTstampVal = null;
		String sRefVal=null;
		boolean booRetVal;
		java.sql.Timestamp inTimeVal2=null;
		
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;
			
			sRefVal = sqlp.getProperty("Ref_Milli_Val","");
			long tstampVal2 = Long.parseLong(sRefVal);
			tstampVal2=tstampVal1-valToGeneralize-tstampVal2;

			inTimeVal1= new Timestamp(tstampVal1);
			logMsg("Timestamp Value # 1 : " + inTimeVal1);

			inTimeVal2= new Timestamp(tstampVal2);
			logMsg("Timestamp Value # 2 : " + inTimeVal2);

			booRetVal = inTimeVal1.after(inTimeVal2);
			if(booRetVal)
			{
				logMsg("after method returns  " + booRetVal);
			}
			else
			{
				logErr("after method does not return expected Value "+ booRetVal);
				throw new Fault("Call to after is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception   " + e.getMessage());
			throw new Fault("Call to after is Failed!");
		}
	}


	/*
	 * @testName:         testAfter02
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method after(Timestamp ts) checks whether this Timestamp
	 *                    object is after Timestamp ts or not . True if this Timestamp
	 *                    object is after Timestamp ts ; False if they are equal or if
	 *                    this Timestamp Object is before Timestamp ts .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the after(Timestamp ts) method 
	 *                    with the value of ts is not after than the Timestamp
	 *                    It should return a boolean value and the value should be equal 
	 *                    to false
	 */
	public void testAfter02() throws Fault
	{
		String sLongTstampVal = null;
		String sRefVal=null;
		java.sql.Timestamp inTimeVal2=null;
		boolean booRetVal;
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;

			sRefVal = sqlp.getProperty("Ref_Milli_Val","");
			long tstampVal2 = Long.parseLong(sRefVal);
			tstampVal2=tstampVal1 - valToGeneralize + tstampVal2;

			inTimeVal1= new Timestamp(tstampVal1);
			logMsg("Timestamp Value # 1 : " + inTimeVal1);

			inTimeVal2= new Timestamp(tstampVal2);
			logMsg("Timestamp Value # 2 : " + inTimeVal2);

			booRetVal=inTimeVal1.after(inTimeVal2);
			if(!booRetVal)
				logMsg("after method returns : "+ booRetVal);
			else
			{
				logErr("after method does not return the expected Value "+ booRetVal);
				throw new Fault("Call to after is Failed!");
			}
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception "+ e.getMessage());
			throw new Fault("Call to after is Failed!");
		}
	}


	/*
	 * @testName:         testAfter03 
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method after(Timestamp ts) checks whether this Timestamp
	 *                    object is after Timestamp ts or not . True if this Timestamp
	 *                    object is after Timestamp ts ; False if they are equal or if
	 *                    this Timestamp Object is before Timestamp ts .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the after(Timestamp ts) method 
	 *                    with the value of ts is after than the Timestamp in Nano second level
	 *                    It should return a boolean value and the value should be equal 
	 *                    to true
	 */
	public void testAfter03() throws Fault
	{
		Timestamp inTimeVal2 = null;
		String sLongTstampVal = null;
		String sNanosVal = null;
		boolean booRetVal;
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;

			sNanosVal = sqlp.getProperty("Ref_Nano_Val","");
			int nanosSet = Integer.parseInt(sNanosVal);

			inTimeVal1= new Timestamp(tstampVal1);
			inTimeVal1.setNanos(nanosSet);
			logMsg("Timestamp Value # 1  :  " + inTimeVal1);

			inTimeVal2= new Timestamp(tstampVal1);
			logMsg("Timestamp Value # 2  :  " + inTimeVal2);

			booRetVal = inTimeVal1.after(inTimeVal2);
			if(booRetVal)
				logMsg("after method returns" + booRetVal);
			else
			{
				logErr("after method does not return the expected Value "+ booRetVal);
				throw new Fault("Call to after is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("UnExpected Exception  "+ e.getMessage());
			throw new Fault("Call to after is Failed!");
		}
	}


	/*
	 * @testName:         testAfter04
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method after(Timestamp ts) checks whether this Timestamp
	 *                    object is after Timestamp ts or not . True if this Timestamp
	 *                    object is after Timestamp ts ; False if they are equal or if
	 *                    this Timestamp Object is before Timestamp ts .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the after(Timestamp ts) method 
	 *                    with the value of ts is not after than the Timestamp with
	 *                    Nano seconds level
	 *                    It should return a boolean value and the value should be equal 
	 *                    to false
	 */
	public void testAfter04() throws Fault
	{
		String sLongTstampVal = null;
		boolean booRetVal;
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			tstampVal=tstampVal-valToGeneralize;

			inTimeVal= new Timestamp(tstampVal);
			logMsg("TimeStamp Value # 1 :  " + inTimeVal);

			inTimeVal1= new Timestamp(tstampVal);

			String sNanosVal = sqlp.getProperty("Ref_Nano_Val","");
			int nanoVal = Integer.parseInt(sNanosVal);

			inTimeVal1.setNanos(nanoVal);
			logMsg("TimeStamp Value # 2 :  " + inTimeVal1);

			booRetVal = inTimeVal.after(inTimeVal1);
			if(!booRetVal)
				logMsg("after method returns "+ booRetVal);
			else
			{
				logErr("after method does not return the expected value" + booRetVal);
				throw new Fault("Call to after is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception "+ e.getMessage());
			throw new Fault("Call to after is Failed!");
		}
	}


	/*
	 * @testName:         testBefore01
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method before(Timestamp ts) checks whether this Timestamp
	 *                    object is before Timestamp ts or not . True if this Timestamp
	 *                    object is before Timestamp ts ; False if they are equal or if
	 *                    this Timestamp Object is after Timestamp ts .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the before(Timestamp ts) method 
	 *                    with the value of ts is before than the Timestamp
	 *                    It should return a boolean value and the value should be equal 
	 *                    to true
	 */
	public void testBefore01() throws Fault
	{
		String sTimestampVal = null;
		String sLongTstampVal = null;
		String sRefVal = null;
		boolean booRetVal;
		try
		{
			sTimestampVal = sqlp.getProperty("DateTime_Long_Val1","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;

			sRefVal = sqlp.getProperty("Ref_Milli_Val","");
			long tstampVal2 = Long.parseLong(sRefVal);
			tstampVal2=tstampVal1-valToGeneralize+tstampVal2;

			inTimeVal= new Timestamp(tstampVal1);
			logMsg("Timestamp Value1 : " + inTimeVal);

			inTimeVal1= new Timestamp(tstampVal2);
			logMsg("Timestamp Value2 : " + inTimeVal1);

			booRetVal=inTimeVal.before(inTimeVal1);
			if(booRetVal)
				logMsg("before method returns : "+ booRetVal);
			else
			{
				logErr("before method does not return the expected value "+ booRetVal);
				throw new Fault("Call to before is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception "+ e.getMessage());
			throw new Fault("Call to before is Failed!");
		}
	}


	/*
	 * @testName:         testBefore02
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method before(Timestamp ts) checks whether this Timestamp
	 *                    object is before Timestamp ts or not . True if this Timestamp
	 *                    object is before Timestamp ts ; False if they are equal or if
	 *                    this Timestamp Object is after Timestamp ts .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the before(Timestamp ts) method 
	 *                    with the value of ts is not before than the Timestamp
	 *                    It should return a boolean value and the value should be equal 
	 *                    to false
	 *
	 */
	public void testBefore02() throws Fault
	{
		String sTimestampVal = null;
		String sLongTstampVal = null;
		String sRefVal = null;
		boolean booRetVal;
		try
		{
			sTimestampVal = sqlp.getProperty("DateTime_Long_Val1","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;

			sRefVal = sqlp.getProperty("Ref_Milli_Val","");
			long tstampVal2 = Long.parseLong(sRefVal);
			tstampVal2=tstampVal1-valToGeneralize-tstampVal2;

			inTimeVal= new Timestamp(tstampVal1);
			logMsg("Timestamp Value1 :  " + inTimeVal);

			inTimeVal1= new Timestamp(tstampVal2);
			logMsg("Timestamp Value2 :  " + inTimeVal1);

			booRetVal=inTimeVal.before(inTimeVal1);
			if(!booRetVal)
				logMsg("before method returns : "+ booRetVal);
			else
			{
				logErr("before method does not return the expected Value "+ booRetVal);
				throw new Fault("Call to before is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception  "+ e.getMessage());
			throw new Fault("Call to before is Failed!");
		}
	}


	/*
	 * @testName:         testBefore03
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method before(Timestamp ts) checks whether this Timestamp
	 *                    object is before Timestamp ts or not . True if this Timestamp
	 *                    object is before Timestamp ts ; False if they are equal or if
	 *                    this Timestamp Object is after Timestamp ts .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the before(Timestamp ts) method 
	 *                    with the value of ts is before than the Timestamp in Nano 
	 *                    second level It should return a boolean value and the value 
	 *                    should be equal to true.
	 *                    
	 */
	public void testBefore03() throws Fault
	{
		String sLongTstampVal = null;
		Timestamp inTimeVal1 = null;
		boolean booRetVal;

		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			tstampVal=tstampVal-valToGeneralize;

			inTimeVal= new Timestamp(tstampVal);
			logMsg("Timestamp Value # 1 : " + inTimeVal);

			inTimeVal1= new Timestamp(tstampVal);
			String sNanosVal = sqlp.getProperty("Ref_Nano_Val","");
			int nanosSet = Integer.parseInt(sNanosVal);
			inTimeVal1.setNanos(nanosSet);
			logMsg("Timestamp Value # 2 : " + inTimeVal1);

			booRetVal=inTimeVal.before(inTimeVal1);
			if(booRetVal)
			{
				logMsg("before method returns " + booRetVal);
			}
			else
			{
				logErr("before method does not return the expected value "+ booRetVal);
				throw new Fault("Call to before is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception  "+ e.getMessage());
			throw new Fault("Call to before is Failed");
		}
	}


	/*
	 * @testName:         testBefore04
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds 
	 *                    
	 *                    The method before(Timestamp ts) checks whether this Timestamp
	 *                    object is before Timestamp ts or not . True if this Timestamp
	 *                    object is before Timestamp ts ; False if they are equal or if
	 *                    this Timestamp Object is after Timestamp ts .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the before(Timestamp ts) method 
	 *                    with the value of ts is not before than the Timestamp with
	 *                    Nano seconds level
	 *                    It should return a boolean value and the value should be equal 
	 *                    to false
	 */
	public void testBefore04() throws Fault
	{
		String sLongTstampVal = null;
		String sNanosVal = null;
		boolean booRetVal;

		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal = Long.parseLong(sLongTstampVal);
			tstampVal=tstampVal-valToGeneralize;

			inTimeVal= new Timestamp(tstampVal);
			logMsg("Timestamp Value 1" + inTimeVal);

			inTimeVal1= new Timestamp(tstampVal);
			sNanosVal = sqlp.getProperty("Ref_Nano_Val","");
			int nanosSet = Integer.parseInt(sNanosVal);
			inTimeVal1.setNanos(nanosSet);
			logMsg("Timestamp Value 2" + inTimeVal1);

			booRetVal=inTimeVal.before(inTimeVal1);
			if(booRetVal)
			{
				logMsg("before method returns "+ booRetVal);
			}
			else
			{
				logErr("before method does not return the expected Value"+booRetVal);
				throw new Fault("Call to before is Failed!");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected exception "+e.getMessage());
			throw new Fault("Call to before is Failed!");
		}
	}


	/*
	 * @testName:         testEqualsTimestamp01
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The method equals(Timestamp ts) tests to see if this is equal
	 *                    to Timestamp object ts. true if the two Timestamp Objects are
	 *                    equal;false otherwise
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial , Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the equals(Timestamp ts) method 
	 *                    with equal value of Timestamp 
	 *                    It should return a boolean value and the value should be equal
	 *                    to true
	 */
	public void testEqualsTimestamp01() throws Fault
	{
		String sLongTstampVal = null;
		boolean booRetVal;
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;

			String sRefMilliVal = sqlp.getProperty("Ref_Milli_Val","");
			long tstampVal2 = Long.parseLong(sRefMilliVal);
			tstampVal2=tstampVal2-valToGeneralize;

			String sRefNanoVal = sqlp.getProperty("Ref_Nano_Val2","");
			int setNanosVal = Integer.parseInt(sRefNanoVal);

			inTimeVal = new Timestamp(tstampVal1);
			logMsg("Timestamp Value1 : " + inTimeVal);

			inTimeVal1 = new Timestamp(tstampVal2);
			inTimeVal1.setNanos(setNanosVal);
			logMsg("Timestamp Value2 : " + inTimeVal1);

			booRetVal=inTimeVal.equals(inTimeVal1);
			if(booRetVal)
			{
				logMsg("The method equals() returns the expected value");
			}	
			else
			{
				logErr("The method equals() doesnt work as expected");
				throw new Fault("call to equals() failed");
			}
		}
		catch(Exception e)
		{
			logErr("Unexpected exception thrown"+e.getMessage());
			throw new Fault("Call to equals is Failed !");
		}
	}


	/*
	 * @testName:         testEqualsObject01
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The method equals(Object ob) tests to see if this is equal
	 *                    to Timestamp object ob as Object Reference . True if the both 
	 *                    the values are equal;false otherwise
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial , Section 43.1)
	 *                    
	 * @test_Strategy:    Get a Timestamp object and call the equals(Object obj) method 
	 *                    with equal value of Timestamp 
	 *                    It should return a boolean value and the value should be equal
	 *                    to true
	 */
	public void testEqualsObject01() throws Fault
	{
		String sLongTstampVal = null;
		boolean booRetVal;
		try
		{
			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;

			inTimeVal = new Timestamp(tstampVal1);
			logMsg("Timestamp Value1:  "+ inTimeVal);

			Object tsObj = new Timestamp(tstampVal1);
			logMsg("Timestamp Object Value1:  "+ tsObj);

			booRetVal=inTimeVal.equals(tsObj);
			if(booRetVal)
			{
				logMsg("The method equals() returns the expected value");
			}
			else
			{
				logErr("The method equals() doesnt work as expected");
				throw new Fault("call to equals() failed");
			}
		}
		catch(Exception e)
		{
			logMsg("Unexpected exception thrown"+ e.getMessage());
			throw new Fault("Call to equals is Failed!");
		}
	}


	/*
	 * @testName:         testEqualsObject02
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The method equals(Object ob) tests to see if this is equal
	 *                    to Timestamp object ob in Object reference.True if both the
	 *                    values are equal; false otherwise .
	 *                    
	 *                    (Refer JDBC 2.0 API Reference and Tutorial , Section 43.1)
	 *                    
	 *@test_Strategy:     Get a Timestamp object and call the equals(Object obj) method 
	 *                    with equal value of Timestamp in Nano seconds level
	 *                    It should return a boolean value and the value should be equal
	 *                    to true
	 */
	public void testEqualsObject02() throws Fault
	{
		String sTimestampVal = null;
		String sLongTstampVal = null;
		boolean booRetVal;
		try
		{
			sTimestampVal = sqlp.getProperty("DateTime_Long_Val1","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;

			String sRefMilliVal = sqlp.getProperty("Ref_Milli_Val","");
			long tstampVal2 = Long.parseLong(sRefMilliVal);
			tstampVal2=tstampVal2-valToGeneralize;

			String sRefNanoVal = sqlp.getProperty("Ref_Nano_Val2","");
			int setNanosVal = Integer.parseInt(sRefNanoVal);

			inTimeVal = new Timestamp(tstampVal2);
			inTimeVal.setNanos(setNanosVal);
			logMsg("TimeStamp Value    " + inTimeVal);

			Object tsObj = new Timestamp(tstampVal1);
			logMsg("Object Value " + tsObj);

			booRetVal=inTimeVal.equals(tsObj);
			if(booRetVal)
			{
				logMsg("The method equals() returns the expected value");
			}
			else
			{
				logErr("The method equals() doesnt work as expected");
				throw new Fault("call to equals() failed");
			}
		}
		catch(Exception e)
		{
			logMsg("Unexpected exception thrown");
			throw new Fault("call to equals() failed");
		}
	}


	/*
	 * @testName:         testValueOf01
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The valueOf a static method in java.sql.Timestamp class
	 *                    converts a formatted String (yyyy-mm-dd hh:mm:ss.f) to a
	 *                    valid Timestamp Object .The driver uses default time zone 
	 *                    in its conversion of a String Object to Timestamp Object.
	 *                    
	 *                    (Refer JDBC 2.0 API Tutorial and Reference Section 43.1)
	 *                    
	 * @test_Strategy:    Call valueof(String ts) static method in java.sql.Timestamp
	 *                    class with a String argument to get a Timestamp object 
	 *                    Check whether it is same as Timestamp object obtained from
	 *                    equivalent long value .
	 */
	 
	public void testValueOf01() throws Fault
	{
		String sTimestampVal = null;
		String sLongTstampVal = null;
		String sTestTimestampVal = null;
		boolean booRetVal;
		String sInTimeVal = null;

		try
		{
			sTimestampVal = sqlp.getProperty("DateTime_Str_Val1","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val1","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;
		
			inTimeVal = new Timestamp(tstampVal1);
			sInTimeVal = inTimeVal.toString();
			logMsg("TimeStamp Value    " + inTimeVal);

			inTimeVal1 = Timestamp.valueOf(sTimestampVal);
			sTestTimestampVal = inTimeVal1.toString().trim();
			logMsg("Test Timestamp object's Value " + sTestTimestampVal);

			booRetVal=sInTimeVal.equals(sTestTimestampVal);
			if(booRetVal)
			{
				logMsg("The method valueOf() returns the correct object");
			}
			else
			{
				logErr("The method valueOf() doesnt work as expected");
				throw new Fault("call to valueOf() failed");
			}
		}
		catch(Exception e)
		{
			logMsg("Unexpected exception thrown");
			throw new Fault("call to valueOf() failed");
		}
	}


	/*
	 * @testName:         testValueOf02
	 * @assertion:        The class java.sql.Timestamp represents a JDBC Timestamp 
	 *                    value in Java Programming language.A JDBC TIMESTAMP value
	 *                    has date and time information and also a field for 
	 *                    nanoseconds .
	 *                    
	 *                    The valueOf a static method in java.sql.Timestamp class
	 *                    converts a formatted String (yyyy-mm-dd hh:mm:ss.f) to a
	 *                    valid Timestamp Object .The driver uses default time zone 
	 *                    in its conversion of a String Object to Timestamp Object.
	 *                    
	 * @test_Strategy:    Call valueof(String ts) static method in java.sql.Timestamp
	 *                    class with a String argument to get a Timestamp object 
	 *                    Check whether it is same as Timestamp object obtained from
	 *                    equivalent long value .
	 */
	public void testValueOf02() throws Fault
	{
		String sTimestampVal = null;
		String sLongTstampVal = null;
		String sTestTimestampVal = null;
		boolean booRetVal;
		String sInTimeVal = null;

		try
		{
			sTimestampVal = sqlp.getProperty("DateTime_Str_Val2","");
			logMsg("Timestamp String Value :  " + sTimestampVal);

			sLongTstampVal = sqlp.getProperty("DateTime_Long_Val2","");
			long tstampVal1 = Long.parseLong(sLongTstampVal);
			tstampVal1=tstampVal1-valToGeneralize;

			inTimeVal = new Timestamp(tstampVal1);
			sInTimeVal = inTimeVal.toString();
			logMsg("TimeStamp Value    " + inTimeVal);

			inTimeVal1 = Timestamp.valueOf(sTimestampVal);
			sTestTimestampVal = inTimeVal1.toString().trim();
			logMsg("Test Timestamp object's Value " + sTestTimestampVal);

			booRetVal=sInTimeVal.equals(sTestTimestampVal);
			if(booRetVal)
			{
				logMsg("The method valueOf() returns the correct object");
			}
			else
			{
				logErr("The method valueOf() doesnt work as expected");
				throw new Fault("call to valueOf() failed");
			}
		}
		catch(Exception e)
		{
			logMsg("Unexpected exception thrown");
			throw new Fault("call to valueOf() failed");
		}
	}


	/* cleanup */
	public void  cleanup() throws Fault	
	{
		try
		{
			logMsg("Cleanup ok;");
		}
		catch (Exception e)
		{
			logErr("An error occurred in Cleanup method");
		}
	}
}
