|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package jtr.runners; |
|
8 |
| |
|
9 |
| import jtr.config.TestConfig; |
|
10 |
| import jtr.config.RegisteredFactories; |
|
11 |
| import jtr.test.IOutcomeFactory; |
|
12 |
| import jtr.test.ITestCompletionListener; |
|
13 |
| import org.apache.log4j.Logger; |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| public class RunnerCreator { |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
98
| public synchronized static IRunnerClean create(String fqn, TestConfig testConfig, ITestCompletionListener testComplLsnr) throws IRunnerCreationException {
|
|
35 |
98
| IRunnerClean cRunner = null;
|
|
36 |
98
| try {
|
|
37 |
98
| Class clazz = Class.forName(fqn, true, Thread.currentThread().getContextClassLoader());
|
|
38 |
98
| try {
|
|
39 |
98
| cRunner = (IRunnerClean) clazz.newInstance();
|
|
40 |
98
| cRunner.setName(cRunner.getDefaultName() + "-" + instanceCounter + "-" + System.nanoTime());
|
|
41 |
98
| cRunner.setOutcomeFactory((IOutcomeFactory) RegisteredFactories.getFactory(RegisteredFactories.IOUTCOME_FACTORY));
|
|
42 |
98
| cRunner.setTestCompletionListener(testComplLsnr);
|
|
43 |
98
| logger.debug("Created IRunner called " + cRunner.getName());
|
|
44 |
| } catch (IllegalAccessException e) { |
|
45 |
0
| String msg = "Unable to find the required IRunner implementation class: " + fqn;
|
|
46 |
0
| IRunnerCreationException irce = new IRunnerCreationException(msg, e);
|
|
47 |
0
| logger.fatal(msg, irce);
|
|
48 |
0
| throw irce;
|
|
49 |
| } catch (InstantiationException e) { |
|
50 |
0
| String msg = "Unable to find the required IRunner implementation class: " + fqn;
|
|
51 |
0
| IRunnerCreationException irce = new IRunnerCreationException(msg, e);
|
|
52 |
0
| logger.fatal(msg, irce);
|
|
53 |
0
| throw irce;
|
|
54 |
| } |
|
55 |
| } catch (ClassNotFoundException e) { |
|
56 |
0
| String msg = "Unable to find the required IRunner implementation class: " + fqn;
|
|
57 |
0
| IRunnerCreationException irce = new IRunnerCreationException(msg, e);
|
|
58 |
0
| logger.fatal(msg, irce);
|
|
59 |
0
| throw irce;
|
|
60 |
| } |
|
61 |
98
| return cRunner;
|
|
62 |
| } |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
12
| public synchronized static IRunnerClean[] create(String fqn, TestConfig testConfig, int count, ITestCompletionListener testComplLsnr) throws IRunnerCreationException {
|
|
76 |
12
| IRunner[] cRunners = new IRunner[count];
|
|
77 |
12
| for (int i = 0; i < count; i++) {
|
|
78 |
98
| cRunners[i] = (IRunner) create(fqn, testConfig, testComplLsnr);
|
|
79 |
98
| instanceCounter++;
|
|
80 |
| } |
|
81 |
12
| instanceCounter = 0;
|
|
82 |
12
| return cRunners;
|
|
83 |
| } |
|
84 |
| |
|
85 |
| private static Logger logger = Logger.getLogger(RunnerCreator.class); |
|
86 |
| private static int instanceCounter = 0; |
|
87 |
| } |