1 package org.apache.torque.engine.database;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 239624 2005-08-24 12:18:03Z henning $
30 */
31 public class TestPackageHandling extends TestCase
32 {
33 private XmlToAppData xmlToAppData = null;
34 private Database database = null;
35
36 public TestPackageHandling(String name)
37 {
38 super(name);
39 }
40
41 protected void setUp() throws Exception
42 {
43 super.setUp();
44 }
45
46 protected void tearDown() throws Exception
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
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
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 }