db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r554710 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java
Date Mon, 09 Jul 2007 17:03:01 GMT
Author: kmarsden
Date: Mon Jul  9 10:03:00 2007
New Revision: 554710

URL: http://svn.apache.org/viewvc?view=rev&rev=554710
Log:
Reformat LargeDataLocksTest with spaces.  Accidentally committed with mixed tabs/spaces.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java?view=diff&rev=554710&r1=554709&r2=554710
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java
Mon Jul  9 10:03:00 2007
@@ -23,151 +23,141 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.sql.Clob;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.derbyTesting.functionTests.tests.lang.ScrollCursors1Test;
-import org.apache.derbyTesting.functionTests.tests.lang.UpdateCursorTest;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
-import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
-import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
-import org.apache.derbyTesting.junit.Utilities;
 import org.apache.derbyTesting.junit.TestConfiguration;
+import org.apache.derbyTesting.junit.Utilities;
 
 public class LargeDataLocksTest extends BaseJDBCTestCase {
 
-	
     public LargeDataLocksTest(String name) {
         super(name);
     }
-    
-   
- /**
- * Test that ResultSet.getCharacterStream does not hold locks after the
- * ResultSet is closed
- * @throws SQLException
- * @throws IOException
- */
-public void testGetCharacterStream() throws SQLException, IOException {
-	   // getCharacterStream() no locks expected after retrieval
-		int numChars = 0;
-		Statement stmt=createStatement();		
-		String sql = "SELECT bc from t1";
-		// First with getCharacterStream
-		ResultSet rs = stmt.executeQuery(sql);
-		rs.next();
-		java.io.Reader characterStream = rs.getCharacterStream(1);
-		// Extract all the characters
-		int read = characterStream.read();
-		while (read != -1) {
-			read = characterStream.read();
-			numChars ++;
-		}
-		assertEquals(38000,numChars);
-		rs.close();
-		assertEquals(0,countLocks());
-		commit();		
-   }
-  
-/**
- * Verify that getBytes does not hold locks after ResultSet is closed.
- * @throws SQLException
- */
-public void testGetBytes() throws SQLException {
-	// getBytes() no locks expected after retrieval
-	Statement stmt=createStatement();		
-	String sql = "SELECT bincol from t1" ;
-	ResultSet rs = stmt.executeQuery(sql);
-	rs.next();
-	byte[] value = rs.getBytes(1);
-	assertEquals(38000,value.length);
-	rs.close();
-	assertEquals(0,countLocks());
-	commit();
-	
-}
 
- /**
- * Verify that getBinaryStream() does not hold locks after retrieval
- * @throws SQLException
- * @throws IOException 
- */
-public void testGetBinaryStream() throws SQLException, IOException {
-		int numBytes = 0;
-		getConnection().setAutoCommit(false);
-	  Statement stmt=createStatement();		
-		String sql = "SELECT bincol from t1" ;
-		ResultSet rs = stmt.executeQuery(sql);
-		rs.next();
-		InputStream stream = rs.getBinaryStream(1);
-		int read = stream.read();
-		while (read != -1) {
-			read = stream.read();
-			numBytes ++;
-		}
-		assertEquals(38000,numBytes);
-		rs.close();
-		assertEquals(0,countLocks());
-		commit(); 	  
-  }
-  
- /**
- * Test that ResultSet.getString() does not hold locks after the ResultSet is closed
- * @throws SQLException
- * @throws IOException
- */
-public void testGetString() throws SQLException, IOException {
-	   // getString() no locks expected after retrieval
-		Statement stmt=createStatement();		
-		String sql = "SELECT bc from t1" ;
-		ResultSet rs = stmt.executeQuery(sql);
-		rs.next();
-		String value = rs.getString(1);
-		assertEquals(38000,value.length());
-		rs.close();
-		assertEquals(0,countLocks());
-		commit();		
-   }
-   
-   
-   
-   
- /**
-  * Create a new connection and count the number of locks held.
- * @return  number of locks held
- * 
- * @throws SQLException
- */
-public int countLocks() throws SQLException
-   {
-	   		Connection conn = openDefaultConnection();
-			String sql;
-			Statement stmt = conn.createStatement();
-				
-			sql = "Select count(*) from new org.apache.derby.diag.LockTable() as LT";
-			ResultSet lockrs = stmt.executeQuery(sql);
-			lockrs.next();
-			int count = lockrs.getInt(1);
-			lockrs.close();
-			stmt.close();
-			conn.close();
-			return count;
-		}
-   
-	
+    /**
+     * Test that ResultSet.getCharacterStream does not hold locks after the
+     * ResultSet is closed
+     * 
+     * @throws SQLException
+     * @throws IOException
+     */
+    public void testGetCharacterStream() throws SQLException, IOException {
+        // getCharacterStream() no locks expected after retrieval
+        int numChars = 0;
+        Statement stmt = createStatement();
+        String sql = "SELECT bc from t1";
+        // First with getCharacterStream
+        ResultSet rs = stmt.executeQuery(sql);
+        rs.next();
+        java.io.Reader characterStream = rs.getCharacterStream(1);
+        // Extract all the characters
+        int read = characterStream.read();
+        while (read != -1) {
+            read = characterStream.read();
+            numChars++;
+        }
+        assertEquals(38000, numChars);
+        rs.close();
+        assertEquals(0, countLocks());
+        commit();
+    }
+
+    /**
+     * Verify that getBytes does not hold locks after ResultSet is closed.
+     * 
+     * @throws SQLException
+     */
+    public void testGetBytes() throws SQLException {
+        // getBytes() no locks expected after retrieval
+        Statement stmt = createStatement();
+        String sql = "SELECT bincol from t1";
+        ResultSet rs = stmt.executeQuery(sql);
+        rs.next();
+        byte[] value = rs.getBytes(1);
+        assertEquals(38000, value.length);
+        rs.close();
+        assertEquals(0, countLocks());
+        commit();
+
+    }
+
+    /**
+     * Verify that getBinaryStream() does not hold locks after retrieval
+     * 
+     * @throws SQLException
+     * @throws IOException
+     */
+    public void testGetBinaryStream() throws SQLException, IOException {
+        int numBytes = 0;
+        getConnection().setAutoCommit(false);
+        Statement stmt = createStatement();
+        String sql = "SELECT bincol from t1";
+        ResultSet rs = stmt.executeQuery(sql);
+        rs.next();
+        InputStream stream = rs.getBinaryStream(1);
+        int read = stream.read();
+        while (read != -1) {
+            read = stream.read();
+            numBytes++;
+        }
+        assertEquals(38000, numBytes);
+        rs.close();
+        assertEquals(0, countLocks());
+        commit();
+    }
+
+    /**
+     * Test that ResultSet.getString() does not hold locks after the ResultSet
+     * is closed
+     * 
+     * @throws SQLException
+     * @throws IOException
+     */
+    public void testGetString() throws SQLException, IOException {
+        // getString() no locks expected after retrieval
+        Statement stmt = createStatement();
+        String sql = "SELECT bc from t1";
+        ResultSet rs = stmt.executeQuery(sql);
+        rs.next();
+        String value = rs.getString(1);
+        assertEquals(38000, value.length());
+        rs.close();
+        assertEquals(0, countLocks());
+        commit();
+    }
+
+    /**
+     * Create a new connection and count the number of locks held.
+     * 
+     * @return number of locks held
+     * 
+     * @throws SQLException
+     */
+    public int countLocks() throws SQLException {
+        Connection conn = openDefaultConnection();
+        String sql;
+        Statement stmt = conn.createStatement();
+
+        sql = "Select count(*) from new org.apache.derby.diag.LockTable() as LT";
+        ResultSet lockrs = stmt.executeQuery(sql);
+        lockrs.next();
+        int count = lockrs.getInt(1);
+        lockrs.close();
+        stmt.close();
+        conn.close();
+        return count;
+    }
 
-    
-	public static Test baseSuite(String name) {
+    public static Test baseSuite(String name) {
 
         TestSuite suite = new TestSuite(name);
         suite.addTestSuite(LargeDataLocksTest.class);
@@ -180,26 +170,25 @@
              * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
              */
             protected void decorateSQL(Statement s) throws SQLException {
-            	Connection conn = getConnection();
-    			conn.setAutoCommit(false);
-    	   		PreparedStatement ps = null;
-    			String sql;
-    			
-    			
-    			sql = "CREATE TABLE t1 (bc CLOB(1M), bincol BLOB(1M), datalen int)";
-    			s.executeUpdate(sql);
-    			
-    			// Insert big and little values
-    			sql = "INSERT into t1 values(?,?,?)";		
-    			ps = conn.prepareStatement(sql);
-
-    			ps.setCharacterStream(1, new
-    				java.io.StringReader(Utilities.repeatChar("a",38000)),38000);
-    			ps.setBytes(2,Utilities.repeatChar("a",38000).getBytes());
-    			ps.setInt(3,38000);
-    			ps.executeUpdate();
-    			ps.close();
-    			conn.commit();
+                Connection conn = getConnection();
+                conn.setAutoCommit(false);
+                PreparedStatement ps = null;
+                String sql;
+
+                sql = "CREATE TABLE t1 (bc CLOB(1M), bincol BLOB(1M), datalen int)";
+                s.executeUpdate(sql);
+
+                // Insert big and little values
+                sql = "INSERT into t1 values(?,?,?)";
+                ps = conn.prepareStatement(sql);
+
+                ps.setCharacterStream(1, new java.io.StringReader(Utilities
+                        .repeatChar("a", 38000)), 38000);
+                ps.setBytes(2, Utilities.repeatChar("a", 38000).getBytes());
+                ps.setInt(3, 38000);
+                ps.executeUpdate();
+                ps.close();
+                conn.commit();
             }
         };
     }
@@ -207,11 +196,10 @@
     public static Test suite() {
         TestSuite suite = new TestSuite("LargeDataLocksTest");
         suite.addTest(baseSuite("LargeDataLocksTest:embedded"));
-       // Disable for client until DERBY-2892 is fixed
+        // Disable for client until DERBY-2892 is fixed
         //suite.addTest(TestConfiguration.clientServerDecorator(baseSuite("LargeDataLocksTest:client")));
         return suite;
 
     }
 
 }
-    



Mime
View raw message