mirror of https://github.com/apache/jmeter.git
				
				
				
			Revamping internal contoller code
git-svn-id: https://svn.apache.org/repos/asf/jakarta/jmeter/trunk@323231 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: 4db8fdffe4
			
			
This commit is contained in:
		
							parent
							
								
									135d169f0d
								
							
						
					
					
						commit
						0a5d9d1643
					
				|  | @ -1,3 +1,3 @@ | |||
| #! /bin/sh | ||||
| 
 | ||||
| java -Xincgc -jar `dirname $0`/ApacheJMeter.jar "$@" | ||||
| java -Xincgc -Xmx256m -jar `dirname $0`/ApacheJMeter.jar "$@" | ||||
|  |  | |||
|  | @ -1,3 +1,5 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| set CLASSPATH=`dirname $0`/../lib/ext/ApacheJMeter_core.jar:`dirname $0`/../lib/jorphan.jar:`dirname $0`/../lib/logkit-1.0.1.jar | ||||
| rmiregistry & | ||||
| set CLASSPATH= | ||||
| `dirname $0`/jmeter -s | ||||
|  |  | |||
|  | @ -1,2 +1,4 @@ | |||
| @echo off | ||||
| echo on | ||||
| set CLASSPATH=%JMETER_HOME%\lib\ext\ApacheJMeter_core.jar;%JMETER_HOME%\lib\jorphan.jar;%JMETER_HOME%\lib\logkit-1.0.1.jar | ||||
| START rmiregistry | ||||
| jmeter -s | ||||
|  |  | |||
|  | @ -71,17 +71,17 @@ not_in_menu=Remote Method Configuration,JNDI Configuration,JNDI Lookup Configura | |||
| 
 | ||||
| #Logging levels for the logging categories in JMeter.  Correct values are FATAL_ERROR, ERROR, WARN, INFO, and DEBUG | ||||
| log_level.jmeter=WARN | ||||
| log_level.jmeter.engine=DEBUG | ||||
| log_level.jmeter.gui=DEBUG | ||||
| log_level.jmeter.engine=WARN | ||||
| log_level.jmeter.gui=WARN | ||||
| log_level.jmeter.elements=DEBUG | ||||
| log_level.jmeter.util=DEBUG | ||||
| log_level.jmeter.util=WARN | ||||
| log_level.jmeter.util.classfinder=WARN | ||||
| log_level.jmeter.test=DEBUG | ||||
| log_level.jmeter.protocol.http=DEBUG | ||||
| log_level.jmeter.protocol.http=WARN | ||||
| log_level.jmeter.protocol.ftp=WARN | ||||
| log_level.jmeter.protocol.jdbc=WARN | ||||
| log_level.jmeter.protocol.java=WARN | ||||
| log_level.jmeter.elements.properties=DEBUG | ||||
| log_level.jmeter.elements.properties=WARN | ||||
| log_level.jorphan=ERROR | ||||
| 
 | ||||
| #Log file for log messages. | ||||
|  |  | |||
|  | @ -52,13 +52,16 @@ | |||
|  * information on the Apache Software Foundation, please see | ||||
|  * <http://www.apache.org/>. | ||||
|  */ | ||||
| 
 | ||||
| package org.apache.jmeter.control; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| import org.apache.jmeter.samplers.AbstractSampler; | ||||
| import junit.framework.TestSuite; | ||||
| 
 | ||||
| import org.apache.jmeter.junit.JMeterTestCase; | ||||
| import org.apache.jmeter.junit.stubs.TestSampler; | ||||
| import org.apache.jmeter.samplers.Sampler; | ||||
| import org.apache.jmeter.testelement.PerSampleClonable; | ||||
| import org.apache.jmeter.testelement.TestElement; | ||||
| import org.apache.jmeter.testelement.property.IntegerProperty; | ||||
| 
 | ||||
|  | @ -72,343 +75,394 @@ import org.apache.jmeter.testelement.property.IntegerProperty; | |||
| 
 | ||||
| public class InterleaveControl extends GenericController implements Serializable | ||||
| { | ||||
|     private static final String STYLE = "InterleaveControl.style"; | ||||
|     public static final int IGNORE_SUB_CONTROLLERS = 0; | ||||
|     public static final int USE_SUB_CONTROLLERS = 1; | ||||
|     private boolean skipNext; | ||||
|     private boolean doNotIncrement = false; | ||||
|     private TestElement searchStart = null; | ||||
|     private boolean currentReturnedAtLeastOne; | ||||
| 
 | ||||
| 	private static final String STYLE = "InterleaveControl.style"; | ||||
| 	public static final int DEFAULT_STYLE = 0; | ||||
| 	public static final int NEW_STYLE = 1; | ||||
| 	private boolean interleave; | ||||
| 	private boolean doNotIncrement = false; | ||||
| 	private Controller searchStart = null; | ||||
|     /**************************************** | ||||
|      * Constructor for the InterleaveControl object | ||||
|      ***************************************/ | ||||
|     public InterleaveControl() | ||||
|     {} | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * Constructor for the InterleaveControl object | ||||
| 	 ***************************************/ | ||||
| 	public InterleaveControl() | ||||
| 	{ | ||||
| 		 | ||||
| 	} | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.GenericController#reInitialize() | ||||
|      */ | ||||
|     public void reInitialize() | ||||
|     { | ||||
|         currentReturnedAtLeastOne = false; | ||||
|         searchStart = null; | ||||
|         skipNext = false; | ||||
|         incrementIterCount(); | ||||
|     } | ||||
| 
 | ||||
| 	public void initialize() | ||||
| 	{ | ||||
| 		super.initialize(); | ||||
| 		interleave = false; | ||||
| 	} | ||||
|     public void setStyle(int style) | ||||
|     { | ||||
|         setProperty(new IntegerProperty(STYLE, style)); | ||||
|     } | ||||
| 
 | ||||
| 	public void reInitialize() | ||||
| 	{ | ||||
| 		super.initialize(); | ||||
| 		interleave = false; | ||||
| 	} | ||||
|     public int getStyle() | ||||
|     { | ||||
|         return getPropertyAsInt(STYLE); | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|         * @see org.apache.jmeter.control.Controller#next() | ||||
|         */ | ||||
|        public Sampler next() | ||||
|        { | ||||
|            if(isSkipNext()) | ||||
|            { | ||||
|                reInitialize(); | ||||
|                return null; | ||||
|            } | ||||
|            return super.next(); | ||||
|        } | ||||
| 
 | ||||
| 	public boolean hasNext() | ||||
| 	{ | ||||
| 		if(interleave) | ||||
| 		{ | ||||
| 			interleave = false; | ||||
| 			return false; | ||||
| 		} | ||||
| 		 | ||||
| 		boolean retVal; | ||||
| 		Object controller = getCurrentController(); | ||||
| 		if(controller == null) | ||||
| 		{ | ||||
| 			retVal = hasNextAtEnd(); | ||||
| 		} | ||||
| 		else if(controller instanceof Controller) | ||||
| 		{ | ||||
| 			if (searchStart != null && ((Controller)controller).equals(searchStart)) | ||||
| 			{ | ||||
| 				retVal = false;	 | ||||
| 			} | ||||
| 			else if(((Controller)controller).hasNext()) | ||||
| 			{ | ||||
| 				retVal = true; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				currentHasNextIsFalse(); | ||||
| 				if(((Controller)controller).samplersReturned() == 0) | ||||
| 				{ | ||||
| 					interleave = false; | ||||
| 					if (searchStart == null ) | ||||
| 						searchStart = (Controller)controller; | ||||
| 				} | ||||
| 				retVal = hasNext(); | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			retVal = true; | ||||
| 		} | ||||
| 		searchStart = null; | ||||
| 		return retVal; | ||||
| 	} | ||||
| 	 | ||||
| 	protected boolean hasNextAtEnd() | ||||
| 	{ | ||||
| 		if (subControllersAndSamplers.size() == 0) | ||||
| 			return false; | ||||
| 		else  | ||||
| 		{ | ||||
| 			resetCurrent(); | ||||
| 			return hasNext(); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	protected void removeCurrentController() | ||||
| 	{ | ||||
| //		setInterleave(NEW_STYLE); | ||||
| 		super.removeCurrentController(); | ||||
| 	} | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.GenericController#nextIsAController(org.apache.jmeter.testelement.TestElement) | ||||
|      */ | ||||
|     protected Sampler nextIsAController(Controller controller) throws NextIsNullException | ||||
|     { | ||||
|         Sampler sampler = controller.next(); | ||||
|         if (sampler == null) | ||||
|         { | ||||
|             currentReturnedNull(controller); | ||||
|             return next(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             currentReturnedAtLeastOne = true; | ||||
|             if (getStyle() == IGNORE_SUB_CONTROLLERS) | ||||
|             { | ||||
|                 incrementCurrent(); | ||||
|                 skipNext = true; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 searchStart = null; | ||||
|             } | ||||
|             return sampler; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	protected void incrementCurrent() | ||||
| 	{ | ||||
| 		setInterleave(NEW_STYLE); | ||||
| 		super.incrementCurrent(); | ||||
| 	} | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.GenericController#nextIsASampler(org.apache.jmeter.testelement.TestElement) | ||||
|      */ | ||||
|     protected Sampler nextIsASampler(Sampler element) throws NextIsNullException | ||||
|     { | ||||
|         skipNext = true; | ||||
|         incrementCurrent(); | ||||
|         return element; | ||||
|     } | ||||
| 
 | ||||
| 	protected void setInterleave(int style) | ||||
| 	{ | ||||
| 		if(getStyle() == style) | ||||
| 		{ | ||||
| 			interleave = true; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public void setStyle(int style) | ||||
| 	{ | ||||
| 		setProperty(new IntegerProperty(STYLE,style)); | ||||
| 	} | ||||
| 	 | ||||
| 	public int getStyle() | ||||
| 	{ | ||||
| 		return getPropertyAsInt(STYLE); | ||||
| 	} | ||||
|     /** | ||||
|      * If the current is null, reset and continue searching.  The  | ||||
|      * searchStart attribute will break us off when we start a repeat. | ||||
|      *  | ||||
|      * @see org.apache.jmeter.testelement.AbstractTestElement#nextIsNull() | ||||
|      */ | ||||
|     protected Sampler nextIsNull() | ||||
|     { | ||||
|         resetCurrent(); | ||||
|         if (getStyle() == USE_SUB_CONTROLLERS) | ||||
|         { | ||||
|             setFirst(true); | ||||
|         } | ||||
|         return next(); | ||||
|     } | ||||
| 
 | ||||
| 	public Sampler next() | ||||
| 	{ | ||||
| 		setInterleave(DEFAULT_STYLE); | ||||
| 		TestElement controller = getCurrentController(); | ||||
| 		fireIterEvents(controller); | ||||
| 		if(controller == null) | ||||
| 		{ | ||||
| 			nextAtEnd(); | ||||
| 			return next(); | ||||
| 		} | ||||
| 		if(controller instanceof Sampler) | ||||
| 		{ | ||||
| 			incrementCurrent(); | ||||
| 			return (Sampler)controller; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			Controller c = (Controller)controller; | ||||
| 			if(c.hasNext()) | ||||
| 			{ | ||||
| 				Sampler s = c.next(); | ||||
| 				if(getStyle() == DEFAULT_STYLE) | ||||
| 				{ | ||||
| 					incrementCurrent(); | ||||
| 				} | ||||
| 				return s; | ||||
| 			} | ||||
| 			else if(c.isDone()) | ||||
| 			{ | ||||
| 				removeCurrentController(); | ||||
| 				return next(); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				incrementCurrent(); | ||||
| 				return next(); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.GenericController#setCurrentElement(org.apache.jmeter.testelement.TestElement) | ||||
|      */ | ||||
|     protected void setCurrentElement(TestElement currentElement) throws NextIsNullException | ||||
|     { | ||||
|         if (searchStart == null) // set the position when next is first called, and don't overwrite until reInitialize is called | ||||
|         { | ||||
|             searchStart = currentElement; | ||||
|         } | ||||
|         else if (searchStart == currentElement && !currentReturnedAtLeastOne) // we've gone through the whole list and are now back at the start point of our search. | ||||
|         { | ||||
|             throw new NextIsNullException(); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     /* (non-Javadoc) | ||||
|      * @see org.apache.jmeter.control.GenericController#currentReturnedNull(org.apache.jmeter.control.Controller) | ||||
|      */ | ||||
|     protected void currentReturnedNull(Controller c) | ||||
|     { | ||||
|         if (c.isDone()) | ||||
|         { | ||||
|             removeCurrentElement(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             incrementCurrent(); | ||||
|         } | ||||
|         if (getStyle() == USE_SUB_CONTROLLERS && currentReturnedAtLeastOne) | ||||
|         { | ||||
|             skipNext = true; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	public static class Test extends junit.framework.TestCase | ||||
| 	{ | ||||
| 		public Test(String name) | ||||
| 		{ | ||||
| 			super(name); | ||||
| 		} | ||||
|     /** | ||||
|      * @return skipNext | ||||
|      */ | ||||
|     protected boolean isSkipNext() | ||||
|     { | ||||
|         return skipNext; | ||||
|     } | ||||
| 
 | ||||
| 		public void testProcessing() throws Exception | ||||
| 		{ | ||||
| 			GenericController controller = new GenericController(); | ||||
| 			InterleaveControl sub_1 = new InterleaveControl(); | ||||
| 			sub_1.setStyle(DEFAULT_STYLE); | ||||
| 			sub_1.addTestElement(makeSampler("one")); | ||||
| 			sub_1.addTestElement(makeSampler("two")); | ||||
| 			controller.addTestElement(sub_1); | ||||
| 			controller.addTestElement(makeSampler("three")); | ||||
| 			LoopController sub_2 = new LoopController(); | ||||
| 			sub_2.setLoops(3); | ||||
| 			GenericController sub_3 = new GenericController(); | ||||
| 			sub_2.addTestElement(makeSampler("four")); | ||||
| 			sub_3.addTestElement(makeSampler("five")); | ||||
| 			sub_3.addTestElement(makeSampler("six")); | ||||
| 			sub_2.addTestElement(sub_3); | ||||
| 			sub_2.addTestElement(makeSampler("seven")); | ||||
| 			controller.addTestElement(sub_2); | ||||
| 			String[] interleaveOrder = new String[]{"one","two"}; | ||||
| 			String[] order = new String[]{"dummy","three","four","five","six","seven", | ||||
| 						"four","five","six","seven","four","five","six","seven"}; | ||||
| 			int counter = 14; | ||||
| 			for (int i = 0; i < 4; i++) | ||||
| 			{ | ||||
| 				assertEquals(14,counter); | ||||
| 				counter = 0; | ||||
| 				while(controller.hasNext()) | ||||
| 				{ | ||||
| 					TestElement sampler = controller.next(); | ||||
| 					if(counter == 0) | ||||
| 					{ | ||||
| 						assertEquals(interleaveOrder[i%2],sampler.getPropertyAsString(TestElement.NAME)); | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						assertEquals(order[counter],sampler.getPropertyAsString(TestElement.NAME)); | ||||
| 					} | ||||
| 					counter++; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		public void testProcessing2() throws Exception | ||||
| 		{ | ||||
| 			GenericController controller = new GenericController(); | ||||
| 			InterleaveControl sub_1 = new InterleaveControl(); | ||||
| 			sub_1.setStyle(DEFAULT_STYLE); | ||||
| 			sub_1.addTestElement(makeSampler("one")); | ||||
| 			sub_1.addTestElement(makeSampler("two")); | ||||
| 			controller.addTestElement(sub_1); | ||||
| 			controller.addTestElement(makeSampler("three")); | ||||
| 			LoopController sub_2 = new LoopController(); | ||||
| 			sub_2.setLoops(3); | ||||
| 			GenericController sub_3 = new GenericController(); | ||||
| 			sub_2.addTestElement(makeSampler("four")); | ||||
| 			sub_3.addTestElement(makeSampler("five")); | ||||
| 			sub_3.addTestElement(makeSampler("six")); | ||||
| 			sub_2.addTestElement(sub_3); | ||||
| 			sub_2.addTestElement(makeSampler("seven")); | ||||
| 			sub_1.addTestElement(sub_2); | ||||
| 			String[] order = new String[]{"one","three","two","three","four","three", | ||||
| 						"one","three","two","three","five","three","one","three", | ||||
| 						"two","three","six","three","one","three"}; | ||||
| 			int counter = 0; | ||||
| 			while (counter < order.length) | ||||
| 			{ | ||||
| 				while(controller.hasNext()) | ||||
| 				{ | ||||
| 					TestElement sampler = controller.next(); | ||||
| 					assertEquals("failed on "+counter, | ||||
| 							order[counter],sampler.getPropertyAsString(TestElement.NAME)); | ||||
| 					counter++; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		public void testProcessing3() throws Exception | ||||
| 		{ | ||||
| 			GenericController controller = new GenericController(); | ||||
| 			InterleaveControl sub_1 = new InterleaveControl(); | ||||
| 			sub_1.setStyle(NEW_STYLE); | ||||
| 			sub_1.addTestElement(makeSampler("one")); | ||||
| 			sub_1.addTestElement(makeSampler("two")); | ||||
| 			controller.addTestElement(sub_1); | ||||
| 			controller.addTestElement(makeSampler("three")); | ||||
| 			LoopController sub_2 = new LoopController(); | ||||
| 			sub_2.setLoops(3); | ||||
| 			GenericController sub_3 = new GenericController(); | ||||
| 			sub_2.addTestElement(makeSampler("four")); | ||||
| 			sub_3.addTestElement(makeSampler("five")); | ||||
| 			sub_3.addTestElement(makeSampler("six")); | ||||
| 			sub_2.addTestElement(sub_3); | ||||
| 			sub_2.addTestElement(makeSampler("seven")); | ||||
| 			sub_1.addTestElement(sub_2); | ||||
| 			String[] order = new String[]{"one","three","two","three","four","five", | ||||
| 						"six","seven","four","five","six","seven","four","five", | ||||
| 						"six","seven","three","one","three","two","three"}; | ||||
| 			int counter = 0; | ||||
| 			while (counter < order.length) | ||||
| 			{ | ||||
| 				while(controller.hasNext()) | ||||
| 				{ | ||||
| 					TestElement sampler = controller.next(); | ||||
| 					assertEquals("failed on "+counter,order[counter],sampler.getPropertyAsString(TestElement.NAME)); | ||||
| 					counter++; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		public void testProcessing4() throws Exception | ||||
| 		{ | ||||
| 			GenericController controller = new GenericController(); | ||||
| 			InterleaveControl sub_1 = new InterleaveControl(); | ||||
| 			sub_1.setStyle(DEFAULT_STYLE); | ||||
| 			controller.addTestElement(sub_1); | ||||
| 			GenericController sub_2 = new GenericController(); | ||||
| 			sub_2.addTestElement(makeSampler("one")); | ||||
| 			sub_2.addTestElement(makeSampler("two")); | ||||
| 			sub_1.addTestElement(sub_2); | ||||
| 			GenericController sub_3 = new GenericController(); | ||||
| 			sub_3.addTestElement(makeSampler("three")); | ||||
| 			sub_3.addTestElement(makeSampler("four")); | ||||
| 			sub_1.addTestElement(sub_3); | ||||
| 			String[] order = new String[]{"one","three","two","four"}; | ||||
| 			int counter = 0; | ||||
| 			while (counter < order.length) | ||||
| 			{ | ||||
| 				while(controller.hasNext()) | ||||
| 				{ | ||||
| 					TestElement sampler = controller.next(); | ||||
| 					assertEquals("failed on "+counter,order[counter],sampler.getPropertyAsString(TestElement.NAME)); | ||||
| 					counter++; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		public void testProcessing5() throws Exception | ||||
| 		{ | ||||
| 			GenericController controller = new GenericController(); | ||||
| 			InterleaveControl sub_1 = new InterleaveControl(); | ||||
| 			sub_1.setStyle(NEW_STYLE); | ||||
| 			controller.addTestElement(sub_1); | ||||
| 			GenericController sub_2 = new GenericController(); | ||||
| 			sub_2.addTestElement(makeSampler("one")); | ||||
| 			sub_2.addTestElement(makeSampler("two")); | ||||
| 			sub_1.addTestElement(sub_2); | ||||
| 			GenericController sub_3 = new GenericController(); | ||||
| 			sub_3.addTestElement(makeSampler("three")); | ||||
| 			sub_3.addTestElement(makeSampler("four")); | ||||
| 			sub_1.addTestElement(sub_3); | ||||
| 			String[] order = new String[]{"one","two","three","four"}; | ||||
| 			int counter = 0; | ||||
| 			while (counter < order.length) | ||||
| 			{ | ||||
| 				while(controller.hasNext()) | ||||
| 				{ | ||||
| 					TestElement sampler = controller.next(); | ||||
| 					assertEquals("failed on "+counter,order[counter],sampler.getPropertyAsString(TestElement.NAME)); | ||||
| 					counter++; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|     /** | ||||
|      * @param skipNext | ||||
|      */ | ||||
|     protected void setSkipNext(boolean skipNext) | ||||
|     { | ||||
|         this.skipNext = skipNext; | ||||
|     } | ||||
| 
 | ||||
|     public static class Test extends JMeterTestCase | ||||
|     { | ||||
|         public Test(String name) | ||||
|         { | ||||
|             super(name); | ||||
|         } | ||||
| 
 | ||||
|         public void testProcessing() throws Exception | ||||
|         { | ||||
|             testLog.debug("Testing Interleave Controller 1"); | ||||
|             GenericController controller = new GenericController(); | ||||
|             InterleaveControl sub_1 = new InterleaveControl(); | ||||
|             sub_1.setStyle(IGNORE_SUB_CONTROLLERS); | ||||
|             sub_1.addTestElement(new TestSampler("one")); | ||||
|             sub_1.addTestElement(new TestSampler("two")); | ||||
|             controller.addTestElement(sub_1); | ||||
|             controller.addTestElement(new TestSampler("three")); | ||||
|             LoopController sub_2 = new LoopController(); | ||||
|             sub_2.setLoops(3); | ||||
|             GenericController sub_3 = new GenericController(); | ||||
|             sub_2.addTestElement(new TestSampler("four")); | ||||
|             sub_3.addTestElement(new TestSampler("five")); | ||||
|             sub_3.addTestElement(new TestSampler("six")); | ||||
|             sub_2.addTestElement(sub_3); | ||||
|             sub_2.addTestElement(new TestSampler("seven")); | ||||
|             controller.addTestElement(sub_2); | ||||
|             String[] interleaveOrder = new String[] { "one", "two" }; | ||||
|             String[] order = new String[] { "dummy", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven" }; | ||||
|             int counter = 14; | ||||
|             controller.initialize(); | ||||
|             for (int i = 0; i < 4; i++) | ||||
|             { | ||||
|                 assertEquals(14, counter); | ||||
|                 counter = 0; | ||||
|                 TestElement sampler = null; | ||||
|                 while ((sampler = controller.next()) != null) | ||||
|                 { | ||||
|                     if (counter == 0) | ||||
|                     { | ||||
|                         assertEquals(interleaveOrder[i % 2], sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         assertEquals(order[counter], sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                     } | ||||
|                     counter++; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public void testProcessing2() throws Exception | ||||
|         { | ||||
|             testLog.debug("Testing Interleave Controller 2"); | ||||
|             GenericController controller = new GenericController(); | ||||
|             InterleaveControl sub_1 = new InterleaveControl(); | ||||
|             sub_1.setStyle(IGNORE_SUB_CONTROLLERS); | ||||
|             sub_1.addTestElement(new TestSampler("one")); | ||||
|             sub_1.addTestElement(new TestSampler("two")); | ||||
|             controller.addTestElement(sub_1); | ||||
|             controller.addTestElement(new TestSampler("three")); | ||||
|             LoopController sub_2 = new LoopController(); | ||||
|             sub_2.setLoops(3); | ||||
|             GenericController sub_3 = new GenericController(); | ||||
|             sub_2.addTestElement(new TestSampler("four")); | ||||
|             sub_3.addTestElement(new TestSampler("five")); | ||||
|             sub_3.addTestElement(new TestSampler("six")); | ||||
|             sub_2.addTestElement(sub_3); | ||||
|             sub_2.addTestElement(new TestSampler("seven")); | ||||
|             sub_1.addTestElement(sub_2); | ||||
|             String[] order = | ||||
|                 new String[] { | ||||
|                     "one", | ||||
|                     "three", | ||||
|                     "two", | ||||
|                     "three", | ||||
|                     "four", | ||||
|                     "three", | ||||
|                     "one", | ||||
|                     "three", | ||||
|                     "two", | ||||
|                     "three", | ||||
|                     "five", | ||||
|                     "three", | ||||
|                     "one", | ||||
|                     "three", | ||||
|                     "two", | ||||
|                     "three", | ||||
|                     "six", | ||||
|                     "three", | ||||
|                     "one", | ||||
|                     "three" }; | ||||
|             int counter = 0; | ||||
|             int loops = 1; | ||||
|             controller.initialize(); | ||||
|             while (counter < order.length) | ||||
|             { | ||||
|                 TestElement sampler = null; | ||||
|                 while ((sampler = controller.next()) != null) | ||||
|                 { | ||||
|                     assertEquals("failed on " + counter, order[counter], sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                     counter++; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public void testProcessing3() throws Exception | ||||
|         { | ||||
|             testLog.debug("Testing Interleave Controller 3"); | ||||
|             GenericController controller = new GenericController(); | ||||
|             InterleaveControl sub_1 = new InterleaveControl(); | ||||
|             sub_1.setStyle(USE_SUB_CONTROLLERS); | ||||
|             sub_1.addTestElement(new TestSampler("one")); | ||||
|             sub_1.addTestElement(new TestSampler("two")); | ||||
|             controller.addTestElement(sub_1); | ||||
|             controller.addTestElement(new TestSampler("three")); | ||||
|             LoopController sub_2 = new LoopController(); | ||||
|             sub_2.setLoops(3); | ||||
|             GenericController sub_3 = new GenericController(); | ||||
|             sub_2.addTestElement(new TestSampler("four")); | ||||
|             sub_3.addTestElement(new TestSampler("five")); | ||||
|             sub_3.addTestElement(new TestSampler("six")); | ||||
|             sub_2.addTestElement(sub_3); | ||||
|             sub_2.addTestElement(new TestSampler("seven")); | ||||
|             sub_1.addTestElement(sub_2); | ||||
|             String[] order = | ||||
|                 new String[] { | ||||
|                     "one", | ||||
|                     "three", | ||||
|                     "two", | ||||
|                     "three", | ||||
|                     "four", | ||||
|                     "five", | ||||
|                     "six", | ||||
|                     "seven", | ||||
|                     "four", | ||||
|                     "five", | ||||
|                     "six", | ||||
|                     "seven", | ||||
|                     "four", | ||||
|                     "five", | ||||
|                     "six", | ||||
|                     "seven", | ||||
|                     "three", | ||||
|                     "one", | ||||
|                     "three", | ||||
|                     "two", | ||||
|                     "three" }; | ||||
|             int counter = 0; | ||||
|             int loops = 1; | ||||
|             controller.initialize(); | ||||
|             while (counter < order.length) | ||||
|             { | ||||
|                 TestElement sampler = null; | ||||
|                 while ((sampler = controller.next()) != null) | ||||
|                 { | ||||
|                     assertEquals("failed on" + counter, order[counter], sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                     counter++; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public void testProcessing4() throws Exception | ||||
|         { | ||||
|             testLog.debug("Testing Interleave Controller 4"); | ||||
|             GenericController controller = new GenericController(); | ||||
|             InterleaveControl sub_1 = new InterleaveControl(); | ||||
|             sub_1.setStyle(IGNORE_SUB_CONTROLLERS); | ||||
|             controller.addTestElement(sub_1); | ||||
|             GenericController sub_2 = new GenericController(); | ||||
|             sub_2.addTestElement(new TestSampler("one")); | ||||
|             sub_2.addTestElement(new TestSampler("two")); | ||||
|             sub_1.addTestElement(sub_2); | ||||
|             GenericController sub_3 = new GenericController(); | ||||
|             sub_3.addTestElement(new TestSampler("three")); | ||||
|             sub_3.addTestElement(new TestSampler("four")); | ||||
|             sub_1.addTestElement(sub_3); | ||||
|             String[] order = new String[] { "one", "three", "two", "four" }; | ||||
|             int counter = 0; | ||||
|             int loops = 1; | ||||
|             controller.initialize(); | ||||
|             while (counter < order.length) | ||||
|             { | ||||
|                 TestElement sampler = null; | ||||
|                 while ((sampler = controller.next()) != null) | ||||
|                 { | ||||
|                     assertEquals("failed on" + counter, order[counter], sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                     counter++; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public void testProcessing5() throws Exception | ||||
|         { | ||||
|             testLog.debug("Testing Interleave Controller 5"); | ||||
|             GenericController controller = new GenericController(); | ||||
|             InterleaveControl sub_1 = new InterleaveControl(); | ||||
|             sub_1.setStyle(USE_SUB_CONTROLLERS); | ||||
|             controller.addTestElement(sub_1); | ||||
|             GenericController sub_2 = new GenericController(); | ||||
|             sub_2.addTestElement(new TestSampler("one")); | ||||
|             sub_2.addTestElement(new TestSampler("two")); | ||||
|             sub_1.addTestElement(sub_2); | ||||
|             GenericController sub_3 = new GenericController(); | ||||
|             sub_3.addTestElement(new TestSampler("three")); | ||||
|             sub_3.addTestElement(new TestSampler("four")); | ||||
|             sub_1.addTestElement(sub_3); | ||||
|             String[] order = new String[] { "one", "two", "three", "four" }; | ||||
|             int counter = 0; | ||||
|             int loops = 1; | ||||
|             controller.initialize(); | ||||
|             while (counter < order.length) | ||||
|             { | ||||
|                 TestElement sampler = null; | ||||
|                 while ((sampler = controller.next()) != null) | ||||
|                 { | ||||
|                     assertEquals("failed on" + counter, order[counter], sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                     counter++; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static void main(String args[]) | ||||
|     { | ||||
|         junit.textui.TestRunner.run(suite()); | ||||
|     } | ||||
| 
 | ||||
|     public static TestSuite suite() | ||||
|     { | ||||
|         TestSuite suite = new TestSuite(); | ||||
|         suite.addTest(new Test("testProcessing")); | ||||
|         suite.addTest(new Test("testProcessing2")); | ||||
|         suite.addTest(new Test("testProcessing3")); | ||||
|         suite.addTest(new Test("testProcessing4")); | ||||
|         suite.addTest(new Test("testProcessing5")); | ||||
|         //suite.addTestSuite(Test.class); | ||||
|         return suite; | ||||
|     } | ||||
| 
 | ||||
| 		private TestElement makeSampler(String name) | ||||
| 		{ | ||||
| 		  	TestSampler s= new TestSampler(); | ||||
| 			s.setName(name); | ||||
| 			return s; | ||||
| 		} | ||||
| 		public class TestSampler extends AbstractSampler | ||||
| 						implements PerSampleClonable { | ||||
| 		  public void addCustomTestElement(TestElement t) { } | ||||
| 		  public org.apache.jmeter.samplers.SampleResult sample(org.apache.jmeter.samplers.Entry e) { return null; } | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public static void main(String args[]) {  | ||||
| 		junit.textui.TestRunner.run(new Test("testProcessing")); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -52,43 +52,55 @@ | |||
|  * information on the Apache Software Foundation, please see | ||||
|  * <http://www.apache.org/>. | ||||
|  */ | ||||
| 
 | ||||
| package org.apache.jmeter.control; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| import org.apache.jmeter.samplers.AbstractSampler; | ||||
| import org.apache.jmeter.testelement.PerSampleClonable; | ||||
| import junit.framework.TestSuite; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationDeliverEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationListener; | ||||
| import org.apache.jmeter.junit.stubs.TestSampler; | ||||
| import org.apache.jmeter.samplers.Sampler; | ||||
| import org.apache.jmeter.testelement.TestElement; | ||||
| 
 | ||||
| /************************************************************ | ||||
|  *  Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company: | ||||
|  *  Apache Foundation | ||||
|  *  Title: Apache JMeter Description:  | ||||
|  * Copyright: Copyright (c) 2000  | ||||
|  * Company: Apache Foundation | ||||
|  * | ||||
|  *@author     Michael Stover | ||||
|  *@created    March 13, 2001 | ||||
|  *@version    1.0 | ||||
|  ***********************************************************/ | ||||
| 
 | ||||
| public class OnceOnlyController extends GenericController implements Serializable | ||||
| public class OnceOnlyController  | ||||
| 	extends GenericController  | ||||
| 	implements Serializable,LoopIterationListener | ||||
| { | ||||
| 
 | ||||
| 	/************************************************************ | ||||
| 	 *  Constructor for the OnceOnlyController object | ||||
| 	 ***********************************************************/ | ||||
| 	public OnceOnlyController() | ||||
| 	{ | ||||
| 	} | ||||
| 	public OnceOnlyController() {} | ||||
| 
 | ||||
| 	public void reInitialize() | ||||
| 	{ | ||||
| 		//don't do anything | ||||
| 	} | ||||
| 
 | ||||
| 	protected boolean hasNextAtEnd() | ||||
| 	{ | ||||
| 		this.setShortCircuit(true); | ||||
| 		return false; | ||||
| 	} | ||||
| 	/** | ||||
| 	 * @see org.apache.jmeter.engine.event.LoopIterationListener#iterationStart(org.apache.jmeter.engine.event.LoopIterationEvent) | ||||
| 	 */ | ||||
|     public void iterationStart(LoopIterationEvent event) | ||||
|     { | ||||
|         if (event.getIteration() == 1) | ||||
|         { | ||||
|             reInitialize(); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     protected Sampler nextIsNull() throws NextIsNullException | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
| 	public static class Test extends junit.framework.TestCase | ||||
| 	{ | ||||
|  | @ -101,23 +113,24 @@ public class OnceOnlyController extends GenericController implements Serializabl | |||
| 		{ | ||||
| 			GenericController controller = new GenericController(); | ||||
| 			GenericController sub_1 = new OnceOnlyController(); | ||||
| 			sub_1.addTestElement(makeSampler("one")); | ||||
| 			sub_1.addTestElement(makeSampler("two")); | ||||
| 			sub_1.addTestElement(new TestSampler("one")); | ||||
| 			sub_1.addTestElement(new TestSampler("two")); | ||||
| 			controller.addTestElement(sub_1); | ||||
| 			controller.addTestElement(makeSampler("three")); | ||||
| 			controller.addTestElement(new TestSampler("three")); | ||||
| 			LoopController sub_2 = new LoopController(); | ||||
| 			sub_2.setLoops(3); | ||||
| 			GenericController sub_3 = new GenericController(); | ||||
| 			sub_2.addTestElement(makeSampler("four")); | ||||
| 			sub_3.addTestElement(makeSampler("five")); | ||||
| 			sub_3.addTestElement(makeSampler("six")); | ||||
| 			sub_2.addTestElement(new TestSampler("four")); | ||||
| 			sub_3.addTestElement(new TestSampler("five")); | ||||
| 			sub_3.addTestElement(new TestSampler("six")); | ||||
| 			sub_2.addTestElement(sub_3); | ||||
| 			sub_2.addTestElement(makeSampler("seven")); | ||||
| 			sub_2.addTestElement(new TestSampler("seven")); | ||||
| 			controller.addTestElement(sub_2); | ||||
| 			String[] interleaveOrder = new String[]{"one","two"}; | ||||
| 			String[] order = new String[]{"","","three","four","five","six","seven", | ||||
| 						"four","five","six","seven","four","five","six","seven"}; | ||||
| 			int counter = 15; | ||||
|             controller.initialize(); | ||||
| 			for (int i = 0; i < 4; i++) | ||||
| 			{ | ||||
| 				assertEquals(15,counter); | ||||
|  | @ -126,9 +139,9 @@ public class OnceOnlyController extends GenericController implements Serializabl | |||
| 				{ | ||||
| 					counter = 2; | ||||
| 				} | ||||
| 				while(controller.hasNext()) | ||||
|                 TestElement sampler = null; | ||||
| 				while((sampler = controller.next()) != null) | ||||
| 				{ | ||||
| 					TestElement sampler = controller.next(); | ||||
| 					if(i == 0 && counter < 2) | ||||
| 					{ | ||||
| 						assertEquals(interleaveOrder[counter],sampler.getPropertyAsString(TestElement.NAME)); | ||||
|  | @ -141,17 +154,74 @@ public class OnceOnlyController extends GenericController implements Serializabl | |||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		private TestElement makeSampler(String name) | ||||
| 		{ | ||||
| 		  	TestSampler s= new TestSampler(); | ||||
| 			s.setName(name); | ||||
| 			return s; | ||||
| 		} | ||||
| 		public class TestSampler extends AbstractSampler | ||||
| 						implements PerSampleClonable { | ||||
| 		  public void addCustomTestElement(TestElement t) { } | ||||
| 		  public org.apache.jmeter.samplers.SampleResult sample(org.apache.jmeter.samplers.Entry e) { return null; } | ||||
| 		} | ||||
|          | ||||
|         public void testProcessing2() throws Exception | ||||
|                 { | ||||
|                     GenericController controller = new GenericController(); | ||||
|                     GenericController sub_1 = new OnceOnlyController(); | ||||
|                     sub_1.addTestElement(new TestSampler("one")); | ||||
|                     sub_1.addTestElement(new TestSampler("two")); | ||||
|                     controller.addTestElement(sub_1); | ||||
|                     controller.addTestElement(new TestSampler("three")); | ||||
|                     LoopController sub_2 = new LoopController(); | ||||
|                     sub_2.setLoops(3); | ||||
|                     OnceOnlyController sub_3 = new OnceOnlyController(); | ||||
|                     sub_2.addTestElement(new TestSampler("four")); | ||||
|                     sub_3.addTestElement(new TestSampler("five")); | ||||
|                     sub_3.addTestElement(new TestSampler("six")); | ||||
|                     sub_2.addTestElement(sub_3); | ||||
|                     sub_2.addIterationListener(sub_3); | ||||
|                     sub_2.addTestElement(new TestSampler("seven")); | ||||
|                     controller.addTestElement(sub_2); | ||||
|                     String[] interleaveOrder = new String[]{"one","two"}; | ||||
|                     String[] order = new String[]{"","","three","four","five","six","seven", | ||||
|                                 "four","seven","four","seven"}; | ||||
|                     int counter = 11; | ||||
|                     controller.initialize(); | ||||
|                     for (int i = 0; i < 4; i++) | ||||
|                     { | ||||
|                         assertEquals(11,counter); | ||||
|                         counter = 0; | ||||
|                         if(i > 0) | ||||
|                         { | ||||
|                             counter = 2; | ||||
|                         } | ||||
|                         TestElement sampler = null; | ||||
|                         while((sampler = controller.next()) != null) | ||||
|                         { | ||||
|                             if(i == 0 && counter < 2) | ||||
|                             { | ||||
|                                 assertEquals(interleaveOrder[counter],sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                             } | ||||
|                             else | ||||
|                             { | ||||
|                                 assertEquals(order[counter],sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                             } | ||||
|                             counter++; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
| 	} | ||||
| 	 | ||||
| 	public static void main(String args[]) {  | ||||
| 		junit.textui.TestRunner.run(suite()); | ||||
| 	} | ||||
| 	 | ||||
| 	public static TestSuite suite() | ||||
| 	{ | ||||
| 		TestSuite suite = new TestSuite(); | ||||
| 		suite.addTest(new Test("testProcessing")); | ||||
|         suite.addTest(new Test("testProcessing2")); | ||||
| 		return suite; | ||||
| 	} | ||||
|     /* (non-Javadoc) | ||||
|      * @see org.apache.jmeter.engine.event.LoopIterationListener#iteration(org.apache.jmeter.engine.event.IterationDeliverEvent) | ||||
|      */ | ||||
|     public void iteration(IterationDeliverEvent iterEvent) | ||||
|     { | ||||
|         // TODO Auto-generated method stub | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -52,33 +52,26 @@ | |||
|  * information on the Apache Software Foundation, please see | ||||
|  * <http://www.apache.org/>. | ||||
|  */ | ||||
|   | ||||
|  package org.apache.jmeter.control; | ||||
| 
 | ||||
| package org.apache.jmeter.control; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| import java.util.Random; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.IterationListener; | ||||
| import org.apache.jmeter.threads.JMeterVariables; | ||||
| 
 | ||||
| /** | ||||
|  * @author Administrator | ||||
|  * | ||||
|  * To change this generated comment edit the template variable "typecomment": | ||||
|  * Window>Preferences>Java>Templates. | ||||
|  *@author Michael Stover | ||||
|  */ | ||||
| public class RandomController | ||||
| 	extends InterleaveControl | ||||
| 	implements Serializable,IterationListener | ||||
| 	implements Serializable | ||||
| { | ||||
| 	static Random rand = new Random(); | ||||
| 	 | ||||
| 	public RandomController() | ||||
| 	{ | ||||
| 		 | ||||
| 	} | ||||
| 	public RandomController() {} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * @see org.apache.jmeter.control.GenericController#resetCurrent() | ||||
| 	 */ | ||||
| 	protected void resetCurrent() | ||||
| 	{ | ||||
| 		if(getSubControllers().size() > 0) | ||||
|  | @ -91,33 +84,12 @@ public class RandomController | |||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * @see org.apache.jmeter.control.GenericController#incrementCurrent() | ||||
| 	 */ | ||||
| 	protected void incrementCurrent() | ||||
| 	{ | ||||
| 		setInterleave(NEW_STYLE); | ||||
| 		current = rand.nextInt(this.getSubControllers().size()); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @see org.apache.jmeter.engine.event.IterationListener#iterationStarted(org.apache.jmeter.engine.event.IterationEvent) | ||||
| 	 */ | ||||
| 	public void iterationStart(IterationEvent event) | ||||
| 	{ | ||||
| 		if(event.getIteration() == 1) | ||||
| 		{ | ||||
| 			resetCurrent(); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * @see org.apache.jmeter.engine.event.IterationListener#iteration(org.apache.jmeter.engine.event.IterationEvent) | ||||
| 	 */ | ||||
| 	public void iteration(IterationEvent event) {} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @see org.apache.jmeter.testelement.ThreadListener#setJMeterVariables(org.apache.jmeter.threads.JMeterVariables) | ||||
| 	 */ | ||||
| 	public void setJMeterVariables(JMeterVariables jmVars) | ||||
| 	{} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -84,7 +84,7 @@ public class InterleaveControlGui extends AbstractControllerGui | |||
| 	public void configure(TestElement el) | ||||
| 	{ | ||||
| 		super.configure(el); | ||||
| 		if(((InterleaveControl)el).getStyle() == InterleaveControl.DEFAULT_STYLE) | ||||
| 		if(((InterleaveControl)el).getStyle() == InterleaveControl.IGNORE_SUB_CONTROLLERS) | ||||
| 		{ | ||||
| 			style.setSelected(true); | ||||
| 		} | ||||
|  | @ -115,11 +115,11 @@ public class InterleaveControlGui extends AbstractControllerGui | |||
|         configureTestElement(ic); | ||||
|         if(style.isSelected()) | ||||
|         { | ||||
|         	((InterleaveControl)ic).setStyle(InterleaveControl.DEFAULT_STYLE); | ||||
|         	((InterleaveControl)ic).setStyle(InterleaveControl.IGNORE_SUB_CONTROLLERS); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|         	((InterleaveControl)ic).setStyle(InterleaveControl.NEW_STYLE); | ||||
|         	((InterleaveControl)ic).setStyle(InterleaveControl.USE_SUB_CONTROLLERS); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -103,18 +103,18 @@ public class RandomControlGui extends AbstractControllerGui | |||
|         configureTestElement(ic); | ||||
|         if(style.isSelected()) | ||||
|         { | ||||
|         	((RandomController)ic).setStyle(InterleaveControl.DEFAULT_STYLE); | ||||
|         	((RandomController)ic).setStyle(InterleaveControl.IGNORE_SUB_CONTROLLERS); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|         	((RandomController)ic).setStyle(InterleaveControl.NEW_STYLE); | ||||
|         	((RandomController)ic).setStyle(InterleaveControl.USE_SUB_CONTROLLERS); | ||||
|         } | ||||
|     } | ||||
| 	 | ||||
| 	public void configure(TestElement el) | ||||
| 	{ | ||||
| 		super.configure(el); | ||||
| 		if(((RandomController)el).getStyle() == InterleaveControl.DEFAULT_STYLE) | ||||
| 		if(((RandomController)el).getStyle() == InterleaveControl.IGNORE_SUB_CONTROLLERS) | ||||
| 		{ | ||||
| 			style.setSelected(true); | ||||
| 		} | ||||
|  |  | |||
|  | @ -2,8 +2,9 @@ package org.apache.jmeter.modifiers; | |||
| import java.io.Serializable; | ||||
| 
 | ||||
| import org.apache.jmeter.config.ConfigTestElement; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.IterationListener; | ||||
| import org.apache.jmeter.engine.event.IterationDeliverEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationListener; | ||||
| import org.apache.jmeter.engine.util.NoThreadClone; | ||||
| import org.apache.jmeter.testelement.property.BooleanProperty; | ||||
| import org.apache.jmeter.testelement.property.IntegerProperty; | ||||
|  | @ -20,7 +21,7 @@ import org.apache.log.Logger; | |||
|  */ | ||||
| public class CounterConfig | ||||
| 	extends ConfigTestElement | ||||
| 	implements Serializable, IterationListener,NoThreadClone | ||||
| 	implements Serializable, LoopIterationListener,NoThreadClone | ||||
| { | ||||
| 	private static Logger log = LoggingManager.getLoggerFor(JMeterUtils.ELEMENTS); | ||||
| 	private final static String START = "CounterConfig.start"; | ||||
|  | @ -38,7 +39,7 @@ public class CounterConfig | |||
| 	/** | ||||
| 	 * @see org.apache.jmeter.engine.event.IterationListener#iterationStarted(org.apache.jmeter.engine.event.IterationEvent) | ||||
| 	 */ | ||||
| 	public synchronized void iterationStart(IterationEvent event) | ||||
| 	public synchronized void iterationStart(LoopIterationEvent event) | ||||
| 	{ | ||||
| 		JMeterVariables variables = JMeterContextService.getContext().getVariables(); | ||||
| 		if(!isPerUser()) | ||||
|  | @ -83,7 +84,7 @@ public class CounterConfig | |||
| 	/** | ||||
| 	 * @see org.apache.jmeter.engine.event.IterationListener#iteration(org.apache.jmeter.engine.event.IterationEvent) | ||||
| 	 */ | ||||
| 	public void iteration(IterationEvent event) {} | ||||
| 	public void iteration(IterationDeliverEvent event) {} | ||||
| 	 | ||||
| 	public void setStart(int start) | ||||
| 	{ | ||||
|  |  | |||
|  | @ -5,8 +5,9 @@ import java.util.Collection; | |||
| import java.util.LinkedList; | ||||
| 
 | ||||
| import org.apache.jmeter.config.ConfigTestElement; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.IterationListener; | ||||
| import org.apache.jmeter.engine.event.IterationDeliverEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationListener; | ||||
| import org.apache.jmeter.processor.PreProcessor; | ||||
| import org.apache.jmeter.testelement.property.BooleanProperty; | ||||
| import org.apache.jmeter.testelement.property.CollectionProperty; | ||||
|  | @ -20,7 +21,7 @@ import org.apache.jmeter.threads.JMeterVariables; | |||
|  * To change this generated comment edit the template variable "typecomment": | ||||
|  * Window>Preferences>Java>Templates. | ||||
|  */ | ||||
| public class UserParameters extends ConfigTestElement implements Serializable, PreProcessor,IterationListener | ||||
| public class UserParameters extends ConfigTestElement implements Serializable, PreProcessor,LoopIterationListener | ||||
| { | ||||
| 
 | ||||
|     public static final String NAMES = "UserParameters.names"; | ||||
|  | @ -125,7 +126,7 @@ public class UserParameters extends ConfigTestElement implements Serializable, P | |||
|     /** | ||||
|      * @see org.apache.jmeter.engine.event.IterationListener#iterationStarted(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void iterationStart(IterationEvent event) | ||||
|     public void iterationStart(LoopIterationEvent event) | ||||
|     { | ||||
|         if(isPerIteration()) | ||||
|         { | ||||
|  | @ -136,7 +137,7 @@ public class UserParameters extends ConfigTestElement implements Serializable, P | |||
| 	/** | ||||
| 	 * @see org.apache.jmeter.engine.event.IterationListener#iteration(org.apache.jmeter.engine.event.IterationEvent) | ||||
| 	 */ | ||||
| 	public void iteration(IterationEvent event) {} | ||||
| 	public void iteration(IterationDeliverEvent event) {} | ||||
| 
 | ||||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.ThreadListener#setJMeterVariables(org.apache.jmeter.threads.JMeterVariables) | ||||
|  |  | |||
|  | @ -59,8 +59,9 @@ import java.io.Serializable; | |||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.IterationListener; | ||||
| import org.apache.jmeter.engine.event.IterationDeliverEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationListener; | ||||
| import org.apache.jmeter.testelement.AbstractTestElement; | ||||
| import org.apache.jmeter.testelement.VariablesCollection; | ||||
| import org.apache.jmeter.threads.JMeterVariables; | ||||
|  | @ -78,7 +79,7 @@ import org.apache.log.Logger; | |||
|  */ | ||||
| public class ConstantTimer | ||||
|     extends AbstractTestElement | ||||
|     implements Timer, Serializable, IterationListener | ||||
|     implements Timer, Serializable, LoopIterationListener | ||||
| { | ||||
|     private static Logger log = | ||||
|         Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.elements"); | ||||
|  | @ -162,7 +163,7 @@ public class ConstantTimer | |||
|      *  | ||||
|      * @see org.apache.jmeter.engine.event.IterationListener#iterationStarted(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void iterationStart(IterationEvent event) | ||||
|     public void iterationStart(LoopIterationEvent event) | ||||
|     { | ||||
|         delay = getPropertyAsLong(DELAY); | ||||
|          | ||||
|  | @ -171,7 +172,7 @@ public class ConstantTimer | |||
| 	/** | ||||
| 	 * @see org.apache.jmeter.engine.event.IterationListener#iteration(org.apache.jmeter.engine.event.IterationEvent) | ||||
| 	 */ | ||||
| 	public void iteration(IterationEvent event) {} | ||||
| 	public void iteration(IterationDeliverEvent event) {} | ||||
| 	 | ||||
|     /** | ||||
|      * Make changes to variables available elsewhere. | ||||
|  |  | |||
|  | @ -72,7 +72,7 @@ import org.apache.jmeter.control.gui.WorkBenchGui; | |||
| import org.apache.jmeter.engine.RemoteJMeterEngine; | ||||
| import org.apache.jmeter.engine.RemoteJMeterEngineImpl; | ||||
| import org.apache.jmeter.engine.StandardJMeterEngine; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.exceptions.IllegalUserActionException; | ||||
| import org.apache.jmeter.gui.GuiPackage; | ||||
| import org.apache.jmeter.gui.action.ActionRouter; | ||||
|  | @ -415,7 +415,7 @@ public class JMeter implements JMeterPlugin { | |||
|         /** | ||||
|          * @see org.apache.jmeter.testelement.TestListener#iterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|          */ | ||||
|         public void testIterationStart(IterationEvent event) | ||||
|         public void testIterationStart(LoopIterationEvent event) | ||||
|         {} | ||||
| 
 | ||||
| 	} | ||||
|  |  | |||
|  | @ -52,8 +52,10 @@ | |||
|  * information on the Apache Software Foundation, please see | ||||
|  * <http://www.apache.org/>. | ||||
|  */ | ||||
|   | ||||
| package org.apache.jmeter.control; | ||||
| import org.apache.jmeter.engine.event.IterationListener; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.LoopIterationListener; | ||||
| import org.apache.jmeter.samplers.Sampler; | ||||
| import org.apache.jmeter.testelement.TestElement; | ||||
| 
 | ||||
|  | @ -68,17 +70,13 @@ import org.apache.jmeter.testelement.TestElement; | |||
|  * } | ||||
|  * | ||||
|  *@author    Michael Stover | ||||
|  *@author    Thad Smith | ||||
|  *@created   $Date$ | ||||
|  *@version   1.0 | ||||
|  ***************************************/ | ||||
| public interface Controller extends TestElement | ||||
| { | ||||
|      | ||||
|     /** | ||||
|      * Controllers have to notify listeners of when they begin an iteration | ||||
|      * through their sub-elements. | ||||
|      */ | ||||
|     public void addIterationListener(IterationListener lis); | ||||
|     | ||||
| 	/** | ||||
| 	 * Delivers the next Sampler. | ||||
| 	 * @return org.apache.jmeter.samplers.Sampler | ||||
|  | @ -86,30 +84,21 @@ public interface Controller extends TestElement | |||
| 	public Sampler next(); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Indicates whether the Controller has another Sampler to deliver during the | ||||
| 	 * current test iteration. | ||||
| 	 * @return boolean | ||||
| 	 */ | ||||
| 	public boolean hasNext(); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Indicates whether the Controller is done delivering Samplers for the rest | ||||
| 	 * of the test. | ||||
| 	 * Indicates whether the Controller is done delivering Samplers for  | ||||
| 	 * the rest of the test. | ||||
| 	 * @return boolean | ||||
| 	 */ | ||||
| 	public boolean isDone(); | ||||
| 	 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * By using this method, one can ask the controller if the next Sampler is the | ||||
| 	 * first in the Controller's list. | ||||
| 	 * @return boolean | ||||
| 	 * Controllers have to notify listeners of when they begin an iteration | ||||
| 	 * through their sub-elements. | ||||
| 	 */ | ||||
| 	public boolean isNextFirst(); | ||||
| 	 | ||||
| 	public void addIterationListener(LoopIterationListener listener); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Returns the number of samplers that the controller has returned | ||||
| 	 * via next() during the current iteration | ||||
| 	 * @return int | ||||
| 	 * Called to initialize a controller at the beginning of a test | ||||
| 	 * iteration. | ||||
| 	 */ | ||||
| 	public int samplersReturned(); | ||||
| 	public void initialize(); | ||||
| } | ||||
|  |  | |||
|  | @ -52,390 +52,348 @@ | |||
|  * information on the Apache Software Foundation, please see | ||||
|  * <http://www.apache.org/>. | ||||
|  */ | ||||
| 
 | ||||
| package org.apache.jmeter.control; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.IterationListener; | ||||
| import org.apache.jmeter.samplers.AbstractSampler; | ||||
| import junit.framework.TestSuite; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationDeliverEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationListener; | ||||
| import org.apache.jmeter.junit.JMeterTestCase; | ||||
| import org.apache.jmeter.junit.stubs.TestSampler; | ||||
| import org.apache.jmeter.samplers.Sampler; | ||||
| import org.apache.jmeter.testelement.AbstractTestElement; | ||||
| import org.apache.jmeter.testelement.PerSampleClonable; | ||||
| import org.apache.jmeter.testelement.PerThreadClonable; | ||||
| import org.apache.jmeter.testelement.TestElement; | ||||
| import org.apache.jmeter.util.JMeterUtils; | ||||
| import org.apache.jorphan.logging.LoggingManager; | ||||
| import org.apache.log.Logger; | ||||
| 
 | ||||
| /**************************************** | ||||
|  * Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache | ||||
|  * Title: JMeter  | ||||
|  * Description: Copyright: Copyright (c) 2000  | ||||
|  * Company: Apache | ||||
|  * | ||||
|  *@author    Michael Stover | ||||
|  *@created   $Date$ | ||||
|  *@version   1.0 | ||||
|  *@author	Michael Stover | ||||
|  *@author	Thad Smith | ||||
|  *@created	$Date$ | ||||
|  *@version	1.0 | ||||
|  ***************************************/ | ||||
| 
 | ||||
| public class GenericController extends AbstractTestElement implements Controller, | ||||
| 		Serializable,PerThreadClonable,IterationListener | ||||
| public class GenericController extends AbstractTestElement implements Controller, Serializable | ||||
| { | ||||
|     protected static Logger log = LoggingManager.getLoggerFor(JMeterUtils.ELEMENTS); | ||||
|     protected List iterationListeners = new LinkedList(); | ||||
| 	/**************************************** | ||||
| 	 * !ToDo (Field description) | ||||
| 	 ***************************************/ | ||||
| 	protected List subControllersAndSamplers = new ArrayList(); | ||||
| 	/**************************************** | ||||
| 	 * !ToDo (Field description) | ||||
| 	 ***************************************/ | ||||
| 	protected int current = 0; | ||||
| 	/**************************************** | ||||
| 	 * !ToDo (Field description) | ||||
| 	 ***************************************/ | ||||
| 	protected Iterator controlIt; | ||||
| 	private List configs = new LinkedList(); | ||||
| 	private boolean returnedNull = false; | ||||
| 	private boolean done = false, timeForNext = false; | ||||
| 	private List assertions = new LinkedList(); | ||||
|     private boolean first = true; | ||||
|     private int samplersReturned = 0; | ||||
|     protected List subControllersAndSamplers = new ArrayList(); | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * !ToDo (Constructor description) | ||||
| 	 ***************************************/ | ||||
| 	public GenericController() | ||||
| 	{ | ||||
| 		 | ||||
| 	} | ||||
|      | ||||
|     public void addIterationListener(IterationListener lis) | ||||
|     protected int current; | ||||
|     private int iterCount; | ||||
|     private boolean done, first; | ||||
| 
 | ||||
|     /** | ||||
|      * Creates a Generic Controller | ||||
|      */ | ||||
|     public GenericController() | ||||
|     { | ||||
|         initialize(); | ||||
|     } | ||||
| 
 | ||||
|     public void initialize() | ||||
|     { | ||||
|         resetCurrent(); | ||||
|         resetIterCount(); | ||||
|         done = false; | ||||
|         first = true; | ||||
|         TestElement elem; | ||||
|         for (int i = 0; i < subControllersAndSamplers.size(); i++) | ||||
|         { | ||||
|             elem = (TestElement) subControllersAndSamplers.get(i); | ||||
|             if (elem instanceof Controller) | ||||
|             { | ||||
|                 ((Controller) elem).initialize(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     protected void reInitialize() | ||||
|     { | ||||
|         resetCurrent(); | ||||
|         incrementIterCount(); | ||||
|         setFirst(true); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.Controller#next() | ||||
|      */ | ||||
|     public Sampler next() | ||||
|     { | ||||
|         log.debug("Calling next on: " + this.getClass().getName()); | ||||
|         Sampler returnValue = null; | ||||
|         TestElement currentElement = null; | ||||
|         try | ||||
|         { | ||||
|             currentElement = getCurrentElement(); | ||||
|             log.debug("next element = " + currentElement); | ||||
|             setCurrentElement(currentElement); | ||||
|             if (currentElement == null) | ||||
|             { | ||||
|                 //incrementCurrent();   | ||||
|                 returnValue = nextIsNull(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 fireIterEvents(currentElement); | ||||
|                 if (currentElement instanceof Sampler) | ||||
|                 { | ||||
|                     returnValue = nextIsASampler((Sampler) currentElement); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     returnValue = nextIsAController((Controller) currentElement); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         catch (NextIsNullException e) | ||||
|         { | ||||
|             returnValue = null; | ||||
|         } | ||||
|         return returnValue; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.Controller#isDone() | ||||
|      */ | ||||
|     public boolean isDone() | ||||
|     { | ||||
|         return done; | ||||
|     } | ||||
| 
 | ||||
|     protected void setDone(boolean done) | ||||
|     { | ||||
|         this.done = done; | ||||
|     } | ||||
| 
 | ||||
|     protected boolean isFirst() | ||||
|     { | ||||
|         return first; | ||||
|     } | ||||
| 
 | ||||
|     public void setFirst(boolean b) | ||||
|     { | ||||
|         first = b; | ||||
|     } | ||||
| 
 | ||||
|     protected Sampler nextIsAController(Controller controller) throws NextIsNullException | ||||
|     { | ||||
|         Sampler returnValue; | ||||
|         Sampler sampler = controller.next(); | ||||
|         if (sampler == null) | ||||
|         { | ||||
|             currentReturnedNull(controller); | ||||
|             returnValue = next(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             returnValue = sampler; | ||||
|         } | ||||
|         return returnValue; | ||||
|     } | ||||
| 
 | ||||
|     protected Sampler nextIsASampler(Sampler element) throws NextIsNullException | ||||
|     { | ||||
|         incrementCurrent(); | ||||
|         return element; | ||||
|     } | ||||
| 
 | ||||
|     protected Sampler nextIsNull() throws NextIsNullException | ||||
|     { | ||||
|         reInitialize(); | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     protected void currentReturnedNull(Controller c) | ||||
|     { | ||||
|         if (c.isDone()) | ||||
|         { | ||||
|             removeCurrentElement(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             incrementCurrent(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Gets the SubControllers attribute of the  | ||||
|      * GenericController object | ||||
|      * | ||||
|      *	@return	The SubControllers value | ||||
|      */ | ||||
|     protected List getSubControllers() | ||||
|     { | ||||
|         return subControllersAndSamplers; | ||||
|     } | ||||
| 
 | ||||
|     private void addElement(TestElement child) | ||||
|     { | ||||
|         subControllersAndSamplers.add(child); | ||||
|     } | ||||
| 
 | ||||
|     protected void setCurrentElement(TestElement currentElement) throws NextIsNullException | ||||
|     {} | ||||
| 
 | ||||
|     protected TestElement getCurrentElement() | ||||
|     { | ||||
|         if (current < subControllersAndSamplers.size()) | ||||
|         { | ||||
|             return (TestElement) subControllersAndSamplers.get(current); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             if (subControllersAndSamplers.size() == 0) | ||||
|             { | ||||
|                 setDone(true); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     protected void removeCurrentElement() | ||||
|     { | ||||
|         subControllersAndSamplers.remove(current); | ||||
|     } | ||||
| 
 | ||||
|     protected void incrementCurrent() | ||||
|     { | ||||
|         current++; | ||||
|     } | ||||
| 
 | ||||
|     protected void resetCurrent() | ||||
|     { | ||||
|         current = 0; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestElement#addTestElement(org.apache.jmeter.testelement.TestElement) | ||||
|      */ | ||||
|     public void addTestElement(TestElement child) | ||||
|     { | ||||
|         if (child instanceof Controller || child instanceof Sampler) | ||||
|         { | ||||
|             addElement(child); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void addIterationListener(LoopIterationListener lis) | ||||
|     { | ||||
|         iterationListeners.add(lis); | ||||
|     } | ||||
| 	 | ||||
| 	public boolean isNextFirst() | ||||
| 	{ | ||||
| 		return first; | ||||
| 	} | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * Gets the ConfigElements attribute of the GenericController object | ||||
| 	 * | ||||
| 	 *@return   The ConfigElements value | ||||
| 	 ***************************************/ | ||||
| 	protected List getConfigElements() | ||||
| 	{ | ||||
| 		return configs; | ||||
| 	} | ||||
| 
 | ||||
| 	private void addConfigElement(TestElement el) | ||||
| 	{ | ||||
| 		configs.add(el); | ||||
| 	} | ||||
| 
 | ||||
| 	public void initialize() | ||||
| 	{ | ||||
|         first = true; | ||||
| 		resetCurrent(); | ||||
| 	} | ||||
| 
 | ||||
| 	public void reInitialize() | ||||
| 	{ | ||||
| 		resetCurrent(); | ||||
| 	} | ||||
| 
 | ||||
| 	protected void removeCurrentController() | ||||
| 	{ | ||||
| 		subControllersAndSamplers.remove(current); | ||||
| 	} | ||||
| 
 | ||||
| 	protected void resetCurrent() | ||||
| 	{ | ||||
|         first = true; | ||||
| 		current = 0; | ||||
| 	} | ||||
| 
 | ||||
| 	protected void incrementCurrent() | ||||
| 	{ | ||||
| 		current++; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Answers the question: when the end of subcontrollers and samplers is reached, | ||||
| 	 * how does this Controller answert the question: hasNext()?  For most controllers, | ||||
| 	 * the answer is to return false.  For some, it depends.  The LoopController, for | ||||
| 	 * instance will repeat the list of subcontrollers a given number of times | ||||
| 	 * before signalling false to 'hasNext()'. | ||||
| 	 */ | ||||
| 	protected boolean hasNextAtEnd() | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	protected void nextAtEnd() | ||||
| 	{ | ||||
| 		resetCurrent(); | ||||
| 	} | ||||
| 
 | ||||
| 	public boolean hasNext() | ||||
| 	{ | ||||
| 		boolean retVal; | ||||
| 		Object controller = getCurrentController(); | ||||
| 		if(controller == null) | ||||
| 		{ | ||||
| 			retVal = hasNextAtEnd(); | ||||
| 			resetCurrent(); | ||||
| 		} | ||||
| 		else if(controller instanceof Controller) | ||||
| 		{ | ||||
| 			if(((Controller)controller).hasNext()) | ||||
| 			{ | ||||
| 				retVal = true; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				currentHasNextIsFalse(); | ||||
| 				retVal = hasNext(); | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			retVal = true; | ||||
| 		} | ||||
| 
 | ||||
| 		return retVal; | ||||
| 	} | ||||
| 
 | ||||
| 	protected void currentHasNextIsFalse() | ||||
| 	{ | ||||
| 		if(((Controller)getCurrentController()).isDone()) | ||||
| 		{ | ||||
| 			removeCurrentController(); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			incrementCurrent(); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	protected boolean shortCircuitIsDone() | ||||
| 	{ | ||||
| 		return done; | ||||
| 	} | ||||
| 
 | ||||
| 	protected void setShortCircuit(boolean done) | ||||
| 	{ | ||||
| 		this.done = done; | ||||
| 	} | ||||
| 
 | ||||
| 	public boolean isDone() | ||||
| 	{ | ||||
| 		if(shortCircuitIsDone()) | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
| 		boolean isdone = true; | ||||
| 		Iterator iter = subControllersAndSamplers.iterator(); | ||||
| 		while (iter.hasNext()) | ||||
| 		{ | ||||
| 			Object item = iter.next(); | ||||
| 			if(item instanceof Sampler) | ||||
| 			{ | ||||
| 				return false; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				isdone = isdone && ((Controller)item).isDone(); | ||||
| 			} | ||||
| 		} | ||||
| 		setShortCircuit(isdone); | ||||
| 		return isdone; | ||||
| 	} | ||||
| 
 | ||||
| 	protected TestElement getCurrentController() | ||||
| 	{ | ||||
| 		if(current < subControllersAndSamplers.size()) | ||||
| 		{ | ||||
| 			return (TestElement)subControllersAndSamplers.get(current); | ||||
| 		} | ||||
| 		else return null; | ||||
| 	} | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * Gets the SubControllers attribute of the GenericController object | ||||
| 	 * | ||||
| 	 *@return   The SubControllers value | ||||
| 	 ***************************************/ | ||||
| 	protected List getSubControllers() | ||||
| 	{ | ||||
| 		return subControllersAndSamplers; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * @see org.apache.jmeter.control.Controller#samplersReturned() | ||||
| 	 */ | ||||
| 	public int samplersReturned() | ||||
| 	{ | ||||
| 		return samplersReturned; | ||||
| 	} | ||||
| 	 | ||||
| 	protected void resetSamplersReturned() | ||||
| 	{ | ||||
| 		samplersReturned = 0; | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * !ToDo | ||||
| 	 * | ||||
| 	 *@param child  !ToDo | ||||
| 	 ***************************************/ | ||||
| 	public void addTestElement(TestElement child) | ||||
| 	{ | ||||
| 		if(child instanceof Controller || child instanceof Sampler) | ||||
| 		{ | ||||
| 			addController(child); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	private void addController(TestElement child) | ||||
| 	{ | ||||
| 		subControllersAndSamplers.add(child); | ||||
| 	} | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * Retrieves the next Entry to be sampled. | ||||
| 	 * | ||||
| 	 *@return   !ToDo (Return description) | ||||
| 	 ***************************************/ | ||||
| 	public Sampler next() | ||||
| 	{     | ||||
| 		TestElement controller = getCurrentController(); | ||||
| 		fireIterEvents(controller); | ||||
| 		if(controller == null) | ||||
| 		{ | ||||
| 			nextAtEnd(); | ||||
| 			if (subControllersAndSamplers.size()>0) | ||||
| 				return next(); | ||||
| 			else | ||||
| 				return null; | ||||
| 		} | ||||
| 		if(controller instanceof Sampler) | ||||
| 		{ | ||||
| 			incrementCurrent(); | ||||
| 			samplersReturned++; | ||||
| 			return (Sampler)controller; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			Controller c = (Controller)controller; | ||||
| 			if(c.hasNext()) | ||||
| 			{ | ||||
| 				Sampler s = c.next(); | ||||
| 				return s; | ||||
| 			} | ||||
| 			else if(c.isDone()) | ||||
| 			{ | ||||
| 				removeCurrentController(); | ||||
| 				return next(); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				incrementCurrent(); | ||||
| 				return next(); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|     protected void fireIterEvents(TestElement current) | ||||
|     { | ||||
|         if(isNextFirst()) | ||||
|         if (isFirst()) | ||||
|         { | ||||
|             fireIterationStart(current); | ||||
|             fireIterationStart(); | ||||
|             first = false; | ||||
|         } | ||||
|         if (current instanceof GenericController && ((GenericController)current).isNextFirst())  | ||||
|         {  | ||||
| 	        fireIteration(current); | ||||
|         if (current instanceof GenericController && ((GenericController) current).isFirst()) | ||||
|         { | ||||
|             fireIteration(current); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     protected int getIterCount() | ||||
|     { | ||||
|         return 1; | ||||
|     } | ||||
|      | ||||
|     protected void fireIterationStart(TestElement current) | ||||
| 
 | ||||
|     protected void fireIterationStart() | ||||
|     { | ||||
|         Iterator iter = iterationListeners.iterator(); | ||||
|         LoopIterationEvent event = new LoopIterationEvent(this, getIterCount()); | ||||
|         while (iter.hasNext()) | ||||
|         { | ||||
|             IterationListener item = (IterationListener)iter.next(); | ||||
|             item.iterationStart(new IterationEvent(this,current,getIterCount()));             | ||||
|             LoopIterationListener item = (LoopIterationListener) iter.next(); | ||||
|             item.iterationStart(event); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     protected void fireIteration(TestElement current) { | ||||
|     	Iterator iter = iterationListeners.iterator(); | ||||
|     	while (iter.hasNext()) | ||||
|     	{ | ||||
|     		IterationListener item = (IterationListener)iter.next(); | ||||
|     		item.iteration(new IterationEvent(this,current,getIterCount())); | ||||
|     	} | ||||
|     } | ||||
|      | ||||
|     public void iterationStart(IterationEvent event) | ||||
| 
 | ||||
|     protected void fireIteration(TestElement current) | ||||
|     { | ||||
|     	resetSamplersReturned(); | ||||
|         Iterator iter = iterationListeners.iterator(); | ||||
|         IterationDeliverEvent event = new IterationDeliverEvent(this, current); | ||||
|         while (iter.hasNext()) | ||||
|         { | ||||
|             LoopIterationListener item = (LoopIterationListener) iter.next(); | ||||
|             item.iteration(event); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     public void iteration(IterationEvent event) {} | ||||
| 
 | ||||
| 	public static class Test extends junit.framework.TestCase | ||||
| 	{ | ||||
| 		public Test(String name) | ||||
| 		{ | ||||
| 			super(name); | ||||
| 		} | ||||
|     protected int getIterCount() | ||||
|     { | ||||
|         return iterCount; | ||||
|     } | ||||
| 
 | ||||
| 		public void testProcessing() throws Exception | ||||
| 		{ | ||||
| 			GenericController controller = new GenericController(); | ||||
| 			GenericController sub_1 = new GenericController(); | ||||
| 			sub_1.addTestElement(makeSampler("one")); | ||||
| 			sub_1.addTestElement(makeSampler("two")); | ||||
| 			controller.addTestElement(sub_1); | ||||
| 			controller.addTestElement(makeSampler("three")); | ||||
| 			GenericController sub_2 = new GenericController(); | ||||
| 			GenericController sub_3 = new GenericController(); | ||||
| 			sub_2.addTestElement(makeSampler("four")); | ||||
| 			sub_3.addTestElement(makeSampler("five")); | ||||
| 			sub_3.addTestElement(makeSampler("six")); | ||||
| 			sub_2.addTestElement(sub_3); | ||||
| 			sub_2.addTestElement(makeSampler("seven")); | ||||
| 			controller.addTestElement(sub_2); | ||||
| 			String[] order = new String[]{"one","two","three","four","five","six","seven"}; | ||||
| 			int counter = 7; | ||||
| 			for (int i = 0; i < 2; i++) | ||||
| 			{ | ||||
| 				assertEquals(7,counter); | ||||
| 				counter = 0; | ||||
| 				while(controller.hasNext()) | ||||
| 				{ | ||||
| 					TestElement sampler = controller.next(); | ||||
| 					assertEquals(order[counter++],sampler.getPropertyAsString(TestElement.NAME)); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|     protected void incrementIterCount() | ||||
|     { | ||||
|         iterCount++; | ||||
|     } | ||||
| 
 | ||||
| 		private TestElement makeSampler(String name) | ||||
| 		{ | ||||
| 			TestSampler s = new TestSampler(); | ||||
| 			s.setName(name); | ||||
| 			return s; | ||||
| 		} | ||||
| 		class TestSampler extends AbstractSampler implements PerSampleClonable { | ||||
| 		  public void addCustomTestElement(TestElement t) { } | ||||
| 		  public org.apache.jmeter.samplers.SampleResult sample(org.apache.jmeter.samplers.Entry e) { return null; } | ||||
| 		} | ||||
| 	} | ||||
|     protected void resetIterCount() | ||||
|     { | ||||
|         iterCount = 0; | ||||
|     } | ||||
| 
 | ||||
|     public static class Test extends JMeterTestCase | ||||
|     { | ||||
|         public Test(String name) | ||||
|         { | ||||
|             super(name); | ||||
|         } | ||||
| 
 | ||||
|         public void testProcessing() throws Exception | ||||
|         { | ||||
|             testLog.debug("Testing Generic Controller"); | ||||
|             GenericController controller = new GenericController(); | ||||
|             GenericController sub_1 = new GenericController(); | ||||
|             sub_1.addTestElement(new TestSampler("one")); | ||||
|             sub_1.addTestElement(new TestSampler("two")); | ||||
|             controller.addTestElement(sub_1); | ||||
|             controller.addTestElement(new TestSampler("three")); | ||||
|             GenericController sub_2 = new GenericController(); | ||||
|             GenericController sub_3 = new GenericController(); | ||||
|             sub_2.addTestElement(new TestSampler("four")); | ||||
|             sub_3.addTestElement(new TestSampler("five")); | ||||
|             sub_3.addTestElement(new TestSampler("six")); | ||||
|             sub_2.addTestElement(sub_3); | ||||
|             sub_2.addTestElement(new TestSampler("seven")); | ||||
|             controller.addTestElement(sub_2); | ||||
|             String[] order = new String[] { "one", "two", "three", "four", "five", "six", "seven" }; | ||||
|             int counter = 7; | ||||
|             controller.initialize(); | ||||
|             for (int i = 0; i < 2; i++) | ||||
|             { | ||||
|                 assertEquals(7, counter); | ||||
|                 counter = 0; | ||||
|                 TestElement sampler = null; | ||||
|                 while ((sampler = controller.next()) != null) | ||||
|                 { | ||||
|                     assertEquals(order[counter++], sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static void main(String args[]) | ||||
|     { | ||||
|         junit.textui.TestRunner.run(suite()); | ||||
|     } | ||||
| 
 | ||||
|     public static TestSuite suite() | ||||
|     { | ||||
|         TestSuite suite = new TestSuite(); | ||||
|         suite.addTest(new Test("testProcessing")); | ||||
|         return suite; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -52,12 +52,16 @@ | |||
|  * information on the Apache Software Foundation, please see | ||||
|  * <http://www.apache.org/>. | ||||
|  */ | ||||
| 
 | ||||
| package org.apache.jmeter.control; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| import org.apache.jmeter.samplers.AbstractSampler; | ||||
| //import org.apache.jmeter.samplers.Sampler; | ||||
| import org.apache.jmeter.testelement.PerSampleClonable; | ||||
| import junit.framework.TestSuite; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.junit.stubs.TestSampler; | ||||
| import org.apache.jmeter.samplers.Sampler; | ||||
| import org.apache.jmeter.testelement.TestElement; | ||||
| import org.apache.jmeter.testelement.property.BooleanProperty; | ||||
| import org.apache.jmeter.testelement.property.IntegerProperty; | ||||
|  | @ -66,9 +70,11 @@ import org.apache.jmeter.util.JMeterUtils; | |||
| import org.apache.jorphan.logging.LoggingManager; | ||||
| import org.apache.log.Logger; | ||||
| /**************************************** | ||||
|  * Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache | ||||
|  * Title: JMeter Description: Copyright: Copyright (c) 2000 Company:  | ||||
| Apache | ||||
|  * | ||||
|  *@author    Michael Stover | ||||
|  *@author    Thad Smith | ||||
|  *@created   $Date$ | ||||
|  *@version   1.0 | ||||
|  ***************************************/ | ||||
|  | @ -76,196 +82,100 @@ import org.apache.log.Logger; | |||
| public class LoopController extends GenericController implements Serializable | ||||
| { | ||||
|     private static Logger log = LoggingManager.getLoggerFor(JMeterUtils.ELEMENTS); | ||||
| 	private final static String LOOPS = "LoopController.loops"; | ||||
| 	private final static String CONTINUE_FOREVER = "LoopController.continue_forever"; | ||||
| 	private int loopCount = 0; | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * !ToDo (Constructor description) | ||||
| 	 ***************************************/ | ||||
| 	public LoopController() | ||||
| 	{ | ||||
| 		setContinueForever(true); | ||||
| 	} | ||||
|     private final static String LOOPS = "LoopController.loops"; | ||||
|     private final static String CONTINUE_FOREVER = "LoopController.continue_forever"; | ||||
|     private int loopCount = 0; | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * !ToDo (Method description) | ||||
| 	 * | ||||
| 	 *@param loops  !ToDo (Parameter description) | ||||
| 	 ***************************************/ | ||||
| 	public void setLoops(int loops) | ||||
| 	{ | ||||
| 		setProperty(new IntegerProperty(LOOPS,loops)); | ||||
| 	} | ||||
|      | ||||
|     public void setLoops(String loopValue) | ||||
|     public LoopController() | ||||
|     { | ||||
|         setProperty(new StringProperty(LOOPS,loopValue)); | ||||
|         setContinueForever(true); | ||||
|     } | ||||
| 
 | ||||
|     public void setLoops(int loops) | ||||
|     { | ||||
|         setProperty(new IntegerProperty(LOOPS, loops)); | ||||
|     } | ||||
| 
 | ||||
|     public void setLoops(String loopValue) | ||||
|     { | ||||
|         setProperty(new StringProperty(LOOPS, loopValue)); | ||||
|     } | ||||
| 
 | ||||
|     public int getLoops() | ||||
|     { | ||||
|         return getPropertyAsInt(LOOPS); | ||||
|     } | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * !ToDoo (Method description) | ||||
| 	 * | ||||
| 	 *@return   !ToDo (Return description) | ||||
| 	 ***************************************/ | ||||
| 	public int getLoops() | ||||
| 	{ | ||||
| 		return getPropertyAsInt(LOOPS); | ||||
| 	} | ||||
|      | ||||
|     public String getLoopString() | ||||
|     { | ||||
|         return getPropertyAsString(LOOPS); | ||||
|     } | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * !ToDo (Method description) | ||||
| 	 * | ||||
| 	 *@param forever  !ToDo (Parameter description) | ||||
| 	 ***************************************/ | ||||
| 	public void setContinueForever(boolean forever) | ||||
| 	{ | ||||
| 		setProperty(new BooleanProperty(CONTINUE_FOREVER,forever)); | ||||
| 	} | ||||
|     public void setContinueForever(boolean forever) | ||||
|     { | ||||
|         setProperty(new BooleanProperty(CONTINUE_FOREVER, forever)); | ||||
|     } | ||||
| 
 | ||||
|     public boolean getContinueForever() | ||||
|     { | ||||
|         return getPropertyAsBoolean(CONTINUE_FOREVER); | ||||
|     } | ||||
| 
 | ||||
| 	/**************************************** | ||||
| 	 * !ToDoo (Method description) | ||||
| 	 * | ||||
| 	 *@return   !ToDo (Return description) | ||||
| 	 ***************************************/ | ||||
| 	public boolean getContinueForever() | ||||
| 	{ | ||||
| 		return getPropertyAsBoolean(CONTINUE_FOREVER); | ||||
| 	} | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.Controller#isDone() | ||||
|      */ | ||||
|     public boolean isDone() | ||||
|     { | ||||
|         if (getLoops() != 0) | ||||
|         { | ||||
|             return super.isDone(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	public void initialize() | ||||
| 	{ | ||||
| 		super.initialize(); | ||||
| 		resetLoopCount(); | ||||
| 	} | ||||
|     private boolean endOfLoop() | ||||
|     { | ||||
|         return (getLoops() > -1) && loopCount >= getLoops(); | ||||
|     } | ||||
| 
 | ||||
| 	public void reInitialize() | ||||
| 	{ | ||||
| 		super.reInitialize(); | ||||
| 		resetLoopCount(); | ||||
| 	} | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.GenericController#nextIfCurrentNull() | ||||
|      */ | ||||
|     protected Sampler nextIsNull() throws NextIsNullException | ||||
|     { | ||||
|         reInitialize(); | ||||
|         if (endOfLoop()) | ||||
|         { | ||||
|             if (!getContinueForever()) | ||||
|             { | ||||
|                 setDone(true); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 resetLoopCount(); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return next(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	protected void incrementLoopCount() | ||||
| 	{ | ||||
| 		loopCount++; | ||||
| 	} | ||||
|     protected void incrementLoopCount() | ||||
|     { | ||||
|         loopCount++; | ||||
|     } | ||||
| 
 | ||||
| 	protected void resetLoopCount() | ||||
| 	{ | ||||
| 		if(!getContinueForever() && getLoops() > -1) | ||||
| 		{ | ||||
| 			this.setShortCircuit(true); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			loopCount = 0; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public boolean hasNext()  | ||||
| 	{ | ||||
| 		if (getLoops()!=0 && !endOfLoop())  | ||||
| 		{ | ||||
| 			return super.hasNext(); | ||||
| 		}  | ||||
| 		else  | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
|     protected void resetLoopCount() | ||||
|     { | ||||
|         loopCount = 0; | ||||
|     } | ||||
| 
 | ||||
| 	protected boolean hasNextAtEnd() | ||||
| 	{ | ||||
| 		incrementLoopCount(); | ||||
| 		if(endOfLoop()) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			resetCurrent(); | ||||
| 			return hasNext(); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public boolean isDone() { | ||||
| 		if (getLoops()!=0)  | ||||
| 		{ | ||||
| 			return super.isDone(); | ||||
| 		}  | ||||
| 		else  | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	protected void nextAtEnd() | ||||
| 	{ | ||||
| 		resetCurrent(); | ||||
| 		incrementLoopCount(); | ||||
| 	} | ||||
| 
 | ||||
| 	private boolean endOfLoop() | ||||
| 	{ | ||||
| 		return (!getContinueForever() || getLoops() > -1) && loopCount >= getLoops(); | ||||
| 	} | ||||
| 
 | ||||
| 	public static class Test extends junit.framework.TestCase | ||||
| 	{ | ||||
| 		public Test(String name) | ||||
| 		{ | ||||
| 			super(name); | ||||
| 		} | ||||
| 
 | ||||
| 		public void testProcessing() throws Exception | ||||
| 		{ | ||||
| 			GenericController controller = new GenericController(); | ||||
| 			GenericController sub_1 = new GenericController(); | ||||
| 			sub_1.addTestElement(makeSampler("one")); | ||||
| 			sub_1.addTestElement(makeSampler("two")); | ||||
| 			controller.addTestElement(sub_1); | ||||
| 			controller.addTestElement(makeSampler("three")); | ||||
| 			LoopController sub_2 = new LoopController(); | ||||
| 			sub_2.setLoops(3); | ||||
| 			GenericController sub_3 = new GenericController(); | ||||
| 			sub_2.addTestElement(makeSampler("four")); | ||||
| 			sub_3.addTestElement(makeSampler("five")); | ||||
| 			sub_3.addTestElement(makeSampler("six")); | ||||
| 			sub_2.addTestElement(sub_3); | ||||
| 			sub_2.addTestElement(makeSampler("seven")); | ||||
| 			controller.addTestElement(sub_2); | ||||
| 			String[] order = new String[]{"one","two","three","four","five","six","seven", | ||||
| 						"four","five","six","seven","four","five","six","seven"}; | ||||
| 			int counter = 15; | ||||
| 			for (int i = 0; i < 2; i++) | ||||
| 			{ | ||||
| 				assertEquals(15,counter); | ||||
| 				counter = 0; | ||||
| 				while(controller.hasNext()) | ||||
| 				{ | ||||
| 					TestElement sampler = controller.next(); | ||||
| 					assertEquals(order[counter++],sampler.getPropertyAsString(TestElement.NAME)); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		private TestElement makeSampler(String name) | ||||
| 		{ | ||||
| 		  	TestSampler s= new TestSampler(); | ||||
| 			s.setName(name); | ||||
| 			return s; | ||||
| 		} | ||||
| 		class TestSampler extends AbstractSampler implements PerSampleClonable { | ||||
| 		  public void addCustomTestElement(TestElement t) { } | ||||
| 		  public org.apache.jmeter.samplers.SampleResult sample(org.apache.jmeter.samplers.Entry e) { return null; } | ||||
| 		} | ||||
| 	} | ||||
|     /** | ||||
|      * @see org.apache.jmeter.control.GenericController#getIterCount() | ||||
|      */ | ||||
|  | @ -274,4 +184,66 @@ public class LoopController extends GenericController implements Serializable | |||
|         return loopCount + 1; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|     public static class Test extends junit.framework.TestCase | ||||
|     { | ||||
|         public Test(String name) | ||||
|         { | ||||
|             super(name); | ||||
|         } | ||||
| 
 | ||||
|         public void testProcessing() throws Exception | ||||
|         { | ||||
|             GenericController controller = new GenericController(); | ||||
|             GenericController sub_1 = new GenericController(); | ||||
|             sub_1.addTestElement(new TestSampler("one")); | ||||
|             sub_1.addTestElement(new TestSampler("two")); | ||||
|             controller.addTestElement(sub_1); | ||||
|             controller.addTestElement(new TestSampler("three")); | ||||
|             LoopController sub_2 = new LoopController(); | ||||
|             sub_2.setLoops(3); | ||||
|             GenericController sub_3 = new GenericController(); | ||||
|             sub_2.addTestElement(new TestSampler("four")); | ||||
|             sub_3.addTestElement(new TestSampler("five")); | ||||
|             sub_3.addTestElement(new TestSampler("six")); | ||||
|             sub_2.addTestElement(sub_3); | ||||
|             sub_2.addTestElement(new TestSampler("seven")); | ||||
|             controller.addTestElement(sub_2); | ||||
|             String[] order = | ||||
|                 new String[] { "one", "two", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven" }; | ||||
|             int counter = 15; | ||||
|             controller.initialize(); | ||||
|             for (int i = 0; i < 2; i++) | ||||
|             { | ||||
|                 assertEquals(15, counter); | ||||
|                 counter = 0; | ||||
|                 TestElement sampler = null; | ||||
|                 while ((sampler = controller.next()) != null) | ||||
|                 { | ||||
|                     assertEquals(order[counter++], sampler.getPropertyAsString(TestElement.NAME)); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static void main(String args[]) | ||||
|     { | ||||
|         junit.textui.TestRunner.run(suite()); | ||||
|     } | ||||
| 
 | ||||
|     public static TestSuite suite() | ||||
|     { | ||||
|         TestSuite suite = new TestSuite(); | ||||
|         suite.addTest(new Test("testProcessing")); | ||||
|         return suite; | ||||
|     } | ||||
|     /* (non-Javadoc) | ||||
|      * @see org.apache.jmeter.control.GenericController#reInitialize() | ||||
|      */ | ||||
|     protected void reInitialize() | ||||
|     { | ||||
|         setFirst(true); | ||||
|         resetCurrent(); | ||||
|         incrementLoopCount(); | ||||
|     } | ||||
| 
 | ||||
| }; | ||||
|  | @ -0,0 +1,17 @@ | |||
| /* | ||||
|  * Created on Apr 30, 2003 | ||||
|  * | ||||
|  * To change the template for this generated file go to | ||||
|  * Window>Preferences>Java>Code Generation>Code and Comments | ||||
|  */ | ||||
| package org.apache.jmeter.control; | ||||
| 
 | ||||
| /** | ||||
|  * @author Administrator | ||||
|  * | ||||
|  * To change the template for this generated type comment go to | ||||
|  * Window>Preferences>Java>Code Generation>Code and Comments | ||||
|  */ | ||||
| public class NextIsNullException extends Exception { | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,59 @@ | |||
| /* | ||||
|  * Created on Apr 30, 2003 | ||||
|  * | ||||
|  * To change the template for this generated file go to | ||||
|  * Window>Preferences>Java>Code Generation>Code and Comments | ||||
|  */ | ||||
| package org.apache.jmeter.engine.event; | ||||
| 
 | ||||
| import org.apache.jmeter.testelement.TestElement; | ||||
| 
 | ||||
| /** | ||||
|  * @author Administrator | ||||
|  * | ||||
|  * To change the template for this generated type comment go to | ||||
|  * Window>Preferences>Java>Code Generation>Code and Comments | ||||
|  */ | ||||
| public class IterationDeliverEvent   | ||||
| {   | ||||
| 	TestElement current;   | ||||
| 	TestElement source;   | ||||
|        | ||||
| 	public IterationDeliverEvent(TestElement source,TestElement c)   | ||||
| 	{   | ||||
| 		current = c;   | ||||
| 		this.source = source;   | ||||
| 	}   | ||||
| 	/**   | ||||
| 	 * @return   | ||||
| 	 */   | ||||
| 	public TestElement getCurrent()   | ||||
| 	{   | ||||
| 		return current;   | ||||
| 	}   | ||||
|    | ||||
| 	/**   | ||||
| 	 * @param element   | ||||
| 	 */   | ||||
| 	public void setCurrent(TestElement element)   | ||||
| 	{   | ||||
| 		current = element;   | ||||
| 	}   | ||||
|    | ||||
| 	/**   | ||||
| 	 * @return   | ||||
| 	 */   | ||||
| 	public TestElement getSource()   | ||||
| 	{   | ||||
| 		return source;   | ||||
| 	}   | ||||
|    | ||||
| 	/**   | ||||
| 	 * @param element   | ||||
| 	 */   | ||||
| 	public void setSource(TestElement element)   | ||||
| 	{   | ||||
| 		source = element;   | ||||
| 	}   | ||||
|    | ||||
| } | ||||
|  | @ -1,69 +0,0 @@ | |||
| package org.apache.jmeter.engine.event; | ||||
| 
 | ||||
| import org.apache.jmeter.testelement.TestElement; | ||||
| 
 | ||||
| /** | ||||
|  * An iteration event provides information about the iteration number and the | ||||
|  * source of the event. | ||||
|  */ | ||||
| public class IterationEvent | ||||
| { | ||||
|      | ||||
|     int iteration; | ||||
|     TestElement source; | ||||
|     TestElement current; | ||||
|      | ||||
|     public IterationEvent(TestElement source,TestElement current,int iter) | ||||
|     { | ||||
|         iteration = iter; | ||||
|         this.current = current; | ||||
|         this.source = source; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the iteration. | ||||
|      * @return int | ||||
|      */ | ||||
|     public int getIteration() | ||||
|     { | ||||
|         return iteration; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the source. | ||||
|      * @return TestElement | ||||
|      */ | ||||
|     public TestElement getSource() | ||||
|     { | ||||
|         return source; | ||||
|     } | ||||
|      | ||||
|     public TestElement getCurrent() | ||||
|     { | ||||
|     	return current; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Sets the iteration. | ||||
|      * @param iteration The iteration to set | ||||
|      */ | ||||
|     public void setIteration(int iteration) | ||||
|     { | ||||
|         this.iteration = iteration; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Sets the source. | ||||
|      * @param source The source to set | ||||
|      */ | ||||
|     public void setSource(TestElement source) | ||||
|     { | ||||
|         this.source = source; | ||||
|     } | ||||
|      | ||||
|     public void setCurrent(TestElement current) | ||||
|     { | ||||
|     	this.current = current; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,48 @@ | |||
| package org.apache.jmeter.engine.event; | ||||
| 
 | ||||
| import org.apache.jmeter.testelement.TestElement; | ||||
| 
 | ||||
| /** | ||||
|  * An iteration event provides information about the iteration number and the | ||||
|  * source of the event. | ||||
|  */ | ||||
| public class LoopIterationEvent   | ||||
| {   | ||||
|        | ||||
| 	int iteration;   | ||||
| 	TestElement source;   | ||||
|        | ||||
| 	public LoopIterationEvent(TestElement source,int iter)   | ||||
| 	{   | ||||
| 		iteration = iter;   | ||||
| 		this.source = source;   | ||||
| 	}   | ||||
|    | ||||
| 	/**   | ||||
| 	 * Returns the iteration.   | ||||
| 	 * @return int   | ||||
| 	 */   | ||||
| 	public int getIteration()   | ||||
| 	{   | ||||
| 		return iteration;   | ||||
| 	}   | ||||
|    | ||||
| 	/**   | ||||
| 	 * Returns the source.   | ||||
| 	 * @return TestElement   | ||||
| 	 */   | ||||
| 	public TestElement getSource()   | ||||
| 	{   | ||||
| 		return source;   | ||||
| 	}   | ||||
|    | ||||
| 	/**   | ||||
| 	 * Sets the iteration.   | ||||
| 	 * @param iteration The iteration to set   | ||||
| 	 */   | ||||
| 	public void setIteration(int iteration)   | ||||
| 	{   | ||||
| 		this.iteration = iteration;   | ||||
| 	}   | ||||
|    | ||||
| } | ||||
|  | @ -6,8 +6,8 @@ package org.apache.jmeter.engine.event; | |||
|  * To change this generated comment edit the template variable "typecomment": | ||||
|  * Window>Preferences>Java>Templates. | ||||
|  */ | ||||
| public interface IterationListener | ||||
| public interface LoopIterationListener | ||||
| { | ||||
|     public void iterationStart(IterationEvent iterEvent); | ||||
|     public void iteration(IterationEvent iterEvent); | ||||
|     public void iterationStart(LoopIterationEvent iterEvent); | ||||
|     public void iteration(IterationDeliverEvent iterEvent); | ||||
| } | ||||
|  | @ -87,7 +87,7 @@ import javax.swing.tree.DefaultTreeCellRenderer; | |||
| import javax.swing.tree.TreeCellRenderer; | ||||
| import javax.swing.tree.TreeModel; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.gui.action.ActionRouter; | ||||
| import org.apache.jmeter.gui.action.GlobalMouseListener; | ||||
| import org.apache.jmeter.gui.tree.JMeterCellRenderer; | ||||
|  | @ -443,7 +443,7 @@ public class MainFrame extends JFrame implements TestListener,Remoteable | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#iterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -74,61 +74,61 @@ import org.apache.jmeter.util.JMeterUtils; | |||
| public class ExitCommand implements Command | ||||
| { | ||||
| 
 | ||||
| 	private static Set commands = new HashSet(); | ||||
|     private static Set commands = new HashSet(); | ||||
| 
 | ||||
| 	/** | ||||
| 	 *  Constructor for the ExitCommand object | ||||
| 	 */ | ||||
| 	public ExitCommand() | ||||
| 	{ | ||||
| 	} | ||||
|     /** | ||||
|      *  Constructor for the ExitCommand object | ||||
|      */ | ||||
|     public ExitCommand() | ||||
|     {} | ||||
| 
 | ||||
| 	/** | ||||
| 	 *  Gets the ActionNames attribute of the ExitCommand object | ||||
| 	 * | ||||
| 	 *@return    The ActionNames value | ||||
| 	 */ | ||||
| 	public Set getActionNames() | ||||
| 	{ | ||||
| 		return commands; | ||||
| 	} | ||||
| 	 | ||||
| 	 | ||||
|     /** | ||||
|      *  Gets the ActionNames attribute of the ExitCommand object | ||||
|      * | ||||
|      *@return    The ActionNames value | ||||
|      */ | ||||
|     public Set getActionNames() | ||||
|     { | ||||
|         return commands; | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 *  Description of the Method | ||||
| 	 * | ||||
| 	 *@param  e  Description of Parameter | ||||
| 	 */ | ||||
| 	public void doAction(ActionEvent e) | ||||
| 	{ | ||||
| 		ActionRouter.getInstance().actionPerformed(new ActionEvent( | ||||
| 				e.getSource(),e.getID(),CheckDirty.CHECK_DIRTY)); | ||||
| 		if(GuiPackage.getInstance().isDirty()) | ||||
| 		{ | ||||
|             int chosenOption = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(), | ||||
|             JMeterUtils.getResString("cancel_exit_to_save"), | ||||
|             JMeterUtils.getResString("Save?"), | ||||
|             JOptionPane.YES_NO_CANCEL_OPTION, | ||||
|             JOptionPane.QUESTION_MESSAGE); | ||||
| 			if(chosenOption == JOptionPane.NO_OPTION) | ||||
| 			{ | ||||
| 				System.exit(0); | ||||
| 			} | ||||
|             else if(chosenOption == JOptionPane.YES_OPTION) | ||||
|     /** | ||||
|      *  Description of the Method | ||||
|      * | ||||
|      *@param  e  Description of Parameter | ||||
|      */ | ||||
|     public void doAction(ActionEvent e) | ||||
|     { | ||||
|         ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(), e.getID(), CheckDirty.CHECK_DIRTY)); | ||||
|         if (GuiPackage.getInstance().isDirty()) | ||||
|         { | ||||
|             int chosenOption = | ||||
|                 JOptionPane.showConfirmDialog( | ||||
|                     GuiPackage.getInstance().getMainFrame(), | ||||
|                     JMeterUtils.getResString("cancel_exit_to_save"), | ||||
|                     JMeterUtils.getResString("Save?"), | ||||
|                     JOptionPane.YES_NO_CANCEL_OPTION, | ||||
|                     JOptionPane.QUESTION_MESSAGE); | ||||
|             if (chosenOption == JOptionPane.NO_OPTION) | ||||
|             { | ||||
|                 ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(),e.getID(),Save.SAVE_ALL)); | ||||
|                 System.exit(0); | ||||
|             } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 				System.exit(0); | ||||
| 		} | ||||
| 	} | ||||
|             else if (chosenOption == JOptionPane.YES_OPTION) | ||||
|             { | ||||
|                 ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(), e.getID(), Save.SAVE_ALL)); | ||||
|                 if (!GuiPackage.getInstance().isDirty()) | ||||
|                 { | ||||
|                     System.exit(0); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             System.exit(0); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	static | ||||
| 	{ | ||||
| 		commands.add("exit"); | ||||
| 	} | ||||
|     static { | ||||
|         commands.add("exit"); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -94,8 +94,7 @@ public class SSLManagerCommand implements Command { | |||
|         HashSet commands = new HashSet(); | ||||
|         commands.add("sslManager"); | ||||
|         SSLManagerCommand.commandSet = Collections.unmodifiableSet(commands); | ||||
|         System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); | ||||
|         System.setProperty("javax.net.ssl.debug", "all"); | ||||
|          | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  |  | |||
|  | @ -0,0 +1,32 @@ | |||
| /* | ||||
|  * Created on Apr 30, 2003 | ||||
|  * | ||||
|  * To change the template for this generated file go to | ||||
|  * Window>Preferences>Java>Code Generation>Code and Comments | ||||
|  */ | ||||
| package org.apache.jmeter.junit; | ||||
| 
 | ||||
| import junit.framework.TestCase; | ||||
| 
 | ||||
| import org.apache.jmeter.util.JMeterUtils; | ||||
| import org.apache.jorphan.logging.LoggingManager; | ||||
| import org.apache.log.Logger; | ||||
| 
 | ||||
| /** | ||||
|  * @author ano ano | ||||
|  * | ||||
|  * To change the template for this generated type comment go to | ||||
|  * Window>Preferences>Java>Code Generation>Code and Comments | ||||
|  */ | ||||
| public abstract class JMeterTestCase extends TestCase | ||||
| { | ||||
|      | ||||
|     public JMeterTestCase(String name) | ||||
|     { | ||||
|         super(name); | ||||
|     } | ||||
|      | ||||
|     protected static Logger testLog =  | ||||
| LoggingManager.getLoggerFor(JMeterUtils.TEST); | ||||
| } | ||||
| 
 | ||||
|  | @ -0,0 +1,46 @@ | |||
| /* | ||||
|  * Created on Apr 30, 2003 | ||||
|  * | ||||
|  * To change the template for this generated file go to | ||||
|  * Window>Preferences>Java>Code Generation>Code and Comments | ||||
|  */ | ||||
| package org.apache.jmeter.junit.stubs; | ||||
| 
 | ||||
| import org.apache.jmeter.samplers.AbstractSampler; | ||||
| import org.apache.jmeter.samplers.Entry; | ||||
| import org.apache.jmeter.samplers.SampleResult; | ||||
| 
 | ||||
| /** | ||||
|  * @author ano ano | ||||
|  * | ||||
|  * To change the template for this generated type comment go to | ||||
|  * Window>Preferences>Java>Code Generation>Code and Comments | ||||
|  */ | ||||
| public class TestSampler extends AbstractSampler | ||||
| { | ||||
| 
 | ||||
|     /* (non-Javadoc) | ||||
|      * @see  | ||||
| org.apache.jmeter.samplers.Sampler#sample(org.apache.jmeter.samplers.Entry) | ||||
|      */ | ||||
|     public SampleResult sample(Entry e) | ||||
|     { | ||||
|         // TODO Auto-generated method stub | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     public TestSampler(String name) | ||||
|     { | ||||
|         setName(name); | ||||
|     } | ||||
| 
 | ||||
|     public TestSampler() | ||||
|     {} | ||||
|      | ||||
|     public String toString() | ||||
|     { | ||||
|         return getName(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
|  | @ -73,7 +73,7 @@ import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.configuration.ConfigurationException; | ||||
| import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; | ||||
| import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.engine.util.NoThreadClone; | ||||
| import org.apache.jmeter.samplers.Clearable; | ||||
| import org.apache.jmeter.samplers.Remoteable; | ||||
|  | @ -473,7 +473,7 @@ public class ResultCollector extends AbstractListenerElement | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#iterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -3,7 +3,8 @@ package org.apache.jmeter.samplers; | |||
| import java.io.Serializable; | ||||
| import java.rmi.RemoteException; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.engine.util.NoThreadClone; | ||||
| import org.apache.jmeter.testelement.AbstractTestElement; | ||||
| import org.apache.jmeter.testelement.TestListener; | ||||
| import org.apache.log.Hierarchy; | ||||
|  | @ -19,7 +20,7 @@ import org.apache.log.Logger; | |||
|  */ | ||||
| 
 | ||||
| public class RemoteListenerWrapper extends AbstractTestElement implements | ||||
| 		SampleListener,TestListener,Serializable | ||||
| 		SampleListener,TestListener,Serializable,NoThreadClone | ||||
| { | ||||
| 	transient private static Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor( | ||||
| 			"jmeter.elements"); | ||||
|  | @ -116,7 +117,7 @@ public class RemoteListenerWrapper extends AbstractTestElement implements | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#iterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
| } | ||||
|  | @ -55,7 +55,7 @@ | |||
| 
 | ||||
| import java.rmi.RemoteException; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.testelement.TestListener; | ||||
| 
 | ||||
| /************************************************************ | ||||
|  | @ -174,7 +174,7 @@ public class RemoteSampleListenerImpl | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#iterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ package org.apache.jmeter.samplers; | |||
| import java.io.Serializable; | ||||
| import java.rmi.RemoteException; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.util.NoThreadClone; | ||||
| import org.apache.jmeter.testelement.AbstractTestElement; | ||||
| import org.apache.log.Hierarchy; | ||||
| import org.apache.log.Logger; | ||||
|  | @ -17,7 +18,7 @@ import org.apache.log.Logger; | |||
|  */ | ||||
| 
 | ||||
| public class RemoteSampleListenerWrapper extends AbstractTestElement implements | ||||
| 		SampleListener,Serializable | ||||
| 		SampleListener,Serializable,NoThreadClone | ||||
| { | ||||
| 	transient private static Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor( | ||||
| 			"jmeter.elements"); | ||||
|  |  | |||
|  | @ -2,7 +2,8 @@ package org.apache.jmeter.samplers; | |||
| 
 | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.engine.util.NoThreadClone; | ||||
| import org.apache.jmeter.testelement.AbstractTestElement; | ||||
| import org.apache.jmeter.testelement.TestListener; | ||||
| import org.apache.log.Hierarchy; | ||||
|  | @ -18,7 +19,7 @@ import org.apache.log.Logger; | |||
|  */ | ||||
| 
 | ||||
| public class RemoteTestListenerWrapper extends AbstractTestElement implements | ||||
| 		TestListener,Serializable | ||||
| 		TestListener,Serializable,NoThreadClone | ||||
| { | ||||
| 	transient private static Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor( | ||||
| 			"jmeter.elements"); | ||||
|  | @ -80,7 +81,7 @@ public class RemoteTestListenerWrapper extends AbstractTestElement implements | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#iterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
| } | ||||
|  | @ -1,6 +1,6 @@ | |||
| package org.apache.jmeter.testelement; | ||||
| 
 | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| 
 | ||||
| /** | ||||
|  * <p>Title: </p> | ||||
|  | @ -27,5 +27,5 @@ public interface TestListener | |||
|      * fired. | ||||
|      * @param event | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event); | ||||
|     public void testIterationStart(LoopIterationEvent event); | ||||
| } | ||||
|  | @ -63,7 +63,7 @@ import java.util.Map; | |||
| import org.apache.jmeter.assertions.Assertion; | ||||
| import org.apache.jmeter.assertions.AssertionResult; | ||||
| import org.apache.jmeter.control.Controller; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.processor.PostProcessor; | ||||
| import org.apache.jmeter.samplers.SampleEvent; | ||||
| import org.apache.jmeter.samplers.SampleResult; | ||||
|  | @ -143,17 +143,19 @@ public class JMeterThread implements Runnable, java.io.Serializable | |||
|             Sampler entry = null; | ||||
|             rampUpDelay(); | ||||
|             log.info("Thread " + Thread.currentThread().getName() + " started"); | ||||
|             controller.initialize(); | ||||
|             int i=0; | ||||
|             while (running) | ||||
|             { | ||||
|                 while (controller.hasNext() && running) | ||||
|             	Sampler sam; | ||||
|                 while (running && (sam=controller.next())!=null) | ||||
|                 { | ||||
|                     try | ||||
|                     { | ||||
|                         if (controller.isNextFirst()) | ||||
|                         if (i==0) | ||||
|                         { | ||||
|                             notifyTestListeners(); | ||||
|                         } | ||||
|                         Sampler sam = controller.next(); | ||||
|                         threadContext.setCurrentSampler(sam); | ||||
|                         SamplePackage pack = compiler.configureSampler(sam); | ||||
|                         delay(pack.getTimers()); | ||||
|  | @ -165,6 +167,7 @@ public class JMeterThread implements Runnable, java.io.Serializable | |||
|                         runPostProcessors(pack.getPostProcessors()); | ||||
|                         notifyListeners(pack.getSampleListeners(), result); | ||||
|                         compiler.done(pack); | ||||
|                         i++; | ||||
|                     } | ||||
|                     catch (Exception e) | ||||
|                     { | ||||
|  | @ -175,6 +178,11 @@ public class JMeterThread implements Runnable, java.io.Serializable | |||
|                 { | ||||
|                     running = false; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                 	i=0; | ||||
|                 	controller.initialize(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         finally | ||||
|  | @ -248,12 +256,12 @@ public class JMeterThread implements Runnable, java.io.Serializable | |||
|             TestListener listener = (TestListener)iter.next(); | ||||
|             if(listener instanceof TestElement) | ||||
|             { | ||||
|                 listener.testIterationStart(new IterationEvent(controller,null,threadVars.getIteration())); | ||||
|                 listener.testIterationStart(new LoopIterationEvent(controller,threadVars.getIteration())); | ||||
|                 ((TestElement)listener).recoverRunningVersion(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 listener.testIterationStart(new IterationEvent(controller,null,threadVars.getIteration())); | ||||
|                 listener.testIterationStart(new LoopIterationEvent(controller,threadVars.getIteration())); | ||||
|             } | ||||
|              | ||||
|         } | ||||
|  |  | |||
|  | @ -14,7 +14,7 @@ import org.apache.jmeter.config.Modifier; | |||
| import org.apache.jmeter.config.ResponseBasedModifier; | ||||
| import org.apache.jmeter.control.Controller; | ||||
| import org.apache.jmeter.control.GenericController; | ||||
| import org.apache.jmeter.engine.event.IterationListener; | ||||
| import org.apache.jmeter.engine.event.LoopIterationListener; | ||||
| import org.apache.jmeter.processor.PostProcessor; | ||||
| import org.apache.jmeter.processor.PreProcessor; | ||||
| import org.apache.jmeter.samplers.AbstractSampler; | ||||
|  | @ -324,9 +324,9 @@ public class TestCompiler implements HashTreeTraverser, SampleListener | |||
|             { | ||||
|                 parent.addTestElement(child); | ||||
|             } | ||||
|             if(parent instanceof Controller && child instanceof IterationListener) | ||||
|             if(parent instanceof Controller && child instanceof LoopIterationListener) | ||||
|             { | ||||
|                 ((Controller)parent).addIterationListener((IterationListener)child); | ||||
|                 ((Controller)parent).addIterationListener((LoopIterationListener)child); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -63,7 +63,7 @@ import java.util.List; | |||
| 
 | ||||
| import org.apache.jmeter.control.Controller; | ||||
| import org.apache.jmeter.control.LoopController; | ||||
| import org.apache.jmeter.engine.event.IterationListener; | ||||
| import org.apache.jmeter.engine.event.LoopIterationListener; | ||||
| import org.apache.jmeter.samplers.RemoteSampleListener; | ||||
| import org.apache.jmeter.samplers.SampleEvent; | ||||
| import org.apache.jmeter.samplers.SampleListener; | ||||
|  | @ -122,20 +122,10 @@ public class ThreadGroup | |||
|         return getSamplerController().isDone(); | ||||
|     } | ||||
| 
 | ||||
|     public boolean hasNext() | ||||
|     { | ||||
|         return getSamplerController().hasNext(); | ||||
|     } | ||||
| 
 | ||||
|     public Sampler next() | ||||
|     { | ||||
|         return getSamplerController().next(); | ||||
|     } | ||||
|      | ||||
|     public int samplersReturned() | ||||
|     { | ||||
|     	return getSamplerController().samplersReturned(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Set the ramp-up value. | ||||
|  | @ -147,11 +137,6 @@ public class ThreadGroup | |||
|         setProperty(new IntegerProperty(RAMP_TIME,rampUp)); | ||||
|     } | ||||
| 
 | ||||
|     public boolean isNextFirst() | ||||
|     { | ||||
|         return getSamplerController().isNextFirst(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get the ramp-up value. | ||||
|      * | ||||
|  | @ -363,9 +348,17 @@ public class ThreadGroup | |||
|     /** | ||||
|      * @see org.apache.jmeter.control.Controller#addIterationListener(org.apache.jmeter.engine.event.IterationListener) | ||||
|      */ | ||||
|     public void addIterationListener(IterationListener lis) | ||||
|     public void addIterationListener(LoopIterationListener lis) | ||||
|     { | ||||
|         getSamplerController().addIterationListener(lis); | ||||
|     } | ||||
| 
 | ||||
|     /* (non-Javadoc) | ||||
|      * @see org.apache.jmeter.control.Controller#initialize() | ||||
|      */ | ||||
|     public void initialize() | ||||
|     { | ||||
|         getSamplerController().initialize(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ package org.apache.jmeter.protocol.http.modifier; | |||
| import java.io.Serializable; | ||||
| 
 | ||||
| import org.apache.jmeter.config.Argument; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.processor.PreProcessor; | ||||
| import org.apache.jmeter.protocol.http.sampler.HTTPSampler; | ||||
| import org.apache.jmeter.samplers.Sampler; | ||||
|  | @ -154,7 +154,7 @@ public class ParamModifier extends AbstractTestElement implements TestListener,P | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#iterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -60,7 +60,7 @@ import java.util.Map; | |||
| 
 | ||||
| import org.apache.jmeter.config.Argument; | ||||
| import org.apache.jmeter.config.ConfigTestElement; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.processor.PreProcessor; | ||||
| import org.apache.jmeter.protocol.http.sampler.HTTPSampler; | ||||
| import org.apache.jmeter.samplers.Sampler; | ||||
|  | @ -195,7 +195,7 @@ public class UserParameterModifier | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#testIterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
| } | ||||
|  | @ -82,6 +82,7 @@ import org.apache.jmeter.testelement.property.JMeterProperty; | |||
| import org.apache.jmeter.testelement.property.PropertyIterator; | ||||
| import org.apache.jmeter.testelement.property.StringProperty; | ||||
| import org.apache.jmeter.testelement.property.TestElementProperty; | ||||
| import org.apache.jmeter.util.JMeterUtils; | ||||
| import org.apache.jmeter.util.SSLManager; | ||||
| import org.apache.jorphan.util.JOrphanUtils; | ||||
| import org.apache.log.Hierarchy; | ||||
|  | @ -137,6 +138,12 @@ public class HTTPSampler extends AbstractSampler implements PerSampleClonable | |||
|     private static final PostWriter postWriter = new PostWriter(); | ||||
|     transient protected HttpURLConnection conn; | ||||
|     private HTTPSamplerFull imageSampler; | ||||
|      | ||||
|     static | ||||
|     { | ||||
|         System.setProperty("java.protocol.handler.pkgs", JMeterUtils.getPropDefault("ssl.pkgs","com.sun.net.ssl.internal.www.protocol")); | ||||
|                 System.setProperty("javax.net.ssl.debug", "all"); | ||||
|     } | ||||
| 
 | ||||
|     private static PatternCacheLRU patternCache = new PatternCacheLRU(1000, new Perl5Compiler()); | ||||
| 
 | ||||
|  |  | |||
|  | @ -60,7 +60,7 @@ import java.util.Iterator; | |||
| import java.util.Set; | ||||
| 
 | ||||
| import org.apache.jmeter.config.Arguments; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.protocol.java.config.JavaConfig; | ||||
| import org.apache.jmeter.samplers.AbstractSampler; | ||||
| import org.apache.jmeter.samplers.Entry; | ||||
|  | @ -313,7 +313,7 @@ public class JavaSampler extends AbstractSampler | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#testIterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
|     class ErrorSamplerClient extends AbstractJavaSamplerClient { | ||||
|  |  | |||
|  | @ -62,7 +62,7 @@ import java.util.HashMap; | |||
| import java.util.Map; | ||||
| 
 | ||||
| import org.apache.jmeter.config.ConfigTestElement; | ||||
| import org.apache.jmeter.engine.event.IterationEvent; | ||||
| import org.apache.jmeter.engine.event.LoopIterationEvent; | ||||
| import org.apache.jmeter.protocol.jdbc.util.DBConnectionManager; | ||||
| import org.apache.jmeter.protocol.jdbc.util.DBKey; | ||||
| import org.apache.jmeter.samplers.AbstractSampler; | ||||
|  | @ -310,7 +310,7 @@ public class JDBCSampler extends AbstractSampler | |||
|     /** | ||||
|      * @see org.apache.jmeter.testelement.TestListener#testIterationStart(org.apache.jmeter.engine.event.IterationEvent) | ||||
|      */ | ||||
|     public void testIterationStart(IterationEvent event) | ||||
|     public void testIterationStart(LoopIterationEvent event) | ||||
|     {} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue