Clover coverage report -
Coverage timestamp: Sat Jul 7 2007 16:41:13 CEST
file stats: LOC: 353   Methods: 25
NCLOC: 134   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RunnerConfig.java 75% 87.5% 88% 85.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.config;
 8   
 9    import java.io.Serializable;
 10    import java.util.*;
 11   
 12    import jtr.assigner.IAssignmentPolicy;
 13    import jtr.assigner.UnknownAssignmentPolicyException;
 14    import jtr.assigner.IAssignmentPolicyFactory;
 15    import jtr.assigner.impl.DefaultAssignmentPolicyFactory;
 16    import org.apache.log4j.Logger;
 17   
 18    /**
 19    * Instances of this class represent configurations associated with specific
 20    * <code>IRunner</code> implementation classes.<br>
 21    * A <code>RunnerConfig</code> instance typically contains information such as
 22    * the FQN of the associated <code>IRunner</code> concrete class, the number
 23    * of instances that have to be created by the JTR framework, and the set of
 24    * parameters to be assigned to runners at runtime along with the desired
 25    * assignment policy.
 26    *
 27    * @author Francesco Russo (frusso@dev.java.net)
 28    * @version 4.0
 29    * @since 1.0
 30    */
 31    public class RunnerConfig implements Serializable {
 32    /**
 33    * Constructor.
 34    */
 35  6 public RunnerConfig() {
 36  6 params = new Vector<ParametersMap>();
 37    }
 38   
 39    /**
 40    * Gets the FQN of the runner associated with this <code>RunnerConfig</code>
 41    * instance.
 42    *
 43    * @return String
 44    */
 45  18 public String getRunnerFqn() {
 46  18 return runnerFqn;
 47    }
 48   
 49    /**
 50    * Sets the FQN of the runner associated with this <code>RunnerConfig</code>
 51    * instance.
 52    *
 53    * @param runnerFqn
 54    * String
 55    */
 56  6 public void setRunnerFqn(String runnerFqn) {
 57  6 this.runnerFqn = runnerFqn;
 58    }
 59   
 60    /**
 61    * Gets the number of instances that have to be created at runtime
 62    *
 63    * @return int
 64    */
 65  16086 public int getCount() {
 66  16086 return count;
 67    }
 68   
 69    /**
 70    * Sets the number of instances that have to be created at runtime
 71    *
 72    * @param count
 73    * int
 74    */
 75  6 public void setCount(int count) {
 76  6 this.count = count;
 77    }
 78   
 79    /**
 80    * Adds a new <code>ParametersMap</code> to the set of currently available
 81    * <code>ParameterMaps</code>
 82    *
 83    * @param runnerParam
 84    * ParametersMap
 85    */
 86  13 public void addParameterSet(final ParametersMap runnerParam) {
 87  13 params.add(runnerParam);
 88  13 params.trimToSize();
 89    }
 90   
 91    /**
 92    * Gets all the configured <code>ParmetersMap</code>s as a
 93    * <code>Vector&ltParametersMap&gt</code>.
 94    *
 95    * @return Vector
 96    */
 97  31939 public Vector getParameterMaps() {
 98  31945 return params;
 99    }
 100   
 101    /**
 102    * Returns the <code>String</code> which identifies the
 103    * <code>IAssignmentPolicy</code> associated with the current
 104    * <code>RunnerConfig</code>.
 105    *
 106    * @return String
 107    */
 108  12 public String getParametersAssignmetPolicy() {
 109  12 return parametersAssignmetPolicy;
 110    }
 111   
 112    /**
 113    * Short-hand method useful to instantiate the concrete
 114    * <code>IAssignmentPolicy</code> that will handle the parameterization
 115    * for this runner configuration.
 116    *
 117    * @throws UnknownAssignmentPolicyException
 118    * @return IAssignmentPolicy
 119    */
 120  12 public IAssignmentPolicy getAssignmetPolicy() throws UnknownAssignmentPolicyException {
 121  12 return ((IAssignmentPolicyFactory) RegisteredFactories.getFactory(RegisteredFactories.IASSIGNMENT_POLICY_FACTORY)).getInstance(getParametersAssignmetPolicy());
 122    }
 123   
 124    /**
 125    * Sets the <code>String</code> which identifies the
 126    * <code>IAssignmentPolicy</code> associated with the current
 127    * <code>RunnerConfig</code>.
 128    *
 129    * @param parametersAssignmetPolicy
 130    * String
 131    */
 132  6 public void setParametersAssignmetPolicy(String parametersAssignmetPolicy) {
 133  6 this.parametersAssignmetPolicy = parametersAssignmetPolicy;
 134    }
 135   
 136    /**
 137    * Returns the defautl sleep time for this runner configuration.
 138    *
 139    * @return long
 140    */
 141  0 public long getSleepTime() {
 142  0 return sleepTime;
 143    }
 144   
 145    /**
 146    * Sets the default sleep time for this runner configuration.
 147    *
 148    * @param sleepTime
 149    * long
 150    */
 151  0 public void setSleepTime(long sleepTime) {
 152  0 this.sleepTime = sleepTime;
 153    }
 154   
 155    /**
 156    * Sets the default number of times each runner belonging to this runner
 157    * configuration will have to run.
 158    *
 159    * @return int
 160    */
 161  16074 public int getRuns() {
 162  16073 return runs;
 163    }
 164   
 165    /**
 166    * Gets the default number of times each runner belonging to this runner
 167    * configuration will have to run.
 168    *
 169    * @param runs
 170    * int
 171    */
 172  36 public void setRuns(int runs) {
 173  36 this.runs = runs;
 174    }
 175   
 176    /**
 177    * Returns the default enterprise configuration unique name associated with
 178    * the current runner configuration.
 179    *
 180    * @return String
 181    */
 182  26078 public String getEnterprise() {
 183  26078 return enterprise;
 184    }
 185   
 186    /**
 187    * Sets the default enterprise configuration unique name associated with the
 188    * current runner configuration.
 189    *
 190    * @param enterprise
 191    * String
 192    */
 193  18 public void setEnterprise(String enterprise) {
 194  18 this.enterprise = enterprise;
 195    }
 196   
 197    /**
 198    * Sets the unique id of the JMS configuration to be used by the current
 199    * runner.
 200    *
 201    * @param id
 202    * The JMS unique id
 203    */
 204  6 public void setJms(String id) {
 205  6 jms = id;
 206    }
 207   
 208    /**
 209    * Gets the unique id of the JMS configuration to be used by the current
 210    * runner.
 211    *
 212    * @return String
 213    */
 214  16081 public String getJms() {
 215  16082 return jms;
 216    }
 217   
 218    /**
 219    * Ties the current runner configuration to the <code>TestConfig</code> it
 220    * belongs to.
 221    *
 222    * @param parent
 223    * TestConfig
 224    */
 225  6 public void setParent(TestConfig parent) {
 226  6 this.parent = parent;
 227    }
 228   
 229    /**
 230    * Set the reference to the webservice configuration this runner configuration points to.
 231    * @param webservice The webservice configuration unique name
 232    */
 233  0 public void setWebservice(String webservice) {
 234  0 this.webservice = webservice;
 235    }
 236   
 237    /**
 238    * Get the unique name of the webservice configuration this runner configuration points to.
 239    * @return String The webservice configuration unique name
 240    */
 241  16068 public String getWebservice() {
 242  16068 return webservice;
 243    }
 244   
 245    /**
 246    * Set the default binding associated with the runner.
 247    * @param binding The webservice binding unique name
 248    */
 249  6 public void setBinding(String binding) {
 250  6 this.binding = binding;
 251    }
 252   
 253    /**
 254    * Get the default binding associated with the runner.
 255    * @return String The webservice binding unique name
 256    */
 257  10070 public String getBinding() {
 258  10070 return binding;
 259    }
 260   
 261    /**
 262    * Returns the belonging to <code>TestConfig</code> instance.
 263    *
 264    * @return TestConfig
 265    */
 266  64270 public TestConfig getParent() {
 267  64270 return parent;
 268    }
 269   
 270    /**
 271    * @see java.lang.Object#toString()
 272    */
 273  48208 public String toString() {
 274  48209 String res = "";
 275  48208 if (runnerFqn != null) {
 276  48203 res = res + "FQN: " + runnerFqn + ", ";
 277    } else {
 278  0 res = res + "FQN: null, ";
 279    }
 280  48205 res = res + "InstanceCount: " + count + ", ";
 281  48208 if (parametersAssignmetPolicy != null) {
 282  48207 res = res + parametersAssignmetPolicy + ", ";
 283    } else {
 284  0 res = res + "InstanceCount: null, ";
 285    }
 286  48202 res = res + "DefaultSleepTime: " + sleepTime + ", ";
 287  48198 res = res + "DefaultRunsCount: " + runs + ", ";
 288  48203 if (enterprise != null) {
 289  30087 res = res + "EnterpriseConfig: " + enterprise + ", ";
 290    } else {
 291  18122 res = res + "EnterpriseConfig: see test's default enterprise, ";
 292    }
 293  48202 if (jms != null) {
 294  28 res = res + "JMSConfig: " + jms + "\n";
 295    } else {
 296  48178 res = res + "JMSConfig: see test's default enterprise\n";
 297    }
 298  48204 if (params != null) {
 299  48208 Iterator iter = params.iterator();
 300  48204 while (iter.hasNext()) {
 301  138311 res = res + " " + iter.next().toString();
 302    }
 303    } else {
 304  0 logger.error("Params is null!");
 305    }
 306  48210 logger.debug(res);
 307  48210 return res;
 308    }
 309   
 310    private Vector<ParametersMap> params;
 311   
 312    private String runnerFqn;
 313   
 314    private int count = DEFAULT_COUNT;
 315   
 316    private String parametersAssignmetPolicy = DEFAULT_ASSIGNMENT_POLICY;
 317   
 318    private long sleepTime = DEFAULT_SLEEP_TIME;
 319   
 320    private int runs = DEFAULT_RUNS;
 321   
 322    private String enterprise;
 323   
 324    private String jms;
 325   
 326    private String webservice;
 327   
 328    private String binding;
 329   
 330    /**
 331    * Default value for an <code>IRunner</code> sleep time is -1 (undefined)
 332    */
 333    public static final long DEFAULT_SLEEP_TIME = -1;
 334   
 335    /**
 336    * Default value for an <code>IRunner</code> number of instances is 1
 337    */
 338    public static final int DEFAULT_RUNS = 1;
 339   
 340    /**
 341    * Default value for an <code>IRunner</code> number of runs is 1
 342    */
 343    public static final int DEFAULT_COUNT = 1;
 344   
 345    /**
 346    * Default assignment policy is <code>CYCLIC</code>
 347    */
 348    public static final String DEFAULT_ASSIGNMENT_POLICY = DefaultAssignmentPolicyFactory.CYCLIC;
 349   
 350    private TestConfig parent;
 351   
 352    private static Logger logger = Logger.getLogger(RunnerConfig.class);
 353    }