001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/test/junit/alltests/AllTests.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstr. 19
030: 53115 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042:
043: ---------------------------------------------------------------------------*/
044: package alltests;
045:
046: import java.io.FileInputStream;
047: import java.io.FileNotFoundException;
048: import java.io.IOException;
049: import java.util.Properties;
050:
051: import junit.framework.Test;
052: import junit.framework.TestSuite;
053: import junit.swingui.TestRunner;
054:
055: import org.deegree.framework.log.ILogger;
056: import org.deegree.framework.log.LoggerFactory;
057:
058: /**
059: * Main test class for project deegree.
060: * <p>
061: * Uses the list of test classes from property "test.classfiles" in file "test.properties".
062: * </p>
063: *
064: * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe </a>
065: * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a>
066: * @author last edited by: $Author: apoth $
067: *
068: * @version $Revision: 9335 $, $Date: 2007-12-27 02:51:08 -0800 (Thu, 27 Dec 2007) $
069: */
070: public final class AllTests {
071:
072: private static final String TEST_PROPERTIES_FILE = "test.properties";
073:
074: private static final String TEST_CLASSFILES = "test.classfiles";
075:
076: private static final int DOT_CLASS_LENGTH = ".class".length();
077:
078: /**
079: * Logger for test cases
080: */
081: public static final ILogger LOG = LoggerFactory
082: .getLogger(AllTests.class);
083:
084: /**
085: * @return list of tests
086: */
087: public static Test suite() {
088: TestSuite suite = new TestSuite();
089:
090: try {
091: Properties properties = new Properties();
092: properties.load(new FileInputStream(TEST_PROPERTIES_FILE));
093: String testClassesString = properties
094: .getProperty(TEST_CLASSFILES);
095: String[] testClasses = testClassesString
096: .split("[ \\t\\n\\\\]");
097: for (int i = 0; i < testClasses.length; i++) {
098: String testClassName = testClasses[i].replace('/', '.')
099: .substring(
100: 0,
101: testClasses[i].length()
102: - DOT_CLASS_LENGTH);
103: try {
104: Class<?> testClass = Class.forName(testClassName);
105: suite.addTestSuite(testClass);
106: } catch (ClassNotFoundException e1) {
107: LOG.logError("Cannot load test class '"
108: + testClassName + "'.");
109: }
110: }
111: } catch (FileNotFoundException e) {
112: LOG.logError("File '" + TEST_PROPERTIES_FILE
113: + "' not found.");
114: } catch (IOException e) {
115: LOG.logError("Error reading file '" + TEST_PROPERTIES_FILE
116: + "'.");
117: }
118: return suite;
119: }
120:
121: /**
122: * @param args
123: */
124: public static void main(String[] args) {
125: TestRunner runner = new TestRunner();
126: if (args.length == 0) {
127: args = new String[] { "-noloading", "alltests.AllTests" };
128: }
129: runner.start(args);
130: }
131:
132: }
|