本文整理汇总了Java中org.apache.jmeter.control.LoopController类的典型用法代码示例。如果您正苦于以下问题:Java LoopController类的具体用法?Java LoopController怎么用?Java LoopController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoopController类属于org.apache.jmeter.control包,在下文中一共展示了LoopController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: runDebugEngine
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Test
public void runDebugEngine() throws Exception {
TestProvider prov = new TestProvider();
Debugger sel = new Debugger(prov, new FrontendMock());
AbstractThreadGroup tg = prov.getTG(0);
sel.selectThreadGroup(tg);
HashTree testTree = sel.getSelectedTree();
DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree);
LoopController samplerController = (LoopController) tg2.getSamplerController();
samplerController.setLoops(1);
samplerController.setContinueForever(false);
JMeter.convertSubTree(testTree);
DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext());
StepTriggerCounter hook = new StepTriggerCounter();
engine.setStepper(hook);
engine.configure(testTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
assertEquals(88, hook.cnt);
}
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:27,代码来源:DebuggerEngineTest.java
示例2: testThreadStopping
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Test
public void testThreadStopping() throws Exception {
DirectoryListingConfig config = new DirectoryListingConfig();
File rootDir = TestDirectoryListingConfigActionTest.createFileTree();
setDirectoryConfig(config, rootDir.getAbsolutePath(), VARIABLE_NAME, true, false, false, false, true, false);
final HashTree hashTree = new HashTree();
hashTree.add(new LoopController());
JMeterThread thread = new JMeterThread(hashTree, null, null);
JMeterContextService.getContext().setThread(thread);
testFlow(config);
try {
config.iterationStart(null);
} catch (JMeterStopThreadException ex) {
assertEquals("All files in the directory have been passed.", ex.getMessage());
}
}
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:23,代码来源:DirectoryListingConfigTest.java
示例3: runVariablesDebugEngine
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Test
public void runVariablesDebugEngine() throws Exception {
TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/vars.jmx", "vars.jmx");
Debugger sel = new Debugger(prov, new FrontendMock());
AbstractThreadGroup tg = prov.getTG(0);
sel.selectThreadGroup(tg);
HashTree testTree = sel.getSelectedTree();
TestSampleListener listener = new TestSampleListener();
testTree.add(testTree.getArray()[0], listener);
DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree);
LoopController samplerController = (LoopController) tg2.getSamplerController();
samplerController.setLoops(1);
samplerController.setContinueForever(false);
JMeter.convertSubTree(testTree);
DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext());
StepTriggerCounter hook = new StepTriggerCounter();
engine.setStepper(hook);
engine.configure(testTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
assertEquals(8, hook.cnt);
assertEquals(3, listener.events.size());
for (SampleEvent event : listener.events) {
SampleResult res = event.getResult();
String label = res.getSampleLabel();
assertTrue("Label: " + label + " must end with '123'", label.endsWith("123"));
assertFalse("Variable ${VAR} must be changed to '123' value. label: " + label, label.contains("${VAR}"));
assertTrue("label: '" + label + "' response: '" + res.getResponseMessage() +"'", res.isSuccessful());
}
}
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:39,代码来源:DebuggerEngineTest.java
示例4: runVariablesInAssertions
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Test
public void runVariablesInAssertions() throws Exception {
TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/debug.jmx", "debug.jmx");
Debugger sel = new Debugger(prov, new FrontendMock());
AbstractThreadGroup tg = prov.getTG(0);
sel.selectThreadGroup(tg);
HashTree testTree = sel.getSelectedTree();
TestSampleListener listener = new TestSampleListener();
testTree.add(testTree.getArray()[0], listener);
DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree);
LoopController samplerController = (LoopController) tg2.getSamplerController();
samplerController.setLoops(1);
samplerController.setContinueForever(false);
JMeter.convertSubTree(testTree);
DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext());
StepTriggerCounter hook = new StepTriggerCounter();
engine.setStepper(hook);
engine.configure(testTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
assertEquals(4, hook.cnt);
assertEquals(1, listener.events.size());
SampleEvent event = listener.events.get(0);
SampleResult result = event.getResult();
AssertionResult[] assertionResults = result.getAssertionResults();
assertEquals(1, assertionResults.length);
AssertionResult assertionRes = assertionResults[0];
assertNull(assertionRes.getFailureMessage());
}
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:39,代码来源:DebuggerEngineTest.java
示例5: runVariablesInControllers
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Test
public void runVariablesInControllers() throws Exception {
TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/loops.jmx", "loops.jmx");
Debugger sel = new Debugger(prov, new FrontendMock());
AbstractThreadGroup tg = prov.getTG(0);
sel.selectThreadGroup(tg);
HashTree testTree = sel.getSelectedTree();
TestSampleListener listener = new TestSampleListener();
testTree.add(testTree.getArray()[0], listener);
DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree);
LoopController samplerController = (LoopController) tg2.getSamplerController();
samplerController.setLoops(1);
samplerController.setContinueForever(false);
JMeter.convertSubTree(testTree);
DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext());
StepTriggerCounter hook = new StepTriggerCounter();
engine.setStepper(hook);
engine.configure(testTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
assertEquals(12, hook.cnt);
assertEquals(3, listener.events.size());
}
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:32,代码来源:DebuggerEngineTest.java
示例6: modifyTestElement
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
/**
* Modifies a given TestElement to mirror the data in the gui components.
*
* @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
*/
@Override
public void modifyTestElement(TestElement tg) {
super.configureTestElement(tg);
if (tg instanceof AbstractThreadGroup) {
((AbstractThreadGroup) tg).setSamplerController((LoopController) loopPanel.createTestElement());
}
tg.setProperty(AbstractThreadGroup.NUM_THREADS, threadInput.getText());
tg.setProperty(ThreadGroup.RAMP_TIME, rampInput.getText());
tg.setProperty(new LongProperty(ThreadGroup.START_TIME, start.getDate().getTime()));
tg.setProperty(new LongProperty(ThreadGroup.END_TIME, end.getDate().getTime()));
if (showDelayedStart) {
tg.setProperty(ThreadGroup.DELAYED_START, delayedStart.isSelected(), false);
}
tg.setProperty(new BooleanProperty(ThreadGroup.SCHEDULER, scheduler.isSelected()));
tg.setProperty(ThreadGroup.DURATION, duration.getText());
tg.setProperty(ThreadGroup.DELAY, delay.getText());
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:24,代码来源:ThreadGroupGui.java
示例7: executePlan
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
private Map<String, String> executePlan(int numLoops, int numThreads, int rampUp) throws IOException {
HashTree testPlanTree = new HashTree();
HTTPSamplerProxy httpSampler = makeSampler();
LoopController loopController = new LoopController();
loopController.setLoops(numLoops);
loopController.addTestElement(httpSampler);
loopController.setFirst(true);
loopController.initialize();
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(numThreads);
threadGroup.setRampUp(rampUp);
threadGroup.setSamplerController(loopController);
TestPlan testPlan = new TestPlan("JMeter regression test");
HashTree tpConfig = testPlanTree.add(testPlan);
HashTree tgConfig = tpConfig.add(threadGroup);
tgConfig.add(httpSampler);
Summariser summer = new Summariser("summary");
ResultCollector logger = new ResultCollector(summer);
tgConfig.add(logger);
jmeter.configure(testPlanTree);
jmeter.run();
return extractTotals(summer);
}
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:30,代码来源:ConverterLoadTest.java
示例8: getTestTree
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
private HashTree getTestTree(TestElement te) {
LoopController wrapper = new LoopController(); // can't use GenericController because of infinite looping
wrapper.setLoops(1);
wrapper.setContinueForever(false);
wrapper.addTestElement(te);
wrapper.setName("wrapped " + te.getName());
wrapper.setRunningVersion(isRunningVersion());
HashTree tree = new HashTree();
tree.add(wrapper);
return tree;
}
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:14,代码来源:ParallelSampler.java
示例9: underLoop
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Test
public void underLoop() throws Exception {
EmulSampler payload = new EmulSampler();
payload.setName("payload");
ParallelSampler sam = new ParallelSampler();
sam.threadStarted();
sam.setName("Parallel Sampler");
sam.addTestElement(payload);
LoopController ctl = getLoopController(5);
ctl.addTestElement(sam);
JMeterThread thr = new JMeterThread(new HashTree(ctl), sam, sam.notifier);
thr.setThreadName("root");
thr.setThreadGroup(new DummyThreadGroup());
JMeterContextService.getContext().setThread(thr);
addToContext(sam, thr);
addToContext(payload, thr);
sam.setRunningVersion(true);
ctl.setRunningVersion(true);
payload.setRunningVersion(true);
thr.run();
assertEquals(5, EmulSampler.count.get());
}
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:28,代码来源:ParallelSamplerTest.java
示例10: getLoopController
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
private LoopController getLoopController(int loops) {
LoopController ctl = new LoopControllerTracked();
ctl.setName("Top Loop");
ctl.setLoops(loops);
ctl.setContinueForever(false);
return ctl;
}
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:8,代码来源:ParallelSamplerTest.java
示例11: main
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
public static void main(String[] args) {
//JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
//JMeter initialization (properties, log levels, locale, etc)
JMeterUtils.loadJMeterProperties("/path/to/your/jmeter/bin/jmeter.properties");
JMeterUtils.setLocale(Locale.ENGLISH);
// ??? 啥用
JMeterUtils.setJMeterHome("");
JMeterUtils.initLocale();
// JMeter Test Plan, basic all u JOrphan HashTree
HashTree testPlanTree = new HashTree();
// Java Sampler
JavaSampler javaSampler = new JavaSampler();
javaSampler.setClassname("这里设置要运行的case主类");
javaSampler.setName("");
javaSampler.setComment("这个采集器的描述信息");
// Loop Controller
LoopController loopController = new LoopController();
// 循环次数
loopController.setLoops(1);
loopController.addTestElement(javaSampler);
loopController.setFirst(true);
loopController.initialize();
// Thread Group
org.apache.jmeter.threads.ThreadGroup threadGroup = new org.apache.jmeter.threads.ThreadGroup();
// 设置线程数
threadGroup.setNumThreads(1);
//
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
// Test Plan
TestPlan testPlan = new TestPlan("Create JMeter Script From Java Code");
// Construct Test Plan from previously initialized elements
testPlanTree.add("testPlan", testPlan);
testPlanTree.add("loopController", loopController);
testPlanTree.add("threadGroup", threadGroup);
testPlanTree.add("javaSampler", javaSampler);
// Run Test Plan
jmeter.configure(testPlanTree);
jmeter.run();
}
开发者ID:cbooy,项目名称:cakes,代码行数:51,代码来源:Demo1.java
示例12: DebuggingThreadGroup
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
public DebuggingThreadGroup() {
super();
setDelay(0);
setNumThreads(1);
setRampUp(0);
LoopController ctl = new LoopController();
ctl.setContinueForever(true);
ctl.setLoops(-1);
setSamplerController(ctl);
}
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:11,代码来源:DebuggingThreadGroup.java
示例13: initilizeElement
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Override
public TestElement initilizeElement() {
LoopController ele = new LoopController();
this.baseElement(ele, "Loop Controller");
ele.setLoops(1);
ele.setContinueForever(true);
return ele;
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:11,代码来源:LoopControllerInitializer.java
示例14: getLoopController
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
public LoopController getLoopController() {
Preconditions.checkNotNull(name);
LoopController loopController = new LoopController();
loopController.setProperty(TestElement.GUI_CLASS, LoopControlPanel.class.getName());
loopController.setProperty(TestElement.TEST_CLASS, LoopController.class.getName());
loopController.setProperty(TestElement.NAME, name);
loopController.setProperty(TestElement.ENABLED, true);
loopController.setLoops(getOptionalValue(loopCount, 1));
loopController.setContinueForever(getOptionalValue(continueForever, false));
loopController.setFirst(getOptionalValue(isFirst, true));
return loopController;
}
开发者ID:lithiumtech,项目名称:mineraloil-jmeter,代码行数:13,代码来源:LoopElement.java
示例15: configure
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
/**
* A newly created component can be initialized with the contents of a Test
* Element object by calling this method. The component is responsible for
* querying the Test Element object for the relevant information to display
* in its GUI.
*
* @param element
* the TestElement to configure
*/
@Override
public void configure(TestElement element) {
super.configure(element);
if (element instanceof LoopController) {
setState(((LoopController) element).getLoopString());
} else {
setState(1);
}
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:19,代码来源:LoopControlPanel.java
示例16: modifyTestElement
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Override
public void modifyTestElement(TestElement lc) {
configureTestElement(lc);
if (lc instanceof LoopController) {
if (loops.getText().length() > 0) {
((LoopController) lc).setLoops(loops.getText());
} else {
((LoopController) lc).setLoops(LoopController.INFINITE_LOOP_COUNT);
}
}
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:12,代码来源:LoopControlPanel.java
示例17: setState
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
/**
* Set the number of loops which should be reflected in the GUI. If the
* loopCount is less than 0, the number of loops will be assumed to be
* infinity.
*
* @param loopCount
* the number of loops
*/
private void setState(int loopCount) {
if (loopCount <= LoopController.INFINITE_LOOP_COUNT) {
infinite.setSelected(true);
loops.setEnabled(false);
loops.setText(""); // $NON-NLS-1$
} else {
infinite.setSelected(false);
loops.setEnabled(true);
loops.setText(Integer.toString(loopCount));
}
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:20,代码来源:LoopControlPanel.java
示例18: createControllerPanel
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
private JPanel createControllerPanel() {
loopPanel = new LoopControlPanel(false);
LoopController looper = (LoopController) loopPanel.createTestElement();
looper.setLoops(1);
loopPanel.configure(looper);
return loopPanel;
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:8,代码来源:ThreadGroupGui.java
示例19: testNestedSimpleControllers
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Test
public void testNestedSimpleControllers() throws Exception {
JMeterContextService.getContext().setVariables(new JMeterVariables());
TestSampleListener listener = new TestSampleListener();
// top WSC
WeightedSwitchController topWSC = new WeightedSwitchController();
PowerTableModel topPTM = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class});
topPTM.addRow(new String[]{"ex1", "10"});
topPTM.addRow(new String[]{"ex2", "20"});
topWSC.setData(topPTM);
// first child: simple controller
GenericController ex1 = new GenericController();
ex1.setName("ex1");
DebugSampler example1_1 = new DebugSampler();
example1_1.setName("example1_1");
DebugSampler example1_2 = new DebugSampler();
example1_2.setName("example1_2");
// second child: simple controller
GenericController ex2 = new GenericController();
ex2.setName("ex2");
DebugSampler example2_1 = new DebugSampler();
example2_1.setName("example2_1");
DebugSampler example2_2 = new DebugSampler();
example2_2.setName("example2_2");
// main loop
LoopController loop = new LoopController();
loop.setLoops(60);
loop.setContinueForever(false);
// test tree
ListedHashTree hashTree = new ListedHashTree();
hashTree.add(loop);
hashTree.add(loop, topWSC);
hashTree.add(topWSC, listener);
hashTree.add(topWSC, ex1);
hashTree.add(ex1, example1_1);
hashTree.add(ex1, example1_2);
hashTree.add(ex1, listener);
hashTree.add(topWSC, ex2);
hashTree.add(ex2, example2_1);
hashTree.add(ex2, example2_2);
hashTree.add(ex2, listener);
TestCompiler compiler = new TestCompiler(hashTree);
hashTree.traverse(compiler);
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(1);
ListenerNotifier notifier = new ListenerNotifier();
JMeterThread thread = new JMeterThread(hashTree, threadGroup, notifier);
thread.setThreadGroup(threadGroup);
thread.setOnErrorStopThread(true);
thread.run();
Map<String, Integer> totalResults = new HashMap<>();
for (SampleEvent event : listener.events) {
String label = event.getResult().getSampleLabel();
if (totalResults.containsKey(label)) {
totalResults.put(label, totalResults.get(label) + 1);
} else {
totalResults.put(label, 1);
}
}
assertEquals(120, listener.events.size());
assertEquals(20, (int) totalResults.get("example1_1"));
assertEquals(20, (int) totalResults.get("example1_2"));
assertEquals(40, (int) totalResults.get("example2_1"));
assertEquals(40, (int) totalResults.get("example2_2"));
}
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:80,代码来源:WeightedSwitchControllerTest.java
示例20: testNestedTransactionControllers
import org.apache.jmeter.control.LoopController; //导入依赖的package包/类
@Test
public void testNestedTransactionControllers() throws Exception {
JMeterContextService.getContext().setVariables(new JMeterVariables());
TestSampleListener listener = new TestSampleListener();
// top WSC
WeightedSwitchController topWSC = new WeightedSwitchController();
PowerTableModel topPTM = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class});
topPTM.addRow(new String[]{"ex1", "10"});
topPTM.addRow(new String[]{"ex2", "20"});
topWSC.setData(topPTM);
// first child: transaction controller
TransactionController ex1 = new TransactionController();
ex1.setName("ex1");
DebugSampler example1_1 = new DebugSampler();
example1_1.setName("example1_1");
DebugSampler example1_2 = new DebugSampler();
example1_2.setName("example1_2");
// second child: transaction controller
TransactionController ex2 = new TransactionController();
ex2.setName("ex2");
DebugSampler example2_1 = new DebugSampler();
example2_1.setName("example2_1");
DebugSampler example2_2 = new DebugSampler();
example2_2.setName("example2_2");
// main loop
LoopController loop = new LoopController();
loop.setLoops(60);
loop.setContinueForever(false);
// test tree
ListedHashTree hashTree = new ListedHashTree();
hashTree.add(loop);
hashTree.add(loop, topWSC);
hashTree.add(topWSC, listener);
hashTree.add(topWSC, ex1);
hashTree.add(ex1, example1_1);
hashTree.add(ex1, example1_2);
hashTree.add(ex1, listener);
hashTree.add(topWSC, ex2);
hashTree.add(ex2, example2_1);
hashTree.add(ex2, example2_2);
hashTree.add(ex2, listener);
TestCompiler compiler = new TestCompiler(hashTree);
hashTree.traverse(compiler);
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(1);
ListenerNotifier notifier = new ListenerNotifier();
JMeterThread thread = new JMeterThread(hashTree, threadGroup, notifier);
thread.setThreadGroup(threadGroup);
thread.setOnErrorStopThread(true);
thread.run();
Map<String, Integer> totalResults = new HashMap<>();
for (SampleEvent event : listener.events) {
String label = event.getResult().getSampleLabel();
if (totalResults.containsKey(label)) {
totalResults.put(label, totalResults.get(label) + 1);
} else {
totalResults.put(label, 1);
}
}
assertEquals(120, listener.events.size());
assertEquals(20, (int) totalResults.get("example1_1"));
assertEquals(40, (int) totalResults.get("example2_1"));
assertEquals(20, (int) totalResults.get("ex1")); // transaction result
assertEquals(40, (int) totalResults.get("ex2")); // transaction result
}
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:80,代码来源:WeightedSwitchControllerTest.java
注:本文中的org.apache.jmeter.control.LoopController类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论