You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2011/04/01 19:03:13 UTC

svn commit: r1087809 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/madhare.out suites/storemats.runall tests/store/MadhareTest.java tests/store/_Suite.java tests/store/madhare.sql

Author: kmarsden
Date: Fri Apr  1 17:03:13 2011
New Revision: 1087809

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

Contributed by Siddharth Srivastava


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java   (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/madhare.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/madhare.sql
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall?rev=1087809&r1=1087808&r2=1087809&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall Fri Apr  1 17:03:13 2011
@@ -1,6 +1,5 @@
 store/RowLockBasic.sql
 store/TableLockBasic.sql
 store/longColumn.sql
-store/madhare.sql
 store/updatelocksJDBC30.sql
 store/updatelocks.sql

Added: 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=1087809&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java Fri Apr  1 17:03:13 2011
@@ -0,0 +1,123 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.functionTests.store.MadhareTest
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+
+ package org.apache.derbyTesting.functionTests.tests.store;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * This test shows basic functionality of creating and executing 
+ * simple SQL statements
+ */
+public final class MadhareTest extends BaseJDBCTestCase {
+
+    /**
+      * public constructor required for running test as a standalone JUnit
+      */
+      public MadhareTest( String name )
+      {
+        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(
+                    "insert into t(i) values (1956)");
+
+        st.executeQuery(
+                    "select i from t");
+
+        // 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)");
+
+        // do not list the columns
+        st.executeUpdate(
+                    "insert into s values (10,11,12,13,14,15)");
+
+        // select some of the columns
+        st.executeQuery(
+                    "select i from s");
+        // select in random orders
+        st.executeQuery(
+                    "select n,e,r,i,t,g from s");
+
+        // select with constants
+        st.executeQuery(
+                    "select 20,n,22,e,24,r from s");
+
+        // prepare statement and execute support
+        PreparedStatement pst = prepareStatement(
+                                            "select i,n,t,e,g,r from s");
+
+        pst.executeQuery();
+        //execute can be done multiple times
+        pst.executeQuery();
+
+        // with smallint
+        st.executeUpdate(
+                    "create table r(s smallint, i int)");
+
+        st.executeUpdate(
+                    "insert into r values (23,2)");
+
+        st.executeQuery(
+                    "select s,i from r");
+
+        pst.close();
+
+        //cleanup
+        st.executeUpdate(
+                    "drop table r");
+        st.executeUpdate(
+                    "drop table s");
+        st.executeUpdate(
+                    "drop table t");
+        st.close();
+        }
+    }
\ No newline at end of file

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/MadhareTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?rev=1087809&r1=1087808&r2=1087809&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java Fri Apr  1 17:03:13 2011
@@ -72,6 +72,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(AutomaticIndexStatisticsTest.suite());
         suite.addTest(AutomaticIndexStatisticsMultiTest.suite());
         suite.addTest(BTreeMaxScanTest.suite());
+        suite.addTest(MadhareTest.suite());
         
         /* Tests that only run in sane builds */
         if (SanityManager.DEBUG) {