use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class TestJSONPathAssertion method testGetResult_null.
@Test
void testGetResult_null() {
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": null}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval");
instance.setExpectNull(true);
instance.setJsonValidationBool(true);
AssertionResult expResult = new AssertionResult("");
AssertionResult result = instance.getResult(samplerResult);
assertEquals(expResult.getName(), result.getName());
assertFalse(result.isFailure());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class CompoundVariable method execute.
public String execute() {
if (isDynamic || permanentResults == null) {
JMeterContext context = JMeterContextService.getContext();
SampleResult previousResult = context.getPreviousResult();
Sampler currentSampler = context.getCurrentSampler();
return execute(previousResult, currentSampler);
}
// $NON-NLS-1$
return permanentResults;
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class TransactionController method sampleOccurred.
@Override
public void sampleOccurred(SampleEvent se) {
if (!isGenerateParentSample()) {
// Check if we are still sampling our children
if (res != null && !se.isTransactionSampleEvent()) {
SampleResult sampleResult = se.getResult();
res.setThreadName(sampleResult.getThreadName());
res.setBytes(res.getBytesAsLong() + sampleResult.getBytesAsLong());
res.setSentBytes(res.getSentBytes() + sampleResult.getSentBytes());
if (!isIncludeTimers()) {
// Accumulate waiting time for later
pauseTime += sampleResult.getEndTime() - sampleResult.getTime() - prevEndTime;
prevEndTime = sampleResult.getEndTime();
}
if (!sampleResult.isSuccessful()) {
res.setSuccessful(false);
noFailingSamples++;
}
res.setAllThreads(sampleResult.getAllThreads());
res.setGroupThreads(sampleResult.getGroupThreads());
res.setLatency(res.getLatency() + sampleResult.getLatency());
res.setConnectTime(res.getConnectTime() + sampleResult.getConnectTime());
}
}
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class AbstractFunction method execute.
public String execute() throws InvalidVariableException {
JMeterContext context = JMeterContextService.getContext();
SampleResult previousResult = context.getPreviousResult();
Sampler currentSampler = context.getCurrentSampler();
return execute(previousResult, currentSampler);
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.
the class SMIMEAssertion method getMessageFromResponse.
/**
* extracts a MIME message from the SampleResult
*/
private static MimeMessage getMessageFromResponse(SampleResult response, int messageNumber) throws MessagingException {
SampleResult[] subResults = response.getSubResults();
if (messageNumber >= subResults.length || messageNumber < 0) {
throw new MessagingException("Message number not present in results: " + messageNumber);
}
final SampleResult sampleResult = subResults[messageNumber];
if (log.isDebugEnabled()) {
log.debug("Bytes: {}, Content Type: {}", sampleResult.getBytesAsLong(), sampleResult.getContentType());
}
byte[] data = sampleResult.getResponseData();
Session session = Session.getDefaultInstance(new Properties());
MimeMessage msg = new MimeMessage(session, new ByteArrayInputStream(data));
if (log.isDebugEnabled()) {
log.debug("msg.getSize() = {}", msg.getSize());
}
return msg;
}
Aggregations