KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > torque > engine > database > TestPackageHandling


1 package org.apache.torque.engine.database;
2
3 /*
4  * Copyright 2001-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.model.Database;
22 import org.apache.torque.engine.database.model.Table;
23 import org.apache.torque.engine.database.transform.XmlToAppData;
24
25 /**
26  * Tests for package handling.
27  *
28  * @author <a HREF="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
29  * @version $Id: TestPackageHandling.java,v 1.6 2004/02/22 06:29:38 jmcnally Exp $
30  */

31 public class TestPackageHandling extends TestCase
32 {
33     private XmlToAppData xmlToAppData = null;
34     private Database database = null;
35
36     public TestPackageHandling(String JavaDoc name)
37     {
38         super(name);
39     }
40
41     protected void setUp() throws Exception JavaDoc
42     {
43         super.setUp();
44     }
45
46     protected void tearDown() throws Exception JavaDoc
47     {
48         xmlToAppData = null;
49         super.tearDown();
50     }
51
52     /**
53      * test if the tables get the package name from the properties file
54      */

55     public void testDefaultPackageName()
56             throws Exception JavaDoc
57     {
58         xmlToAppData = new XmlToAppData("mysql", "defaultpackage");
59         database = xmlToAppData.parseFile(
60             "src/test/org/apache/torque/engine/database/package-schema.xml");
61         assertEquals("defaultpackage", database.getPackage());
62         Table table = database.getTable("table_a");
63         assertEquals("defaultpackage", table.getPackage());
64     }
65
66     /**
67      * test if the tables get the package name from the database tag
68      */

69     public void testDatabasePackageName()
70             throws Exception JavaDoc
71     {
72         xmlToAppData = new XmlToAppData("mysql", "defaultpackage");
73         database = xmlToAppData.parseFile(
74             "src/test/org/apache/torque/engine/database/package2-schema.xml");
75         assertEquals("packagefromdb", database.getPackage());
76         Table table = database.getTable("table_a");
77         assertEquals("packagefromdb", table.getPackage());
78     }
79
80 }
81
Popular Tags