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.ser;
019:
020: import junit.framework.Test;
021: import junit.framework.TestSuite;
022: import org.mandarax.kernel.LogicFactory;
023:
024: /**
025: * Test suite for serialization of mandarax related objects.
026: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
027: * @version 3.4 <7 March 05>
028: * @since 1.9.1
029: */
030: public class SerializationTests {
031: /**
032: * Launch the test suite. See TestRunner for interpretation
033: * of command line parameters.
034: * @see test.org.mandarax.testsupport.TestRunner
035: * @param args parameters
036: */
037: public static void main(String[] args) {
038: org.apache.log4j.BasicConfigurator.configure();
039: test.org.mandarax.testsupport.TestRunner.run(
040: SerializationTests.class, args);
041: }
042:
043: /**
044: * Get the test suite.
045: * @return the test suite
046: */
047: public static Test suite() {
048: LogicFactory lfactory = LogicFactory.getDefaultFactory();
049:
050: TestSuite suite = new TestSuite("Test cases for serialization");
051:
052: // objects referenced in other test cases
053: addTest(SerializationTestCase4SerializableTestObjects.class,
054: suite, lfactory);
055: addTest(
056: SerializationTestCase4SerializableDataSourceDummies.class,
057: suite, lfactory);
058: // functions and predicates
059: addTest(SerializationTestCase4SimplePredicates.class, suite,
060: lfactory);
061: addTest(SerializationTestCase4JFunctions.class, suite, lfactory);
062: addTest(SerializationTestCase4DynaBeanFunctions.class, suite,
063: lfactory);
064: addTest(SerializationTestCase4MandaraxLibFunctions.class,
065: suite, lfactory);
066: addTest(SerializationTestCase4JPredicates.class, suite,
067: lfactory);
068: addTest(SerializationTestCase4MandaraxLibPredicates.class,
069: suite, lfactory);
070: // sql functions, predicates and clause sets
071: addTest(SerializationTestCase4SQLPredicates.class, suite,
072: lfactory);
073: addTest(SerializationTestCase4SQLFunctions.class, suite,
074: lfactory);
075: addTest(SerializationTestCase4SQLClauseSets.class, suite,
076: lfactory);
077:
078: // terms
079: addTest(SerializationTestCase4ConstantTerms.class, suite,
080: lfactory);
081: addTest(SerializationTestCase4VariableTerms.class, suite,
082: lfactory);
083: addTest(SerializationTestCase4ComplexTerms.class, suite,
084: lfactory);
085: // clause sets
086: addTest(SerializationTestCase4Rules.class, suite, lfactory);
087: addTest(SerializationTestCase4Facts.class, suite, lfactory);
088: addTest(SerializationTestCase4Queries.class, suite, lfactory);
089: // knowledge bases
090: addTest(SerializationTestCase4KnowledgeBases.class, suite,
091: lfactory);
092: addTest(SerializationTestCase4AdvancedKnowledgeBases.class,
093: suite, lfactory);
094: // misc
095: addTest(SerializationTestCase4Comparators.class, suite,
096: lfactory);
097:
098: return suite;
099: }
100:
101: /**
102: * Add a test to a test suite.
103: * @param testClass the test class
104: * @param suite a test suite
105: * @param lfactory the logic factory used to create objects
106: */
107: private static void addTest(Class testClass, TestSuite suite,
108: LogicFactory lfactory) {
109: try {
110: SerializationTestCase test = (SerializationTestCase) testClass
111: .newInstance();
112: test
113: .setSerializationMode(SerializationTestCase.BIN_SERIALIZE);
114: test.setLogicFactory(lfactory);
115: suite.addTest(test);
116:
117: test = (SerializationTestCase) testClass.newInstance();
118: test
119: .setSerializationMode(SerializationTestCase.XML_SERIALIZE);
120: test.setLogicFactory(lfactory);
121: suite.addTest(test);
122:
123: test = (SerializationTestCase) testClass.newInstance();
124: test
125: .setSerializationMode(SerializationTestCase.XML_SERIALIZE_WITH_DELEGATES);
126: test.setLogicFactory(lfactory);
127: suite.addTest(test);
128: } catch (Exception x) {
129: x.printStackTrace();
130: }
131: }
132: }
|