Clover coverage report -
Coverage timestamp: Sat Jul 7 2007 16:41:13 CEST
file stats: LOC: 94   Methods: 2
NCLOC: 41   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractRunner.java 100% 91.7% 100% 93.8%
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 org.apache.log4j.Logger;
 10   
 11    /**
 12    * This is the base class every application level runner should extend. It
 13    * provides a lot of useful methods along with the handling of the interactions
 14    * with the JTR runtime.
 15    *
 16    * @author Francesco Russo (frusso@dev.java.net)
 17    * @version 4.0
 18    * @since 1.0
 19    */
 20    public abstract class AbstractRunner extends AbstractRunnerAncestor {
 21   
 22    /**
 23    * This method wraps the <code>test()</code> method implemented by
 24    * application developed runners.<br>
 25    * It manages the execution of the <code>test()</code> method according to
 26    * the sleep time interval associated with the wrapped <code>IRunner</code>
 27    * instance, according to the declared number of required runs and so on.<br>
 28    * Furthermore there is a fundamental exception accounting feature which
 29    * enables JTR to collect information about each single <code>IRunner</code>
 30    * run and the handling of boring/complex tasks such as the reinitialization
 31    * of each runner parameters according to the associated
 32    * <code>IAssignmentPolicy</code>.
 33    */
 34  2500 public final void run() {
 35  2500 logger = Logger.getLogger(this.getClass().getName());
 36  2500 logger.debug("Running client thread...");
 37  2500 for (currentRun = 0; currentRun < getRuns(); currentRun++) {
 38    // let's start the test logic...
 39  29995 try {
 40  29997 logger.debug("Starting run " + currentRun + " in epoch " + epoch);
 41  29992 doRunTest();
 42    } catch (Throwable t) {
 43  10003 handleFailure(currentRun, t);
 44    }
 45    // it's time to sleep
 46  30000 try {
 47  30000 if (currentRun < getRuns() - 1) {
 48  27500 logger.debug("Completed, going to bed for a while... [" + getSleepTime() + " mSecs.]");
 49  27500 Thread.sleep(getSleepTime());
 50  27498 logger.debug("Awaken");
 51    // since we have some other runs to execute, let's check for
 52    // reinitialization
 53  27497 logger.debug("Check for reinitialization");
 54  27499 if (paramsAssigner.requiresReinitialization()) {
 55    // let's do that...
 56  9500 logger.debug("Reinitialization required...");
 57  9499 paramsAssigner.reAssign(clean());
 58  9500 logger.debug("... reinitialized");
 59    } else {
 60    // nop
 61  17998 logger.debug("Reinitialization not required");
 62    }
 63    }
 64    } catch (InterruptedException e) {
 65  0 String msg = "The current test-thread " + Thread.currentThread().getName() + " received an interrupt while sleeping";
 66  0 logger.warn(msg, e);
 67    }
 68    }
 69    // runs are over... back into the pool
 70  2500 logger.debug("Completed all the runs [" + getRuns() + "], going back into the pool");
 71  2500 logger.debug("Getting IPoolManager instance...");
 72  2500 pool.getPoolManager().backIntoPool(this);
 73    }
 74   
 75    /**
 76    * Return the current run assigned to the <code>IRunner</code>
 77    *
 78    * @return int The current run
 79    */
 80  39999 public int getCurrentRun() {
 81  39998 return currentRun;
 82    }
 83   
 84    /**
 85    * This is the only one method application-level runner developers are
 86    * required to implement.<br>
 87    * It contains the testing logic specific to each runner.
 88    *
 89    * @throws Throwable
 90    */
 91    public abstract void test() throws Throwable;
 92   
 93    private int currentRun;
 94    }