Search in sources :

Example 96 with SampleResult

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());
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 97 with SampleResult

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;
}
Also used : JMeterContext(org.apache.jmeter.threads.JMeterContext) Sampler(org.apache.jmeter.samplers.Sampler) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 98 with SampleResult

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());
        }
    }
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 99 with SampleResult

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);
}
Also used : JMeterContext(org.apache.jmeter.threads.JMeterContext) Sampler(org.apache.jmeter.samplers.Sampler) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 100 with SampleResult

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;
}
Also used : MessagingException(javax.mail.MessagingException) MimeMessage(javax.mail.internet.MimeMessage) ByteArrayInputStream(java.io.ByteArrayInputStream) SampleResult(org.apache.jmeter.samplers.SampleResult) Properties(java.util.Properties) Session(javax.mail.Session)

Aggregations

SampleResult (org.apache.jmeter.samplers.SampleResult)379 Test (org.junit.Test)83 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)71 Test (org.junit.jupiter.api.Test)59 JMeterContext (org.apache.jmeter.threads.JMeterContext)47 BeforeEach (org.junit.jupiter.api.BeforeEach)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 SampleEvent (org.apache.jmeter.samplers.SampleEvent)30 Sampler (org.apache.jmeter.samplers.Sampler)30 AssertionResult (org.apache.jmeter.assertions.AssertionResult)27 ArrayList (java.util.ArrayList)26 CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)20 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)20 IOException (java.io.IOException)17 Arguments (org.apache.jmeter.config.Arguments)16 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 CorrectedResultCollector (kg.apc.jmeter.vizualizers.CorrectedResultCollector)12 URL (java.net.URL)9 File (java.io.File)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7