db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r507208 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CursorTest.java
Date Tue, 13 Feb 2007 20:42:18 GMT
Author: kmarsden
Date: Tue Feb 13 12:42:17 2007
New Revision: 507208

URL: http://svn.apache.org/viewvc?view=rev&rev=507208
Log:
DERBY-2299 enable for client and reformat tabs to spaces

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=507208&r1=507207&r2=507208
==============================================================================
--- 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
Tue Feb 13 12:42:17 2007
@@ -23,12 +23,12 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.sql.Connection;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import org.apache.derbyTesting.junit.BaseJDBCTestCase;
-
 
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * Tests cursors
@@ -37,132 +37,156 @@
 
     /**
      * Creates a new <code>CursorTest</code> instance.
-     *
-     * @param name name of the test
+     * 
+     * @param name
+     *            name of the test
      */
     public CursorTest(String name) {
         super(name);
     }
-    
 
-   /**
-    * Test cursor methods with regular cursor 
-    * @throws SQLException
-   */
-  public void testCursor() throws SQLException {
-		PreparedStatement select;
-		ResultSet cursor;
-	
-		
-		// because there is no order by (nor can there be)
-		// the fact that this test prints out rows may someday
-		// be a problem.  When that day comes, the row printing
-		// can (should) be removed from this test.
-
-		select = prepareStatement("select i, c from t for update");
-		cursor = select.executeQuery(); // cursor is now open
-		cursor.next();
-		assertEquals(1956, cursor.getInt(1));
-		assertEquals("hello world", cursor.getString(2).trim());
-		// close and then test that fetch causes an error
-		cursor.close();
-		assertNextError("XCL16", cursor);
-		//restart the query for another test
-		cursor = select.executeQuery();
-		// test next/getInt past the end of table
-		while (cursor.next());
-		cursor.next();
-		assertGetIntError(1, "24000",cursor); 
-  }
-  
-   
-  /**
-  * Test cursor methods with parameter
-  * @throws SQLException
-  */
-   public void testCursorParam() throws SQLException{
-	   PreparedStatement select;
-	   ResultSet cursor;
-	   select = prepareStatement("select i, c from t where ?=1 for update");
-       select.setInt(1,1);
-       cursor = select.executeQuery();
-       //TEST: fetch of a row works
-       assertTrue("FAIL: unable to fetch row.",cursor.next());
-       assertEquals("FAIL: Wrong row on fetch with param", 1956,cursor.getInt(1));
-      // TEST: Close and then fetch gets an error on fetch.
-       cursor.close();
-       assertNextError("XCL16", cursor);
-		// restart the query for another test
-		select.setBoolean(1,false);
-		select.setCursorName("ForCoverageSake");
-		cursor = select.executeQuery();
-		assertEquals(cursor.getCursorName(),"ForCoverageSake");
-		cursor.next();
-		assertGetIntError(1,"24000", cursor);
-   }
-
-   
-   
-  /**
-   * Test getCursorName with and without update cursor
-   * @throws SQLException
-   */
-   public void  testGetCursorName()throws SQLException {
-	  Statement s = createStatement();
-	  ResultSet rs = s.executeQuery("select * from t");
-	  assertNull(rs.getCursorName());
-	  rs.close();
-	  
-	  // test Automatic naming of cursor for update
-	  rs = s.executeQuery("select * from t for update");
-	  assertEquals("SQLCUR0",rs.getCursorName());
-	  rs.close();
-	  
-	  rs = s.executeQuery("select * from t for update of i");
-	  assertEquals("SQLCUR1", rs.getCursorName());
-	  rs.close();
-	  
-	  s.setCursorName("myselect");
-	  rs = s.executeQuery("select * from t");
-	  assertEquals("myselect", rs.getCursorName());
-	  rs.close();
-	  
-	  s.setCursorName("myselect2");
-	  rs = s.executeQuery("select * from t for update");
-	  assertEquals("myselect2",rs.getCursorName());
-	
-	  s.setCursorName("myselect3");
-	  rs = s.executeQuery("select * from t for update of i");
-	  rs.close();
-	  s.close();
-   }
-   public static Test suite() {
-	TestSuite suite = new TestSuite("CursorTestJunit");
-	suite.addTestSuite(CursorTest.class);
-	return suite;
-   }
-
-protected void setUp() throws SQLException {
-	getConnection().setAutoCommit(false);
-	Statement stmt = createStatement();
-	stmt.executeUpdate("create table t (i int, c char(50))");
-	stmt.executeUpdate("create table s (i int, c char(50))");
-	stmt.executeUpdate("insert into t values (1956, 'hello world')");
-	stmt.executeUpdate("insert into t values (456, 'hi yourself')");
-	stmt.executeUpdate("insert into t values (180, 'rubber ducky')");
-	stmt.executeUpdate("insert into t values (3, 'you are the one')");
-
-	stmt.close();
-	commit();
-}
-
-protected void tearDown() throws Exception {
-	Statement stmt = createStatement();
-	stmt.executeUpdate("drop table t");
-	stmt.executeUpdate("drop table s");
-	stmt.close();
-	commit();
-	super.tearDown();
-}
+    /**
+     * Test cursor methods with regular cursor
+     * 
+     * @throws SQLException
+     */
+    public void testCursor() throws SQLException {
+        PreparedStatement select;
+        ResultSet cursor;
+
+        // because there is no order by (nor can there be)
+        // the fact that this test prints out rows may someday
+        // be a problem. When that day comes, the row printing
+        // can (should) be removed from this test.
+
+        select = prepareStatement("select i, c from t for update");
+        cursor = select.executeQuery(); // cursor is now open
+        cursor.next();
+        assertEquals(1956, cursor.getInt(1));
+        assertEquals("hello world", cursor.getString(2).trim());
+        // close and then test that fetch causes an error
+        cursor.close();
+        if (usingEmbedded()) {
+            assertNextError("XCL16", cursor);
+        } else if (usingDerbyNetClient()) {
+            assertNextError("XCL16", cursor);
+        }
+        // restart the query for another test
+        cursor = select.executeQuery();
+        // test next/getInt past the end of table
+        while (cursor.next())
+            ;
+        cursor.next();
+        if (usingEmbedded()) {
+            assertGetIntError(1, "24000", cursor);
+        } else if (usingDerbyNetClient()) {
+            assertGetIntError(1, "XJ121", cursor);
+        }
+        cursor.close();
+        }
+
+    /**
+     * Test cursor methods with parameter
+     * 
+     * @throws SQLException
+     */
+    public void testCursorParam() throws SQLException {
+        PreparedStatement select;
+        ResultSet cursor;
+        select = prepareStatement("select i, c from t where ?=1 for update");
+        select.setInt(1, 1);
+        cursor = select.executeQuery();
+        // TEST: fetch of a row works
+        assertTrue("FAIL: unable to fetch row.", cursor.next());
+        assertEquals("FAIL: Wrong row on fetch with param", 1956, cursor
+                .getInt(1));
+        // TEST: Close and then fetch gets an error on fetch.
+        cursor.close();
+        assertNextError("XCL16", cursor);
+        // restart the query for another test
+        select.setBoolean(1, false);
+        select.setCursorName("ForCoverageSake");
+        cursor = select.executeQuery();
+        assertEquals("ForCoverageSake", cursor.getCursorName());
+        cursor.next();
+        if (usingEmbedded()) {
+            assertGetIntError(1, "24000", cursor);
+        } else if (usingDerbyNetClient()) {
+            assertGetIntError(1, "XJ121", cursor);
+        }
+        cursor.close();
+    }
+
+    /**
+     * Test getCursorName with and without update cursor
+     * 
+     * @throws SQLException
+     */
+    public void testGetCursorName() throws SQLException {
+        Statement s = createStatement();
+        ResultSet rs = s.executeQuery("select * from t");
+        if (usingEmbedded())
+            assertNull(rs.getCursorName());
+        else if (usingDerbyNetClient())
+            assertNotNull(rs.getCursorName());
+        rs.close();
+
+        // test Automatic naming of cursor for update
+        rs = s.executeQuery("select * from t for update");
+        assertNotNull( rs.getCursorName());
+         rs.close();
+        
+        rs = s.executeQuery("select * from t for update of i");
+        assertNotNull(rs.getCursorName());
+        rs.close();
+        
+
+        s.setCursorName("myselect");
+        rs = s.executeQuery("select * from t");
+        assertEquals("myselect", rs.getCursorName());
+        rs.close();
+
+        s.setCursorName("myselect2");
+        rs = s.executeQuery("select * from t for update");
+        assertEquals("myselect2", rs.getCursorName());
+        rs.close();
+        
+        s.setCursorName("myselect3");
+        rs = s.executeQuery("select * from t for update of i");
+        rs.close();
+        s.close();
+    }
+
+    public static Test suite() {
+        //TestSuite suite = new TestSuite("CursorTestJunit");
+        //suite.addTestSuite(CursorTest.class);
+        //return suite;
+         return TestConfiguration.defaultSuite(CursorTest.class);
+
+    }
+
+    protected void setUp() throws SQLException {
+        getConnection().setAutoCommit(false);
+        Statement stmt = createStatement();
+        stmt.executeUpdate("create table t (i int, c char(50))");
+        stmt.executeUpdate("create table s (i int, c char(50))");
+        stmt.executeUpdate("insert into t values (1956, 'hello world')");
+        stmt.executeUpdate("insert into t values (456, 'hi yourself')");
+        stmt.executeUpdate("insert into t values (180, 'rubber ducky')");
+        stmt.executeUpdate("insert into t values (3, 'you are the one')");
+
+        stmt.close();
+        commit();
+    }
+
+    protected void tearDown() throws Exception {
+        Statement stmt = createStatement();
+        rollback();
+        stmt.executeUpdate("drop table t");
+        stmt.executeUpdate("drop table s");
+        stmt.close();
+        commit();
+        super.tearDown();
+    }
 
 }



Mime
View raw message