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.testsupport;
019:
020: import java.lang.reflect.Method;
021: import junit.framework.TestSuite;
022: import org.apache.log4j.BasicConfigurator;
023: import org.apache.log4j.Category;
024: import org.apache.log4j.Level;
025:
026: /**
027: * Executable class to run all mandarax test suites together.
028: * To avoid glueing packages together, test suites (class defining
029: * a static method <code>suite()</code>) are referenced by name.
030: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
031: * @version 3.4 <7 March 05>
032: * @since 1.2
033: */
034: public class TestAll {
035:
036: /**
037: * Get an array of all mandarax classes defining
038: * a static suite method.
039: * @return an array of class names
040: */
041: public static String[] getAllTestSuites() {
042: String[] classes = {
043:
044: "test.org.mandarax.lib.math.IntArithmeticTests",
045: "test.org.mandarax.lib.math.DoubleArithmeticTests",
046: "test.org.mandarax.lib.date.DateArithmeticTests",
047: "test.org.mandarax.reference.ResolutionInferenceEngineTests",
048: "test.org.mandarax.reference.KnowledgeBaseTests",
049: "test.org.mandarax.reference.AdvancedKnowledgeBaseTests",
050: "test.org.mandarax.reference.ClauseSetEventsTests",
051: "test.org.mandarax.reference.NAFTests",
052: "test.org.mandarax.util.AutoFactsTests",
053: "test.org.mandarax.reference.SimpleLoopCheckerTests",
054: "test.org.mandarax.xkb.XKBTests",
055: "test.org.mandarax.ser.SerializationTests",
056: "test.org.mandarax.reference.CutTests",
057: "test.org.mandarax.reference.derivationeventlisteners.DerivationEventListenerTests",
058: "test.org.mandarax.zkb.ZKBTests",
059: "test.org.mandarax.zkb.ZKBValidationTests",
060: "test.org.mandarax.util.WildcardMatcherTests",
061: "test.org.mandarax.util.resultsetfilters.GroupByTests",
062: "test.org.mandarax.util.resultsetfilters.OrderByTests",
063: "test.org.mandarax.util.resultsetfilters.WhereTests",
064:
065: /* jdbc has been moved into separate module in v 3.3.1
066: "test.org.mandarax.jdbc.CreateConnectionTests",
067: "test.org.mandarax.jdbc.QueryTests1",
068: "test.org.mandarax.jdbc.QueryTests2",
069: "test.org.mandarax.jdbc.NetQueryTests1",
070: "test.org.mandarax.jdbc.ResultSetMetaDataTests",
071: "test.org.mandarax.jdbc.parser.SQLValidationTestCases",
072: "test.org.mandarax.jdbc.parser.SQLParserTestCasesForSelectAndFromClause",
073: "test.org.mandarax.jdbc.parser.SQLParserTestCasesForSimpleConditions",
074: "test.org.mandarax.jdbc.parser.SQLParserTestCasesForCompoundConditions",
075: */
076: };
077:
078: return classes;
079: }
080:
081: /**
082: * Launch the test suite. See TestRunner for interpretation
083: * of command line parameters.
084: * @see test.org.mandarax.testsupport.TestRunner
085: * @param args parameters
086: */
087: public static void main(String[] args) {
088: BasicConfigurator.configure();
089: Category.getRoot().setLevel(Level.WARN);
090: // disable next line if you dont want to see logs on System.out !
091: Category.getRoot().removeAllAppenders();
092: test.org.mandarax.testsupport.TestRunner.run(TestAll.class,
093: args, false);
094: }
095:
096: /**
097: * Get a test suite. This suite is the result of merging
098: * all test suites defined in the classes registered in
099: * getAllTestSuites().
100: * @return a test suite
101: */
102: public static TestSuite suite() {
103: TestSuite suite = new TestSuite("All mandarax test cases");
104: String[] classNames = getAllTestSuites();
105:
106: for (int i = 0; i < classNames.length; i++) {
107: try {
108: Class clazz = Class.forName(classNames[i]);
109: Method m = clazz.getMethod("suite", new Class[0]);
110: TestSuite part = (TestSuite) m.invoke(null,
111: new Object[0]);
112:
113: suite.addTest(part);
114: } catch (Exception x) {
115: System.err
116: .println("Cannot add class "
117: + classNames[i]
118: + " to merged test suite, check whether this class is in the class path and defines a static method suite() returning a test suite !");
119: x.printStackTrace(System.err);
120: }
121: }
122:
123: return suite;
124: }
125: }
|