View Javadoc

1   /*
2    * Created on Oct 7, 2005
3    */
4   package com.flexiblewebsolutions.xdriveunit;
5   
6   import org.apache.log4j.Logger;
7   
8   import com.flexiblewebsolutions.xml.util.XMLStringParser;
9   
10  /***
11   * @author Donavon Buss
12   */
13  public class LoadTestUtils
14  {
15      static Logger logger = Logger.getLogger( LoadTestUtils.class.getName() );
16      
17      /***
18  	 * Initialize parameters for click timer
19  	 * 
20  	 * @param pClickTimerVals -
21  	 *            XML list of values
22  	 * @return ClickTimer object to be used to delay clicks
23  	 */
24  	public DelayTimer initClickTimer(String pClickTimerVals) {
25  	    logger.debug( "initClickTimer" );
26  		DelayTimer returnTimer = new DelayTimer();
27  		StringBuffer delayTag = new StringBuffer(pClickTimerVals);
28  		String seconds = XMLStringParser.getValueForTag(delayTag, "seconds");
29  
30  		// option of setting seconds to random or actual value
31  		if (seconds != null) {
32  			if (seconds.toUpperCase().equals("RANDOM")) {
33  				returnTimer.setRandomDelay(true);
34  				String upperRandom = XMLStringParser.getValueForTag(delayTag,
35  						"randomMax");
36  				String lowerRandom = XMLStringParser.getValueForTag(delayTag,
37  						"randomMin");
38  				if (upperRandom != null) {
39  					int maxSeconds = Integer.parseInt(upperRandom);
40  					returnTimer.setRandomMax(maxSeconds);
41  				}
42  				if (lowerRandom != null) {
43  					int minSeconds = Integer.parseInt(lowerRandom);
44  					returnTimer.setRandomMin(minSeconds);
45  				}
46  			} else {
47  				returnTimer.setRandomDelay(false);
48  				int sec = Integer.parseInt(seconds);
49  				returnTimer.setDelaySeconds(sec);
50  			}
51  		}
52  		return (returnTimer);
53  	}
54  }