本文整理匯總了Java中org.apache.jmeter.samplers.SampleResult.getAssertionResults方法的典型用法代碼示例。如果您正苦於以下問題:Java SampleResult.getAssertionResults方法的具體用法?Java SampleResult.getAssertionResults怎麽用?Java SampleResult.getAssertionResults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jmeter.samplers.SampleResult
的用法示例。
在下文中一共展示了SampleResult.getAssertionResults方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateGui
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
/**
* Update the visualizer with new data.
*/
private synchronized void updateGui(SampleResult res) {
// Add sample
DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel);
treeModel.insertNodeInto(currNode, root, root.getChildCount());
addSubResults(currNode, res);
// Add any assertion that failed as children of the sample node
AssertionResult[] assertionResults = res.getAssertionResults();
int assertionIndex = currNode.getChildCount();
for (AssertionResult assertionResult : assertionResults) {
if (assertionResult.isFailure() || assertionResult.isError()) {
DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult, treeModel);
treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++);
}
}
if (root.getChildCount() == 1) {
jTree.expandPath(new TreePath(root));
}
if (autoScrollCB.isSelected() && root.getChildCount() > 1) {
jTree.scrollPathToVisible(new TreePath(new Object[] { root,
treeModel.getChild(root, root.getChildCount() - 1) }));
}
}
示例2: getElasticData
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
public Map<String, Object> getElasticData(SampleResult sr, BackendListenerContext context) {
HashMap<String, Object> jsonObject = new HashMap<>();
SimpleDateFormat sdf = new SimpleDateFormat(context.getParameter(ES_TIMESTAMP));
//add all the default SampleResult parameters
jsonObject.put("AllThreads", sr.getAllThreads());
jsonObject.put("BodySize", sr.getBodySizeAsLong());
jsonObject.put("Bytes", sr.getBytesAsLong());
jsonObject.put("SentBytes", sr.getSentBytes());
jsonObject.put("ConnectTime", sr.getConnectTime());
jsonObject.put("ContentType", sr.getContentType());
jsonObject.put("DataType", sr.getDataType());
jsonObject.put("ErrorCount", sr.getErrorCount());
jsonObject.put("GrpThreads", sr.getGroupThreads());
jsonObject.put("IdleTime", sr.getIdleTime());
jsonObject.put("Latency", sr.getLatency());
jsonObject.put("ResponseTime", sr.getTime());
jsonObject.put("SampleCount", sr.getSampleCount());
jsonObject.put("SampleLabel", sr.getSampleLabel());
jsonObject.put("StartTime", sdf.format(new Date(sr.getStartTime())));
jsonObject.put("EndTime", sdf.format(new Date(sr.getEndTime())));
jsonObject.put("ThreadName", sr.getThreadName());
jsonObject.put("URL", sr.getURL());
jsonObject.put("Timestamp", sdf.format(new Date(sr.getTimeStamp())));
jsonObject.put(ElasticsearchBackend.BUILD_NUMBER, this.buildNumber);
// If built from Jenkins, add the hard-coded version to be able to compare response time
// of two builds over the elapsed time
if(this.buildNumber != 0) {
Date elapsedTimeComparison = getElapsedTime(true);
if(elapsedTimeComparison != null)
jsonObject.put("ElapsedTimeComparison", elapsedTimeComparison);
}
Date elapsedTime = getElapsedTime(false);
if(elapsedTime != null)
jsonObject.put("ElapsedTime", elapsedTime);
jsonObject.put("ResponseCode", (sr.isResponseCodeOK() &&
StringUtils.isNumeric(sr.getResponseCode())) ?
sr.getResponseCode() : context.getParameter(ES_STATUS_CODE));
//all assertions
AssertionResult[] assertionResults = sr.getAssertionResults();
if(assertionResults != null) {
Map<String, Object>[] assertionArray = new HashMap[assertionResults.length];
Integer i = 0;
for(AssertionResult assertionResult : assertionResults) {
HashMap<String, Object> assertionMap = new HashMap<>();
boolean failure = assertionResult.isFailure() || assertionResult.isError();
assertionMap.put("failure", failure);
assertionMap.put("failureMessage", assertionResult.getFailureMessage());
assertionMap.put("name", assertionResult.getName());
assertionArray[i] = assertionMap;
i++;
}
jsonObject.put("AssertionResults", assertionArray);
}
return jsonObject;
}