本文整理汇总了Java中org.apache.jmeter.JMeter类的典型用法代码示例。如果您正苦于以下问题:Java JMeter类的具体用法?Java JMeter怎么用?Java JMeter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JMeter类属于org.apache.jmeter包,在下文中一共展示了JMeter类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.jmeter.JMeter; //导入依赖的package包/类
public void start() {
log.debug("Start debugging");
frontend.started();
HashTree hashTree = getSelectedTree();
StandardJMeterEngine.register(new StateListener()); // oh, dear, they use static field then clean it...
engine = new DebuggerEngine(JMeterContextService.getContext());
engine.setStepper(this);
JMeter.convertSubTree(hashTree);
engine.configure(hashTree);
try {
engine.runTest();
} catch (JMeterEngineException e) {
log.error("Failed to pauseContinue debug", e);
stop();
}
}
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:18,代码来源:Debugger.java
示例2: runRealEngine
import org.apache.jmeter.JMeter; //导入依赖的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);
}
}
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:15,代码来源:DebuggerEngineTest.java
示例3: startEngine
import org.apache.jmeter.JMeter; //导入依赖的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());
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:24,代码来源:Start.java
示例4: runDebugEngine
import org.apache.jmeter.JMeter; //导入依赖的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
示例5: checkProxy
import org.apache.jmeter.JMeter; //导入依赖的package包/类
private void checkProxy() {
if (JMeter.isNonGUI()) {
this.setUseProxy(true);
// we check to see if the proxy host and port are set
String port = this.getPropertyAsString(PROXY_PORT);
String host = this.getPropertyAsString(PROXY_HOST);
if (host == null || host.length() == 0) {
// it's not set, lets check if the user passed
// proxy host and port from command line
host = System.getProperty("http.proxyHost");
if (host != null) {
this.setProxyHost(host);
}
}
if (port == null || port.length() == 0) {
// it's not set, lets check if the user passed
// proxy host and port from command line
port = System.getProperty("http.proxyPort");
if (port != null) {
this.setProxyPort(port);
}
}
}
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:25,代码来源:WebServiceSampler.java
示例6: main
import org.apache.jmeter.JMeter; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
int port = JMeter.UDP_PORT_DEFAULT;
if (args.length > 1){
port = Integer.parseInt(args[1]);
} else if (args.length == 0) {
throw new RuntimeException("Usage: command [port]");
}
String command = args[0];
System.out.println("Sending "+command+" request to port "+port);
DatagramSocket socket = new DatagramSocket();
byte[] buf = command.getBytes("ASCII");
InetAddress address = InetAddress.getByName("localhost");
DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port);
socket.send(packet);
socket.close();
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:17,代码来源:ShutdownClient.java
示例7: createHTTPClient
import org.apache.jmeter.JMeter; //导入依赖的package包/类
private static AbstractHttpClient createHTTPClient() {
AbstractHttpClient client = new DefaultHttpClient();
String proxyHost = System.getProperty("https.proxyHost", "");
if (!proxyHost.isEmpty()) {
int proxyPort = Integer.parseInt(System.getProperty("https.proxyPort", "-1"));
log.info("Using proxy " + proxyHost + ":" + proxyPort);
HttpParams params = client.getParams();
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
String proxyUser = System.getProperty(JMeter.HTTP_PROXY_USER, JMeterUtils.getProperty(JMeter.HTTP_PROXY_USER));
if (proxyUser != null) {
log.info("Using authenticated proxy with username: " + proxyUser);
String proxyPass = System.getProperty(JMeter.HTTP_PROXY_PASS, JMeterUtils.getProperty(JMeter.HTTP_PROXY_PASS));
String localHost;
try {
localHost = InetAddress.getLocalHost().getCanonicalHostName();
} catch (Throwable e) {
log.error("Failed to get local host name, defaulting to 'localhost'", e);
localHost = "localhost";
}
AuthScope authscope = new AuthScope(proxyHost, proxyPort);
String proxyDomain = JMeterUtils.getPropDefault("http.proxyDomain", "");
NTCredentials credentials = new NTCredentials(proxyUser, proxyPass, localHost, proxyDomain);
client.getCredentialsProvider().setCredentials(authscope, credentials);
}
}
return client;
}
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:32,代码来源:HttpUtils.java
示例8: testEnded
import org.apache.jmeter.JMeter; //导入依赖的package包/类
@Override
public void testEnded(String arg0) {
logger.info("in testEnded, isNonGUI=" + JMeter.isNonGUI() + ", sleepFlag=" + sleepFlag.get());
this.interrupt = true;
try {
if (JMeter.isNonGUI()) {
if(!sleepFlag.get()) {
//The keepTime is saved as static variable, because keepTime variable in testEnded()
//returns with initial value.
logger.info("The work has been done, will keep connection for " + keepTime + " sceconds.");
TimeUnit.SECONDS.sleep(keepTime);
sleepFlag.set(true);
}
//The following code does not make sense, because the connection variable was already reset.
//But it makes sense in threadFinished method.
//The reason for not sleeping and then disconnecting in threadFinished is to avoid maintain too much of threads.
//Otherwise each thread (for a thread-group) will be kept open before sleeping.
/*if(this.connection != null) {
this.connection.disconnect();
logger.info(MessageFormat.format("The connection {0} disconneted successfully.", connection));
}*/
}
} catch(Exception ex) {
logger.error(ex.getMessage(), ex);
}
}
开发者ID:emqtt,项目名称:mqtt-jmeter,代码行数:29,代码来源:ConnectionSampler.java
示例9: interrupt
import org.apache.jmeter.JMeter; //导入依赖的package包/类
@Override
public boolean interrupt() {
this.interrupt = true;
if (!JMeter.isNonGUI()) {
logger.info("In GUI mode, received the interrupt request from user.");
}
return true;
}
开发者ID:emqtt,项目名称:mqtt-jmeter,代码行数:9,代码来源:ConnectionSampler.java
示例10: sampleOccurred
import org.apache.jmeter.JMeter; //导入依赖的package包/类
/**
* In this listener, it can receive the interrupt event trigger by user.
*/
@Override
public void sampleOccurred(SampleEvent event) {
if (!JMeter.isNonGUI() && "MQTT Connection Sampler".equals(event.getResult().getSampleLabel() )) {
logger.info("Created the sampler results, will sleep current thread for " + getConnKeepTime() + " sceconds");
sleepCurrentThreadAndDisconnect();
}
}
开发者ID:emqtt,项目名称:mqtt-jmeter,代码行数:11,代码来源:ConnectionSampler.java
示例11: initProxyConfiguration
import org.apache.jmeter.JMeter; //导入依赖的package包/类
static void initProxyConfiguration() {
proxyHost = System.getProperty("http.proxyHost",null);
proxyPort = Integer.parseInt(System.getProperty("http.proxyPort","0"));
List<String> nonProxyHostList = Arrays.asList(System.getProperty("http.nonProxyHosts","").split("\\|"));
nonProxyHosts = nonProxyHostList.stream().filter(h -> !h.startsWith("*")).collect(Collectors.toList());
nonProxyWildcards = nonProxyHostList.stream().filter(h -> h.startsWith("*")).map(w -> w.substring(1)).collect(Collectors.toList());
proxyUsername = JMeterUtils.getPropDefault(JMeter.HTTP_PROXY_USER,null);
proxyPassword = JMeterUtils.getPropDefault(JMeter.HTTP_PROXY_PASS,null);
}
开发者ID:ptrd,项目名称:jmeter-websocket-samplers,代码行数:10,代码来源:WebsocketSampler.java
示例12: selectThreadGroup
import org.apache.jmeter.JMeter; //导入依赖的package包/类
private void selectThreadGroup(AbstractThreadGroup tg) {
debugger.selectThreadGroup(tg);
treeModel.clearTestPlan();
HashTree origTree = debugger.getSelectedTree();
TreeCloner cloner = new TreeCloner();
origTree.traverse(cloner);
HashTree selectedTree = cloner.getClonedTree();
// Hack to resolve ModuleControllers from JMeter.java
SearchClass<ReplaceableController> replaceableControllers = new SearchClass<>(ReplaceableController.class);
selectedTree.traverse(replaceableControllers);
Collection<ReplaceableController> replaceableControllersRes = replaceableControllers.getSearchResults();
for (ReplaceableController replaceableController : replaceableControllersRes) {
replaceableController.resolveReplacementSubTree((JMeterTreeNode) treeModel.getRoot());
}
JMeter.convertSubTree(selectedTree);
try {
treeModel.addSubTree(selectedTree, (JMeterTreeNode) treeModel.getRoot());
} catch (IllegalUserActionException e) {
throw new RuntimeException(e);
}
// select TG for visual convenience
SearchByClass<DebuggingThreadGroup> tgs = new SearchByClass<>(DebuggingThreadGroup.class);
selectedTree.traverse(tgs);
for (DebuggingThreadGroup forSel : tgs.getSearchResults()) {
Wrapper<AbstractThreadGroup> wtg = new ThreadGroupWrapper();
wtg.setWrappedElement(forSel);
selectTargetInTree(wtg);
}
}
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:33,代码来源:DebuggerDialog.java
示例13: runVariablesDebugEngine
import org.apache.jmeter.JMeter; //导入依赖的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
示例14: runVariablesInAssertions
import org.apache.jmeter.JMeter; //导入依赖的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
示例15: runVariablesInControllers
import org.apache.jmeter.JMeter; //导入依赖的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
示例16: run
import org.apache.jmeter.JMeter; //导入依赖的package包/类
@Override
public void run() {
running = false;
engine = null;
if (now) {
tellThreadGroupsToStop();
pause(10 * countStillActiveThreads());
boolean stopped = verifyThreadsStopped();
if (!stopped) { // we totally failed to stop the test
if (JMeter.isNonGUI()) {
// TODO should we call test listeners? That might hang too ...
log.fatalError(JMeterUtils.getResString("stopping_test_failed")); //$NON-NLS-1$
if (SYSTEM_EXIT_ON_STOP_FAIL) { // default is true
log.fatalError("Exitting");
System.out.println("Fatal error, could not stop test, exitting");
System.exit(1);
} else {
System.out.println("Fatal error, could not stop test");
}
} else {
JMeterUtils.reportErrorToUser(
JMeterUtils.getResString("stopping_test_failed"), //$NON-NLS-1$
JMeterUtils.getResString("stopping_test_title")); //$NON-NLS-1$
}
} // else will be done by threadFinished()
} else {
stopAllThreadGroups();
}
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:30,代码来源:StandardJMeterEngine.java
示例17: initEngine
import org.apache.jmeter.JMeter; //导入依赖的package包/类
/**
* Initializes test on engine.
*
* @param engine
* remote engine object
*/
private void initEngine(JMeterEngine engine) {
GuiPackage gui = GuiPackage.getInstance();
HashTree testTree = gui.getTreeModel().getTestPlan();
JMeter.convertSubTree(testTree);
testTree.add(testTree.getArray()[0], gui.getMainFrame());
// Used for remote notification of threads start/stop,see BUG 54152
testTree.add(testTree.getArray()[0], new RemoteThreadsListenerTestElement());
engine.configure(testTree);
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:16,代码来源:RemoteStart.java
示例18: start
import org.apache.jmeter.JMeter; //导入依赖的package包/类
public void start() throws Exception {
// Subscribe to termination event
this.addEventListener(new BrowserEventListener() {
@Override
public void onEvent(String event) {
terminationEvent.countDown();
}
});
// Setup
setup();
final String jmxExtension = ".jmx";
final String jtlExtension = ".jtl";
final String htmlExtension = ".html";
final String logFile = REPORTS + "jmeter.log";
final String jmeterProperties = ROOT + "bin/jmeter.properties";
final File xsl = new File(ROOT + "bin/jmeter-results-detail.xsl");
File fileFeports = new File(REPORTS);
if (!fileFeports.exists()) {
fileFeports.mkdir();
}
JMeter jmeter = new JMeter();
String[] files = new File(JMXFOLDER).list();
for (String file : files) {
if (file.toLowerCase().endsWith(jmxExtension)) {
// Launching JMeter for each JMX test plan found
String fileNoExt = file.substring(0, file.length() - jmxExtension.length());
String outputFileJtl = REPORTS + fileNoExt + jtlExtension;
String[] arguments = { "-n", "-t", JMXFOLDER + file, "-p", jmeterProperties, "-d", ROOT,
"-l", outputFileJtl, "-j", logFile };
jmeter.start(arguments);
// Waiting for JMeter ending
ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos));
boolean running = true;
do {
BufferedReader br = new BufferedReader(new StringReader(baos.toString()));
String line;
while ((line = br.readLine()) != null) {
running = !line.equals("... end of run");
}
} while (running);
// Transform raw JTL to friendly HTML using XSL
String outputFileHtml = REPORTS + fileNoExt + htmlExtension;
jtl2html(xsl, new File(outputFileJtl), new File(outputFileHtml));
}
}
// End
File jmxFile = new File(JMXFOLDER + JMXFILE);
jmxFile.delete();
}
开发者ID:Kurento,项目名称:kurento-java,代码行数:57,代码来源:JMeterClient.java
注:本文中的org.apache.jmeter.JMeter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论