	/*********************
	 *  Member variables *
	 *********************/
	static protected <%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpCookieCache")%>[] m_httpCookieCache;
	static protected <%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpExecutor")%>[] m_httpExecutor;
	protected <%=helper.getImportedName("java.util.Random")%> rand = new Random();
	
	/*********************
	 *    Extra Methods  *
	 *********************/
	public void populateCookieCache(<%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpCookieCache")%> cookies)
	{
		//By default, the cookie cache is created empty.  To add new cookies, use the following
		//cookies.AddCookie(name, value, domain, path, expires, bSecure);
	}
	
	protected void executeRequest(<%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpRequest")%> request)
	throws <%=exceptionClassName%>
	{
		if (m_httpExecutor == null || m_httpCookieCache == null)
			initializeTest();

		int nUser = <%=helper.getImportedName("org.eclipse.hyades.test.http.runner.internal.util.HttpTestUtil")%>.getCurrentUser(this);
		m_httpCookieCache[nUser].DynamicGetCookie(request);
		<%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpResponse")%> response = m_httpExecutor[nUser].execute(request);
		
		String text = "rc=" + Integer.toString(response.getCode());
		if(response.getDetail() != null)
			text = "\n\n" + response.getDetail();

		//If (response.getCode() < 0) then there was an error when executing the request
		if(response.getCode() < 0)
			throw new <%=exceptionClassName%>(text);

		m_httpCookieCache[nUser].DynamicSetCookie(request, response);
		
		//If (response.getCode() < 400) then the request has failed.
		assertTrue(text, response.getCode() < 400 && response.getCode() > 0);
	}
	
	synchronized protected void initializeTest() 
	{
		int nTotal = <%=helper.getImportedName("org.eclipse.hyades.test.http.runner.internal.util.HttpTestUtil")%>.getTotalUsers(this);
		if (m_httpCookieCache == null)
		{
			m_httpCookieCache = new <%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpCookieCache")%>[nTotal];
			for (int i = 0; i < nTotal; i++)
			{ 
				m_httpCookieCache[i] = new <%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpCookieCache")%>();
				populateCookieCache(m_httpCookieCache[i]);
			}
			 
		}
		if (m_httpExecutor == null)
		{	
			m_httpExecutor = new <%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpExecutor")%>[nTotal];
			for (int i = 0; i < nTotal; i++)
			{
				m_httpExecutor[i] = new <%=helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpExecutor")%>();
			}
		}
	}	
	
	protected long calcThinkTime(long think, int var) 
	{
		if (var > 0 && var < 99) {
			long delta = think * var / 100;
			think += (rand.nextInt((int) delta * 2) - delta);
		}
		return think;
	}
	