db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r516075 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CursorTest.java
Date Thu, 08 Mar 2007 15:35:58 GMT
Author: djd
Date: Thu Mar  8 07:35:57 2007
New Revision: 516075

URL: http://svn.apache.org/viewvc?view=rev&rev=516075
Log:
Add a test fixture to CursorTest that tests Statement.setCursorName only effects the next
execution.
Doesn't work on client due to DERBY-2417.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CursorTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CursorTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CursorTest.java?view=diff&rev=516075&r1=516074&r2=516075
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CursorTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CursorTest.java
Thu Mar  8 07:35:57 2007
@@ -153,16 +153,60 @@
         
         s.setCursorName("myselect3");
         rs = s.executeQuery("select * from t for update of i");
+        assertEquals("myselect3", rs.getCursorName());
         rs.close();
         s.close();
     }
+    
+    /**
+     * Test that Statement.setCursorName affects only the next
+     * execution and not any open ResultSet.
+     */
+    public void derby2417testSetCursorNextExecute() throws SQLException
+    {   
+        // Assert setCursorName only affects the next execution.
+        // For statements
+        Statement s = createStatement();
+        ResultSet rs = s.executeQuery("select * from t for update");
+        s.setCursorName("AFTER_EXECUTE");
+        assertFalse("AFTER_EXECUTE".equals(rs.getCursorName()));
+        rs.close();
+        rs = s.executeQuery("select * from t");
+        assertEquals("AFTER_EXECUTE", rs.getCursorName());
+        s.setCursorName("CHANGE_AGAIN");
+        assertEquals("AFTER_EXECUTE", rs.getCursorName());
+        rs.close();
+        rs = s.executeQuery("select * from t");
+        assertEquals("CHANGE_AGAIN", rs.getCursorName());
+        s.close();
+        
+        // And prepared statements
+        PreparedStatement ps = prepareStatement("select * from t for update");
+        rs = ps.executeQuery();
+        ps.setCursorName("AFTER_EXECUTE");
+        assertFalse("AFTER_EXECUTE".equals(rs.getCursorName()));
+        rs.close();
+        rs = ps.executeQuery();
+        assertEquals("AFTER_EXECUTE", rs.getCursorName());
+        ps.setCursorName("CHANGE_AGAIN");
+        assertEquals("AFTER_EXECUTE", rs.getCursorName());
+        rs.close();
+        rs = ps.executeQuery();
+        assertEquals("CHANGE_AGAIN", rs.getCursorName());
+        ps.close();        
+   
+    }
 
     public static Test suite() {
-        //TestSuite suite = new TestSuite("CursorTestJunit");
-        //suite.addTestSuite(CursorTest.class);
-        //return suite;
-         return TestConfiguration.defaultSuite(CursorTest.class);
-
+        TestSuite suite = new TestSuite("CursorTest");
+        
+        suite.addTest(TestConfiguration.defaultSuite(CursorTest.class));
+        
+        // DERBY-2417 client throws exception for setCursorName
+        // on Statement with active ResultSet.
+        suite.addTest(new CursorTest("derby2417testSetCursorNextExecute"));
+        
+        return suite;
     }
 
     protected void setUp() throws SQLException {



Mime
View raw message