Return-Path: Delivered-To: apmail-db-ddlutils-dev-archive@www.apache.org Received: (qmail 77385 invoked from network); 20 Dec 2005 23:48:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Dec 2005 23:48:09 -0000 Received: (qmail 64082 invoked by uid 500); 20 Dec 2005 23:48:09 -0000 Delivered-To: apmail-db-ddlutils-dev-archive@db.apache.org Received: (qmail 64058 invoked by uid 500); 20 Dec 2005 23:48:08 -0000 Mailing-List: contact ddlutils-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ddlutils-dev@db.apache.org Delivered-To: mailing list ddlutils-dev@db.apache.org Received: (qmail 64046 invoked by uid 500); 20 Dec 2005 23:48:08 -0000 Delivered-To: apmail-db-ddlutils-commits@db.apache.org Received: (qmail 64043 invoked by uid 99); 20 Dec 2005 23:48:08 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2005 15:48:08 -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 [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 20 Dec 2005 15:48:08 -0800 Received: (qmail 77178 invoked by uid 65534); 20 Dec 2005 23:47:47 -0000 Message-ID: <20051220234747.77176.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r358149 - in /db/ddlutils/trunk/src/test/org/apache/ddlutils/io: RoundtripTestBase.java TestRoundtripDerby.java Date: Tue, 20 Dec 2005 23:47:47 -0000 To: ddlutils-commits@db.apache.org From: tomdz@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: tomdz Date: Tue Dec 20 15:47:37 2005 New Revision: 358149 URL: http://svn.apache.org/viewcvs?rev=358149&view=rev Log: More/fixed tests Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestRoundtripDerby.java Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java?rev=358149&r1=358148&r2=358149&view=diff ============================================================================== --- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java (original) +++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java Tue Dec 20 15:47:37 2005 @@ -20,6 +20,7 @@ import org.apache.commons.beanutils.DynaBean; import org.apache.ddlutils.TestDatabaseWriterBase; +import org.apache.ddlutils.model.Column; import org.apache.ddlutils.model.IndexColumn; import org.apache.ddlutils.model.Table; import org.apache.ddlutils.model.UniqueIndex; @@ -47,7 +48,7 @@ "\n"+ " \n"+ " \n"+ - " \n"+ + " \n"+ "
\n"+ "
"; /** Test model with a simple BOOLEAN column. */ @@ -59,6 +60,15 @@ " \n"+ " \n"+ ""; + /** Test model with a BOOLEAN column with a default value. */ + protected static final String TEST_BOOLEAN_MODEL_WITH_DEFAULT = + "\n"+ + "\n"+ + " \n"+ + " \n"+ + " \n"+ + "
\n"+ + "
"; /** * Inserts a row into the designated table. @@ -73,7 +83,9 @@ for (int idx = 0; (idx < table.getColumnCount()) && (idx < columnValues.length); idx++) { - bean.set(table.getColumn(idx).getName(), columnValues[idx]); + Column column = table.getColumn(idx); + + bean.set(column.getName(), columnValues[idx]); } getPlatform().insert(getModel(), bean); } Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestRoundtripDerby.java URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestRoundtripDerby.java?rev=358149&r1=358148&r2=358149&view=diff ============================================================================== --- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestRoundtripDerby.java (original) +++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestRoundtripDerby.java Tue Dec 20 15:47:37 2005 @@ -6,6 +6,9 @@ /** * Performs the roundtrip test against a derby database. + * + * @author Thomas Dudziak + * @version $Revision: 289996 $ */ public class TestRoundtripDerby extends RoundtripTestBase { @@ -58,6 +61,7 @@ // Derby does not have a boolean type, so it gets mapped to SMALLINT // we therefore adjust the original model according to our expectations getModel().getTable(0).getColumn(1).setType("SMALLINT"); + getModel().getTable(0).getColumn(1).setDefaultValue("0"); // Also we get a unique index for the PK addPrimaryKeyUniqueIndicesToModel(); @@ -86,6 +90,35 @@ // Derby does not have a boolean type, so it gets mapped to SMALLINT // we therefore adjust the original model according to our expectations getModel().getTable(0).getColumn(1).setType("SMALLINT"); + + // Also we get a unique index for the PK + addPrimaryKeyUniqueIndicesToModel(); + + assertEquals(getModel(), db); + } + + /** + * Tests a BOOLEAN column with a default value. + */ + public void testBooleanWithDefault() + { + createDatabase(TEST_BOOLEAN_MODEL_WITH_DEFAULT); + insertRow("ROUNDTRIP", new Object[] { new Integer(1), Boolean.TRUE }); + insertRow("ROUNDTRIP", new Object[] { new Integer(2) }); + + List beans = getRows("ROUNDTRIP"); + + assertEquals(Boolean.TRUE, beans.get(0), "VALUE"); + assertEquals(Boolean.TRUE, beans.get(1), "VALUE"); + + Database db = getPlatform().readModelFromDatabase(); + + db.setName("roundtriptest"); + + // Derby does not have a boolean type, so it gets mapped to SMALLINT + // we therefore adjust the original model according to our expectations + getModel().getTable(0).getColumn(1).setType("SMALLINT"); + getModel().getTable(0).getColumn(1).setDefaultValue("1"); // Also we get a unique index for the PK addPrimaryKeyUniqueIndicesToModel();