KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > setup > TestCmsSetupDb


1 /*
2  * File : $Source: /usr/local/cvs/opencms/test/org/opencms/setup/TestCmsSetupDb.java,v $
3  * Date : $Date: 2005/06/27 23:22:20 $
4  * Version: $Revision: 1.11 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.setup;
33
34 import org.opencms.scheduler.TestCmsSchedulerInSystem;
35 import org.opencms.test.OpenCmsTestCase;
36
37 import junit.framework.Test;
38 import junit.framework.TestSuite;
39
40 /**
41  * Tests the database creation / removal used during setup.<p>
42  *
43  * @author Alexander Kandzior
44  *
45  * @version $Revision: 1.11 $
46  *
47  * @since 6.0.0
48  */

49 public class TestCmsSetupDb extends OpenCmsTestCase {
50
51     /**
52      * Default JUnit constructor.<p>
53      *
54      * @param arg0 JUnit parameters
55      */

56     public TestCmsSetupDb(String JavaDoc arg0) {
57
58         super(arg0);
59     }
60
61     /**
62      * Test suite for this test class (becasue the order of test cases is important here).<p>
63      *
64      * @return the test suite
65      */

66     public static Test suite() {
67
68         TestSuite suite = new TestSuite();
69         suite.setName(TestCmsSchedulerInSystem.class.getName());
70
71         suite.addTest(new TestCmsSetupDb("testCreateDatabase"));
72         suite.addTest(new TestCmsSetupDb("testCreateTables"));
73         suite.addTest(new TestCmsSetupDb("testDropTables"));
74         suite.addTest(new TestCmsSetupDb("testDropDatabase"));
75
76         return suite;
77     }
78
79     /**
80      * Tests database creation.<p>
81      */

82     public void testCreateDatabase() {
83
84         if (DB_ORACLE.equals(getDatabaseProduct())) {
85             System.out.println("testCreateDatabase not applicable for oracle.");
86             return;
87         }
88
89         // use create method form superclass
90
CmsSetupDb setupDb = getSetupDb(m_setupConnection);
91         setupDb.createDatabase(m_dbProduct, getReplacer(m_defaultConnection), true);
92
93         // check for errors
94
checkErrors(setupDb);
95
96         // close connections
97
setupDb.closeConnection();
98     }
99
100     /**
101      * Tests table creation.<p>
102      */

103     public void testCreateTables() {
104
105         if (DB_ORACLE.equals(getDatabaseProduct())) {
106             System.out.println("testDropDatabase not applicable for oracle.");
107             return;
108         }
109
110         // use create method form superclass
111
CmsSetupDb setupDb = getSetupDb(m_defaultConnection);
112         setupDb.createTables(m_dbProduct, getReplacer(m_defaultConnection), true);
113
114         // check for errors
115
checkErrors(setupDb);
116
117         // close connections
118
setupDb.closeConnection();
119     }
120
121     /**
122      * Tests database removal.<p>
123      */

124     public void testDropDatabase() {
125
126         if (DB_ORACLE.equals(getDatabaseProduct())) {
127             System.out.println("testDropDatabase not applicable for oracle.");
128             return;
129         }
130
131         // use drop method form superclass
132
CmsSetupDb setupDb = getSetupDb(m_setupConnection);
133         setupDb.dropDatabase(m_dbProduct, getReplacer(m_defaultConnection), true);
134
135         // check for errors
136
checkErrors(setupDb);
137
138         // close connections
139
setupDb.closeConnection();
140     }
141
142     /**
143      * Tests table removal.<p>
144      */

145     public void testDropTables() {
146
147         if (DB_ORACLE.equals(getDatabaseProduct())) {
148             System.out.println("testDropDatabase not applicable for oracle.");
149             return;
150         }
151
152         // use drop method form superclass
153
CmsSetupDb setupDb = getSetupDb(m_defaultConnection);
154         setupDb.dropTables(m_dbProduct, getReplacer(m_defaultConnection), true);
155
156         // check for errors
157
checkErrors(setupDb);
158
159         // close connections
160
setupDb.closeConnection();
161     }
162 }
Popular Tags