本文整理匯總了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;
}