本文整理汇总了Java中org.apache.jmeter.samplers.Sampler.sample方法的典型用法代码示例。如果您正苦于以下问题:Java Sampler.sample方法的具体用法?Java Sampler.sample怎么用?Java Sampler.sample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.samplers.Sampler
的用法示例。
在下文中一共展示了Sampler.sample方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProcessingTrue
import org.apache.jmeter.samplers.Sampler; //导入方法依赖的package包/类
public void testProcessingTrue() throws Exception {
LoopController controller = new LoopController();
controller.setLoops(2);
controller.addTestElement(new TestSampler("Sample1"));
IfController ifCont = new IfController("true==true");
ifCont.setEvaluateAll(true);
ifCont.addTestElement(new TestSampler("Sample2"));
TestSampler sample3 = new TestSampler("Sample3");
ifCont.addTestElement(sample3);
controller.addTestElement(ifCont);
String[] order = new String[] { "Sample1", "Sample2", "Sample3",
"Sample1", "Sample2", "Sample3" };
int counter = 0;
controller.setRunningVersion(true);
ifCont.setRunningVersion(true);
Sampler sampler = null;
while ((sampler = controller.next()) != null) {
sampler.sample(null);
assertEquals(order[counter], sampler.getName());
counter++;
}
assertEquals(counter, 6);
}
示例2: testProcessing
import org.apache.jmeter.samplers.Sampler; //导入方法依赖的package包/类
public void testProcessing() throws Exception {
RunTime controller = new RunTime();
controller.setRuntime(10);
TestSampler samp1 = new TestSampler("Sample 1", 500);
TestSampler samp2 = new TestSampler("Sample 2", 490);
LoopController sub1 = new LoopController();
sub1.setLoops(2);
sub1.setContinueForever(false);
sub1.addTestElement(samp1);
LoopController sub2 = new LoopController();
sub2.setLoops(40);
sub2.setContinueForever(false);
sub2.addTestElement(samp2);
controller.addTestElement(sub1);
controller.addTestElement(sub2);
controller.setRunningVersion(true);
sub1.setRunningVersion(true);
sub2.setRunningVersion(true);
controller.initialize();
Sampler sampler = null;
int loops = 0;
long now = System.currentTimeMillis();
while ((sampler = controller.next()) != null) {
loops++;
sampler.sample(null);
}
long elapsed = System.currentTimeMillis() - now;
assertTrue("Should be at least 20 loops "+loops, loops >= 20);
assertTrue("Should be fewer than 30 loops "+loops, loops < 30);
assertTrue("Should take at least 10 seconds "+elapsed, elapsed >= 10000);
assertTrue("Should take less than 12 seconds "+elapsed, elapsed <= 12000);
assertEquals("Sampler 1 should run 2 times", 2, samp1.getSamples());
assertTrue("Sampler 2 should run >= 18 times", samp2.getSamples() >= 18);
}
示例3: testEvaluateAllChildrenWithoutSubController
import org.apache.jmeter.samplers.Sampler; //导入方法依赖的package包/类
/**
* Test false return on sample3 (sample4 doesn't execute)
* @throws Exception
*/
public void testEvaluateAllChildrenWithoutSubController() throws Exception {
LoopController controller = new LoopController();
controller.setLoops(2);
controller.addTestElement(new TestSampler("Sample1"));
IfController ifCont = new IfController("true==true");
ifCont.setEvaluateAll(true);
controller.addTestElement(ifCont);
ifCont.addTestElement(new TestSampler("Sample2"));
TestSampler sample3 = new TestSampler("Sample3");
ifCont.addTestElement(sample3);
TestSampler sample4 = new TestSampler("Sample4");
ifCont.addTestElement(sample4);
String[] order = new String[] { "Sample1", "Sample2", "Sample3",
"Sample1", "Sample2", "Sample3" };
int counter = 0;
controller.setRunningVersion(true);
ifCont.setRunningVersion(true);
Sampler sampler = null;
while ((sampler = controller.next()) != null) {
sampler.sample(null);
if (sampler.getName().equals("Sample3")) {
ifCont.setCondition("true==false");
}
assertEquals(order[counter], sampler.getName());
counter++;
}
assertEquals(counter, 6);
}
示例4: testEvaluateAllChildrenWithSubController
import org.apache.jmeter.samplers.Sampler; //导入方法依赖的package包/类
/**
* test 2 loops with a sub generic controller (sample4 doesn't execute)
* @throws Exception
*/
public void testEvaluateAllChildrenWithSubController() throws Exception {
LoopController controller = new LoopController();
controller.setLoops(2);
controller.addTestElement(new TestSampler("Sample1"));
IfController ifCont = new IfController("true==true");
ifCont.setEvaluateAll(true);
controller.addTestElement(ifCont);
ifCont.addTestElement(new TestSampler("Sample2"));
GenericController genericCont = new GenericController();
TestSampler sample3 = new TestSampler("Sample3");
genericCont.addTestElement(sample3);
TestSampler sample4 = new TestSampler("Sample4");
genericCont.addTestElement(sample4);
ifCont.addTestElement(genericCont);
String[] order = new String[] { "Sample1", "Sample2", "Sample3",
"Sample1", "Sample2", "Sample3" };
int counter = 0;
controller.setRunningVersion(true);
ifCont.setRunningVersion(true);
genericCont.setRunningVersion(true);
Sampler sampler = null;
while ((sampler = controller.next()) != null) {
sampler.sample(null);
if (sampler.getName().equals("Sample3")) {
ifCont.setCondition("true==false");
}
assertEquals(order[counter], sampler.getName());
counter++;
}
assertEquals(counter, 6);
}