Clover coverage report -
Coverage timestamp: Sat Jul 7 2007 16:41:13 CEST
file stats: LOC: 326   Methods: 28
NCLOC: 148   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TestConfig.java 0% 48.3% 71.4% 47.1%
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.config.enterprise.EnterpriseConfig;
 13    import jtr.config.jms.JMSConfig;
 14    import jtr.config.remote.Nodes;
 15    import jtr.config.ws.WebServiceConfig;
 16    import jtr.config.ws.Bindings;
 17    import org.apache.log4j.Logger;
 18   
 19    /**
 20    * This class represents in an object oriented way the <code>jtr.xml</code>
 21    * configuration file's content, thus contains all the information related to a
 22    * JTR test configuration.
 23    *
 24    * @author Francesco Russo (frusso@dev.java.net)
 25    * @version 4.0
 26    * @since 1.0
 27    */
 28    public class TestConfig implements Serializable {
 29    /**
 30    * Constructor.
 31    */
 32  1 public TestConfig() {
 33  1 runners = new Vector<RunnerConfig>();
 34  1 enterpriseConfig = new HashMap<String,EnterpriseConfig>();
 35  1 jmsConfig = new HashMap<String,JMSConfig>();
 36  1 wsConfig = new HashMap<String,WebServiceConfig>();
 37    }
 38   
 39  1 public void setFactories(Factories f) {
 40  1 factories = f;
 41    }
 42   
 43  2 public Factories getFactories() {
 44  2 return factories;
 45    }
 46   
 47  1 public void setNodes(Nodes n) {
 48  1 nodes = n;
 49    }
 50   
 51  1 public Nodes getNodes() {
 52  1 return nodes;
 53    }
 54   
 55    /**
 56    * @param ws
 57    */
 58  0 public void addWebService(WebServiceConfig ws) {
 59  0 wsConfig.put(ws.getUniqueName(), ws);
 60    }
 61   
 62    /**
 63    * This method adds an <code>IRunner</code> runtime configuration to the
 64    * current JTR test configuration.
 65    *
 66    * @param runner
 67    * RunnerConfig One of the multiple <code>IRunner</code>
 68    * configurations
 69    */
 70  6 public void addRunner(final RunnerConfig runner) {
 71  6 runners.add(runner);
 72  6 runner.setParent(this);
 73  6 runners.trimToSize();
 74    }
 75   
 76    /**
 77    * Returns a <code>Vector&ltRunnerConfig&gt</code>.
 78    *
 79    * @return Vector<RunnerConfig> All the available <code>RunnerConfig</code>s
 80    */
 81  2 public Vector<RunnerConfig> getRunners() {
 82  2 return runners;
 83    }
 84   
 85    /**
 86    * Adds an <code>EnterpriseConfig</code> configuration element to the
 87    * current JTR test configuration.
 88    *
 89    * @param enterprise
 90    * EnterpriseConfig The enterprise configuration
 91    */
 92  2 public void addEnterprise(final EnterpriseConfig enterprise) {
 93  2 enterpriseConfig.put(enterprise.getUniqueName(), enterprise);
 94    }
 95   
 96    /**
 97    * Gets an <code>EnterpriseConfig</code> configuration element from the
 98    * current JTR test configuration. The enterprise configuration is uniquely
 99    * identified by its unique name.
 100    * @param uniqueName
 101    *
 102    * @return enterprise EnterpriseConfig The enterprise configuration
 103    */
 104  10023 public EnterpriseConfig getEnterprise(String uniqueName) {
 105  10021 return (EnterpriseConfig) enterpriseConfig.get(uniqueName);
 106    }
 107   
 108    /**
 109    * Returns the total number of epochs set for the JTR test.
 110    *
 111    * @return int The toal number of epochs
 112    */
 113  2 public int getEpochs() {
 114  2 return epochs;
 115    }
 116   
 117    /**
 118    * Sets the total number of epochs (aka epochs) this test will consist of.
 119    *
 120    *
 121    * @param epochs The number of epochs to be executed
 122    */
 123  1 public void setEpochs(int epochs) {
 124  1 this.epochs = epochs;
 125    }
 126   
 127    /**
 128    * This method returns the total number of runs that
 129    * must be accomplished in a single epoch, according
 130    * to what has been declared in the <code>jtr.xml</code>
 131    * configuration file.
 132    *
 133    * @return The overall amount of epochs
 134    */
 135  1 public int getOverallRuns() {
 136  1 int res = 0;
 137  1 for(RunnerConfig rc : runners) {
 138  6 res = res + rc.getRuns()*rc.getCount();
 139    }
 140  1 return res;
 141    }
 142   
 143    /**
 144    * Sets the default enterprise configuration for the current JTR test. The
 145    * enterprise configuration is uniquely identified by its unique name.
 146    *
 147    * @param enterprise
 148    * String The default enterprise configuration's unique name
 149    */
 150  0 public void setEnterprise(String enterprise) {
 151  0 this.enterprise = enterprise;
 152    }
 153   
 154    /**
 155    * Returns the default enterprise configuration for the current JTR test.
 156    * The enterprise configuration is uniquely identified by its unique name.
 157    *
 158    * @return String The default enterprise configuration's unique name
 159    */
 160  6033 public String getEnterprise() {
 161  6029 return enterprise;
 162    }
 163   
 164    /**
 165    * Sets the unique id of the JMS configuration to be used by the current
 166    * runner.
 167    *
 168    * @param id
 169    * The JMS unique id
 170    */
 171  0 public void setJms(String id) {
 172  0 jms = id;
 173    }
 174   
 175    /**
 176    * Gets the unique id of the JMS configuration to be used by the current
 177    * runner.
 178    *
 179    * @return String
 180    */
 181  16052 public String getJms() {
 182  16053 return jms;
 183    }
 184   
 185    /**
 186    * Set the default webservice binding.
 187    * @param binding The default webservice binding
 188    */
 189  0 public void setBinding(String binding) {
 190  0 this.binding = binding;
 191    }
 192   
 193    /**
 194    * Get the default webservice binding.
 195    * @return String The default webservice binding
 196    */
 197  10054 public String getBinding() {
 198  10054 return binding;
 199    }
 200   
 201    /**
 202    * Set the bindings available to invokers.
 203    * @param bindings The binings
 204    */
 205  1 public void setBindings(Bindings bindings) {
 206  1 this.bindings = bindings;
 207    }
 208   
 209    /**
 210    * Get the bindings available to invokers.
 211    * @return bindings The binings
 212    */
 213  6014 public Bindings getBindings() {
 214  6014 return bindings;
 215    }
 216   
 217    /**
 218    * Set the webservice configuration unique name.
 219    * @param ws The webservice configuration unique name
 220    */
 221  0 public void setWebservice(String ws) {
 222  0 webservice = ws;
 223    }
 224   
 225    /**
 226    * Get the webservice configuration unique name.
 227    * @return String
 228    */
 229  16068 public String getWebservice() {
 230  16068 return webservice;
 231    }
 232   
 233    /**
 234    * Add a JMS configuration to the current jtr-test configuration.
 235    *
 236    * @param jmsc
 237    * The JMS configuration
 238    */
 239  1 public void addJmsConfig(JMSConfig jmsc) {
 240  1 jmsConfig.put(jmsc.getUniqueName(), jmsc);
 241    }
 242   
 243    /**
 244    * Retrieves the JMS configuration associated with the given key (its unique
 245    * id).
 246    *
 247    * @param key
 248    * The JMS configuration unique id
 249    * @return The JMS configuration
 250    */
 251  14 public JMSConfig getJmsConfig(String key) {
 252  14 return (JMSConfig) jmsConfig.get(key);
 253    }
 254   
 255    /**
 256    * Returns all the configured JMS configurations.
 257    *
 258    * @return The JMS configurations
 259    */
 260  0 public Collection getJmsConfigs() {
 261  0 return jmsConfig.values();
 262    }
 263   
 264    /**
 265    * Get the currently configured webservice configuration.
 266    * @param key The webservice configuration unique key
 267    * @return WebServiceConfig
 268    */
 269  0 public WebServiceConfig getWebserviceConfig(String key) {
 270  0 return (WebServiceConfig) wsConfig.get(key);
 271    }
 272   
 273    /**
 274    * @see java.lang.Object#toString()
 275    */
 276  0 public String toString() {
 277  0 Iterator iter;
 278  0 String res = "";
 279  0 res = res + "Test Configuration: \nruns: " + epochs + " ";
 280  0 if (enterprise != null) {
 281  0 res = res + "defaultEnterprise: " + enterprise + " ";
 282    } else {
 283  0 res = res + "defaultEnterprise: null ";
 284    }
 285  0 if (jms != null) {
 286  0 res = res + "defaultJMS: " + jms + "\n";
 287    } else {
 288  0 res = res + "defaultJMS: null\n";
 289    }
 290  0 if (runners != null) {
 291  0 iter = runners.iterator();
 292  0 while (iter.hasNext()) {
 293  0 res = res + iter.next().toString() + "\n";
 294    }
 295    }
 296  0 if (enterpriseConfig != null) {
 297  0 iter = enterpriseConfig.values().iterator();
 298  0 while (iter.hasNext()) {
 299  0 res = res + iter.next().toString();
 300    }
 301    }
 302  0 if (jmsConfig != null) {
 303  0 iter = jmsConfig.values().iterator();
 304  0 while (iter.hasNext()) {
 305  0 res = res + iter.next().toString();
 306    }
 307    }
 308  0 logger.debug(res);
 309  0 return res;
 310    }
 311   
 312    private Factories factories;
 313    private Nodes nodes;
 314    private Vector<RunnerConfig> runners;
 315    // epochs is the same as epochs
 316    private int epochs = 1;
 317    private String enterprise;
 318    private String jms;
 319    private String webservice;
 320    private String binding;
 321    private HashMap<String,EnterpriseConfig> enterpriseConfig;
 322    private HashMap<String,JMSConfig> jmsConfig;
 323    private Bindings bindings;
 324    private HashMap<String,WebServiceConfig> wsConfig;
 325    private static Logger logger = Logger.getLogger(TestConfig.class);
 326    }