|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
RunnerPoolFiller.java | 100% | 100% | 100% | 100% |
|
1 | /** | |
2 | * JTRunner is free software; you can redistribute it and/or modify it under the | |
3 | * terms of the GNU General Public License as published by the Free Software | |
4 | * Foundation; either version 2, or (at your option) any later version. | |
5 | */ | |
6 | ||
7 | package jtr.pool; | |
8 | ||
9 | import java.util.*; | |
10 | ||
11 | import jtr.config.TestConfig; | |
12 | import jtr.runners.IRunnerCreationException; | |
13 | import jtr.assigner.UnknownAssignmentPolicyException; | |
14 | import jtr.config.RunnerConfig; | |
15 | import jtr.runners.IRunner; | |
16 | import jtr.runners.RunnerCreator; | |
17 | import jtr.test.ITestCompletionListener; | |
18 | import jtr.test.TestRunManager; | |
19 | ||
20 | /** | |
21 | * Given a <code>TestConfig</code> and a <code>RunnerPool</code>, this | |
22 | * class takes care of both the instantiation of the configured set of | |
23 | * <code>IRunner</code>s and the filling of the pool. <br> | |
24 | * A <code>RunnerCreator</code> is used the perform the instantiation of the | |
25 | * runners. | |
26 | * | |
27 | * @author Francesco Russo (frusso@dev.java.net) | |
28 | * @version 4.0 | |
29 | * @since 1.0 | |
30 | */ | |
31 | public class RunnerPoolFiller { | |
32 | /** | |
33 | * This method instantiates the runners as dictated by the | |
34 | * <code>TestConfig</code> and uses them to populate the provided | |
35 | * <code>RunnerPool</code>. | |
36 | * | |
37 | * @param testConfig TestConfig | |
38 | * @param pool RunnerPool | |
39 | * @param testComplLsnr | |
40 | * @throws IRunnerCreationException | |
41 | * @throws UnknownAssignmentPolicyException | |
42 | */ | |
43 | 1 | public static void fillPool(TestConfig testConfig, RunnerPool pool, ITestCompletionListener testComplLsnr) throws IRunnerCreationException, UnknownAssignmentPolicyException { |
44 | // let's retrieve all the IRunners configurations | |
45 | 1 | Iterator runners = testConfig.getRunners().iterator(); |
46 | 1 | while (runners.hasNext()) { |
47 | 6 | RunnerConfig runnerConfig = (RunnerConfig) runners.next(); |
48 | 6 | IRunner[] iRunners = (IRunner[]) RunnerCreator.create(runnerConfig.getRunnerFqn(), testConfig, runnerConfig.getCount(), testComplLsnr); |
49 | // let's retrive: | |
50 | // 1. the parameters assignment policy | |
51 | // 2. the actual assigner instance | |
52 | // and then let's perform the assignment | |
53 | 6 | runnerConfig.getAssignmetPolicy().getAssigner().assign(iRunners, runnerConfig); |
54 | // let's add the runners associated with the current RunnerConfig to | |
55 | // the pool | |
56 | 6 | pool.addAll(iRunners); |
57 | } | |
58 | } | |
59 | } |
|