According to the spec a call to DataSet.getWarnings() "may not be called on a closed DataSet object; doing so will cause an SQLRuntimeException to be thrown." However, SQLRuntimeException is never thrown when calling getWarnings() on a closed DataSet.
JDK : Java HotSpot(TM) Client VM (build 1.6.0-beta2-b85, mixed mode)
DB : Oracle 9i, DB2 8.1, SQL Server 2000
Driver : Oracle/I-Net Oranxo.jar, DB2/DataDirect 3.4, SQL Server/I-Net Merlia.jar
Platform[s] : Any
Test source location:
=====================
/net/cady/export/dtf/unified/knight-ws/suites/6.0/jdbc/src/java_sql_eod/dataset/DataSet003_011/DataSet003_011.java
Testcase Description:
=========================================
Create a DataSet instance by executing a @Query. close the DataSet. Then call DataSet.getWarnings(). SQLException should be thrown.
Testcase source (test method only):
====================================
private void doTest() throws DBConnectionException, TestFailureException {
//loads the class and creates Connection object
System.out.println(this.getClass().getName()+".doTest() : getting Connection object.... ");
Connection con = utils.getJdbcConnection();
I_Query006 query = null;
DataSet<PersonInfo> rows = null;
try {
System.out.println(this.getClass().getName()+".doTest() : getting QueryObject handle(JDBC 3.0)....");
//this invocation is for JDBC 3.0 compliant drivers
query = QueryObjectFactory.createQueryObject(I_Query006.class, con);
System.out.println(this.getClass().getName()+".doTest() : got QueryObject handle(JDBC 3.0) ");
} catch (SQLException sqlEx) {
System.err.println(this.getClass().getName()+": SQLException caught "+sqlEx.getMessage());
//free the resources
utils.closeConnection(con);
throw new TestFailureException
("Exception when QueryObjectFactory.createQueryObject. [Message="+sqlEx.getMessage()+"]", sqlEx);
}
//get the DataSet object
String arg = "player2_lName";
System.out.println(this.getClass().getName()+".doTest() : Executing @Select....");
try {
rows = query.getPersonInfo(arg);
}catch (SQLRuntimeException ex) {
System.err.println(this.getClass().getName()+".doTest() : SQLRuntimeException caught when executing @Select : "+ex.getMessage());
throw new TestFailureException
("Un-Expected SQLRuntimeException when getting DataSet by executing @Select. [Message="+ex.getMessage()+"]", ex);
}
finally {
utils.closeConnection(con);
}
if (null == rows || rows.size() != 1) {
System.out.println(this.getClass().getName()+".doTest() : DataSet returned by @Select is null/empty. TEST FAILED");
throw new TestFailureException("DataSet returned by @Select is null/empty. TEST FAILED");
}
System.out.println(this.getClass().getName()+".doTest() : Got Dataset. Calling DataSet.close()");
// close the DataSet..
try {
rows.close();
} catch (SQLRuntimeException ex) {
System.err.println(this.getClass().getName()+".doTest() : SQLRuntimeException caught when executing DataSet.close() : "+ex.getMessage());
throw new TestFailureException
("Un Expected SQLRuntimeException when executing DataSet.close(). [Message="+ex.getMessage()+"]", ex);
}
System.out.println(this.getClass().getName()+".doTest() : Calling DataSet.getWarnings()");
//now call DataSet.getWarnings()
try {
SQLWarning warning = rows.getWarnings();
} catch (SQLRuntimeException ex) {
System.out.println(this.getClass().getName()+".doTest() : SQLRuntimeException caught as expected. [Message="+ex.getMessage()+"]");
System.out.println(this.getClass().getName()+".doTest() : TEST PASSED ");
return;
}
//if we are here, mark the test as FAILED
System.out.println(this.getClass().getName()+".doTest() : No SQLRuntimeException when calling DataSet.getWarnings on a closed DataSet. TEST FAILED");
throw new TestFailureException("No SQLRuntimeException when calling DataSet.getWarnings on a closed DataSet. TEST FAILED");
}
How to reproduce:
=================
1) cd /net/cady/export/sqa/js159705/jdbc/bugs/[bug id]
2) ksh Run_Standalone.ksh
3) Results will be in workDir/$username.$os.$arch/$testcase/ directory.
Other options:
To change other options (such as changing the JDK, database, connection string), you can edit setup file in that directory before running the Run_Standalone.ksh.
Tonga Log output:
=================
[2006-05-31T03:07:34.33] Calling doTest()....
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : getting Connection object....
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : getting QueryObject handle(JDBC 3.0)....
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : got QueryObject handle(JDBC 3.0)
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : Executing @Select....
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : Got Dataset. Calling DataSet.close()
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : Calling DataSet.getWarnings()
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : No SQLRuntimeException when calling DataSet.getWarnings on a closed DataSet. TEST FAILED
JDK : Java HotSpot(TM) Client VM (build 1.6.0-beta2-b85, mixed mode)
DB : Oracle 9i, DB2 8.1, SQL Server 2000
Driver : Oracle/I-Net Oranxo.jar, DB2/DataDirect 3.4, SQL Server/I-Net Merlia.jar
Platform[s] : Any
Test source location:
=====================
/net/cady/export/dtf/unified/knight-ws/suites/6.0/jdbc/src/java_sql_eod/dataset/DataSet003_011/DataSet003_011.java
Testcase Description:
=========================================
Create a DataSet instance by executing a @Query. close the DataSet. Then call DataSet.getWarnings(). SQLException should be thrown.
Testcase source (test method only):
====================================
private void doTest() throws DBConnectionException, TestFailureException {
//loads the class and creates Connection object
System.out.println(this.getClass().getName()+".doTest() : getting Connection object.... ");
Connection con = utils.getJdbcConnection();
I_Query006 query = null;
DataSet<PersonInfo> rows = null;
try {
System.out.println(this.getClass().getName()+".doTest() : getting QueryObject handle(JDBC 3.0)....");
//this invocation is for JDBC 3.0 compliant drivers
query = QueryObjectFactory.createQueryObject(I_Query006.class, con);
System.out.println(this.getClass().getName()+".doTest() : got QueryObject handle(JDBC 3.0) ");
} catch (SQLException sqlEx) {
System.err.println(this.getClass().getName()+": SQLException caught "+sqlEx.getMessage());
//free the resources
utils.closeConnection(con);
throw new TestFailureException
("Exception when QueryObjectFactory.createQueryObject. [Message="+sqlEx.getMessage()+"]", sqlEx);
}
//get the DataSet object
String arg = "player2_lName";
System.out.println(this.getClass().getName()+".doTest() : Executing @Select....");
try {
rows = query.getPersonInfo(arg);
}catch (SQLRuntimeException ex) {
System.err.println(this.getClass().getName()+".doTest() : SQLRuntimeException caught when executing @Select : "+ex.getMessage());
throw new TestFailureException
("Un-Expected SQLRuntimeException when getting DataSet by executing @Select. [Message="+ex.getMessage()+"]", ex);
}
finally {
utils.closeConnection(con);
}
if (null == rows || rows.size() != 1) {
System.out.println(this.getClass().getName()+".doTest() : DataSet returned by @Select is null/empty. TEST FAILED");
throw new TestFailureException("DataSet returned by @Select is null/empty. TEST FAILED");
}
System.out.println(this.getClass().getName()+".doTest() : Got Dataset. Calling DataSet.close()");
// close the DataSet..
try {
rows.close();
} catch (SQLRuntimeException ex) {
System.err.println(this.getClass().getName()+".doTest() : SQLRuntimeException caught when executing DataSet.close() : "+ex.getMessage());
throw new TestFailureException
("Un Expected SQLRuntimeException when executing DataSet.close(). [Message="+ex.getMessage()+"]", ex);
}
System.out.println(this.getClass().getName()+".doTest() : Calling DataSet.getWarnings()");
//now call DataSet.getWarnings()
try {
SQLWarning warning = rows.getWarnings();
} catch (SQLRuntimeException ex) {
System.out.println(this.getClass().getName()+".doTest() : SQLRuntimeException caught as expected. [Message="+ex.getMessage()+"]");
System.out.println(this.getClass().getName()+".doTest() : TEST PASSED ");
return;
}
//if we are here, mark the test as FAILED
System.out.println(this.getClass().getName()+".doTest() : No SQLRuntimeException when calling DataSet.getWarnings on a closed DataSet. TEST FAILED");
throw new TestFailureException("No SQLRuntimeException when calling DataSet.getWarnings on a closed DataSet. TEST FAILED");
}
How to reproduce:
=================
1) cd /net/cady/export/sqa/js159705/jdbc/bugs/[bug id]
2) ksh Run_Standalone.ksh
3) Results will be in workDir/$username.$os.$arch/$testcase/ directory.
Other options:
To change other options (such as changing the JDK, database, connection string), you can edit setup file in that directory before running the Run_Standalone.ksh.
Tonga Log output:
=================
[2006-05-31T03:07:34.33] Calling doTest()....
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : getting Connection object....
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : getting QueryObject handle(JDBC 3.0)....
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : got QueryObject handle(JDBC 3.0)
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : Executing @Select....
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : Got Dataset. Calling DataSet.close()
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : Calling DataSet.getWarnings()
[2006-05-31T03:07:34.33] DataSet003_011.doTest() : No SQLRuntimeException when calling DataSet.getWarnings on a closed DataSet. TEST FAILED