Search in sources :

Example 31 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.

the class IsDefinedTest method testExecute.

@Test
public void testExecute() throws Exception {
    System.out.println("execute 1");
    SampleResult previousResult = null;
    Sampler currentSampler = null;
    Collection<CompoundVariable> parameters = new ArrayList<CompoundVariable>();
    parameters.add(new CompoundVariable("var_to_be_defined1"));
    IsDefined instance = new IsDefined();
    instance.setParameters(parameters);
    String expResult = "0";
    String result = instance.execute(previousResult, currentSampler);
    Assert.assertEquals(expResult, result);
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Sampler(org.apache.jmeter.samplers.Sampler) ArrayList(java.util.ArrayList) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 32 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.

the class LowerCaseTest method testExecute.

/**
 * Test of execute method, of class LowerCase.
 */
@Test
public void testExecute() throws Exception {
    System.out.println("execute");
    Collection<CompoundVariable> parameters = new ArrayList<CompoundVariable>();
    parameters.add(new CompoundVariable("ABC"));
    parameters.add(new CompoundVariable("var"));
    SampleResult previousResult = null;
    Sampler currentSampler = null;
    LowerCase instance = new LowerCase();
    instance.setParameters(parameters);
    String expResult = "abc";
    String result = instance.execute(previousResult, currentSampler);
    Assert.assertEquals(expResult, result);
    Assert.assertEquals(expResult, JMeterContextService.getContext().getVariables().get("var"));
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Sampler(org.apache.jmeter.samplers.Sampler) ArrayList(java.util.ArrayList) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 33 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.

the class MD5Test method testExecute.

/**
 * Test of execute method, of class MD5.
 */
@Test
public void testExecute() throws Exception {
    System.out.println("execute");
    Collection<CompoundVariable> parameters = new ArrayList<CompoundVariable>();
    parameters.add(new CompoundVariable("public void testExecute() throws Exception {}"));
    parameters.add(new CompoundVariable("var"));
    SampleResult previousResult = null;
    Sampler currentSampler = null;
    MD5 instance = new MD5();
    instance.setParameters(parameters);
    String expResult = "cb5b1ca8504cb5a7772f219109e05ccf";
    String result = instance.execute(previousResult, currentSampler);
    Assert.assertEquals(expResult, result);
    Assert.assertEquals(expResult, JMeterContextService.getContext().getVariables().get("var"));
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Sampler(org.apache.jmeter.samplers.Sampler) ArrayList(java.util.ArrayList) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 34 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.

the class ThroughputVsThreadsGuiTest method testAdd.

/**
 * Test of add method, of class ThroughputVsThreadsGui.
 */
@Test
public void testAdd() {
    System.out.println("add");
    ThroughputVsThreadsGui instance = new ThroughputVsThreadsGui();
    instance.add(new SampleResult());
    instance.add(new SampleResult(0, 100));
    instance.add(new SampleResult(0, 100));
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 35 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.

the class ConsoleStatusLogger method sampleOccurred.

@Override
public synchronized void sampleOccurred(SampleEvent se) {
    // TODO: make the interval configurable
    long sec = System.currentTimeMillis() / 1000;
    if (sec != cur && count > 0) {
        if (cur == 0) {
            begin = sec;
        }
        log.debug(cur + " " + begin);
        flush(sec - begin);
        cur = sec;
    }
    SampleResult res = se.getResult();
    count++;
    sumRTime += res.getTime();
    sumLatency += res.getLatency();
    errors += res.isSuccessful() ? 0 : 1;
    threads = res.getAllThreads();
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult)

Aggregations

SampleResult (org.apache.jmeter.samplers.SampleResult)381 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