db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lily...@apache.org
Subject svn commit: r1083094 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4: ConnectionMethodsTest.java ConnectionTest.java
Date Fri, 18 Mar 2011 22:25:53 GMT
Author: lilywei
Date: Fri Mar 18 22:25:52 2011
New Revision: 1083094

URL: http://svn.apache.org/viewvc?rev=1083094&view=rev
Log:
DERBY-4869 Implement JDBC 4.1, th api increment introduced by Java 7. Add tests for Connection.setTypeMap(Map)
when Map is not null. Add extra tests for case in Connection.abort(executor) when executor
is null 

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java?rev=1083094&r1=1083093&r2=1083094&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java
Fri Mar 18 22:25:52 2011
@@ -509,6 +509,14 @@ public class ConnectionMethodsTest exten
             ( conn1, "insert into app.abort_table( a ) values ( 1 )" );
         ps.execute();
         ps.close();
+        
+        ps = prepareStatement( conn1, "select * from app.abort_table");
+        ResultSet rsconn1 = ps.executeQuery();
+        assertTrue(rsconn1.next());
+        rsconn1.close();
+        ps.close();
+        
+        
 
         // abort the connection
         try {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java?rev=1083094&r1=1083093&r2=1083094&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
Fri Mar 18 22:25:52 2011
@@ -31,6 +31,8 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.sql.*;
+import java.util.ArrayList;
+import java.util.Map;
 import java.util.Properties;
 import javax.sql.*;
 
@@ -185,6 +187,64 @@ public class ConnectionTest
     public void testGetTypeMapReturnsEmptyMap() throws SQLException {
         assertTrue(getConnection().getTypeMap().isEmpty());
     }
+    
+    /**
+     * Tests that <code>getTypeMap()</code> returns the input map
+     * @exception SQLException if an error occurs
+     */
+    public void testGetTypeMapReturnsasExcepted() throws SQLException {
+        Statement s = getConnection().createStatement();
+        int ret;
+        try {
+            ret = s.executeUpdate("DROP TABLE T1");
+            ret = s.executeUpdate("DROP TYPE JAVA_UTIL_LIST RESTRICT");
+        } catch (Exception e) {}
+        
+        ret = s.executeUpdate("CREATE TYPE JAVA_UTIL_LIST " +
+                              "EXTERNAL NAME 'java.util.List'" +
+                              "LANGUAGE JAVA");
+
+        s.execute("CREATE TABLE T1 (A1 JAVA_UTIL_LIST)");
+        
+        PreparedStatement ps = getConnection().prepareStatement(
+                "INSERT INTO T1(A1) VALUES (?)");
+        
+        ArrayList lst = new ArrayList();
+        lst.add("First element");
+        lst.add("Second element");
+        
+        ps.setObject(1, lst);
+        ps.execute();     
+        
+        Map<String, Class<?>> map = getConnection().getTypeMap();
+        try {
+             map.put("JAVA_UTIL_LIST", Class.forName("java.util.List"));
+        } catch (ClassNotFoundException se) {
+            se.printStackTrace();
+            println("map.put has exception");
+        }
+        
+        try {
+            getConnection().setTypeMap(map);
+            fail( "Should raise an Unimplemented Feature exception." );
+        }
+        catch (SQLException se)
+        {
+            assertEquals( SQLFeatureNotSupportedException.class.getName(), se.getClass().getName()
);
+        }
+        
+        ResultSet rs = s.executeQuery("select * from T1");
+        assertTrue(rs.next());
+        for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
+            Object o = rs.getObject(i);
+            assertEquals(lst, o);
+            //System.out.print(o + "(Type " + o.getClass().getName() + " )");
+        }
+        s.executeUpdate("DROP TABLE T1");
+        s.executeUpdate("DROP TYPE JAVA_UTIL_LIST RESTRICT");
+        s.close();
+        ps.close();
+    }
 
     public void testIsWrapperReturnsFalse()
         throws SQLException {



Mime
View raw message