harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r597301 - in /harmony/enhanced/classlib/trunk/modules/sql/src: main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
Date Thu, 22 Nov 2007 05:08:31 GMT
Author: tonywu
Date: Wed Nov 21 21:08:30 2007
New Revision: 597301

URL: http://svn.apache.org/viewvc?rev=597301&view=rev
Log:
Apply patch for HARMONY-5169 ([classlib][sql] initial properties to default in CachedRowSetImpl
constructor)

Modified:
    harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java?rev=597301&r1=597300&r2=597301&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
Wed Nov 21 21:08:30 2007
@@ -105,6 +105,17 @@
 
     public CachedRowSetImpl(String providerID) throws SyncFactoryException {
         syncProvider = SyncFactory.getInstance(providerID);
+        initialProperties();
+    }
+
+    private void initialProperties() {
+        try {
+            setEscapeProcessing(true);
+            setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+        } catch (SQLException e) {
+            // ignore, never reached
+        }
+
     }
 
     public CachedRowSetImpl() throws SyncFactoryException {
@@ -544,6 +555,9 @@
     }
 
     public int size() {
+        if (rows == null) {
+            return 0;
+        }
         return rows.size();
     }
 
@@ -667,7 +681,9 @@
     public void close() throws SQLException {
 
         // TODO need more concerns!
-        rows.clear();
+        if (rows != null) {
+            rows.clear();
+        }
         currentRowIndex = 0;
         currentRow = null;
         meta = null;

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java?rev=597301&r1=597300&r2=597301&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
Wed Nov 21 21:08:30 2007
@@ -50,6 +50,8 @@
 
     private CachedRowSet crset;
 
+    private CachedRowSet noInitialCrset;
+
     private final static int DEFAULT_COLUMN_COUNT = 12;
 
     private final static int DEFAULT_ROW_COUNT = 4;
@@ -83,12 +85,17 @@
         rs = st.executeQuery("select * from USER_INFO");
         try {
             crset = (CachedRowSet) Class.forName(
-            "com.sun.rowset.CachedRowSetImpl").newInstance();
+                    "com.sun.rowset.CachedRowSetImpl").newInstance();
+            noInitialCrset = (CachedRowSet) Class.forName(
+                    "com.sun.rowset.CachedRowSetImpl").newInstance();
         } catch (ClassNotFoundException e) {
 
             crset = (CachedRowSet) Class.forName(
                     "org.apache.harmony.sql.internal.rowset.CachedRowSetImpl")
                     .newInstance();
+            noInitialCrset = (CachedRowSet) Class.forName(
+                    "org.apache.harmony.sql.internal.rowset.CachedRowSetImpl")
+                    .newInstance();
 
             System.setProperty("Testing Harmony", "true");
         }
@@ -210,6 +217,8 @@
 
     public void testSize() throws Exception {
         assertEquals(DEFAULT_ROW_COUNT, crset.size());
+        // before populate should return 0
+        assertEquals(0, noInitialCrset.size());
     }
 
     public void testDeleteRow() throws SQLException {
@@ -822,6 +831,63 @@
         if (preStmt != null) {
             preStmt.close();
         }
+    }
+
+    public void testConstructor() throws Exception {
+
+        assertTrue(noInitialCrset.isReadOnly());
+        assertEquals(0, noInitialCrset.size());
+        assertNull(noInitialCrset.getMetaData());
+
+        assertNull(noInitialCrset.getCommand());
+        assertEquals(ResultSet.CONCUR_UPDATABLE, noInitialCrset
+                .getConcurrency());
+        // TODO uncomment after impelemented
+        // try {
+        // crset.getCursorName();
+        // fail("Should throw SQLException");
+        // } catch (SQLException e) {
+        // // expected
+        // }
+        // try {
+        // crset.getMatchColumnIndexes();
+        // fail("Should throw SQLException");
+        // } catch (SQLException e) {
+        // // expected
+        // }
+        //
+        // try {
+        // crset.getMatchColumnNames();
+        // } catch (SQLException e) {
+        // // expected
+        // }
+        // assertEquals(0, crset.getRow());
+        // assertNull(crset.getStatement());
+
+        assertEquals(true, noInitialCrset.getEscapeProcessing());
+        assertEquals(Connection.TRANSACTION_READ_COMMITTED, noInitialCrset
+                .getTransactionIsolation());
+
+        assertEquals(ResultSet.FETCH_FORWARD, noInitialCrset
+                .getFetchDirection());
+        assertEquals(0, noInitialCrset.getFetchSize());
+        assertNull(noInitialCrset.getKeyColumns());
+
+        assertEquals(0, noInitialCrset.getMaxFieldSize());
+        assertEquals(0, noInitialCrset.getMaxRows());
+
+        assertEquals(0, noInitialCrset.getPageSize());
+        assertEquals(null, noInitialCrset.getPassword());
+        assertEquals(0, noInitialCrset.getQueryTimeout());
+        assertEquals(false, noInitialCrset.getShowDeleted());
+
+        assertNull(noInitialCrset.getTableName());
+        assertEquals(ResultSet.TYPE_SCROLL_INSENSITIVE, noInitialCrset
+                .getType());
+
+        assertNull(noInitialCrset.getUrl());
+        assertNull(noInitialCrset.getUsername());
+        
     }
 
     public class Listener implements RowSetListener, Cloneable {



Mime
View raw message