[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/visitorsTests AllTests.java,1.30,1.31
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-08-23 21:30:23
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/visitorsTests In directory sc8-pr-cvs1:/tmp/cvs-serv20167/tests/visitorsTests Modified Files: AllTests.java Log Message: Sixth drop for new i/o subsystem. Isolated htmllexer.jar file and made it compileable and runnable on JDK 1.1 systems. The build.xml file now has four new targets for separate compiling and jaring of the lexer and parser. Significantly refactored the existing Node interface and AbstractNode class to achieve isolation. They now support get/setChildren(), rather than CompositeTag. Various scanners that were directly accessing the childTags node list were affected. The get/setParent is now a generic Node rather than a CompositeTag. The visitor accept() signature was changed to Object to avoid dragging in visitors code. This was *not* changed on classes derived from Tag, although it could be. ChainedException now uses/returns a Vector. Removed the cruft from lexer nodes where possible. Index: AllTests.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/visitorsTests/AllTests.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** AllTests.java 11 Aug 2003 00:18:34 -0000 1.30 --- AllTests.java 23 Aug 2003 17:14:46 -0000 1.31 *************** *** 51,53 **** --- 51,129 ---- return suite; } + + /** + * Mainline for all suites of tests. + * @param args Command line arguments. The following options + * are understood: + * <pre> + * -text -- use junit.textui.TestRunner + * -awt -- use junit.awtui.TestRunner + * -swing -- use junit.swingui.TestRunner (default) + * </pre> + * All other options are passed on to the junit framework. + */ + public static void main(String[] args) + { + String runner; + int i; + String arguments[]; + Class cls; + + runner = null; + for (i = 0; (i < args.length) && (null == runner); i++) + { + if (args[i].equalsIgnoreCase ("-text")) + runner = "junit.textui.TestRunner"; + else if (args[i].equalsIgnoreCase ("-awt")) + runner = "junit.awtui.TestRunner"; + else if (args[i].equalsIgnoreCase ("-swing")) + runner = "junit.swingui.TestRunner"; + } + if (null != runner) + { + // remove it from the arguments + arguments = new String[args.length - 1]; + System.arraycopy (args, 0, arguments, 0, i - 1); + System.arraycopy (args, i, arguments, i - 1, args.length - i); + args = arguments; + } + else + runner = "junit.swingui.TestRunner"; + + /* + * from http://www.mail-archive.com/commons-user%40jakarta.apache.org/msg02958.html + * + * The problem is within the UI test runners of JUnit. They bring + * with them a custom classloader, which causes the + * LogConfigurationException. Unfortunately Log4j doesn't work + * either. + * + * Solution: Disable "Reload classes every run" or start JUnit with + * command line option -noloading before the name of the Testsuite. + */ + + // append the test class + arguments = new String[args.length + 2]; + System.arraycopy (args, 0, arguments, 0, args.length); + arguments[arguments.length - 2] = "-noloading"; + arguments[arguments.length - 1] = "org.htmlparser.tests.visitorsTests.AllTests"; + + // invoke main() of the test runner + try + { + cls = Class.forName (runner); + java.lang.reflect.Method method = cls.getDeclaredMethod ( + "main", new Class[] { String[].class }); + method.invoke ( + null, + new Object[] { arguments }); + } + catch (Throwable t) + { + System.err.println ( + "cannot run unit test (" + + t.getMessage () + + ")"); + } + } } |