db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject cvs commit: db-torque/src/generator/src/test/org/apache/torque/engine/database/model HypersonicDomainTest.java
Date Fri, 20 May 2005 20:19:18 GMT
tfischer    2005/05/20 13:19:18

  Modified:    src/generator/src/java/org/apache/torque/engine/platform
                        PlatformHypersonicImpl.java
  Added:       src/generator/src/test/org/apache/torque/engine/database/model
                        HypersonicDomainTest.java
  Log:
  Support CLOB and BLOB in HSQLDB; added testcase for HSQLDB Platform in the generator.
  
  Thanks to Martin Kalen for the patch
  
  Revision  Changes    Path
  1.6       +6 -4      db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformHypersonicImpl.java
  
  Index: PlatformHypersonicImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformHypersonicImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PlatformHypersonicImpl.java	22 Feb 2004 06:27:19 -0000	1.5
  +++ PlatformHypersonicImpl.java	20 May 2005 20:19:18 -0000	1.6
  @@ -1,7 +1,7 @@
   package org.apache.torque.engine.platform;
   
   /*
  - * Copyright 2003,2004 The Apache Software Foundation.
  + * Copyright 2003-2005 The Apache Software Foundation.
    * 
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -20,7 +20,7 @@
   import org.apache.torque.engine.database.model.SchemaType;
   
   /**
  - * Hypersonic Platform implementation.
  + * HSQLDB (formerly known as Hypersonic) Platform implementation.
    *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
  @@ -45,6 +45,8 @@
           setSchemaDomainMapping(new Domain(SchemaType.BOOLEANCHAR, "VARCHAR"));
           setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "VARCHAR"));
           setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BINARY"));
  -    }
  +        setSchemaDomainMapping(new Domain(SchemaType.BLOB, "BINARY"));
  +        setSchemaDomainMapping(new Domain(SchemaType.CLOB, "LONGVARCHAR"));
  +   }
   
   }
  
  
  
  1.1                  db-torque/src/generator/src/test/org/apache/torque/engine/database/model/HypersonicDomainTest.java
  
  Index: HypersonicDomainTest.java
  ===================================================================
  package org.apache.torque.engine.database.model;
  
  /*
   * Copyright 2003-2005 The Apache Software Foundation.
   *
   * Licensed 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.
   */
  
  import junit.framework.TestCase;
  
  import org.apache.torque.engine.database.transform.XmlToAppData;
  
  /**
   * Tests for domain handling (for HSQLDB formerly known as Hypersonic).
   *
   * @author <a href="mailto:mkalen@apache.org">Martin Kal&eacute;n</a>
   * @version $Id: HypersonicDomainTest.java,v 1.1 2005/05/20 20:19:18 tfischer Exp $
   */
  public class HypersonicDomainTest extends TestCase
  {
  
      private XmlToAppData xmlToAppData;
      private Database db;
  
      public HypersonicDomainTest(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
          xmlToAppData = new XmlToAppData("hypersonic", "defaultpackage");
          db = xmlToAppData.parseFile(
              "src/test/org/apache/torque/engine/database/model/domaintest-schema.xml");
      }
  
      protected void tearDown() throws Exception
      {
          xmlToAppData = null;
          super.tearDown();
      }
  
      /**
       * test if the tables get the package name from the properties file
       */
      public void testDomainColumn() throws Exception
      {
          Table table = db.getTable("product");
          Column name = table.getColumn("name");
          assertEquals("VARCHAR", name.getDomain().getSqlType());
          assertEquals("40", name.getSize());
          assertEquals("name VARCHAR(40)  ", name.getSqlString());
          Column price = table.getColumn("price");
          assertEquals("NUMERIC", price.getTorqueType());
          assertEquals("NUMERIC", price.getDomain().getSqlType());
          assertEquals("10", price.getSize());
          assertEquals("2", price.getScale());
          assertEquals("0", price.getDefaultValue());
          assertEquals("(10,2)", price.printSize());
          assertEquals("price NUMERIC(10,2) default 0  ", price.getSqlString());
      }
  
      /**
       * test if the tables get the package name from the properties file
       */
      public void testExtendedDomainColumn() throws Exception
      {
          Table table = db.getTable("article");
          Column price = table.getColumn("price");
          assertEquals("NUMERIC", price.getTorqueType());
          assertEquals("NUMERIC", price.getDomain().getSqlType());
          assertEquals("12", price.getSize());
          assertEquals("2", price.getScale());
          assertEquals("1000", price.getDefaultValue());
          assertEquals("(12,2)", price.printSize());
          assertEquals("price NUMERIC(12,2) default 1000  ", price.getSqlString());
      }
  
      public void testDecimalColumn() throws Exception
      {
          Table table = db.getTable("article");
          Column col = table.getColumn("decimal_col");
          assertEquals("DECIMAL", col.getTorqueType());
          assertEquals("DECIMAL", col.getDomain().getSqlType());
          assertEquals("10", col.getSize());
          assertEquals("3", col.getScale());
          assertEquals("(10,3)", col.printSize());
          assertEquals("decimal_col DECIMAL(10,3)  ", col.getSqlString());
      }
  
      public void testDateColumn() throws Exception
      {
          Table table = db.getTable("article");
          Column col = table.getColumn("date_col");
          assertEquals("DATE", col.getTorqueType());
          assertEquals("DATE", col.getDomain().getSqlType());
          assertEquals("", col.printSize());
          assertEquals("date_col DATE  ", col.getSqlString());
      }
  
      public void testNativeAutoincrement() throws Exception
      {
          Table table = db.getTable("native");
          Column col = table.getColumn("native_id");
          assertEquals("IDENTITY", col.getAutoIncrementString());
          assertEquals("native_id INTEGER NOT NULL IDENTITY", col.getSqlString());
          col = table.getColumn("name");
          assertEquals("", col.getAutoIncrementString());
      }
  
      public void testIdBrokerAutoincrement() throws Exception
      {
          Table table = db.getTable("article");
          Column col = table.getColumn("article_id");
          assertEquals("", col.getAutoIncrementString());
          assertEquals("article_id INTEGER NOT NULL ", col.getSqlString());
          col = table.getColumn("name");
          assertEquals("", col.getAutoIncrementString());
      }
  
      public void testBooleanint() throws Exception
      {
          Table table = db.getTable("types");
          Column col = table.getColumn("cbooleanint");
          assertEquals("", col.getAutoIncrementString());
          assertEquals("BOOLEANINT", col.getTorqueType());
          assertEquals("INTEGER", col.getDomain().getSqlType());
          assertEquals("cbooleanint INTEGER  ", col.getSqlString());
      }
  
      public void testBlob() throws Exception
      {
          Table table = db.getTable("types");
          Column col = table.getColumn("cblob");
          assertEquals("", col.getAutoIncrementString());
          assertEquals("BLOB", col.getTorqueType());
          assertEquals("BINARY", col.getDomain().getSqlType());
          assertEquals("cblob BINARY  ", col.getSqlString());
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message