|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package jtr.test; |
|
8 |
| |
|
9 |
| import java.io.*; |
|
10 |
| |
|
11 |
| import jtr.config.ConfigDeserializer; |
|
12 |
| import jtr.config.TestConfig; |
|
13 |
| import org.apache.log4j.Logger; |
|
14 |
| |
|
15 |
| import org.apache.log4j.xml.*; |
|
16 |
| import org.xml.sax.*; |
|
17 |
| |
|
18 |
| import jtr.remote.utils.RmiUtil; |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| public class Test extends Thread { |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
1
| public Test(String name) {
|
|
40 |
1
| super(name);
|
|
41 |
| } |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
0
| public Test(ThreadGroup group, String name) {
|
|
52 |
0
| super(group, name);
|
|
53 |
| } |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
1
| public void run() {
|
|
63 |
1
| String jtrConfig = System.getProperty(SystemProperties.JTR_TEST_CONFIGURATION);
|
|
64 |
1
| String log4jConfig = System.getProperty(SystemProperties.LOG4J_CONFIGURATION);
|
|
65 |
| |
|
66 |
1
| if (jtrConfig == null) {
|
|
67 |
0
| System.err.println("\nJTR 4.0 - Wrong argument(s) in call. Usage is:\n" + "if using log4j's default initialization just specify the test xml configuration file, "
|
|
68 |
| + "otherwise specify as first parametr the log4j xml configuration file followed by the test xml configuration file.\n\n"); |
|
69 |
0
| System.exit(1);
|
|
70 |
| } else { |
|
71 |
1
| if (log4jConfig != null) {
|
|
72 |
1
| DOMConfigurator.configure(log4jConfig);
|
|
73 |
| } |
|
74 |
1
| Logger logger = Logger.getLogger(Test.class);
|
|
75 |
1
| try {
|
|
76 |
1
| InputStream is = new BufferedInputStream(new FileInputStream(new File(jtrConfig)));
|
|
77 |
1
| ConfigDeserializer cDes = new ConfigDeserializer(is);
|
|
78 |
1
| try {
|
|
79 |
1
| TestConfig test = cDes.getConfigTree();
|
|
80 |
1
| cDes = null;
|
|
81 |
1
| is.close();
|
|
82 |
1
| is = null;
|
|
83 |
1
| TestRunManager trm = new TestRunManager(test);
|
|
84 |
1
| try {
|
|
85 |
1
| trm.startTest();
|
|
86 |
| } catch (TestFailedException e) { |
|
87 |
0
| logger.fatal("Test failed: ", e);
|
|
88 |
0
| e.printStackTrace();
|
|
89 |
| } |
|
90 |
| } catch (IOException e) { |
|
91 |
0
| logger.fatal("Error while reading in the test configuration: ", e);
|
|
92 |
0
| e.printStackTrace();
|
|
93 |
| } catch (SAXException e) { |
|
94 |
0
| logger.fatal("Error while reading in the test configuration: ", e);
|
|
95 |
0
| e.printStackTrace();
|
|
96 |
| } |
|
97 |
| } catch (IOException e) { |
|
98 |
0
| logger.fatal("Error while reading in the test configuration: ", e);
|
|
99 |
0
| e.printStackTrace();
|
|
100 |
| } |
|
101 |
| } |
|
102 |
| } |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
1
| public static void main(String[] args) {
|
|
111 |
1
| RmiUtil.setSystemProperties();
|
|
112 |
1
| Test test = new Test("Test-Thread");
|
|
113 |
1
| test.run();
|
|
114 |
| } |
|
115 |
| } |