From derby-commits-return-6350-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Wed Feb 07 18:41:57 2007 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 77528 invoked from network); 7 Feb 2007 18:41:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Feb 2007 18:41:56 -0000 Received: (qmail 1412 invoked by uid 500); 7 Feb 2007 18:42:03 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 1383 invoked by uid 500); 7 Feb 2007 18:42:03 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 1363 invoked by uid 99); 7 Feb 2007 18:42:02 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2007 10:42:02 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2007 10:41:53 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id DD1131A981A; Wed, 7 Feb 2007 10:41:32 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r504641 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ suites/ tests/jdbcapi/ Date: Wed, 07 Feb 2007 18:41:30 -0000 To: derby-commits@db.apache.org From: myrnavl@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070207184132.DD1131A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: myrnavl Date: Wed Feb 7 10:41:28 2007 New Revision: 504641 URL: http://svn.apache.org/viewvc?view=rev&rev=504641 Log: DERBY-2293 - basic conversion of test jdbcapi/batchUpdate.java to junit test jdbcapi.BatchUpdateTest Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BatchUpdateTest.java (with props) Removed: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/batchUpdate.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/batchUpdate.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/batchUpdate_app.properties db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/batchUpdate_derby.properties Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc20.runall db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude?view=diff&rev=504641&r1=504640&r2=504641 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude Wed Feb 7 10:41:28 2007 @@ -1,7 +1,6 @@ # excluding resultsetStream.java because this test uses java.io.FileInputStream throughout the test # excluding TestErrorStreamTarget.java since it's not relevant for clients # excluding scrollCursors2.java because updatable resultsets & scroll sensitive cursors are not supported -# excluding batchUpdate.java for it hits a problem in networkserver ('beetle' 5561) # excluding statementJdbc20.java because this tests fetch_reverse throughout the test # excluding jdbcapi/testRelative.java because this is a new test contributed by Shreyas Kaushik and needs to be debugged with JCC in order to get it running with network server # excluding jdbcapi/SetQueryTimeoutTest.java because neither the JCC driver nor the ClientDriver support setQueryTimeout() yet. @@ -16,7 +15,6 @@ jdbcapi/resultsetStream.java lang/errorStream.java lang/scrollCursors2.java -jdbcapi/batchUpdate.java jdbcapi/statementJdbc20.java jdbcapi/testRelative.java jdbcapi/rsgetXXXcolumnNames.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude?view=diff&rev=504641&r1=504640&r2=504641 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude Wed Feb 7 10:41:28 2007 @@ -1,6 +1,5 @@ # excluding TestErrorStreamTarget.java since it's not relevant for clients # excluding scrollCursors2.java because updatable resultsets & scroll sensitive cursors are not supported -# excluding batchUpdate.java for it hits a problem in networkserver ('beetle' 5561) # excluding statementJdbc20.java because this tests fetch_reverse throughout the test # excluding jdbcapi/statementJdbc30.java - Client behaves differently. Need to look into this # excluding jdbcapi/dataSourceReference.java - client side only tests, tests all data sources @@ -10,7 +9,6 @@ lang/errorStream.java # lang/scrollCursors2.java # -jdbcapi/batchUpdate.java jdbcapi/statementJdbc20.java jdbcapi/statementJdbc30.java jdbcapi/dataSourceReference.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc20.runall URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc20.runall?view=diff&rev=504641&r1=504640&r2=504641 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc20.runall (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc20.runall Wed Feb 7 10:41:28 2007 @@ -1,7 +1,6 @@ lang/scrollCursors1.sql lang/scrollCursors2.java lang/scrollCursors3.sql -jdbcapi/batchUpdate.java jdbcapi/getCurConnJdbc20.sql jdbcapi/statementJdbc20.java jdbcapi/connectionJdbc20.java Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BatchUpdateTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BatchUpdateTest.java?view=auto&rev=504641 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BatchUpdateTest.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BatchUpdateTest.java Wed Feb 7 10:41:28 2007 @@ -0,0 +1,1729 @@ +/* + + Derby - Class + org.apache.derbyTesting.functionTests.tests.jdbcapi.BatchUpdateTest + + 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.jdbcapi; + +import java.sql.BatchUpdateException; +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Types; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.derbyTesting.junit.BaseJDBCTestCase; +import org.apache.derbyTesting.junit.CleanDatabaseTestSetup; +import org.apache.derbyTesting.junit.DatabasePropertyTestSetup; +import org.apache.derbyTesting.junit.JDBC; +import org.apache.derbyTesting.junit.TestConfiguration; + + +/** + * Test BatchUpdate functionality. + *

+ * This test examines the behavior fo BatchUpdate test. + * There are 5 actual fixtures, and even the setup is executing in batch, to + * verify basic create table and insert statements also work in batch. + * The five actual fixtures are: + * testStatementBatchUpdatePositive - verifies correct usage with Statements + * work as expected + * testStatementBatchUpdateNegative - verifies incorrect usage with Statments + * gives appropriate errors + * testCallableStatementBatchUpdate - verifies usage with callableStatements + * works as expected + * testPreparedStatementBatchUpdatePositive + * - verifies correct usage with preparedStatements + * testPreparedStatementBatchUpdateNegative + * - verifies incorrect use with preparedStatements + * + * The test executes almost all submethods of these fixtures with both + * embedded and NetworkServer/DerbyNetClient - however, there is a difference + * in functionality between the two when an error condition is reaches. Thus, + * the negative tests have if / else if blocks for embedded and client. + * + * The three subtests that are not running with network server are + * identified with //TODO: tags and have an if (usingEmbedded()) block. + * + */ + +public class BatchUpdateTest extends BaseJDBCTestCase { + + /** Creates a new instance of BatchUpdateTest */ + public BatchUpdateTest(String name) { + super(name); + } + + /** + * Set up the conection to the database. + * This is itself a test of statements creating tables in batch. + */ + public void setUp() throws Exception { + Connection conn = getConnection(); + conn.setAutoCommit(false); + Statement stmt = createStatement(); + stmt.addBatch("create table t1(c1 int)"); + stmt.addBatch("create procedure Integ() language java " + + "parameter style java external name 'java.lang.Integer'"); + stmt.addBatch("create table datetab(c1 date)"); + stmt.addBatch("create table timetab(c1 time)"); + stmt.addBatch("create table timestamptab(c1 timestamp)"); + stmt.addBatch("create table usertypetab(c1 DATE)"); + + int expectedCount[] = {0,0,0,0,0,0}; + assertBatchUpdateCounts(expectedCount, stmt.executeBatch()); + + // for method checkAssociatedParams + stmt.executeUpdate("create table assoc" + + "(x char(10) not null primary key, y char(100))"); + stmt.executeUpdate("create table assocout(x char(10))"); + + conn.commit(); + } + + protected void tearDown() throws Exception { + Statement stmt = createStatement(); + stmt.executeUpdate("DROP TABLE datetab"); + stmt.executeUpdate("DROP TABLE timetab"); + stmt.executeUpdate("DROP TABLE timestamptab"); + stmt.executeUpdate("DROP TABLE usertypetab"); + stmt.executeUpdate("DROP PROCEDURE Integ"); + stmt.executeUpdate("DROP TABLE t1"); + // for method checkAssociatedParams + stmt.executeUpdate("drop table assoc"); + stmt.executeUpdate("drop table assocout"); + commit(); + super.tearDown(); + } + + public static Test suite() { + TestSuite suite = new TestSuite("BatchUpdateTest"); + suite.addTest( + TestConfiguration.defaultSuite(BatchUpdateTest.class)); + + return new CleanDatabaseTestSetup( + DatabasePropertyTestSetup.setLockTimeouts(suite, 2, 4)); + } + + /* + * helper method to check each count in the return array of batchExecute + */ + public void assertBatchUpdateCounts( + int[] expectedBatchResult, int[] executeBatchResult ) + { + assertEquals("length of array should be identical", + expectedBatchResult.length, executeBatchResult.length); + + for (int i=0; i