Clover coverage report -
Coverage timestamp: Sat Jul 7 2007 16:41:13 CEST
file stats: LOC: 115   Methods: 4
NCLOC: 53   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractJMSRunner.java 87.5% 79.3% 100% 82.9%
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.jms.JMSConfig;
 10    import jtr.jms.JMSHelper;
 11    import org.apache.log4j.Logger;
 12   
 13    /**
 14    * This abstract runner has to be the base class of all the application-level
 15    * runners willing to leverage on the JTR runtime for the dynamic injection of
 16    * JMS administered objects defined in the <code>jtr.xml</code> configuration
 17    * file.
 18    *
 19    * @author Francesco Russo (frusso@dev.java.net)
 20    * @version 4.0
 21    * @since 1.1
 22    */
 23    abstract public class AbstractJMSRunner extends AbstractRunnerAncestor implements IRunnerJMS {
 24   
 25    /**
 26    * Set the JMS configuration assigned to the current <code>IRunner</code>
 27    *
 28    * @param jmsConfig
 29    * The JMS configuration
 30    */
 31  14 public void setJmsConfig(JMSConfig jmsConfig) {
 32  14 this.jmsConfig = jmsConfig;
 33    }
 34   
 35    /**
 36    * Get the JMS configuration assigned to the current <code>IRunner</code>
 37    *
 38    * @return JMSConfig
 39    */
 40  4914 public JMSConfig getJmsConfig() {
 41  4914 return jmsConfig;
 42    }
 43   
 44    /**
 45    * This method wraps the <code>test()</code> method implemented by
 46    * application developed runners.<br>
 47    * It manages the execution of the <code>test()</code> method according to
 48    * the sleep time interval associated with the wrapped <code>IRunner</code>
 49    * instance, according to the declared number of required runs and so on.<br>
 50    * Furthermore there is a fundamental exception accounting feature which
 51    * enables JTR to collect information about each single <code>IRunner</code>
 52    * run and the handling of boring/complex tasks such as the reinitialization
 53    * of each runner parameters according to the associated
 54    * <code>IAssignmentPolicy</code>.
 55    */
 56  700 public final void run() {
 57  700 logger = Logger.getLogger(this.getClass().getName());
 58  700 logger.debug("Running client thread...");
 59  700 for (currentRun = 0; currentRun < getRuns(); currentRun++) {
 60    // let's start the test logic...
 61  4897 try {
 62  4899 logger.debug("Starting run " + currentRun + " in epoch " + epoch);
 63  4899 if (epoch == 0 && currentRun == 0) {
 64  14 initializeTimers();
 65    // for performance the initialization of all the JMS
 66    // resources is
 67    // performed only before the first run of the first epoch
 68    // begins
 69  14 JMSHelper.inject(this, getJmsConfig());
 70    }
 71  4899 super.doRunTest();
 72    } catch (Throwable t) {
 73  0 handleFailure(currentRun, t);
 74    }
 75    // it's now time for a sleep
 76  4900 try {
 77  4900 if (currentRun < getRuns() - 1) {
 78  4200 logger.debug("Completed, going to bed for a while... [" + getSleepTime() + " mSecs.]");
 79  4200 Thread.sleep(getSleepTime());
 80  4198 logger.debug("Awaken");
 81    // we have some runs left, let's check for reinitialization
 82  4199 logger.debug("Check for reinitialization");
 83  4195 if (paramsAssigner.requiresReinitialization()) {
 84    // re-initialization required...
 85  0 logger.debug("Reinitialization required...");
 86  0 paramsAssigner.reAssign(clean());
 87  0 logger.debug("... reinitialized");
 88    } else {
 89    // nop
 90  4197 logger.debug("Reinitialization not required");
 91    }
 92    }
 93    } catch (InterruptedException e) {
 94  0 String msg = "The current test-thread " + Thread.currentThread().getName() + " received an interrupt while sleeping";
 95  0 logger.warn(msg, e);
 96    }
 97    }
 98    // runs are over... back into the pool
 99  700 logger.debug("Completed all the runs [" + getRuns() + "], going back into the pool");
 100  700 logger.debug("Getting IPoolManager instance...");
 101  700 pool.getPoolManager().backIntoPool(this);
 102    }
 103   
 104    /**
 105    * Return the current run assigned to the <code>IRunner</code>
 106    *
 107    * @return int The current run
 108    */
 109  4899 public int getCurrentRun() {
 110  4899 return currentRun;
 111    }
 112   
 113    private int currentRun;
 114    private JMSConfig jmsConfig;
 115    }