db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/generator/src/test/org/apache/torque/engine/database/model tabletest-schema.xml TableTest.java
Date Sun, 05 Oct 2003 13:50:34 GMT
mpoeschl    2003/10/05 06:50:34

  Modified:    src/generator/src/test/org/apache/torque/engine/database/model
                        tabletest-schema.xml TableTest.java
  Log:
  add more tests
  
  Revision  Changes    Path
  1.3       +16 -0     db-torque/src/generator/src/test/org/apache/torque/engine/database/model/tabletest-schema.xml
  
  Index: tabletest-schema.xml
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/model/tabletest-schema.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- tabletest-schema.xml	4 Oct 2003 10:11:33 -0000	1.2
  +++ tabletest-schema.xml	5 Oct 2003 13:50:34 -0000	1.3
  @@ -13,6 +13,11 @@
       <column name="col_a" type="CHAR" size="5" />
     </table>
   
  +  <table name="nopk">
  +    <column name="col_a" type="CHAR" size="5" />
  +    <column name="col_b" type="CHAR" size="5" />
  +  </table>
  +
     <table name="singlepk">
       <column name="singlepk_id" required="true" primaryKey="true" type="INTEGER" />
       <column name="col_a" type="CHAR" size="5" />
  @@ -43,6 +48,17 @@
         <reference local="multipk_b" foreign="multipk_b"/>
       </foreign-key>
     </table>
  +  
  +  <table name="unique_test">
  +    <column name="id" required="true" primaryKey="true" type="INTEGER" />
  +    <column name="col_a" type="CHAR" size="5" />
  +    <column name="col_b" type="CHAR" size="5" />
  +    <unique name="unique_name">
  +      <unique-column name="col_a"/>
  +      <unique-column name="col_b"/>
  +    </unique>
  +  </table>
  +  
     
   </database>
   
  
  
  
  1.5       +25 -2     db-torque/src/generator/src/test/org/apache/torque/engine/database/model/TableTest.java
  
  Index: TableTest.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/model/TableTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TableTest.java	4 Oct 2003 11:54:41 -0000	1.4
  +++ TableTest.java	5 Oct 2003 13:50:34 -0000	1.5
  @@ -103,10 +103,20 @@
   		assertEquals(IDMethod.NATIVE, table2.getIdMethod());
       }
       
  +    public void testNoPk() throws Exception
  +    {
  +        Database db = appData.getDatabase("iddb");
  +        Table table = db.getTable("nopk");
  +        assertFalse(table.hasPrimaryKey());
  +        List pks = table.getPrimaryKey();
  +        assertTrue(pks.size() == 0);
  +    }
  +    
       public void testSinglePk() throws Exception
       {
           Database db = appData.getDatabase("iddb");
           Table table = db.getTable("singlepk");
  +        assertTrue(table.hasPrimaryKey());
           List pks = table.getPrimaryKey();
           assertTrue(pks.size() == 1);
           Column col = (Column) pks.get(0);
  @@ -117,12 +127,14 @@
       {
           Database db = appData.getDatabase("iddb");
           Table table = db.getTable("multipk");
  +        assertTrue(table.hasPrimaryKey());
           List pks = table.getPrimaryKey();
           assertTrue(pks.size() == 2);
           Column cola = (Column) pks.get(0);
           assertEquals(cola.getName(), "multipk_a");        
           Column colb = (Column) pks.get(1);
  -        assertEquals(colb.getName(), "multipk_b");        
  +        assertEquals(colb.getName(), "multipk_b");  
  +        assertEquals(table.printPrimaryKey(), "multipk_a,multipk_b");     
       }
    
       public void testSingleFk() throws Exception
  @@ -155,6 +167,17 @@
           assertTrue(refs.size() == 1);
           ForeignKey fk = (ForeignKey) refs.get(0);
           assertEquals(fk.getTableName(), "singlefk");        
  +    }
  +    
  +    public void testUnique() throws Exception
  +    {
  +        Database db = appData.getDatabase("iddb");
  +        Table table = db.getTable("unique_test");
  +        Unique[] unices = table.getUnices();
  +        assertTrue(unices.length == 1);
  +        Unique unique = unices[0];
  +        assertEquals(unique.getName(), "unique_name");   
  +        assertTrue(unique.getColumns().size() == 2);     
       }
       
   }
  
  
  

---------------------------------------------------------------------
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