db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1090359 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java
Date Fri, 08 Apr 2011 17:36:34 GMT
Author: kmarsden
Date: Fri Apr  8 17:36:33 2011
New Revision: 1090359

URL: http://svn.apache.org/viewvc?rev=1090359&view=rev
Log:
DERBY-5127 Convert madhare.sql to JUnit

Fix result checking
Contributed by Siddharth  Srivastava 


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java?rev=1090359&r1=1090358&r2=1090359&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java
Fri Apr  8 17:36:33 2011
@@ -46,78 +46,83 @@ public final class MadhareTest extends B
       {
         super(name);
       }
-      
+
       public static Test suite()
       {
         //Add the test case into the test suite
         TestSuite suite = new TestSuite("MadhareTest Test");
         return TestConfiguration.defaultSuite(MadhareTest.class);
       }
-      
+
       public void testBasicMadhare() throws SQLException
       {
         setAutoCommit(false);
-        
+
         Statement st = createStatement();
-        st.executeUpdate(
-                    "create table t( i int )");
+        st.executeUpdate("create table t( i int )");
+
+        st.executeUpdate("insert into t(i) values (1956)");
 
-        st.executeUpdate(
-                    "insert into t(i) values (1956)");
+        ResultSet rs = st.executeQuery("select i from t");
 
-        st.executeQuery(
-                    "select i from t");
+        JDBC.assertFullResultSet(rs, new String[][] {{"1956"}});
 
-        // multiple columns            
-        st.executeUpdate(
-                    "create table s (i int, n int, t int, e int, g int, r int)");
+        // multiple columns
+        st.executeUpdate("create table s (i int, n int, t int, e int, g int, r int)");
 
         // reorder columns on insert
-        st.executeUpdate(
-                    "insert into s (i,r,t,n,g,e) values (1,6,3,2,5,4)");
+        st.executeUpdate("insert into s (i,r,t,n,g,e) values (1,6,3,2,5,4)");
 
         // do not list the columns
-        st.executeUpdate(
-                    "insert into s values (10,11,12,13,14,15)");
+        st.executeUpdate("insert into s values (10,11,12,13,14,15)");
 
         // select some of the columns
-        st.executeQuery(
-                    "select i from s");
+        rs = st.executeQuery("select i from s");
+
+        String[][] expectedResultSet = {{"1"},{"10"}};
+        JDBC.assertFullResultSet(rs, expectedResultSet);
+
         // select in random orders
-        st.executeQuery(
-                    "select n,e,r,i,t,g from s");
+        rs = st.executeQuery("select n,e,r,i,t,g from s");
+
+        expectedResultSet = new String[][] {{"2","4","6","1","3","5"},
+                                               {"11","13","15","10","12","14"}};
+        JDBC.assertFullResultSet(rs, expectedResultSet);
 
         // select with constants
-        st.executeQuery(
-                    "select 20,n,22,e,24,r from s");
+        rs = st.executeQuery("select 20,n,22,e,24,r from s");
+
+        expectedResultSet = new String[][] {{"20","2","22","4","24","6"}, 
+                                               {"20","11","22","13","24","15"}};
+        JDBC.assertFullResultSet(rs, expectedResultSet);
 
         // prepare statement and execute support
-        PreparedStatement pst = prepareStatement(
-                                            "select i,n,t,e,g,r from s");
+        PreparedStatement pst = prepareStatement("select i,n,t,e,g,r from s");
+
+        rs = pst.executeQuery();
+
+        expectedResultSet = new String[][] {{"1","2","3","4","5","6"},
+                                               {"10","11","12","13","14","15"}};
+        JDBC.assertFullResultSet(rs, expectedResultSet);
 
-        pst.executeQuery();
         //execute can be done multiple times
-        pst.executeQuery();
+        rs = pst.executeQuery();
+        JDBC.assertFullResultSet(rs, expectedResultSet);
+        pst.close();
 
         // with smallint
-        st.executeUpdate(
-                    "create table r(s smallint, i int)");
+        st.executeUpdate("create table r(s smallint, i int)");
 
-        st.executeUpdate(
-                    "insert into r values (23,2)");
+        st.executeUpdate("insert into r values (23,2)");
 
-        st.executeQuery(
-                    "select s,i from r");
+        rs = st.executeQuery("select s,i from r");
 
-        pst.close();
+        JDBC.assertFullResultSet(rs, new String[][] {{"23","2"}});
 
         //cleanup
-        st.executeUpdate(
-                    "drop table r");
-        st.executeUpdate(
-                    "drop table s");
-        st.executeUpdate(
-                    "drop table t");
-        st.close();
-        }
-    }
\ No newline at end of file
+        st.executeUpdate("drop table r");
+        st.executeUpdate("drop table s");
+        st.executeUpdate("drop table t");
+        st.close(); 
+      }
+ }



Mime
View raw message