本文整理汇总了Java中org.apache.jmeter.engine.StandardJMeterEngine.configure方法的典型用法代码示例。如果您正苦于以下问题:Java StandardJMeterEngine.configure方法的具体用法?Java StandardJMeterEngine.configure怎么用?Java StandardJMeterEngine.configure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.engine.StandardJMeterEngine
的用法示例。
在下文中一共展示了StandardJMeterEngine.configure方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadControl1
import org.apache.jmeter.engine.StandardJMeterEngine; //导入方法依赖的package包/类
@Test
public void loadControl1() throws Exception {
log.info("start loadControl1()");
// Initialize Properties, logging, locale, etc.
JMeterUtils.loadJMeterProperties(JMETER_HOME + "/bin/jmeter.properties");
JMeterUtils.setJMeterHome(JMETER_HOME);
JMeterUtils.initLocale();
// Initialize JMeter SaveService
SaveService.loadProperties();
// Load existing .jmx Test Plan
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL url = classLoader.getResource("tutorial/jmeter/Tutorial6.jmx");
File file = new File(url.toURI());
HashTree testPlanTree = SaveService.loadTree(file);
// Run JMeter Test
StandardJMeterEngine jmeter = new StandardJMeterEngine();
jmeter.configure(testPlanTree);
jmeter.run();
}
示例2: runRealEngine
import org.apache.jmeter.engine.StandardJMeterEngine; //导入方法依赖的package包/类
@Test
public void runRealEngine() throws Exception {
TestTreeProvider prov = new TestProvider();
HashTree hashTree = prov.getTestTree();
JMeter.convertSubTree(hashTree);
StandardJMeterEngine engine = new StandardJMeterEngine();
engine.configure(hashTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
}
示例3: startEngine
import org.apache.jmeter.engine.StandardJMeterEngine; //导入方法依赖的package包/类
/**
* Start JMeter engine
* @param noTimer ignore timers
*/
private void startEngine(boolean ignoreTimer) {
GuiPackage gui = GuiPackage.getInstance();
HashTree testTree = gui.getTreeModel().getTestPlan();
JMeter.convertSubTree(testTree);
testTree.add(testTree.getArray()[0], gui.getMainFrame());
log.debug("test plan before cloning is running version: "
+ ((TestPlan) testTree.getArray()[0]).isRunningVersion());
TreeCloner cloner = cloneTree(testTree, ignoreTimer);
engine = new StandardJMeterEngine();
engine.configure(cloner.getClonedTree());
try {
engine.runTest();
} catch (JMeterEngineException e) {
JOptionPane.showMessageDialog(gui.getMainFrame(), e.getMessage(),
JMeterUtils.getResString("error_occurred"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
}
log.debug("test plan after cloning and running test is running version: "
+ ((TestPlan) testTree.getArray()[0]).isRunningVersion());
}
示例4: main
import org.apache.jmeter.engine.StandardJMeterEngine; //导入方法依赖的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();
}
示例5: requestsAreSubmitted
import org.apache.jmeter.engine.StandardJMeterEngine; //导入方法依赖的package包/类
@When("^(.+) requests are submitted for endpoints$")
public void requestsAreSubmitted(final Integer loops,
final List<Endpoint> endpoints) {
// Set status vars - number of endpoints and a CPU sampler
this.samplersCount = endpoints.size() + 1;
// Create JMeter engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
// Init JMeter engine
// TODO Refactor config
JMeterUtils.setJMeterHome("JMETER_HOME");
JMeterUtils.loadJMeterProperties("JMETER_HOME/bin/jmeter.properties");
JMeterUtils.initLocale();
// Build samplers, use path for name of the sampler
Stream<HTTPSampler> httpSamplers = endpoints.stream().map(endpoint -> {
HTTPSampler httpSampler = new HTTPSampler();
httpSampler.setName(endpoint.getPath());
httpSampler.setDomain(endpoint.getDomain());
httpSampler.setPort(endpoint.getPort());
httpSampler.setPath(endpoint.getPath());
httpSampler.setMethod(endpoint.getMethod());
return httpSampler;
});
// Build a CPU sampler
CpuSampler cpuSampler = new CpuSampler();
cpuSampler.setName("cpu");
// Loop Controller
LoopController loopController = new LoopController();
loopController.setName("Default Loop Controller");
loopController.setLoops(loops);
loopController.setFirst(true);
loopController.initialize();
// Thread Group
org.apache.jmeter.threads.ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setName("Default Thread Group");
threadGroup.setNumThreads(1);
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
// Create results collector
ResultCollector logger = new ResultCollector();
logger.setName("Default Results Collector");
logger.setFilename("metrics.csv");
// Create a test structure
HashTree testPlanTree = new HashTree();
// Add Test Plan
TestPlan testPlan = new TestPlan("Sample R integration test plan");
testPlanTree.add(testPlan);
// Hang off Thread Group off Test Plan
HashTree threadGroupHashTree = testPlanTree.add(testPlan, threadGroup);
// Add samplers
threadGroupHashTree.add(httpSamplers.toArray());
threadGroupHashTree.add(cpuSampler);
// Add logger
testPlanTree.add(testPlan, logger);
// Run Test Plan
jmeter.configure(testPlanTree);
jmeter.run();
threadGroup.waitThreadsStopped();
}
开发者ID:cadmiumkitty,项目名称:cucumber-jmeter-r-integration,代码行数:73,代码来源:DataScienceLabDemoTestPerformanceAnomaliesSteps.java
示例6: handle
import org.apache.jmeter.engine.StandardJMeterEngine; //导入方法依赖的package包/类
@Override
public OutputMessage handle(AgentTokenWrapper token, InputMessage message) throws Exception {
ApplicationContext context = token.getServices().getApplicationContextBuilder().getCurrentContext();
if(context.get("initialized")==null) {
FileVersionId jmeterLibs = getFileVersionId("$jmeter.libraries", message.getProperties());
FileVersion jmeterLibFolder = token.getServices().getFileManagerClient().requestFileVersion(jmeterLibs.getFileId(), jmeterLibs.getVersion());
jmeterHome = jmeterLibFolder.getFile().getAbsolutePath();
updateClasspathSystemProperty();
JMeterUtils.setJMeterHome(jmeterHome);
JMeterUtils.loadJMeterProperties(jmeterHome+"/bin/jmeter.properties");
JMeterUtils.initLogging();
JMeterUtils.initLocale();
context.put("initialized", true);
}
OutputMessageBuilder out = new OutputMessageBuilder();
File testPlanFile = retrieveFileVersion("$jmeter.testplan.file", message.getProperties()).getFile();
StandardJMeterEngine jmeter = new StandardJMeterEngine();
HashTree testPlanTree = SaveService.loadTree(testPlanFile);
Arguments arguments = createArguments(message);
SampleListenerImpl listener = new SampleListenerImpl(out);
testPlanTree.traverse(new HashTreeTraverser() {
@Override
public void subtractNode() {
}
@Override
public void processPath() {
}
@Override
public void addNode(Object node, HashTree subTree) {
if (node instanceof TestPlan) {
testPlanTree.getTree(node).add(listener);
testPlanTree.getTree(node).add(arguments);
}
}
});
jmeter.configure(testPlanTree);
try {
jmeter.run();
} finally {
listener.collect();
}
return out.build();
}
示例7: runJMeter
import org.apache.jmeter.engine.StandardJMeterEngine; //导入方法依赖的package包/类
protected void runJMeter(String className) throws Exception {
int iterations = Integer.valueOf(getTestConfiguration(className, "iterations", "1"));
int threads = Integer.valueOf(getTestConfiguration(className, "threads", "1"));
log.info("starting test " + StringUtils.substringAfterLast(className, "."));
// loop controller
LoopController loopController = new LoopController();
loopController.setLoops(iterations);
loopController.setFirst(true);
loopController.initialize();
// thread group
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(threads);
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
// JavaSampler
JavaSampler javaSampler = new JavaSampler();
javaSampler.setClassname(className);
javaSampler.setArguments(arguments);
// summary
Summariser summariser = new Summariser("summary");
ResultCollector logger = new ResultCollector(summariser);
// simple listener to track if at least one test failed
GlobalResult globalResult = new GlobalResult();
// create test plan
TestPlan testPlan = new TestPlan();
// assemble the test plan from previously initialized elements
HashTree testPlanHashTree = new HashTree();
testPlanHashTree.add(testPlan);
HashTree threadGroupHashTree = new HashTree();
threadGroupHashTree = testPlanHashTree.add(testPlan, threadGroup);
HashTree javaSamplerHashTree = new HashTree();
javaSamplerHashTree = threadGroupHashTree.add(javaSampler);
javaSamplerHashTree.add(logger);
javaSamplerHashTree.add(globalResult);
// start JMeter test
StandardJMeterEngine jmeter = new StandardJMeterEngine();
jmeter.configure(testPlanHashTree);
jmeter.run();
// increase log level to display the final summary
LoggingManager.setPriority(Priority.INFO, "jmeter.reporters.Summariser");
logger.testEnded();
LoggingManager.setPriority(Priority.WARN, "jmeter.reporters.Summariser");
// set the JUnit test result
assertTrue(!globalResult.isFailed());
}