Clover coverage report -
Coverage timestamp: Sat Jul 7 2007 16:41:13 CEST
file stats: LOC: 87   Methods: 2
NCLOC: 47   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RunnerCreator.java 100% 57.1% 100% 62.5%
coverage coverage
 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.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    * This class is in charge of instantiating runners.
 17    *
 18    * @author Francesco Russo (frusso@dev.java.net)
 19    * @version 4.0
 20    * @since 1.0
 21    */
 22    public class RunnerCreator {
 23   
 24    /**
 25    * Creates a runner in <code>CLEAN</code> state using the provided FQN and
 26    * the given <code>TestConfig</code>.
 27    *
 28    * @param fqn
 29    * @param testConfig
 30    * @param testComplLsnr
 31    * @throws IRunnerCreationException
 32    * @return IRunnerClean
 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    * Short-hand method for instantiating a set of runners in
 66    * <code>CLEAN</code> state.
 67    *
 68    * @param fqn
 69    * @param testConfig
 70    * @param count
 71    * @param testComplLsnr
 72    * @throws IRunnerCreationException
 73    * @return IRunnerClean[]
 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    }