From derby-commits-return-5700-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Fri Nov 10 18:26:59 2006 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 75103 invoked from network); 10 Nov 2006 18:26:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Nov 2006 18:26:56 -0000 Received: (qmail 37648 invoked by uid 500); 10 Nov 2006 18:27:00 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 37614 invoked by uid 500); 10 Nov 2006 18:27:00 -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 37578 invoked by uid 99); 10 Nov 2006 18:27:00 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 10:27:00 -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; Fri, 10 Nov 2006 10:26:48 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 2C4D71A984D; Fri, 10 Nov 2006 10:26:20 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r473413 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: junit/BaseJDBCTestCase.java system/oe/run/ system/oe/run/Load.java Date: Fri, 10 Nov 2006 18:26:20 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061110182620.2C4D71A984D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Fri Nov 10 10:26:19 2006 New Revision: 473413 URL: http://svn.apache.org/viewvc?view=rev&rev=473413 Log: DERBY-2055 1) Adds a new class Load.java to execute the schema scripts for OE within the junit framework. 2) Adds a new utility method to BaseJDBCTestCase to take a resource name and execute it using runScript. Contributed by Sunitha Kambhampati ksunithaghm@gmail.com Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Load.java (with props) Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?view=diff&rev=473413&r1=473412&r2=473413 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Fri Nov 10 10:26:19 2006 @@ -26,6 +26,8 @@ import java.io.PrintStream; import java.io.Reader; import java.io.UnsupportedEncodingException; +import java.security.PrivilegedActionException; +import java.net.URL; import java.sql.*; import junit.framework.AssertionFailedError; @@ -213,6 +215,33 @@ // Use the same encoding as the input for the output. return ij.runScript(getConnection(), script, encoding, sink, encoding); + } + + /** + * Run a SQL script through ij discarding the output + * using this object's default connection. Intended for + * setup scripts. + * @return Number of errors executing the script + * @throws UnsupportedEncodingException + * @throws PrivilegedActionException + * @throws SQLException + */ + public int runScript(String resource,String encoding) + throws UnsupportedEncodingException, SQLException, + PrivilegedActionException,IOException + { + + URL sql = getTestResource(resource); + assertNotNull("SQL script missing: " + resource, sql); + InputStream sqlIn = openTestResource(sql); + Connection conn = getConnection(); + int numErrors = runScript(sqlIn,encoding); + sqlIn.close(); + + if (!conn.isClosed() && !conn.getAutoCommit()) + conn.commit(); + + return numErrors; } /** Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Load.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Load.java?view=auto&rev=473413 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Load.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Load.java Fri Nov 10 10:26:19 2006 @@ -0,0 +1,80 @@ +/* + * + * Derby - Class Load + * + * 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.system.oe.run; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.derbyTesting.junit.JDBCPerfTestCase; + + +/** + * Driver to do the load phase. (partial) + * This class currently only creates the schema. + * After the population code is checked in, one can measure performance + * using 1) load data after creating constraints 2) load data and then create + * constraints. + */ +public class Load extends JDBCPerfTestCase{ + + + + /** + * Create a test case with the given name. + * + * @param name of the test case. + */ + public Load(String name) + { + super(name); + } + + /** + * junit tests to do the OE load. + * @return the tests to run + */ + public static Test suite() + { + TestSuite suite = new TestSuite("OE_Load"); + suite.addTest(new Load("createSchemaWithConstraints")); + + // more to come. (see DERBY-1987) + // need to add the population phase. + + return suite; + + } + + /** + * Create tables, primary, foreign key constraints + * and indexes for the OE benchmark + */ + public void createSchemaWithConstraints() + throws Exception + { + int numExceptions = 0; + numExceptions += runScript("org/apache/derbyTesting/system/oe/schema/schema.sql","US-ASCII"); + numExceptions += runScript("org/apache/derbyTesting/system/oe/schema/primarykey.sql","US-ASCII"); + numExceptions += runScript("org/apache/derbyTesting/system/oe/schema/foreignkey.sql","US-ASCII"); + numExceptions += runScript("org/apache/derbyTesting/system/oe/schema/index.sql","US-ASCII"); + assertEquals("Number of sql exceptions ",0,numExceptions); + } + +} Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Load.java ------------------------------------------------------------------------------ svn:eol-style = native