Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 80872 invoked from network); 6 Jul 2007 18:56:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jul 2007 18:56:36 -0000 Received: (qmail 58082 invoked by uid 500); 6 Jul 2007 18:56:39 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 58015 invoked by uid 500); 6 Jul 2007 18:56:39 -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 58004 invoked by uid 99); 6 Jul 2007 18:56:39 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jul 2007 11:56:39 -0700 X-ASF-Spam-Status: No, hits=-99.5 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, 06 Jul 2007 11:56:36 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id CE9821A981A; Fri, 6 Jul 2007 11:56:15 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r553997 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java Date: Fri, 06 Jul 2007 18:56:15 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070706185615.CE9821A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Fri Jul 6 11:56:15 2007 New Revision: 553997 URL: http://svn.apache.org/viewvc?view=rev&rev=553997 Log: Do not compress tables (SYSDEPENDS) on CleanDatabaseTestSetup.tearDown. The setUp() method performs the compression to ensure a clean environment for the decorated tests. The cleanup on shutdown is to ensure any failures in dropping objects can be easily associated with the tests that created them. Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java?view=diff&rev=553997&r1=553996&r2=553997 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java Fri Jul 6 11:56:15 2007 @@ -29,7 +29,10 @@ /** * Test decorator that cleans a database on setUp and * tearDown to provide a test with a consistent empty - * database as a starting point. + * database as a starting point. The obejcts are cleaned + * (dropped) on tearDown to ensure any filures dropping + * the objects can easily be associated with the test + * fixtures that created them. *

* Tests can extend to provide a decorator that defines * some schema items and then have CleanDatabaseTestSetup @@ -64,7 +67,10 @@ protected void setUp() throws Exception { Connection conn = getConnection(); conn.setAutoCommit(false); - CleanDatabaseTestSetup.cleanDatabase(conn); + + // compress as well to allow the fixtures wrapped in + // this decorator to start with a clean database. + CleanDatabaseTestSetup.cleanDatabase(conn, true); Statement s = conn.createStatement(); decorateSQL(s); @@ -97,19 +103,31 @@ protected void tearDown() throws Exception { Connection conn = getConnection(); conn.setAutoCommit(false); - CleanDatabaseTestSetup.cleanDatabase(conn); + + // Clean the database, ensures that any failure dropping + // objects can easily be linked to test fixtures that + // created them + // + // No need to compress, any test requiring such a clean + // setup should not assume it is following another test + // with this decorator, it should wrap itself in a CleanDatabaseTestSetup. + // Compress is a somewhat expensive operation so avoid it if possible. + CleanDatabaseTestSetup.cleanDatabase(conn, false); super.tearDown(); } /** * Clean a complete database * @param conn Connection to be used, must not be in auto-commit mode. + * @param compress True if selected system tables are to be compressed + * to avoid potential ordering differences in test output. * @throws SQLException database error */ - public static void cleanDatabase(Connection conn) throws SQLException { + public static void cleanDatabase(Connection conn, boolean compress) throws SQLException { clearProperties(conn); removeObjects(conn); - compressObjects(conn); + if (compress) + compressObjects(conn); } /**