本文整理汇总了Java中org.apache.jmeter.samplers.SampleResult.setDataType方法的典型用法代码示例。如果您正苦于以下问题:Java SampleResult.setDataType方法的具体用法?Java SampleResult.setDataType怎么用?Java SampleResult.setDataType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.samplers.SampleResult
的用法示例。
在下文中一共展示了SampleResult.setDataType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sample
import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
public SampleResult sample(Entry arg0) {
SampleResult res = new SampleResult();
res.setSampleLabel("函数助手小工具");
res.sampleStart();
// 输出GUI界面所输入的函数方法返回结果
JMeterProperty properties = this.getProperty(FUNCTION);
System.out.println(properties);
//
if (properties != null) {
res.setResponseData("Function结果是:" + properties.getStringValue(), null);
res.setDataType(SampleResult.TEXT);
}
res.sampleEnd();
res.setSuccessful(true);
return res;
}
示例2: runTest
import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
/**
* 开始测试,从arg0参数可以获得参数值;
*/
public SampleResult runTest(JavaSamplerContext arg0) {
name = arg0.getParameter("name");
SampleResult sr = new SampleResult();
sr.setSampleLabel("Java请求--sayHelloToPerson");
try {
// jmeter 开始统计响应时间标记
sr.sampleStart();
Hello test = new Hello();
// 通过下面的操作就可以将被测方法的响应输出到Jmeter的察看结果树中的响应数据里面了。
resultData = test.sayHelloToPerson(name);
if (resultData != null && resultData.length() > 0) {
sr.setResponseData("结果是:" + resultData, null);
sr.setDataType(SampleResult.TEXT);
}
sr.setSuccessful(true);
} catch (Throwable e) {
sr.setSuccessful(false);
e.printStackTrace();
} finally {
// jmeter 结束统计响应时间标记
sr.sampleEnd();
}
return sr;
}
示例3: runTest
import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
public SampleResult runTest(JavaSamplerContext context) {
String name = context.getParameter("name");
getNewLogger().info("dubbo test - {} start", name);
SampleResult sr = new SampleResult();
// 开始测试
sr.sampleStart();
start = System.currentTimeMillis();
sr.setSampleLabel("Dubbo请求--sayHello");
try {
String result = this.userService.sayHello();
if (null != result && result.length() > 0) {
sr.setResponseData("结果是:" + result, null);
sr.setDataType(SampleResult.TEXT);
}
sr.setSuccessful(true);
} catch (Exception e) {
sr.setSuccessful(false);
e.printStackTrace();
} finally {
sr.sampleEnd();
}
return sr;
}
示例4: sample
import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
@Override
public SampleResult sample(Entry entry) {
SampleResult res = new SampleResult();
res.setSampleLabel(getName());
res.setDataType(SampleResult.TEXT);
res.setSuccessful(true);
res.setResponseCode("200");
res.setResponseMessage("OK");
res.sampleStart();
try {
if (connConfig == null) {
throw new RuntimeException("Cannot sample XMPP without XMPP Connection component");
}
XMPPConnection conn = getXMPPConnection();
if (conn == null) {
throw new RuntimeException("No XMPP Connection available");
}
String headers = "Connection ID: " + conn.getConnectionID() + "\r\n";
String action = getAction();
if (!conn.isConnected() && !action.equals(Connect.class.getCanonicalName())) {
log.error("Please call Connect before calling other actions");
throw new SmackException.NotConnectedException();
}
headers += "User: " + conn.getUser() + "\r\n";
res.setRequestHeaders(headers);
AbstractXMPPAction actObject = connConfig.getActions().get(action);
if (actObject.perform(this, res) == null) {
return null;
}
} catch (Exception e) {
log.error("Error in XMPP Sampler: ", e);
res.setSuccessful(false);
res.setResponseCode("500");
res.setResponseMessage((e.getMessage() == null || e.getMessage().isEmpty()) ? e.toString() : e.getMessage());
res.setResponseData(ExceptionUtils.getStackTrace(e).getBytes());
}
res.sampleEnd();
return res;
}