001: /*
002: * Copyright 2006 Le Duc Bao, Ralf Joachim
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package org.castor.ddlgen.engine.pointbase;
017:
018: import junit.framework.Test;
019: import junit.framework.TestSuite;
020:
021: import org.castor.ddlgen.DDLGenConfiguration;
022: import org.castor.ddlgen.KeyGeneratorRegistry;
023: import org.castor.ddlgen.test.framework.AbstractGeneratorTest;
024: import org.castor.ddlgen.test.framework.Expected;
025:
026: /**
027: * PointBase generator test.
028: *
029: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
030: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
031: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
032: * @since 1.1
033: */
034: public final class PointBaseGeneratorTest extends AbstractGeneratorTest {
035: public PointBaseGeneratorTest(final String testcase) {
036: super (testcase);
037: }
038:
039: public PointBaseGeneratorTest(final String testcase,
040: final boolean useDBlEngine) {
041: super (testcase);
042:
043: if (useDBlEngine) {
044: setEngine(Expected.ENGINE_POINTBASE);
045: }
046: }
047:
048: public static Test suite() throws Exception {
049: TestSuite suite = new TestSuite(
050: "All org.castor.ddlgen.engine.pointbase tests");
051:
052: //schema test
053: suite.addTest(new PointBaseGeneratorTest("testCreateSchema",
054: true));
055:
056: // drop test
057: suite
058: .addTest(new PointBaseGeneratorTest("testDropTable",
059: false));
060:
061: // table test
062: suite.addTest(new PointBaseGeneratorTest("testSingleTable",
063: false));
064: suite.addTest(new PointBaseGeneratorTest("testMultipleTable",
065: false));
066: suite.addTest(new PointBaseGeneratorTest("testIgnoredTable",
067: false));
068: suite.addTest(new PointBaseGeneratorTest("testNoTable", false));
069:
070: //field test
071: suite.addTest(new PointBaseGeneratorTest("testSingleField",
072: false));
073: suite.addTest(new PointBaseGeneratorTest(
074: "testSingleFieldForAll", true));
075: suite.addTest(new PointBaseGeneratorTest("testIgnoredField",
076: false));
077: suite.addTest(new PointBaseGeneratorTest("testNoField", false));
078: suite.addTest(new PointBaseGeneratorTest(
079: "testManyKeysReference", false));
080: suite.addTest(new PointBaseGeneratorTest(
081: "testManyClassKeysReference", false));
082: suite.addTest(new PointBaseGeneratorTest(
083: "test2LevelsReference", false));
084:
085: // primary key test
086: suite.addTest(new PointBaseGeneratorTest("testClassId", true));
087: suite.addTest(new PointBaseGeneratorTest("testClassMultipleId",
088: true));
089: suite.addTest(new PointBaseGeneratorTest("testFieldId", true));
090: suite.addTest(new PointBaseGeneratorTest("testFieldMultipleId",
091: true));
092: suite.addTest(new PointBaseGeneratorTest(
093: "testOverwriteFieldId", false));
094: suite.addTest(new PointBaseGeneratorTest("testNoId", false));
095:
096: // foreign key test
097: suite.addTest(new PointBaseGeneratorTest(
098: "testOneOneRelationship", false));
099: suite.addTest(new PointBaseGeneratorTest(
100: "testOneManyRelationship", false));
101: suite.addTest(new PointBaseGeneratorTest(
102: "testManyManyRelationship", false));
103:
104: // index test
105: suite.addTest(new PointBaseGeneratorTest("testCreateIndex",
106: false));
107:
108: // key generator test
109: suite.addTest(new PointBaseGeneratorTest("testKeyGenIdentity",
110: true));
111: suite.addTest(new PointBaseGeneratorTest("testKeyGenHighLow",
112: false));
113: suite
114: .addTest(new PointBaseGeneratorTest("testKeyGenMax",
115: false));
116: suite.addTest(new PointBaseGeneratorTest("testKeyGenUUID",
117: false));
118:
119: return suite;
120: }
121:
122: /**
123: * {@inheritDoc}
124: */
125: protected void setUp() throws Exception {
126: super .setUp();
127:
128: DDLGenConfiguration conf = new DDLGenConfiguration();
129: conf
130: .addProperties("org/castor/ddlgen/test/config/ddlgen.properties");
131: conf
132: .addProperties("org/castor/ddlgen/test/config/pointbase.properties");
133: setGenerator(new PointBaseGenerator(conf));
134:
135: KeyGeneratorRegistry keyGenRegistry = new KeyGeneratorRegistry(
136: conf);
137: getGenerator().setKeyGenRegistry(keyGenRegistry);
138:
139: getGenerator().initialize();
140: }
141:
142: /**
143: * {@inheritDoc}
144: */
145: protected void tearDown() throws Exception {
146: super.tearDown();
147:
148: setGenerator(null);
149: }
150: }
|