001: /*
002: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018: package test.org.mandarax.zkb;
019:
020: import junit.framework.Test;
021: import junit.framework.TestSuite;
022: import org.mandarax.kernel.ClauseSet;
023: import org.mandarax.kernel.Query;
024: import org.mandarax.zkb.BinarySerializationOPS;
025: import org.mandarax.zkb.ObjectPersistencyService;
026: import org.mandarax.zkb.ZKBDriver;
027: import org.mandarax.zkb.framework.ZKBDriver_1_0;
028: import org.mandarax.zkb.framework.ZKBDriver_1_1;
029:
030: /**
031: * Test suite for XKB drivers.
032: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
033: * @version 3.4 <7 March 05>
034: * @since 2.3
035: */
036: public class ZKBValidationTests {
037:
038: /**
039: * Launch the test suite. See TestRunner for interpretation
040: * of command line parameters.
041: * @see test.org.mandarax.testsupport.TestRunner
042: * @param args parameters
043: */
044: public static void main(String[] args) {
045: org.apache.log4j.BasicConfigurator.configure();
046: test.org.mandarax.testsupport.TestRunner.run(
047: ZKBValidationTests.class, args);
048: }
049:
050: /**
051: * Get the test suite.
052: * @return the test suite
053: */
054: public static Test suite() {
055: TestSuite suite = new TestSuite(
056: "Test cases for the mandarax ZKB module (DTD verification)");
057: addTests(new ZKBDriver_1_0(), suite);
058: addTests(new ZKBDriver_1_1(), suite);
059: return suite;
060: }
061:
062: /**
063: * Add tests for a certain driver to a test suite.
064: * @param driver the ZKB driver tested
065: * @param suite a test suite
066: */
067: private static void addTests(ZKBDriver driver, TestSuite suite) {
068: addTests(driver, BinarySerializationOPS.class, suite);
069: }
070:
071: /**
072: * Add tests for a certain driver / OPS combination to a test suite.
073: * @param driver the ZKB driver tested
074: * @param ops the object persistency service class
075: * @param suite a test suite
076: */
077: private static void addTests(ZKBDriver driver, Class opsClass,
078: TestSuite suite) {
079: try {
080: // 1 clause set
081: suite.addTest(new ZKBValidationTestCase(driver,
082: (ObjectPersistencyService) opsClass.newInstance(),
083: TestData.fact1(), "testcase 1"));
084: suite.addTest(new ZKBValidationTestCase(driver,
085: (ObjectPersistencyService) opsClass.newInstance(),
086: TestData.fact2(), "testcase 2"));
087: suite.addTest(new ZKBValidationTestCase(driver,
088: (ObjectPersistencyService) opsClass.newInstance(),
089: TestData.fact3(), "testcase 3"));
090: suite.addTest(new ZKBValidationTestCase(driver,
091: (ObjectPersistencyService) opsClass.newInstance(),
092: TestData.fact4(), "testcase 4"));
093: suite.addTest(new ZKBValidationTestCase(driver,
094: (ObjectPersistencyService) opsClass.newInstance(),
095: TestData.fact5(), "testcase 5"));
096: suite.addTest(new ZKBValidationTestCase(driver,
097: (ObjectPersistencyService) opsClass.newInstance(),
098: TestData.fact6(), "testcase 6"));
099: suite.addTest(new ZKBValidationTestCase(driver,
100: (ObjectPersistencyService) opsClass.newInstance(),
101: TestData.fact7(), "testcase 7"));
102: suite.addTest(new ZKBValidationTestCase(driver,
103: (ObjectPersistencyService) opsClass.newInstance(),
104: TestData.fact8(), "testcase 8"));
105: suite.addTest(new ZKBValidationTestCase(driver,
106: (ObjectPersistencyService) opsClass.newInstance(),
107: TestData.fact9(), "testcase 9"));
108: suite.addTest(new ZKBValidationTestCase(driver,
109: (ObjectPersistencyService) opsClass.newInstance(),
110: TestData.fact10(), "testcase 10"));
111: suite.addTest(new ZKBValidationTestCase(driver,
112: (ObjectPersistencyService) opsClass.newInstance(),
113: TestData.rule1(), "testcase 11"));
114: suite.addTest(new ZKBValidationTestCase(driver,
115: (ObjectPersistencyService) opsClass.newInstance(),
116: TestData.andRule(), "testcase 12"));
117: suite.addTest(new ZKBValidationTestCase(driver,
118: (ObjectPersistencyService) opsClass.newInstance(),
119: TestData.orRule(), "testcase 13"));
120: suite.addTest(new ZKBValidationTestCase(driver,
121: (ObjectPersistencyService) opsClass.newInstance(),
122: TestData.sqlClauseSet(), "testcase 14"));
123: suite.addTest(new ZKBValidationTestCase(driver,
124: (ObjectPersistencyService) opsClass.newInstance(),
125: TestData.negRule(), "testcase 15"));
126:
127: // 1 query
128: suite.addTest(new ZKBValidationTestCase(driver,
129: (ObjectPersistencyService) opsClass.newInstance(),
130: null, TestData.query1(), "testcase 17"));
131: suite.addTest(new ZKBValidationTestCase(driver,
132: (ObjectPersistencyService) opsClass.newInstance(),
133: null, TestData.query2(), "testcase 18"));
134: suite.addTest(new ZKBValidationTestCase(driver,
135: (ObjectPersistencyService) opsClass.newInstance(),
136: null, TestData.query3(), "testcase 19"));
137:
138: // 2 clause sets/ 2 queries - check whether order is maintained
139: suite.addTest(new ZKBValidationTestCase(driver,
140: (ObjectPersistencyService) opsClass.newInstance(),
141: null, new ClauseSet[] { TestData.fact1(),
142: TestData.fact2() }, null, "testcase 20"));
143: suite.addTest(new ZKBValidationTestCase(driver,
144: (ObjectPersistencyService) opsClass.newInstance(),
145: null, null, new Query[] { TestData.query1(),
146: TestData.query2() }, "testcase 21"));
147: } catch (Exception x) {
148: x.printStackTrace();
149: }
150:
151: }
152:
153: }
|