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,107 +75,29 @@ 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 DEFAULT_STYLE = 0;
|
||||
public static final int NEW_STYLE = 1;
|
||||
private boolean interleave;
|
||||
public static final int IGNORE_SUB_CONTROLLERS = 0;
|
||||
public static final int USE_SUB_CONTROLLERS = 1;
|
||||
private boolean skipNext;
|
||||
private boolean doNotIncrement = false;
|
||||
private Controller searchStart = null;
|
||||
private TestElement searchStart = null;
|
||||
private boolean currentReturnedAtLeastOne;
|
||||
|
||||
/****************************************
|
||||
* Constructor for the InterleaveControl object
|
||||
***************************************/
|
||||
public InterleaveControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
super.initialize();
|
||||
interleave = false;
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* @see org.apache.jmeter.control.GenericController#reInitialize()
|
||||
*/
|
||||
public void reInitialize()
|
||||
{
|
||||
super.initialize();
|
||||
interleave = false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
currentReturnedAtLeastOne = false;
|
||||
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();
|
||||
}
|
||||
|
||||
protected void incrementCurrent()
|
||||
{
|
||||
setInterleave(NEW_STYLE);
|
||||
super.incrementCurrent();
|
||||
}
|
||||
|
||||
protected void setInterleave(int style)
|
||||
{
|
||||
if(getStyle() == style)
|
||||
{
|
||||
interleave = true;
|
||||
}
|
||||
skipNext = false;
|
||||
incrementIterCount();
|
||||
}
|
||||
|
||||
public void setStyle(int style)
|
||||
|
|
@ -185,47 +110,123 @@ public class InterleaveControl extends GenericController implements Serializable
|
|||
return getPropertyAsInt(STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.jmeter.control.Controller#next()
|
||||
*/
|
||||
public Sampler next()
|
||||
{
|
||||
setInterleave(DEFAULT_STYLE);
|
||||
TestElement controller = getCurrentController();
|
||||
fireIterEvents(controller);
|
||||
if(controller == null)
|
||||
if(isSkipNext())
|
||||
{
|
||||
nextAtEnd();
|
||||
return next();
|
||||
reInitialize();
|
||||
return null;
|
||||
}
|
||||
if(controller instanceof Sampler)
|
||||
{
|
||||
incrementCurrent();
|
||||
return (Sampler)controller;
|
||||
return super.next();
|
||||
}
|
||||
else
|
||||
|
||||
/**
|
||||
* @see org.apache.jmeter.control.GenericController#nextIsAController(org.apache.jmeter.testelement.TestElement)
|
||||
*/
|
||||
protected Sampler nextIsAController(Controller controller) throws NextIsNullException
|
||||
{
|
||||
Controller c = (Controller)controller;
|
||||
if(c.hasNext())
|
||||
Sampler sampler = controller.next();
|
||||
if (sampler == null)
|
||||
{
|
||||
Sampler s = c.next();
|
||||
if(getStyle() == DEFAULT_STYLE)
|
||||
{
|
||||
incrementCurrent();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
else if(c.isDone())
|
||||
{
|
||||
removeCurrentController();
|
||||
currentReturnedNull(controller);
|
||||
return next();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentReturnedAtLeastOne = true;
|
||||
if (getStyle() == IGNORE_SUB_CONTROLLERS)
|
||||
{
|
||||
incrementCurrent();
|
||||
return next();
|
||||
skipNext = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
searchStart = null;
|
||||
}
|
||||
return sampler;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Test extends junit.framework.TestCase
|
||||
/**
|
||||
* @see org.apache.jmeter.control.GenericController#nextIsASampler(org.apache.jmeter.testelement.TestElement)
|
||||
*/
|
||||
protected Sampler nextIsASampler(Sampler element) throws NextIsNullException
|
||||
{
|
||||
skipNext = true;
|
||||
incrementCurrent();
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return skipNext
|
||||
*/
|
||||
protected boolean isSkipNext()
|
||||
{
|
||||
return skipNext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param skipNext
|
||||
*/
|
||||
protected void setSkipNext(boolean skipNext)
|
||||
{
|
||||
this.skipNext = skipNext;
|
||||
}
|
||||
|
||||
public static class Test extends JMeterTestCase
|
||||
{
|
||||
public Test(String name)
|
||||
{
|
||||
|
|
@ -234,33 +235,34 @@ public class InterleaveControl extends GenericController implements Serializable
|
|||
|
||||
public void testProcessing() throws Exception
|
||||
{
|
||||
testLog.debug("Testing Interleave Controller 1");
|
||||
GenericController controller = new GenericController();
|
||||
InterleaveControl sub_1 = new InterleaveControl();
|
||||
sub_1.setStyle(DEFAULT_STYLE);
|
||||
sub_1.addTestElement(makeSampler("one"));
|
||||
sub_1.addTestElement(makeSampler("two"));
|
||||
sub_1.setStyle(IGNORE_SUB_CONTROLLERS);
|
||||
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[]{"dummy","three","four","five","six","seven",
|
||||
"four","five","six","seven","four","five","six","seven"};
|
||||
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;
|
||||
while(controller.hasNext())
|
||||
TestElement sampler = null;
|
||||
while ((sampler = controller.next()) != null)
|
||||
{
|
||||
TestElement sampler = controller.next();
|
||||
if (counter == 0)
|
||||
{
|
||||
assertEquals(interleaveOrder[i % 2], sampler.getPropertyAsString(TestElement.NAME));
|
||||
|
|
@ -276,33 +278,54 @@ public class InterleaveControl extends GenericController implements Serializable
|
|||
|
||||
public void testProcessing2() throws Exception
|
||||
{
|
||||
testLog.debug("Testing Interleave Controller 2");
|
||||
GenericController controller = new GenericController();
|
||||
InterleaveControl sub_1 = new InterleaveControl();
|
||||
sub_1.setStyle(DEFAULT_STYLE);
|
||||
sub_1.addTestElement(makeSampler("one"));
|
||||
sub_1.addTestElement(makeSampler("two"));
|
||||
sub_1.setStyle(IGNORE_SUB_CONTROLLERS);
|
||||
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"));
|
||||
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"};
|
||||
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)
|
||||
{
|
||||
while(controller.hasNext())
|
||||
TestElement sampler = null;
|
||||
while ((sampler = controller.next()) != null)
|
||||
{
|
||||
TestElement sampler = controller.next();
|
||||
assertEquals("failed on "+counter,
|
||||
order[counter],sampler.getPropertyAsString(TestElement.NAME));
|
||||
assertEquals("failed on " + counter, order[counter], sampler.getPropertyAsString(TestElement.NAME));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
|
@ -310,31 +333,54 @@ public class InterleaveControl extends GenericController implements Serializable
|
|||
|
||||
public void testProcessing3() throws Exception
|
||||
{
|
||||
testLog.debug("Testing Interleave Controller 3");
|
||||
GenericController controller = new GenericController();
|
||||
InterleaveControl sub_1 = new InterleaveControl();
|
||||
sub_1.setStyle(NEW_STYLE);
|
||||
sub_1.addTestElement(makeSampler("one"));
|
||||
sub_1.addTestElement(makeSampler("two"));
|
||||
sub_1.setStyle(USE_SUB_CONTROLLERS);
|
||||
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"));
|
||||
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"};
|
||||
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)
|
||||
{
|
||||
while(controller.hasNext())
|
||||
TestElement sampler = null;
|
||||
while ((sampler = controller.next()) != null)
|
||||
{
|
||||
TestElement sampler = controller.next();
|
||||
assertEquals("failed on" + counter, order[counter], sampler.getPropertyAsString(TestElement.NAME));
|
||||
counter++;
|
||||
}
|
||||
|
|
@ -343,25 +389,28 @@ public class InterleaveControl extends GenericController implements Serializable
|
|||
|
||||
public void testProcessing4() throws Exception
|
||||
{
|
||||
testLog.debug("Testing Interleave Controller 4");
|
||||
GenericController controller = new GenericController();
|
||||
InterleaveControl sub_1 = new InterleaveControl();
|
||||
sub_1.setStyle(DEFAULT_STYLE);
|
||||
sub_1.setStyle(IGNORE_SUB_CONTROLLERS);
|
||||
controller.addTestElement(sub_1);
|
||||
GenericController sub_2 = new GenericController();
|
||||
sub_2.addTestElement(makeSampler("one"));
|
||||
sub_2.addTestElement(makeSampler("two"));
|
||||
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(makeSampler("three"));
|
||||
sub_3.addTestElement(makeSampler("four"));
|
||||
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)
|
||||
{
|
||||
while(controller.hasNext())
|
||||
TestElement sampler = null;
|
||||
while ((sampler = controller.next()) != null)
|
||||
{
|
||||
TestElement sampler = controller.next();
|
||||
assertEquals("failed on" + counter, order[counter], sampler.getPropertyAsString(TestElement.NAME));
|
||||
counter++;
|
||||
}
|
||||
|
|
@ -370,45 +419,50 @@ public class InterleaveControl extends GenericController implements Serializable
|
|||
|
||||
public void testProcessing5() throws Exception
|
||||
{
|
||||
testLog.debug("Testing Interleave Controller 5");
|
||||
GenericController controller = new GenericController();
|
||||
InterleaveControl sub_1 = new InterleaveControl();
|
||||
sub_1.setStyle(NEW_STYLE);
|
||||
sub_1.setStyle(USE_SUB_CONTROLLERS);
|
||||
controller.addTestElement(sub_1);
|
||||
GenericController sub_2 = new GenericController();
|
||||
sub_2.addTestElement(makeSampler("one"));
|
||||
sub_2.addTestElement(makeSampler("two"));
|
||||
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(makeSampler("three"));
|
||||
sub_3.addTestElement(makeSampler("four"));
|
||||
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)
|
||||
{
|
||||
while(controller.hasNext())
|
||||
TestElement sampler = null;
|
||||
while ((sampler = controller.next()) != null)
|
||||
{
|
||||
TestElement sampler = controller.next();
|
||||
assertEquals("failed on" + counter, order[counter], sampler.getPropertyAsString(TestElement.NAME));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TestElement makeSampler(String name)
|
||||
public static void main(String args[])
|
||||
{
|
||||
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; }
|
||||
}
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
junit.textui.TestRunner.run(new Test("testProcessing"));
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,42 +52,54 @@
|
|||
* 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() {}
|
||||
|
||||
/**
|
||||
* @see org.apache.jmeter.engine.event.LoopIterationListener#iterationStart(org.apache.jmeter.engine.event.LoopIterationEvent)
|
||||
*/
|
||||
public void iterationStart(LoopIterationEvent event)
|
||||
{
|
||||
if (event.getIteration() == 1)
|
||||
{
|
||||
reInitialize();
|
||||
}
|
||||
}
|
||||
|
||||
public void reInitialize()
|
||||
protected Sampler nextIsNull() throws NextIsNullException
|
||||
{
|
||||
//don't do anything
|
||||
}
|
||||
|
||||
protected boolean hasNextAtEnd()
|
||||
{
|
||||
this.setShortCircuit(true);
|
||||
return false;
|
||||
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));
|
||||
|
|
@ -142,16 +155,73 @@ public class OnceOnlyController extends GenericController implements Serializabl
|
|||
}
|
||||
}
|
||||
|
||||
private TestElement makeSampler(String name)
|
||||
public void testProcessing2() throws Exception
|
||||
{
|
||||
TestSampler s= new TestSampler();
|
||||
s.setName(name);
|
||||
return s;
|
||||
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;
|
||||
}
|
||||
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; }
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,27 +58,20 @@
|
|||
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,345 +52,300 @@
|
|||
* 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
|
||||
*@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;
|
||||
|
||||
/****************************************
|
||||
* !ToDo (Constructor description)
|
||||
***************************************/
|
||||
protected int current;
|
||||
private int iterCount;
|
||||
private boolean done, first;
|
||||
|
||||
/**
|
||||
* Creates a Generic Controller
|
||||
*/
|
||||
public GenericController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void addIterationListener(IterationListener 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);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
first = true;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reInitialize()
|
||||
protected void reInitialize()
|
||||
{
|
||||
resetCurrent();
|
||||
incrementIterCount();
|
||||
setFirst(true);
|
||||
}
|
||||
|
||||
protected void removeCurrentController()
|
||||
/**
|
||||
* @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 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()
|
||||
protected void resetCurrent()
|
||||
{
|
||||
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;
|
||||
current = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.jmeter.control.Controller#samplersReturned()
|
||||
* @see org.apache.jmeter.testelement.TestElement#addTestElement(org.apache.jmeter.testelement.TestElement)
|
||||
*/
|
||||
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);
|
||||
addElement(child);
|
||||
}
|
||||
}
|
||||
|
||||
private void addController(TestElement child)
|
||||
public void addIterationListener(LoopIterationListener lis)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
iterationListeners.add(lis);
|
||||
}
|
||||
|
||||
protected void fireIterEvents(TestElement current)
|
||||
{
|
||||
if(isNextFirst())
|
||||
if (isFirst())
|
||||
{
|
||||
fireIterationStart(current);
|
||||
fireIterationStart();
|
||||
first = false;
|
||||
}
|
||||
if (current instanceof GenericController && ((GenericController)current).isNextFirst())
|
||||
if (current instanceof GenericController && ((GenericController) current).isFirst())
|
||||
{
|
||||
fireIteration(current);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fireIterationStart()
|
||||
{
|
||||
Iterator iter = iterationListeners.iterator();
|
||||
LoopIterationEvent event = new LoopIterationEvent(this, getIterCount());
|
||||
while (iter.hasNext())
|
||||
{
|
||||
LoopIterationListener item = (LoopIterationListener) iter.next();
|
||||
item.iterationStart(event);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fireIteration(TestElement current)
|
||||
{
|
||||
Iterator iter = iterationListeners.iterator();
|
||||
IterationDeliverEvent event = new IterationDeliverEvent(this, current);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
LoopIterationListener item = (LoopIterationListener) iter.next();
|
||||
item.iteration(event);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getIterCount()
|
||||
{
|
||||
return 1;
|
||||
return iterCount;
|
||||
}
|
||||
|
||||
protected void fireIterationStart(TestElement current)
|
||||
protected void incrementIterCount()
|
||||
{
|
||||
Iterator iter = iterationListeners.iterator();
|
||||
while (iter.hasNext())
|
||||
iterCount++;
|
||||
}
|
||||
|
||||
protected void resetIterCount()
|
||||
{
|
||||
IterationListener item = (IterationListener)iter.next();
|
||||
item.iterationStart(new IterationEvent(this,current,getIterCount()));
|
||||
}
|
||||
iterCount = 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
resetSamplersReturned();
|
||||
}
|
||||
|
||||
public void iteration(IterationEvent event) {}
|
||||
|
||||
public static class Test extends junit.framework.TestCase
|
||||
public static class Test extends JMeterTestCase
|
||||
{
|
||||
public Test(String name)
|
||||
{
|
||||
|
|
@ -399,43 +354,46 @@ public class GenericController extends AbstractTestElement implements Controller
|
|||
|
||||
public void testProcessing() throws Exception
|
||||
{
|
||||
testLog.debug("Testing Generic Controller");
|
||||
GenericController controller = new GenericController();
|
||||
GenericController sub_1 = new GenericController();
|
||||
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"));
|
||||
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(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[] 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;
|
||||
while(controller.hasNext())
|
||||
TestElement sampler = null;
|
||||
while ((sampler = controller.next()) != null)
|
||||
{
|
||||
TestElement sampler = controller.next();
|
||||
assertEquals(order[counter++], sampler.getPropertyAsString(TestElement.NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TestElement makeSampler(String name)
|
||||
public static void main(String args[])
|
||||
{
|
||||
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; }
|
||||
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,23 +82,16 @@ 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);
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* !ToDo (Method description)
|
||||
*
|
||||
*@param loops !ToDo (Parameter description)
|
||||
***************************************/
|
||||
public void setLoops(int loops)
|
||||
{
|
||||
setProperty(new IntegerProperty(LOOPS, loops));
|
||||
|
|
@ -103,11 +102,6 @@ public class LoopController extends GenericController implements Serializable
|
|||
setProperty(new StringProperty(LOOPS, loopValue));
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* !ToDoo (Method description)
|
||||
*
|
||||
*@return !ToDo (Return description)
|
||||
***************************************/
|
||||
public int getLoops()
|
||||
{
|
||||
return getPropertyAsInt(LOOPS);
|
||||
|
|
@ -118,83 +112,21 @@ public class LoopController extends GenericController implements Serializable
|
|||
return getPropertyAsString(LOOPS);
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* !ToDo (Method description)
|
||||
*
|
||||
*@param forever !ToDo (Parameter description)
|
||||
***************************************/
|
||||
public void setContinueForever(boolean forever)
|
||||
{
|
||||
setProperty(new BooleanProperty(CONTINUE_FOREVER, forever));
|
||||
}
|
||||
|
||||
|
||||
/****************************************
|
||||
* !ToDoo (Method description)
|
||||
*
|
||||
*@return !ToDo (Return description)
|
||||
***************************************/
|
||||
public boolean getContinueForever()
|
||||
{
|
||||
return getPropertyAsBoolean(CONTINUE_FOREVER);
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
/**
|
||||
* @see org.apache.jmeter.control.Controller#isDone()
|
||||
*/
|
||||
public boolean isDone()
|
||||
{
|
||||
super.initialize();
|
||||
resetLoopCount();
|
||||
}
|
||||
|
||||
public void reInitialize()
|
||||
{
|
||||
super.reInitialize();
|
||||
resetLoopCount();
|
||||
}
|
||||
|
||||
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 boolean hasNextAtEnd()
|
||||
{
|
||||
incrementLoopCount();
|
||||
if(endOfLoop())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetCurrent();
|
||||
return hasNext();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
if (getLoops() != 0)
|
||||
{
|
||||
return super.isDone();
|
||||
|
|
@ -205,15 +137,51 @@ public class LoopController extends GenericController implements Serializable
|
|||
}
|
||||
}
|
||||
|
||||
protected void nextAtEnd()
|
||||
{
|
||||
resetCurrent();
|
||||
incrementLoopCount();
|
||||
}
|
||||
|
||||
private boolean endOfLoop()
|
||||
{
|
||||
return (!getContinueForever() || getLoops() > -1) && loopCount >= getLoops();
|
||||
return (getLoops() > -1) && loopCount >= getLoops();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 resetLoopCount()
|
||||
{
|
||||
loopCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.jmeter.control.GenericController#getIterCount()
|
||||
*/
|
||||
protected int getIterCount()
|
||||
{
|
||||
return loopCount + 1;
|
||||
}
|
||||
|
||||
public static class Test extends junit.framework.TestCase
|
||||
|
|
@ -227,51 +195,55 @@ public class LoopController extends GenericController implements Serializable
|
|||
{
|
||||
GenericController controller = new GenericController();
|
||||
GenericController sub_1 = new GenericController();
|
||||
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[] order = new String[]{"one","two","three","four","five","six","seven",
|
||||
"four","five","six","seven","four","five","six","seven"};
|
||||
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;
|
||||
while(controller.hasNext())
|
||||
TestElement sampler = null;
|
||||
while ((sampler = controller.next()) != null)
|
||||
{
|
||||
TestElement sampler = controller.next();
|
||||
assertEquals(order[counter++], sampler.getPropertyAsString(TestElement.NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TestElement makeSampler(String name)
|
||||
public static void main(String args[])
|
||||
{
|
||||
TestSampler s= new TestSampler();
|
||||
s.setName(name);
|
||||
return s;
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
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 TestSuite suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTest(new Test("testProcessing"));
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see org.apache.jmeter.control.GenericController#getIterCount()
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.jmeter.control.GenericController#reInitialize()
|
||||
*/
|
||||
protected int getIterCount()
|
||||
protected void reInitialize()
|
||||
{
|
||||
return loopCount + 1;
|
||||
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)
|
||||
{}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ public class ExitCommand implements Command
|
|||
* Constructor for the ExitCommand object
|
||||
*/
|
||||
public ExitCommand()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* Gets the ActionNames attribute of the ExitCommand object
|
||||
|
|
@ -93,8 +92,6 @@ public class ExitCommand implements Command
|
|||
return commands;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*
|
||||
|
|
@ -102,11 +99,12 @@ public class ExitCommand implements Command
|
|||
*/
|
||||
public void doAction(ActionEvent e)
|
||||
{
|
||||
ActionRouter.getInstance().actionPerformed(new ActionEvent(
|
||||
e.getSource(),e.getID(),CheckDirty.CHECK_DIRTY));
|
||||
ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(), e.getID(), CheckDirty.CHECK_DIRTY));
|
||||
if (GuiPackage.getInstance().isDirty())
|
||||
{
|
||||
int chosenOption = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(),
|
||||
int chosenOption =
|
||||
JOptionPane.showConfirmDialog(
|
||||
GuiPackage.getInstance().getMainFrame(),
|
||||
JMeterUtils.getResString("cancel_exit_to_save"),
|
||||
JMeterUtils.getResString("Save?"),
|
||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||
|
|
@ -118,17 +116,19 @@ public class ExitCommand implements Command
|
|||
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
|
||||
{
|
||||
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,21 +122,11 @@ 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;
|
||||
|
|
@ -138,6 +139,12 @@ public class HTTPSampler extends AbstractSampler implements PerSampleClonable
|
|||
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());
|
||||
|
||||
private static ThreadLocal localMatcher = new ThreadLocal()
|
||||
|
|
|
|||
|
|
@ -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