1   package org.apache.torque.engine.database.model;
2   
3   /*
4    * Copyright 2003-2004 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import junit.framework.TestCase;
20  
21  import org.apache.torque.engine.database.transform.XmlToAppData;
22  
23  /***
24   * Tests for package handling.
25   *
26   * @author <a href="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
27   * @version $Id: TableTest.java,v 1.1.2.2 2004/05/20 04:35:16 seade Exp $
28   */
29  public class TableTest extends TestCase
30  {
31      private XmlToAppData xmlToAppData = null;
32      private AppData appData = null;
33  
34      public TableTest(String name)
35      {
36          super(name);
37      }
38  
39      protected void setUp() throws Exception
40      {
41          super.setUp();
42      }
43  
44      protected void tearDown() throws Exception
45      {
46          xmlToAppData = null;
47          super.tearDown();
48      }
49  
50      /***
51       * test if the tables get the package name from the properties file
52       */
53      public void testIdMethodHandling()
54              throws Exception
55      {
56          xmlToAppData = new XmlToAppData("mysql", "defaultpackage", null);
57          appData = xmlToAppData.parseFile(
58              "src/test/org/apache/torque/engine/database/model/tabletest-schema.xml");
59          Database db = appData.getDatabase("iddb");
60          assertEquals(IDMethod.ID_BROKER, db.getDefaultIdMethod());
61          Table table = db.getTable("table_idbroker");
62          assertEquals(IDMethod.ID_BROKER, table.getIdMethod());
63  		Table table2 = db.getTable("table_native");
64  		assertEquals(IDMethod.NATIVE, table2.getIdMethod());
65      }
66  }