source: trunk/icedtea-web/tests/junit-runner/CommandLine.java

Last change on this file was 429, checked in by dmik, 11 years ago

icedtea-web: Merge version 1.5.1 from vendor to trunk.

File size: 1.8 KB
Line 
1/*
2 * Copyright 2011 Red Hat, Inc.
3 * Based on code from JUnit
4 *
5 * This file is made available under the terms of the Common Public License
6 * v1.0 which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/cpl-v10.html
8 */
9
10import java.io.File;
11import java.util.ArrayList;
12import java.util.List;
13
14import org.junit.internal.JUnitSystem;
15import org.junit.internal.RealSystem;
16import org.junit.runner.JUnitCore;
17import org.junit.runner.Result;
18import org.junit.runner.notification.Failure;
19import org.junit.runner.notification.RunListener;
20
21public class CommandLine extends JUnitCore {
22
23 public static void main(String... args) {
24 runMainAndExit(new RealSystem(), args);
25 }
26
27 public static void runMainAndExit(JUnitSystem system, String... args) {
28 new CommandLine().runMain(system, args);
29 System.exit(0);
30 }
31
32 public Result runMain(JUnitSystem system, String... args) {
33 List<Class<?>> classes = new ArrayList<Class<?>>();
34 List<Failure> missingClasses = new ArrayList<Failure>();
35 for (String each : args) {
36 try {
37 if (each.contains("$")) continue;
38 if (each.toLowerCase().endsWith(".jnlp")) continue;
39 classes.add(Class.forName(each));
40 } catch (ClassNotFoundException e) {
41 system.out().println("ERROR: Could not find class: " + each);
42 }
43 }
44 RunListener jXmlOutput = new JunitLikeXmlOutputListener(system, new File("tests-output.xml"));
45 addListener(jXmlOutput);
46 RunListener listener = new LessVerboseTextListener(system);
47 addListener(listener);
48 Result result = run(classes.toArray(new Class<?>[0]));
49 for (Failure each : missingClasses) {
50 result.getFailures().add(each);
51 }
52 return result;
53 }
54
55}
Note: See TracBrowser for help on using the repository browser.