You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2004/02/22 20:12:26 UTC

cvs commit: jakarta-jmeter/src/core/org/apache/jmeter/testelement AbstractTestElement.java TestElement.java

sebb        2004/02/22 11:12:26

  Modified:    src/core/org/apache/jmeter/testelement
                        AbstractTestElement.java TestElement.java
  Log:
  Add context and ThreadName to TestElements
  
  Revision  Changes    Path
  1.32      +48 -2     jakarta-jmeter/src/core/org/apache/jmeter/testelement/AbstractTestElement.java
  
  Index: AbstractTestElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/AbstractTestElement.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- AbstractTestElement.java	21 Feb 2004 22:29:12 -0000	1.31
  +++ AbstractTestElement.java	22 Feb 2004 19:12:26 -0000	1.32
  @@ -37,6 +37,8 @@
   import org.apache.jmeter.testelement.property.PropertyIteratorImpl;
   import org.apache.jmeter.testelement.property.StringProperty;
   import org.apache.jmeter.testelement.property.TestElementProperty;
  +import org.apache.jmeter.threads.JMeterContext;
  +import org.apache.jmeter.threads.JMeterContextService;
   import org.apache.jorphan.logging.LoggingManager;
   import org.apache.log.Logger;
   
  @@ -53,6 +55,10 @@
   
       private boolean runningVersion = false;
   
  +    // Thread-specific variables saved here to save recalculation
  +    private transient JMeterContext threadContext = null;
  +    private transient String threadName = null;
  +    
       public Object clone()
       {
           TestElement clonedElement = null;
  @@ -413,4 +419,44 @@
           }
       }
   
  +	/**
  +	 * @return Returns the threadContext.
  +	 */
  +	public JMeterContext getThreadContext() {
  +		if (threadContext == null)
  +		{
  +			log.warn("ThreadContext was not set up - should only happen in JUnit testing..."
  +					,new Throwable("Debug"));
  +			threadContext = JMeterContextService.getContext();
  +		}
  +		return threadContext;
  +	}
  +	/**
  +	 * @param threadContext The threadContext to set.
  +	 */
  +	public void setThreadContext(JMeterContext inthreadContext) {
  +		if (threadContext != null)
  +		{
  +			if (inthreadContext != threadContext)
  +			throw new RuntimeException("Attempting to reset the thread context");
  +		}
  +		this.threadContext = inthreadContext;
  +	}
  +	/**
  +	 * @return Returns the threadName.
  +	 */
  +	public String getThreadName() {
  +		return threadName;
  +	}
  +	/**
  +	 * @param threadName The threadName to set.
  +	 */
  +	public void setThreadName(String inthreadName) {
  +		if (threadName != null)
  +		{
  +			if (inthreadName != threadName)
  +			throw new RuntimeException("Attempting to reset the thread name");
  +		}
  +		this.threadName = inthreadName;
  +	}
   }
  
  
  
  1.11      +24 -2     jakarta-jmeter/src/core/org/apache/jmeter/testelement/TestElement.java
  
  Index: TestElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/TestElement.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestElement.java	14 Feb 2004 03:34:30 -0000	1.10
  +++ TestElement.java	22 Feb 2004 19:12:26 -0000	1.11
  @@ -20,6 +20,7 @@
   
   import org.apache.jmeter.testelement.property.JMeterProperty;
   import org.apache.jmeter.testelement.property.PropertyIterator;
  +import org.apache.jmeter.threads.JMeterContext;
   
   /**
    * @author    Michael Stover
  @@ -119,4 +120,25 @@
        * Convenient way to traverse a test element.
        */
       public void traverse(TestElementTraverser traverser);
  +    
  +	/**
  +	 * @return Returns the threadContext.
  +	 */
  +	public JMeterContext getThreadContext();
  +	
  +	/**
  +	 * @param threadContext The threadContext to set.
  +	 */
  +	public void setThreadContext(JMeterContext threadContext);
  +
  +	/**
  +	 * @return Returns the threadName.
  +	 */
  +	public String getThreadName();
  +	
  +	/**
  +	 * @param threadName The threadName to set.
  +	 */
  +	public void setThreadName(String threadName);
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org