use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class ViewResultsFullVisualizer method updateGui.
/**
* Update the visualizer with new data.
*/
private void updateGui() {
TreePath selectedPath = null;
Object oldSelectedElement;
Set<Object> oldExpandedElements;
Set<TreePath> newExpandedPaths = new HashSet<>();
synchronized (buffer) {
if (!dataChanged) {
return;
}
final Enumeration<TreePath> expandedElements = jTree.getExpandedDescendants(new TreePath(root));
oldExpandedElements = extractExpandedObjects(expandedElements);
oldSelectedElement = getSelectedObject();
root.removeAllChildren();
for (SampleResult sampler : buffer) {
SampleResult res = sampler;
// Add sample
DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel);
treeModel.insertNodeInto(currNode, root, root.getChildCount());
List<TreeNode> path = new ArrayList<>(Arrays.asList(root, currNode));
selectedPath = checkExpandedOrSelected(path, res, oldSelectedElement, oldExpandedElements, newExpandedPaths, selectedPath);
TreePath potentialSelection = addSubResults(currNode, res, path, oldSelectedElement, oldExpandedElements, newExpandedPaths);
if (potentialSelection != null) {
selectedPath = potentialSelection;
}
// 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++);
selectedPath = checkExpandedOrSelected(path, assertionResult, oldSelectedElement, oldExpandedElements, newExpandedPaths, selectedPath, assertionNode);
}
}
}
treeModel.nodeStructureChanged(root);
dataChanged = false;
}
if (root.getChildCount() == 1) {
jTree.expandPath(new TreePath(root));
}
newExpandedPaths.stream().forEach(jTree::expandPath);
if (selectedPath != null) {
jTree.setSelectionPath(selectedPath);
}
if (autoScrollCB.isSelected() && root.getChildCount() > 1) {
jTree.scrollPathToVisible(new TreePath(new Object[] { root, treeModel.getChild(root, root.getChildCount() - 1) }));
}
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class ViewResultsFullVisualizer method addSubResults.
private TreePath addSubResults(DefaultMutableTreeNode currNode, SampleResult res, List<TreeNode> path, Object selectedObject, Set<Object> oldExpandedObjects, Set<TreePath> newExpandedPaths) {
SampleResult[] subResults = res.getSubResults();
int leafIndex = 0;
TreePath result = null;
for (SampleResult child : subResults) {
log.debug("updateGui1 : child sample result - {}", child);
DefaultMutableTreeNode leafNode = new SearchableTreeNode(child, treeModel);
treeModel.insertNodeInto(leafNode, currNode, leafIndex++);
List<TreeNode> newPath = new ArrayList<>(path);
newPath.add(leafNode);
result = checkExpandedOrSelected(newPath, child, selectedObject, oldExpandedObjects, newExpandedPaths, result);
addSubResults(leafNode, child, newPath, selectedObject, oldExpandedObjects, newExpandedPaths);
// Add any assertion that failed as children of the sample node
AssertionResult[] assertionResults = child.getAssertionResults();
int assertionIndex = leafNode.getChildCount();
for (AssertionResult item : assertionResults) {
if (item.isFailure() || item.isError()) {
DefaultMutableTreeNode assertionNode = new SearchableTreeNode(item, treeModel);
treeModel.insertNodeInto(assertionNode, leafNode, assertionIndex++);
result = checkExpandedOrSelected(path, item, selectedObject, oldExpandedObjects, newExpandedPaths, result, assertionNode);
}
}
}
return result;
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class SMIMEAssertionTest method setUp.
@BeforeEach
public void setUp() throws MessagingException, IOException {
Session mailSession = Session.getDefaultInstance(new Properties());
msg = new MimeMessage(mailSession, this.getClass().getResourceAsStream("signed_email.eml"));
parent = new SampleResult();
parent.sampleStart();
parent.addSubResult(createChildSample());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class SMIMEAssertionTest method createChildSample.
private SampleResult createChildSample() throws MessagingException, IOException {
SampleResult child = new SampleResult();
child.setSampleLabel("Message " + msg.getMessageNumber());
child.setContentType(msg.getContentType());
child.setEncodingAndType(msg.getContentType());
ByteArrayOutputStream outbuf = new ByteArrayOutputStream();
msg.writeTo(outbuf);
child.setResponseData(outbuf.toByteArray());
child.setDataType(SampleResult.TEXT);
child.setResponseOK();
return child;
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class TestJSONPathAssertion method testGetResult_null_novalidate.
@Test
void testGetResult_null_novalidate() {
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": null}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval");
instance.setJsonValidationBool(false);
AssertionResult expResult = new AssertionResult("");
AssertionResult result = instance.getResult(samplerResult);
assertEquals(expResult.getName(), result.getName());
assertFalse(result.isFailure());
}
Aggregations