harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548556 - in /harmony/enhanced/classlib/trunk/modules/sql/src: main/java/javax/sql/rowset/BaseRowSet.java test/java/org/apache/harmony/sql/tests/javax/sql/rowset/BaseRowSetTest.java
Date Tue, 19 Jun 2007 02:08:28 GMT
Author: tonywu
Date: Mon Jun 18 19:08:27 2007
New Revision: 548556

URL: http://svn.apache.org/viewvc?view=rev&rev=548556
Log:
Apply patch HARMONY-4199 ([classlib][sql] javax.sql.rowset.BaseRowSet has wrong default values
for fetchDirection and typeMap)

Modified:
    harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/BaseRowSetTest.java

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java?view=diff&rev=548556&r1=548555&r2=548556
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java
Mon Jun 18 19:08:27 2007
@@ -32,7 +32,6 @@
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Calendar;
-import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Vector;
@@ -86,7 +85,7 @@
 
     private int isolation;
 
-    private int fetchDir;
+    private int fetchDir = ResultSet.FETCH_FORWARD;
 
     private int fetchSize;
 
@@ -278,13 +277,11 @@
     }
 
     public Map<String, Class<?>> getTypeMap() {
-        //TODO determine if copy is necessary
-        return new HashMap<String, Class<?>>(map);
+        return map;
     }
 
     public void setTypeMap(Map<String, Class<?>> map) {
-        //TODO determine if copy is necessary
-        this.map = new HashMap<String, Class<?>>(map);
+        this.map = map;
     }
 
     public int getMaxFieldSize() throws SQLException {

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/BaseRowSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/BaseRowSetTest.java?view=diff&rev=548556&r1=548555&r2=548556
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/BaseRowSetTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/BaseRowSetTest.java
Mon Jun 18 19:08:27 2007
@@ -21,6 +21,7 @@
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Ref;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Types;
 
@@ -41,6 +42,22 @@
         assertEquals(0, params.length);
     }
     
+    /**
+     * @tests {@link javax.sql.rowset.BaseRowSet#getFetchDirection()}
+     */
+    public void testGetFetchDirection() throws SQLException {
+        BaseRowSetImpl brs = new BaseRowSetImpl();
+        assertEquals(ResultSet.FETCH_FORWARD, brs.getFetchDirection());
+    }
+    
+    /**
+     * @tests {@link javax.sql.rowset.BaseRowSet#getTypeMap()}
+     */
+    public void testGetTypeMap() {
+        BaseRowSetImpl brs = new BaseRowSetImpl();
+        assertNull(brs.getTypeMap());
+    }
+    
     public void testSetNullintint() throws Exception {
         BaseRowSetImpl brs = new BaseRowSetImpl();
         try {
@@ -161,6 +178,43 @@
         assertNotNull(params);
         assertEquals(1, params.length);
         assertEquals(Short.valueOf((short)1), params[0]);
+    }
+    
+    /**
+     * @tests {@link javax.sql.rowset.BaseRowSet#setFetchDirection(int)}
+     */
+    public void testSetFetchDirectionI() throws SQLException {
+    	BaseRowSetImpl brs = new BaseRowSetImpl();
+    	brs.setFetchDirection(ResultSet.FETCH_FORWARD);
+    	assertEquals(ResultSet.FETCH_FORWARD, brs.getFetchDirection());
+    	
+    	brs.setType(ResultSet.TYPE_SCROLL_SENSITIVE);
+    	brs.setFetchDirection(ResultSet.FETCH_UNKNOWN);
+    	assertEquals(ResultSet.FETCH_UNKNOWN, brs.getFetchDirection());
+    	
+    	brs.setType(ResultSet.TYPE_FORWARD_ONLY);
+    	try {
+    		brs.setFetchDirection(ResultSet.FETCH_REVERSE);
+    		fail("should throw SQLException");
+    	} catch (SQLException e) {
+    		// expected
+    	}
+    	
+    	try {
+    		brs.setFetchDirection(1100);
+    		fail("should throw SQLException");
+    	} catch (SQLException e) {
+    		// expected
+    	}
+    }
+    
+    /**
+     * @tests {@link javax.sql.rowset.BaseRowSet#setTypeMap(java.util.Map)}
+     */
+    public void testSetTypeMap() {
+    	BaseRowSetImpl brs = new BaseRowSetImpl();
+    	brs.setTypeMap(null);
+    	assertNull(brs.getTypeMap());
     }
     
     public void testSetArray() throws SQLException {



Mime
View raw message