You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2006/08/18 20:54:32 UTC
svn commit: r432679 [3/3] - in /db/derby/code/branches/10.2: ./
java/client/org/apache/derby/client/am/ java/drda/org/apache/derby/impl/drda/
java/engine/org/apache/derby/impl/sql/compile/ java/testing/
java/testing/org/apache/derbyTesting/functionTest...
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java Fri Aug 18 11:54:23 2006
@@ -19,6 +19,8 @@
*/
package org.apache.derbyTesting.functionTests.tests.jdbcapi;
import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
+
+import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -40,7 +42,7 @@
public SURTest(String name) {
super(name);
}
-
+
/**
* Test that you get a warning when specifying a query which is not
* updatable and concurrency mode CONCUR_UPDATABLE.
@@ -49,7 +51,7 @@
public void testConcurrencyModeWarning1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1 order by a");
@@ -61,6 +63,7 @@
assertWarning(warn, QUERY_NOT_QUALIFIED_FOR_UPDATABLE_RESULTSET);
scrollForward(rs);
rs.close();
+ s.close();
}
/**
@@ -71,7 +74,7 @@
public void testConcurrencyModeWarning2()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery
@@ -85,6 +88,7 @@
assertWarning(warn, QUERY_NOT_QUALIFIED_FOR_UPDATABLE_RESULTSET);
scrollForward(rs);
rs.close();
+ s.close();
}
/**
@@ -96,7 +100,7 @@
public void testForUpdateException1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
try {
String queryString =
@@ -111,7 +115,8 @@
FOR_UPDATE_NOT_PERMITTED_SQL_STATE,
e.getSQLState());
}
- con.rollback();
+ rollback();
+ s.close();
}
/**
@@ -122,7 +127,7 @@
public void testForUpdateException2()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
try {
String queryString =
@@ -138,7 +143,8 @@
FOR_UPDATE_NOT_PERMITTED_SQL_STATE,
e.getSQLState());
}
- con.rollback();
+ rollback();
+ s.close();
}
/**
@@ -148,13 +154,14 @@
public void testForwardOnlyReadOnly1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
scrollForward(rs);
rs.close();
+ s.close();
}
@@ -165,13 +172,14 @@
public void testFailOnUpdateOfReadOnlyResultSet1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
rs.next();
assertFailOnUpdate(rs);
+ s.close();
}
/**
@@ -181,13 +189,14 @@
public void testFailOnUpdateOfReadOnlyResultSet2()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1 order by id");
rs.next();
assertFailOnUpdate(rs);
+ s.close();
}
/**
@@ -197,7 +206,7 @@
public void testFailOnUpdateOfReadOnlyResultSet3()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs =
@@ -205,6 +214,7 @@
rs.next();
assertFailOnUpdate(rs);
+ s.close();
}
/**
@@ -214,7 +224,7 @@
public void testFailOnUpdateOfReadOnlyResultSet4()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery
@@ -223,6 +233,7 @@
rs.next();
verifyTuple(rs);
assertFailOnUpdate(rs);
+ s.close();
}
@@ -233,7 +244,7 @@
public void testFailOnUpdateOfReadOnlyResultSet5()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.
+ Statement s = createStatement(ResultSet.
TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
s.setCursorName(getNextCursorName());
@@ -243,6 +254,7 @@
rs.next();
verifyTuple(rs);
assertFailOnUpdate(rs);
+ s.close();
}
/**
@@ -308,7 +320,7 @@
final int resultSetType)
throws SQLException
{
- final Statement s = con.createStatement(resultSetType,
+ final Statement s = createStatement(resultSetType,
ResultSet.CONCUR_UPDATABLE);
final String cursorName = getNextCursorName();
s.setCursorName(cursorName);
@@ -324,10 +336,10 @@
rs.absolute(recordToUpdate);
}
- con.commit();
+ commit();
PreparedStatement ps =
- con.prepareStatement("update t1 set a=? where current of " +
+ prepareStatement("update t1 set a=? where current of " +
cursorName);
// First: check that we get an exception on update without repositioning:
try {
@@ -362,6 +374,9 @@
rs.updateRow();
}
+ s.close();
+ ps.close();
+
}
/**
@@ -371,7 +386,7 @@
public void testMultiUpdateRow1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
@@ -426,6 +441,7 @@
"updateRow and cancelRowUpdates", rs.rowUpdated());
rs.close();
+ s.close();
}
/**
@@ -435,7 +451,7 @@
public void testMultiUpdateRow2()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
@@ -491,6 +507,7 @@
"updateRow and cancelRowUpdates", rs.rowUpdated());
rs.close();
+ s.close();
}
/**
@@ -500,12 +517,12 @@
public void testCursorOperationConflictWarning1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
rs.next();
- con.createStatement().executeUpdate("delete from t1 where id=" +
+ createStatement().executeUpdate("delete from t1 where id=" +
rs.getString("ID"));
final int newValue = -3333;
final int oldValue = rs.getInt(2);
@@ -528,6 +545,7 @@
assertEquals("Did not expect the resultset to be updated", oldValue, rs.getInt(2));
rs.close();
+ s.close();
}
/**
@@ -538,18 +556,18 @@
public void testCursorOperationConflictWarning2()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
rs.next();
- con.createStatement().executeUpdate ("delete from t1 where id=" +
+ createStatement().executeUpdate ("delete from t1 where id=" +
rs.getString("ID"));
final int newValue = -3333;
final int oldValue = rs.getInt(2);
- Statement s3 = con.createStatement();
+ Statement s3 = createStatement();
int updateCount = s3.executeUpdate
("update t1 set A=" + newValue +
" where current of " + rs.getCursorName());
@@ -562,7 +580,7 @@
assertEquals("Did not expect the resultset to be updated", oldValue, rs.getInt(2));
assertEquals("Expected update count to be 0", 0, updateCount);
- Statement s4 = con.createStatement();
+ Statement s4 = createStatement();
updateCount = s4.executeUpdate("delete from t1 where current of " +
rs.getCursorName());
@@ -575,6 +593,9 @@
assertEquals("Expected update count to be 0", 0, updateCount);
rs.close();
+ s.close();
+ s3.close();
+ s4.close();
}
/**
@@ -584,7 +605,7 @@
public void testIndexedUpdateCursor1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1 where a=1");
@@ -592,6 +613,7 @@
assertTrue("Expected to get a tuple on rs.next()", rs.next());
verifyTuple(rs);
updateTuple(rs);
+ s.close();
}
@@ -602,7 +624,7 @@
public void testIndexedUpdateCursor2()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs =
@@ -611,6 +633,7 @@
assertTrue("Expected to get a tuple on rs.next()", rs.next());
verifyTuple(rs);
updateTuple(rs);
+ s.close();
}
/**
@@ -622,7 +645,7 @@
* to insert a row without being on insert row.
*/
public void testInsertRowWithScrollCursor() throws SQLException {
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
int currentPosition, lastRow;
@@ -773,7 +796,7 @@
testIndexedScrollInsensitiveUpdateCursorWithoutForUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
@@ -785,6 +808,7 @@
rs.previous();
verifyTuple(rs);
updateTuple(rs);
+ s.close();
}
/**
@@ -795,7 +819,7 @@
testIndexedScrollInsensitiveUpdateCursorWithForUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
@@ -818,7 +842,7 @@
public void testPrimaryKeyUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
@@ -835,7 +859,7 @@
rs.updateRow();
}
}
- PreparedStatement ps = con.prepareStatement
+ PreparedStatement ps = prepareStatement
("select * from t1 where id=?");
for (int i=0; i<recordCount; i++) {
int key = (i%2==0) ? -i : i;
@@ -850,6 +874,8 @@
"however rs2.next returned another row",
!rs2.next());
}
+ s.close();
+ ps.close();
}
/**
@@ -859,7 +885,7 @@
public void testOtherPrimaryKeyUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
@@ -867,7 +893,7 @@
rs.last();
int primaryKey = rs.getInt(1);
- PreparedStatement ps = con.prepareStatement
+ PreparedStatement ps = prepareStatement
("update t1 set id = ? where id= ?");
ps.setInt(1, -primaryKey);
ps.setInt(2, primaryKey);
@@ -878,7 +904,7 @@
rs.updateInt(3, -777);
rs.updateRow();
- PreparedStatement ps2 = con.prepareStatement
+ PreparedStatement ps2 = prepareStatement
("select * from t1 where id=?");
ps2.setInt(1, -primaryKey);
ResultSet rs2 = ps2.executeQuery();
@@ -890,6 +916,11 @@
assertEquals("Expected b=-777", -777, rs2.getInt(3));
assertTrue("Did not expect more than 1 row, however " +
"rs2.next() returned another row", !rs2.next());
+
+
+ s.close();
+ ps.close();
+ ps2.close();
}
/**
@@ -900,7 +931,7 @@
public void testOtherAndOwnPrimaryKeyUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
@@ -908,7 +939,7 @@
rs.last();
int primaryKey = rs.getInt(1);
- PreparedStatement ps = con.prepareStatement
+ PreparedStatement ps = prepareStatement
("update t1 set id = ? where id= ?");
ps.setInt(1, -primaryKey);
ps.setInt(2, primaryKey);
@@ -920,7 +951,7 @@
rs.updateRow();
PreparedStatement ps2 =
- con.prepareStatement("select * from t1 where id=?");
+ prepareStatement("select * from t1 where id=?");
ps2.setInt(1, primaryKey*10);
ResultSet rs2 = ps2.executeQuery();
assertTrue("Expected query to have 1 row", rs2.next());
@@ -931,6 +962,10 @@
assertEquals("Expected b=-777", -777, rs2.getInt(3));
assertTrue("Did not expect more than 1 row, however " +
"rs2.next() returned another row", !rs2.next());
+
+ s.close();
+ ps.close();
+ ps2.close();
}
/**
@@ -939,7 +974,7 @@
public void testMultipleKeyUpdates()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
@@ -947,7 +982,7 @@
rs.last();
int primaryKey = rs.getInt(1);
- PreparedStatement ps = con.prepareStatement
+ PreparedStatement ps = s.getConnection().prepareStatement
("update t1 set id = ? where id= ?");
ps.setInt(1, -primaryKey);
ps.setInt(2, primaryKey);
@@ -969,6 +1004,8 @@
rs.updateInt(3, (-777 -i));
rs.updateRow();
}
+ rs.close();
+ s.close();
}
/**
@@ -978,7 +1015,7 @@
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
@@ -992,7 +1029,7 @@
rs.updateInt(2, newKey--);
rs.updateRow();
}
- PreparedStatement ps = con.prepareStatement
+ PreparedStatement ps = prepareStatement
("select * from t1 where a=?");
for (int i=0; i<recordCount; i++) {
int key = -i;
@@ -1007,6 +1044,9 @@
"however rs2.next returned another row",
!rs2.next());
}
+
+ s.close();
+ ps.close();
}
/**
@@ -1016,7 +1056,7 @@
public void testOtherSecondaryKeyUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
@@ -1025,7 +1065,7 @@
rs.last();
int indexedKey = rs.getInt(2);
PreparedStatement ps =
- con.prepareStatement("update t1 set a = ? where a= ?");
+ prepareStatement("update t1 set a = ? where a= ?");
ps.setInt(1, -indexedKey);
ps.setInt(2, indexedKey);
assertEquals("Expected one row to be updated", 1,
@@ -1036,7 +1076,7 @@
rs.updateRow();
PreparedStatement ps2 =
- con.prepareStatement("select * from t1 where a=?");
+ prepareStatement("select * from t1 where a=?");
ps2.setInt(1, -indexedKey);
ResultSet rs2 = ps2.executeQuery();
assertTrue("Expected query to have 1 row", rs2.next());
@@ -1047,6 +1087,10 @@
assertEquals("Expected b=-777", -777, rs2.getInt(3));
assertTrue("Did not expect more than 1 row, however " +
"rs2.next() returned another row", !rs2.next());
+
+ s.close();
+ ps.close();
+ ps2.close();
}
/**
@@ -1055,7 +1099,7 @@
public void testScrollInsensitiveReadOnly1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
s.setCursorName(getNextCursorName());
@@ -1064,6 +1108,7 @@
scrollForward(rs);
scrollBackward(rs);
rs.close();
+ s.close();
}
/**
@@ -1072,13 +1117,14 @@
public void testForwardOnlyConcurUpdatableWithForUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1 for update");
scrollForwardAndUpdate(rs);
rs.close();
+ s.close();
}
/**
@@ -1087,13 +1133,14 @@
public void testForwardOnlyConcurUpdatableWithoutForUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
scrollForwardAndUpdate(rs);
rs.close();
+ s.close();
}
/**
@@ -1103,13 +1150,14 @@
public void testPositionedUpdateWithoutForUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
s.setCursorName("MYCURSOR");
ResultSet rs = s.executeQuery("select * from t1");
scrollForwardAndUpdatePositioned(rs);
rs.close();
+ s.close();
}
/**
@@ -1119,12 +1167,13 @@
public void testPositionedUpdateWithForUpdate1()
throws SQLException
{
- Statement s = con.createStatement();
+ Statement s = createStatement();
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1 for update");
scrollForwardAndUpdatePositioned(rs);
rs.close();
+ s.close();
}
/**
@@ -1133,7 +1182,7 @@
public void testScrollablePositionedUpdateWithForUpdate1()
throws SQLException
{
- Statement s = con.createStatement
+ Statement s = createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
s.setCursorName("MYCURSOR");
@@ -1152,7 +1201,7 @@
final int previousA = rs.getInt(2);
final int previousB = rs.getInt(3);
println(rs.getCursorName());
- PreparedStatement ps = con.prepareStatement
+ PreparedStatement ps = prepareStatement
("update T1 set a=?,b=? where current of " + rs.getCursorName());
ps.setInt(1, 666);
ps.setInt(2, 777);
@@ -1181,7 +1230,9 @@
"," + rs.getInt(3) + "," + rs.getString(4)+ ")");
}
}
-
+
+ s.close();
+ ps.close();
}
/**
@@ -1191,12 +1242,13 @@
public void testScrollInsensitiveConcurUpdatableWithForUpdate1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1 for update");
scrollForwardAndUpdate(rs);
rs.close();
+ s.close();
}
/**
@@ -1206,7 +1258,7 @@
public void testScrollInsensitiveConcurUpdatableWithForUpdate2()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
assertEquals("Invalid resultset concurrency on statement",
ResultSet.CONCUR_UPDATABLE, s.getResultSetConcurrency());
@@ -1218,6 +1270,7 @@
scrollForward(rs);
scrollBackwardAndUpdate(rs);
rs.close();
+ s.close();
}
/**
@@ -1256,7 +1309,7 @@
assertEquals("Incorrect row updated for row " + count, 1000, a);
}
rs.close();
- Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
s.setCursorName(getNextCursorName());
rs = s.executeQuery("select * from t1");
@@ -1267,6 +1320,7 @@
int b = rs.getInt(3);
println("Updated tuple:" + id + "," + a + "," + b);
}
+ s.close();
}
/**
@@ -1277,12 +1331,13 @@
public void testScrollInsensitiveConcurUpdatableWithForUpdate3()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select a,b from t1 for update");
testScrollInsensistiveConurUpdatable3(rs);
+ s.close();
}
/**
@@ -1292,13 +1347,14 @@
public void testScrollInsensitiveConcurUpdatableWithoutForUpdate1()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
scrollForwardAndUpdate(rs);
rs.close();
+ s.close();
}
/**
@@ -1308,7 +1364,7 @@
public void testScrollInsensitiveConcurUpdatableWithoutForUpdate2()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select * from t1");
@@ -1316,6 +1372,7 @@
scrollForward(rs);
scrollBackwardAndUpdate(rs);
rs.close();
+ s.close();
}
/**
@@ -1326,12 +1383,13 @@
public void testScrollInsensitiveConcurUpdatableWithoutForUpdate3()
throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select a,b from t1");
testScrollInsensistiveConurUpdatable3(rs);
+ s.close();
}
/**
@@ -1383,7 +1441,7 @@
* and deleteRow() methods.
*/
public void testRowUpdatedAndRowDeleted() throws SQLException {
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
s.setCursorName(getNextCursorName());
ResultSet rs = s.executeQuery("select a,b from t1");
@@ -1414,7 +1472,7 @@
*/
public void testDetectabilityExceptions() throws SQLException
{
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = s.executeQuery("select * from t1");
@@ -1447,7 +1505,7 @@
s.close();
// Not strictly SUR, but fixed in same patch, so we test it here.
- s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
rs = s.executeQuery("select * from t1");
@@ -1486,7 +1544,7 @@
*
*/
public void testDowngradeToScrollReadOnly() throws SQLException {
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = s.executeQuery("select * from t1 order by b");
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ScrollResultSetTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ScrollResultSetTest.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ScrollResultSetTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ScrollResultSetTest.java Fri Aug 18 11:54:23 2006
@@ -19,9 +19,10 @@
*/
package org.apache.derbyTesting.functionTests.tests.jdbcapi;
-import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
-import org.apache.derbyTesting.functionTests.util.JDBC;
import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+
import junit.framework.*;
import java.sql.*;
@@ -64,7 +65,7 @@
* Set up the connection to the database.
*/
public void setUp() throws Exception {
- con = getConnection();
+ Connection con = getXConnection();
con.setAutoCommit(true);
String createTableWithPK = "CREATE TABLE tableWithPK (" +
@@ -76,6 +77,7 @@
stmt.execute(createTableWithPK);
stmt.execute(insertData);
+ stmt.close();
}
/**
@@ -83,13 +85,16 @@
*/
public void tearDown() throws Exception {
println("TearDown");
+ Statement s = getXConnection().createStatement();
try {
- con.createStatement().executeUpdate("DROP TABLE tableWithPK");
- con.commit();
- con.close();
- } catch (SQLException e) {
+
+ s.executeUpdate("DROP TABLE tableWithPK");
+ } catch (SQLException e) {
printStackTrace(e);
- }
+ }
+ s.close();
+ super.tearDown();
+
}
/**
@@ -98,6 +103,7 @@
*/
public void testNextOnLastRowForwardOnly() throws SQLException{
+ Connection con = getXConnection();
con.setAutoCommit(true);
con.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);
Statement roStmt = con.createStatement(
@@ -130,6 +136,7 @@
*/
public void testNextOnLastRowScrollable() throws SQLException{
+ Connection con = getXConnection();
con.setAutoCommit(true);
con.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);
Statement roStmt = con.createStatement(
@@ -149,8 +156,5 @@
rs.close();
}
-
- /* Connection established in setUp() */
- protected Connection con = null;
}
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.java Fri Aug 18 11:54:23 2006
@@ -21,6 +21,7 @@
package org.apache.derbyTesting.functionTests.tests.jdbcapi;
+import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
@@ -32,12 +33,11 @@
import java.util.Collections;
import org.apache.derby.tools.ij;
-import org.apache.derby.iapi.reference.SQLState;
/**
* Functional test for the Statement.setQueryTimeout() method.
*
- * This test consists of three parts:
+ * This test consists of four parts:
*
* 1. Executes a SELECT query in 4 different threads concurrently.
* The query calls a user-defined, server-side function which
@@ -71,6 +71,8 @@
* 3. Sets an invalid (negative) timeout. Verifies that the correct
* exception is thrown.
*
+ * 4. Tests that the query timeout value is not forgotten after the execution
+ * of a statement (DERBY-1692).
*/
public class SetQueryTimeoutTest
{
@@ -190,7 +192,7 @@
TestFailedException
{
Collection ignore = new HashSet();
- ignore.add(SQLState.LANG_OBJECT_DOES_NOT_EXIST.substring(0,5));
+ ignore.add("42Y55");
exec(conn, "drop table " + tablePrefix + "_orig", ignore);
exec(conn, "drop table " + tablePrefix + "_copy", ignore);
@@ -393,7 +395,7 @@
throw new TestFailedException(failMsg);
} else {
String sqlState = sqlException.getSQLState();
- if (!expectSqlState.startsWith(sqlState)) {
+ if (!expectSqlState.equals(sqlState)) {
throw new TestFailedException(sqlException);
}
}
@@ -475,7 +477,7 @@
* in this class (note that the TIMEOUT constant is in seconds,
* while the execution time is in milliseconds).
*/
- expectException(SQLState.LANG_STATEMENT_CANCELLED_OR_TIMED_OUT,
+ expectException("XCL52",
statementExecutor[0].getSQLException(),
"fetch did not time out. Highest execution time: "
+ statementExecutor[0].getHighestRunTime() + " ms");
@@ -568,7 +570,7 @@
? TIMEOUT
: 0;
if (timeout > 0) {
- expectException(SQLState.LANG_STATEMENT_CANCELLED_OR_TIMED_OUT,
+ expectException("XCL52",
executors[i].getSQLException(),
"exec did not time out. Execution time: "
+ executors[i].getHighestRunTime() + " ms");
@@ -615,7 +617,7 @@
try {
stmt.setQueryTimeout(-1);
} catch (SQLException e) {
- expectException(SQLState.INVALID_QUERYTIMEOUT_VALUE, e,
+ expectException("XJ074", e,
"negative timeout value should give exception");
}
@@ -643,6 +645,63 @@
}
}
+ /** Test for DERBY-1692. */
+ private static void testRememberTimeoutValue(Connection conn)
+ throws TestFailedException
+ {
+ String sql = getFetchQuery("t");
+ try {
+ Statement stmt = conn.createStatement();
+ testStatementRemembersTimeout(stmt);
+ PreparedStatement ps = conn.prepareStatement(sql);
+ testStatementRemembersTimeout(ps);
+ CallableStatement cs = conn.prepareCall(sql);
+ testStatementRemembersTimeout(cs);
+ } catch (SQLException sqle) {
+ throw new TestFailedException("Should not happen", sqle);
+ }
+ }
+
+ /** Test that a statement remembers its timeout value when executed
+ * multiple times. */
+ private static void testStatementRemembersTimeout(Statement stmt)
+ throws SQLException, TestFailedException
+ {
+ System.out.println("Testing that Statement remembers timeout.");
+ stmt.setQueryTimeout(1);
+ for (int i = 0; i < 3; i++) {
+ try {
+ ResultSet rs = stmt.executeQuery(getFetchQuery("t"));
+ while (rs.next());
+ throw new TestFailedException("Should have timed out.");
+ } catch (SQLException sqle) {
+ expectException("XCL52", sqle, "Should have timed out.");
+ }
+ }
+ stmt.close();
+ }
+
+ /** Test that a prepared statement remembers its timeout value when
+ * executed multiple times. */
+ private static void testStatementRemembersTimeout(PreparedStatement ps)
+ throws SQLException, TestFailedException
+ {
+ String name = (ps instanceof CallableStatement) ?
+ "CallableStatement" : "PreparedStatement";
+ System.out.println("Testing that " + name + " remembers timeout.");
+ ps.setQueryTimeout(1);
+ for (int i = 0; i < 3; i++) {
+ try {
+ ResultSet rs = ps.executeQuery();
+ while (rs.next());
+ throw new TestFailedException("Should have timed out.");
+ } catch (SQLException sqle) {
+ expectException("XCL52", sqle, "Should have timed out.");
+ }
+ }
+ ps.close();
+ }
+
/**
* Main program, makes this class invocable from the command line
*/
@@ -654,7 +713,7 @@
/**
* The actual main bulk of this test.
* Sets up the environment, prepares tables,
- * runs part 1 and 2, and shuts down.
+ * runs the tests, and shuts down.
*/
public void go(String[] args)
{
@@ -684,6 +743,7 @@
testTimeoutWithFetch(connections[0], connections[1]);
testTimeoutWithExec(connections);
testInvalidTimeoutValue(connections[0]);
+ testRememberTimeoutValue(connections[0]);
System.out.println("Test SetQueryTimeoutTest PASSED");
} catch (Throwable e) {
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/URCoveringIndexTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/URCoveringIndexTest.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/URCoveringIndexTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/URCoveringIndexTest.java Fri Aug 18 11:54:23 2006
@@ -19,7 +19,9 @@
*/
package org.apache.derbyTesting.functionTests.tests.jdbcapi;
import org.apache.derbyTesting.functionTests.util.TestUtil;
-import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+
import junit.framework.*;
import java.sql.*;
@@ -42,7 +44,7 @@
* Set up the connection to the database.
*/
public void setUp() throws Exception {
- con = getConnection();
+ Connection con = getXConnection();
con.setAutoCommit(false);
String createTableWithPK = "CREATE TABLE tableWithPK (" +
@@ -53,19 +55,8 @@
stmt.execute(createTableWithPK);
stmt.execute(insertData);
- }
-
- /**
- * Rollback the transaction
- */
- public void tearDown() throws Exception {
- println("TearDown");
- try {
- con.rollback();
- con.close();
- } catch (SQLException e) {
- printStackTrace(e);
- }
+
+ stmt.close();
}
private void testUpdateUpdatedTupleWithCoveringIndex(
@@ -76,6 +67,8 @@
int resultsetType = scroll ? ResultSet.TYPE_SCROLL_INSENSITIVE :
ResultSet.TYPE_FORWARD_ONLY;
+ Connection con = getXConnection();
+
if (!(con.getMetaData().supportsResultSetConcurrency(resultsetType,
ResultSet.CONCUR_UPDATABLE))) {
return;
@@ -146,8 +139,4 @@
public void testUpdateUpdatedTupleFOUpdateRow() throws SQLException{
testUpdateUpdatedTupleWithCoveringIndex(false, false);
}
-
-
- protected Connection con = null; // Connection established in setUp()
-
}
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/UpdateXXXTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/UpdateXXXTest.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/UpdateXXXTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/UpdateXXXTest.java Fri Aug 18 11:54:23 2006
@@ -19,8 +19,8 @@
*/
package org.apache.derbyTesting.functionTests.tests.jdbcapi;
-import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
-import org.apache.derbyTesting.functionTests.util.JDBC;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBC;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -57,18 +57,11 @@
if (usingDerbyNet())
return suite;
- suite.addTest(new UpdateXXXTest("testUpdateShort"));
- suite.addTest(new UpdateXXXTest("testUpdateInt"));
- suite.addTest(new UpdateXXXTest("testUpdateLong"));
- suite.addTest(new UpdateXXXTest("testUpdateFloat"));
- suite.addTest(new UpdateXXXTest("testUpdateDouble"));
- suite.addTest(new UpdateXXXTest("testUpdateNull"));
- suite.addTest(new UpdateXXXTest("testUpdateObjectWithNull"));
- suite.addTest(new UpdateXXXTest("testUpdateString"));
+ suite.addTestSuite(UpdateXXXTest.class);
// requires java.math.BigDecimal
if (JDBC.vmSupportsJDBC2())
- suite.addTest(new UpdateXXXTest("testUpdateBigDecimal"));
+ suite.addTest(new UpdateXXXTest("jdbc2testUpdateBigDecimal"));
return suite;
}
@@ -83,8 +76,9 @@
public void setUp()
throws Exception
{
+ Connection con = getXConnection();
try {
- con = getConnection();
+
con.setAutoCommit(false);
Statement stmt = con.createStatement();
@@ -129,22 +123,6 @@
throw e;
}
}
-
- /**
- * Teardown test.
- * Rollback connection and close it.
- * @exception Exceptions causes the test to fail with error
- */
- public void tearDown()
- throws Exception
- {
- try {
- con.rollback();
- con.close();
- } catch (SQLException e) {
- printStackTrace(e);
- }
- }
/**
* Tests calling updateString on all columns of the row.
@@ -254,7 +232,7 @@
* @exception SQLException database access error. Causes test to
* fail with an error.
*/
- public void testUpdateBigDecimal()
+ public void jdbc2testUpdateBigDecimal()
throws SQLException
{
for (int i = 1; i <= COLUMNS; i++) {
@@ -317,7 +295,7 @@
{
rs.close();
- rs = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ rs = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY).
executeQuery(SELECT_STMT);
@@ -343,7 +321,7 @@
{
rs.close();
- rs = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ rs = createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY).
executeQuery(SELECT_STMT);
@@ -363,9 +341,6 @@
/* Updatable ResultSet */
private ResultSet rs = null;
-
- /* Connection */
- private Connection con = null;
/* Table name */
private static final String TABLE_NAME = "MultiTypeTable";
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java Fri Aug 18 11:54:23 2006
@@ -21,8 +21,8 @@
*/
package org.apache.derbyTesting.functionTests.tests.jdbcapi;
-import org.apache.derbyTesting.functionTests.util.BaseTestCase;
-import org.apache.derbyTesting.functionTests.util.JDBC;
+import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.JDBC;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -52,6 +52,8 @@
suite.addTest(SURTest.suite());
suite.addTest(UpdateXXXTest.suite());
suite.addTestSuite(URCoveringIndexTest.class);
+ suite.addTest(ResultSetCloseTest.suite());
+ suite.addTest(DataSourcePropertiesTest.suite());
// Tests that are compiled using 1.4 target need to
// be added this way, otherwise creating the suite
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java Fri Aug 18 11:54:23 2006
@@ -21,8 +21,8 @@
package org.apache.derbyTesting.functionTests.tests.junitTests.derbyNet;
-import org.apache.derbyTesting.functionTests.util.BaseTestCase;
import org.apache.derbyTesting.functionTests.tests.derbynet.SuicideOfStreaming;
+import org.apache.derbyTesting.junit.BaseTestCase;
import org.apache.derby.iapi.services.sanity.SanityManager;
import junit.framework.Test;
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java Fri Aug 18 11:54:23 2006
@@ -22,8 +22,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.derbyTesting.functionTests.util.CleanDatabaseTestSetup;
import org.apache.derbyTesting.functionTests.util.ScriptTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
public final class LangScripts extends ScriptTestCase {
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java Fri Aug 18 11:54:23 2006
@@ -21,8 +21,8 @@
package org.apache.derbyTesting.functionTests.tests.lang;
-import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
-import org.apache.derbyTesting.functionTests.util.JDBC;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBC;
import java.sql.*;
@@ -37,7 +37,6 @@
*/
public class PrepareExecuteDDL extends BaseJDBCTestCase {
- private Connection conn;
private Connection connDDL;
/**
@@ -53,6 +52,10 @@
{
"SELECT * FROM PED001",
"SELECT A, B FROM PED001",
+ "GRANT SELECT ON PED001 TO U_PED_001",
+ "GRANT SELECT(A,B) ON PED001 TO U_PED_001",
+ "REVOKE SELECT(A,B) ON PED001 FROM U_PED_001",
+ "REVOKE SELECT ON PED001 FROM U_PED_001",
};
/**
@@ -85,8 +88,15 @@
this.ddl = ddl;
}
+ private boolean tableDropped()
+ {
+ return ddl.startsWith("DROP TABLE ");
+ }
+
public void testPrepareExcute() throws SQLException
{
+ Connection conn = getXConnection();
+
PreparedStatement[] psa= new PreparedStatement[STMTS.length];
for (int i = 0; i < STMTS.length; i++)
{
@@ -101,6 +111,13 @@
String sql = STMTS[i];
if (sql.startsWith("SELECT "))
checkSelect(psa[i], sql);
+ else if (sql.startsWith("GRANT ")
+ || sql.startsWith("REVOKE "))
+ checkGrantRevoke(psa[i], sql);
+ else
+ fail("unknown SQL" + sql);
+
+ psa[i].close();
}
}
@@ -116,6 +133,7 @@
//TODO: Use DMD to see if table exists or not.
assertSQLState("42X05", e);
+ assertTrue(tableDropped());
return;
}
@@ -134,38 +152,53 @@
JDBC.assertDrainResults(rs);
}
+
+ private void checkGrantRevoke(PreparedStatement ps, String sql)
+ throws SQLException
+ {
+ assertEquals(true, sql.startsWith("GRANT ")
+ || sql.startsWith("REVOKE "));
+
+ try {
+ assertFalse(ps.execute());
+ } catch (SQLException e) {
+
+ assertSQLState("42X05", e);
+ assertTrue(tableDropped());
+
+ return;
+ }
+ }
/**
* Set the fixture up with a clean, standard table PED001.
*/
protected void setUp() throws SQLException
{
- connDDL = getConnection();
+ connDDL = openDefaultConnection();
Statement s = connDDL.createStatement();
s.execute(
"CREATE TABLE PED001 (A INT NOT NULL, B DECIMAL(6,4), C VARCHAR(20))");
s.close();
-
- conn = getConnection();
}
/**
* Tear-down the fixture by removing the table (if it still
* exists).
*/
- protected void tearDown() throws SQLException
+ protected void tearDown() throws Exception
{
- Statement s = conn.createStatement();
+ Statement s = connDDL.createStatement();
try {
s.execute("DROP TABLE PED001");
} catch (SQLException e) {
assertSQLState("42Y55", e);
}
s.close();
- JDBC.cleanup(conn);
JDBC.cleanup(connDDL);
+ super.tearDown();
}
}
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml Fri Aug 18 11:54:23 2006
@@ -58,14 +58,14 @@
<!-- ============ Begin Targets ============== -->
- <target name="FTOtestsubdir" depends="compilet3,compilet2,compilet1,copyfiles"/>
+ <target name="FTOtestsubdir" depends="compilett4,copyfiles"/>
<!-- mkdir / init target may not be necessary, just here for reference... -->
<target name="init">
<mkdir dir="${out.dir}/${derby.testing.functest.dir}/tests/lang"/>
</target>
- <target name="compilet1" depends="compilet2">
+ <target name="compilet1" >
<javac
source="1.3"
target="1.3"
@@ -93,9 +93,10 @@
<exclude name="${this.dir}/procedureJdbc30.java"/>
<exclude name="${this.dir}/SpillHash.java"/>
<exclude name="${this.dir}/unaryArithmeticDynamicParameter.java"/>
+ <exclude name="${this.dir}/_Suite.java"/>
</javac>
</target>
- <target name="compilet2" depends="compilet3">
+ <target name="compilet2" depends="compilet1">
<javac
source="1.3"
target="1.3"
@@ -112,7 +113,6 @@
<classpath>
<pathelement path="${java14compile.classpath}"/>
</classpath>
- <exclude name="${this.dir}/declareGlobalTempTableJavaJDBC30.java"/>
<include name="${this.dir}/holdCursorJavaReflection.java"/>
<include name="${this.dir}/holdCursorJava.java"/>
<include name="${this.dir}/streams.java"/>
@@ -122,7 +122,7 @@
<include name="${this.dir}/unaryArithmeticDynamicParameter.java"/>
</javac>
</target>
- <target name="compilet3">
+ <target name="compilet3" depends="compilet2">
<javac
source="1.4"
target="1.4"
@@ -142,7 +142,31 @@
<include name="${this.dir}/declareGlobalTempTableJavaJDBC30.java"/>
</javac>
</target>
+ <!-- Compile _Suite last as it needs to include all other JUnit classes
+ which may be compiled using a higher compiler level, but it needs to be at
+ base level -->
+ <target name="compilett4" depends="compilet3" >
+ <javac
+ source="1.3"
+ target="1.3"
+ bootclasspath="${empty}"
+ nowarn="on"
+ debug="${debug}"
+ depend="${depend}"
+ deprecation="${deprecation}"
+ optimize="${optimize}"
+ proceed="${proceed}"
+ verbose="${verbose}"
+ srcdir="${derby.testing.src.dir}"
+ destdir="${out.dir}">
+ <classpath>
+ <pathelement path="${compile.classpath}"/>
+ <pathelement path="${junit}"/>
+ </classpath>
+ <include name="${this.dir}/_Suite.java"/>
+ </javac>
+ </target>
<target name="copyfiles">
<copy todir="${out.dir}/${derby.testing.functest.dir}/tests/lang">
<fileset dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/lang"
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java Fri Aug 18 11:54:23 2006
@@ -22,8 +22,8 @@
package org.apache.derbyTesting.functionTests.tests.perf;
-import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
import org.apache.derbyTesting.functionTests.util.JarUtil;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import java.sql.*;
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java Fri Aug 18 11:54:23 2006
@@ -22,7 +22,7 @@
package org.apache.derbyTesting.functionTests.tests.perf;
-import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import java.sql.*;
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java Fri Aug 18 11:54:23 2006
@@ -21,8 +21,8 @@
package org.apache.derbyTesting.functionTests.tests.store;
-import org.apache.derbyTesting.functionTests.util.BaseTestCase;
import org.apache.derbyTesting.functionTests.util.TestUtil;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import junit.framework.*;
import java.sql.*;
@@ -35,7 +35,7 @@
* DERBY-1296 - Setting property derby.system.bootAll causes an Exception
*
*/
-public class BootAllTest extends BaseTestCase {
+public class BootAllTest extends BaseJDBCTestCase {
/** JDBC Connection */
private Connection con;
@@ -57,11 +57,10 @@
*/
public void setUp() throws Exception {
for (int i = 0; i < databases.length; i++) {
- con = CONFIG.getConnection(databases[i]);
+ con = openConnection(databases[i]);
con.close();
try {
- con = CONFIG.
- getConnection(databases[i] + ";shutdown=true");
+ con = openConnection(databases[i] + ";shutdown=true");
} catch (SQLException se) {
assertEquals("Expected exception on setUp " + se.getSQLState(),
DATABASE_SHUT_DOWN, se.getSQLState());
@@ -88,8 +87,7 @@
Class.forName(driverName);
println("Teardown of: " + getName());
try {
- con = CONFIG.
- getConnection(";shutdown=true");
+ con = openConnection(";shutdown=true");
} catch (SQLException se) {
assertEquals("Expected exception on tearDown " + se.getSQLState(),
ALL_DATABASES_SHUT_DOWN, se.getSQLState());
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java Fri Aug 18 11:54:23 2006
@@ -30,7 +30,7 @@
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import org.apache.derby.tools.sysinfo;
-import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
/**
* Test all the static public methods of the sysinfo class.
@@ -38,7 +38,6 @@
public class sysinfo_api extends BaseJDBCTestCase {
- Connection c;
DatabaseMetaData dm;
public sysinfo_api(String name) {
@@ -139,13 +138,9 @@
* with sysinfo
*/
public void setUp() throws SQLException {
- c = getConnection();
- dm = c.getMetaData();
+ dm = getXConnection().getMetaData();
}
- public void tearDown() throws SQLException {
- c.close();
- }
}
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java Fri Aug 18 11:54:23 2006
@@ -29,6 +29,8 @@
import java.net.URL;
import java.sql.Connection;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+
import junit.framework.Test;
/**
@@ -40,11 +42,6 @@
private final String inputEncoding;
private final String outputEncoding = "US-ASCII";
-
- /**
- * Default connection.
- */
- private Connection conn;
/**
* Create a ScriptTestCase to run a single test
@@ -118,7 +115,7 @@
PrintStream printOut = new PrintStream(rawBytes);
- conn = getConnection();
+ Connection conn = getXConnection();
org.apache.derby.tools.ij.runScript(
conn,
sqlIn,
@@ -183,14 +180,5 @@
outFile.close();
throw t;
}
- }
-
- /**
- * Clean up the connection on teardown.
- */
- protected void tearDown() throws Exception
- {
- JDBC.cleanup(conn);
- super.tearDown();
}
}
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/TestDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/TestDataSourceFactory.java?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/TestDataSourceFactory.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/TestDataSourceFactory.java Fri Aug 18 11:54:23 2006
@@ -27,6 +27,8 @@
import javax.sql.ConnectionPoolDataSource;
import javax.sql.XADataSource;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
/**
* Utility class for JDBC JUnit tests.
* Contains methods to obtain the various datasources.
Modified: db/derby/code/branches/10.2/tools/ant/properties/dirs.properties
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/tools/ant/properties/dirs.properties?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/tools/ant/properties/dirs.properties (original)
+++ db/derby/code/branches/10.2/tools/ant/properties/dirs.properties Fri Aug 18 11:54:23 2006
@@ -60,4 +60,5 @@
derby.testing.out.dir=${out.dir}/${derby.testing.dir}
derby.testing.functest.dir=${derby.testing.dir}/functionTests
derby.testing.unittest.dir=${derby.testing.dir}/unitTests
+derby.testing.junit.dir=${derby.testing.dir}/junit
derby.testing.suites.dir=${derby.testing.functest.dir}/suites
Modified: db/derby/code/branches/10.2/tools/release/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/tools/release/build.xml?rev=432679&r1=432678&r2=432679&view=diff
==============================================================================
--- db/derby/code/branches/10.2/tools/release/build.xml (original)
+++ db/derby/code/branches/10.2/tools/release/build.xml Fri Aug 18 11:54:23 2006
@@ -74,6 +74,8 @@
<!-- top-level -->
<zipfileset dir="${crlf.dir}" includes="CHANGES,COPYRIGHT,LICENSE,KEYS,NOTICE"
prefix="${derby.bin}/"/>
+ <!-- bin -->
+ <zipfileset dir="${basedir}/bin" prefix="${derby.bin}/bin" includes="*"/>
<!-- demo -->
<zipfileset dir="${derby.demo.src.dir}" prefix="${derby.bin}/demo/programs"
excludes="**/build.xml,toursdb/toursdb**,toursdb/derby.log"/>
@@ -118,6 +120,8 @@
<!-- top-level -->
<tarfileset dir="${lf.dir}" includes="CHANGES,COPYRIGHT,LICENSE,KEYS,NOTICE"
prefix="${derby.bin}/"/>
+ <!-- bin -->
+ <tarfileset dir="${basedir}/bin" prefix="${derby.bin}/bin" includes="*"/>
<!-- demo -->
<tarfileset dir="${derby.demo.src.dir}" prefix="${derby.bin}/demo/programs"
excludes="**/build.xml,toursdb/toursdb**,toursdb/derby.log"/>