Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 4342 invoked from network); 30 Nov 2007 14:44:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Nov 2007 14:44:45 -0000 Received: (qmail 847 invoked by uid 500); 30 Nov 2007 14:44:33 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 825 invoked by uid 500); 30 Nov 2007 14:44:33 -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 814 invoked by uid 99); 30 Nov 2007 14:44:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Nov 2007 06:44:33 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED 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, 30 Nov 2007 14:44:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2F1461A9832; Fri, 30 Nov 2007 06:44:23 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r599836 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/jdbcapi/ functionTests/tests/junitTests/compatibility/ junit/ Date: Fri, 30 Nov 2007 14:44:20 -0000 To: derby-commits@db.apache.org From: dyre@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071130144423.2F1461A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dyre Date: Fri Nov 30 06:44:18 2007 New Revision: 599836 URL: http://svn.apache.org/viewvc?rev=599836&view=rev Log: DERBY-2807: Patch adds BLOB/CLOB testing to the compatibility testing framework Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java?rev=599836&view=auto ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java Fri Nov 30 06:44:18 2007 @@ -0,0 +1,72 @@ +/* + * + * Derby - Class Compat_BlobClob4BlobTest + * + * 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 junit.framework.*; + +import org.apache.derbyTesting.junit.TestConfiguration; + +/** + * Test of JDBC blob and clob + * Create a test suite running BlobClob4BlobTest, but in a server-client setting + * where the server has already been started. + */ + +public class Compat_BlobClob4BlobTest extends BlobClob4BlobTest { + + /** Creates a new instance of Compat_BlobClob4BlobTest */ + public Compat_BlobClob4BlobTest(String name) { + super(name); + } + + /** + * Set up the connection to the database. + */ + + public void setUp() throws Exception { // IS NEVER RUN! + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + /*** TESTS ***/ + + + /** + * Run the tests of BlobClob4BlobTest in server-client on an already started server. + * + */ + public static Test suite() { + TestSuite suite = new TestSuite("Compat_BlobClob4BlobTest"); + /* Embedded is not relevant for a running server.... + suite.addTest( + TestConfiguration.embeddedSuite(BlobClob4BlobTest.class)); */ + suite.addTest( + TestConfiguration.defaultExistingServerSuite(BlobClob4BlobTest.class, false)); + + return (Test)suite; // Avoiding CleanDatabaseTestSetup and setLockTimeouts which both use embedded. + + + } + + +} Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java?rev=599836&view=auto ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java Fri Nov 30 06:44:18 2007 @@ -0,0 +1,143 @@ +/* + + Derby - Class org.apache.derbyTesting.functionTests.tests.compatibility.BLOBCLOB_CompatibilitySuite + + 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. + + */ +/** + *

+ * This is the JUnit suite verifying compatibility of Derby clients and + * servers across Derby version levels and supported VMs. When you want + * to add a new class of tests to this suite, just add the classname to + * the accumulator in suite(). + *

+ * + */ + +package org.apache.derbyTesting.functionTests.tests.junitTests.compatibility; + +import junit.framework.*; + +import org.apache.derbyTesting.functionTests.tests.jdbcapi.Compat_BlobClob4BlobTest; + +public class BLOBCLOB_CompatibilitySuite extends CompatibilitySuite +{ + + ///////////////////////////////////////////////////////////// + // + // JUnit BEHAVIOR + // + ///////////////////////////////////////////////////////////// + + /** + *

+ * JUnit boilerplate which adds as test cases all public methods + * whose names start with the string "test" in the named classes. + * When you want to add a new class of tests, just wire it into + * this suite. + *

+ */ + public static Test suite() + { + TestSuite testSuite = new TestSuite(); + + testSuite.addTest(Compat_BlobClob4BlobTest.suite()); // ONLY REAL DIFFERENCE FROM CompatibilitySuite + + return testSuite; + } + + + ///////////////////////////////////////////////////////////// + // + // ENTRY POINT + // + ///////////////////////////////////////////////////////////// + + /** + *

+ * Run JDBC compatibility tests using either the specified client or + * the client that is visible + * on the classpath. If there is more than one client on the classpath, + * exits with an error. + *

+ * + *
    + *
  • arg[ 0 ] = required name of database to connect to
  • + *
  • arg[ 1 ] = optional driver to use. if not specified, we'll look for a + * client on the classpath
  • + *
+ */ + public static void main( String args[] ) + throws Exception + { + int exitStatus = FAILURE_EXIT; + + if ( + parseDebug() && + parseArgs( args ) && + parseVMLevel() && + findClient() && + findServer() + ) + { + Test t = suite(); + println("# BLOBCLOB_CompatibilitySuite.main() will run suite with " + + t.countTestCases() + " testcases."); + + TestResult result = junit.textui.TestRunner.run( t ); + + exitStatus = result.errorCount() + result.failureCount(); + } + + Runtime.getRuntime().exit( exitStatus ); + } + + ///////////////////////////////////////////////////////////// + // + // INNER CLASSES + // + ///////////////////////////////////////////////////////////// + + /** + *

+ * This helper class exposes an entry point for creating an empty database. + *

+ */ + public static final class Creator + { + private static BLOBCLOB_CompatibilitySuite _driver = new BLOBCLOB_CompatibilitySuite(); + + /** + *

+ * Wait for server to come up, then create the database. + *

+ * + *
    + *
  • args[ 0 ] = name of database to create.
  • + *
+ */ + public static void main( String[] args ) + throws Exception + { + String databaseName = args[ 0 ]; + findClient(); + _driver.createDB( databaseName ); + } + + } + +} Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java?rev=599836&r1=599835&r2=599836&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java Fri Nov 30 06:44:18 2007 @@ -134,7 +134,11 @@ findServer() ) { - TestResult result = junit.textui.TestRunner.run( suite() ); + Test t = suite(); + println("CompatibilitySuite.main() will run suite with " + + t.countTestCases() + " testcases."); + + TestResult result = junit.textui.TestRunner.run( t ); exitStatus = result.errorCount() + result.failureCount(); } @@ -216,7 +220,7 @@ // We allow for the special case when we're running the embedded client // off the current compiled class tree rather than off product jars. // - private static boolean findClient() + static boolean findClient() throws Exception { // @@ -275,7 +279,7 @@ // Initialize server settings. Assumes that you have called // findClient(). // - private static boolean findServer() + static boolean findServer() throws Exception { try { @@ -299,7 +303,7 @@ return true; } - private static boolean parseVMLevel() + static boolean parseVMLevel() throws Exception { String vmVersion = getVMVersion(); @@ -317,7 +321,7 @@ return true; } - private static boolean parseArgs( String args[] ) + static boolean parseArgs( String args[] ) throws Exception { if ( ( args == null ) || (args.length == 0 ) ) @@ -356,7 +360,7 @@ * Get the vm level of the server. *

*/ - private static void parseServerVMVersion( Connection conn ) + static void parseServerVMVersion( Connection conn ) throws SQLException { dropFunction( conn, SERVER_VERSION_FUNCTION ); Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=599836&r1=599835&r2=599836&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java Fri Nov 30 06:44:18 2007 @@ -245,6 +245,30 @@ return (suite); } + /** + * Equivalent to "defaultSuite" as defined above, but assumes a server + * has already been started. + * Does NOT decorate for running in embedded mode. + */ + public static Test defaultExistingServerSuite(Class testClass) + { + return defaultExistingServerSuite(testClass, true); + } + public static Test defaultExistingServerSuite(Class testClass, boolean cleanDB) + { + final TestSuite suite = new TestSuite(suiteName(testClass)); + + if (cleanDB) + { + suite.addTest(new CleanDatabaseTestSetup(clientExistingServerSuite(testClass))); + } + else + { + suite.addTest(clientExistingServerSuite(testClass)); + } + + return (suite); + } /** * Return a Test suite that contains all the test fixtures @@ -320,6 +344,18 @@ } /** + * Equivalent to 'clientServerSuite' above, but assumes server is + * already running. + * + */ + public static Test clientExistingServerSuite(Class testClass) + { + TestSuite suite = new TestSuite(testClass, + suiteName(testClass)+":client"); + return defaultExistingServerDecorator(suite); // Will not start server and does not stop it when done!. + } + + /** * Return a decorator for the passed in tests that sets the * configuration for the client to be Derby's JDBC client * and to start the network server at setUp. @@ -345,6 +381,28 @@ Test test = new NetworkServerTestSetup(suite, false); return defaultServerDecorator(test,port); + } + /** + * Decorate a test to use suite's default host and port, + * but assuming the server is already running. + */ + public static Test defaultExistingServerDecorator(Test test) + { + // As defaultServerDecorator but assuming + // server is already started. + // Need to have client + // and not running in J2ME (JSR169). + if (!(Derby.hasClient()) + || JDBC.vmSupportsJSR169()) + { + return new TestSuite("empty: no network server support in JSR169 (or derbyclient.jar missing)."); + } + + Test r = + new ServerSetup(test, DEFAULT_HOSTNAME, DEFAULT_PORT); + ((ServerSetup)r).setJDBCClient(JDBCClient.DERBYNETCLIENT); + + return r; } /**