Search in sources :

Example 36 with SampleResult

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

the class DummySamplerTest method testSample.

@Test
public void testSample() {
    System.out.println("sample");
    String data = "test";
    DummySampler instance = new DummySampler();
    instance.setResponseData(data);
    SampleResult result = instance.sample(null);
    Assert.assertEquals(data, result.getResponseDataAsString());
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Example 37 with SampleResult

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

the class FlexibleFileWriterTest method testSampleOccurred.

@Test
public void testSampleOccurred() throws IOException {
    System.out.println("sampleOccurred");
    SampleResult res = new SampleResult();
    res.setResponseData("test".getBytes());
    SampleEvent e = new SampleEvent(res, "Test");
    FlexibleFileWriter instance = new FlexibleFileWriter();
    instance.setColumns("isSuccsessful|\\t||\\t|latency");
    String tmpFile = File.createTempFile("ffw_test_", ".txt").getAbsolutePath();
    instance.setFilename(tmpFile);
    instance.testStarted();
    for (int n = 0; n < 10; n++) {
        String exp = "0\t|\t" + n;
        System.out.println(exp);
        res.setLatency(n);
        res.setSampleLabel("n" + n);
        instance.sampleOccurred(e);
    // ByteBuffer written = instance.fileEmul.getWrittenBytes();
    // assertEquals(exp, JMeterPluginsUtils.byteBufferToString(written));
    }
    instance.testEnded();
    assertTrue(tmpFile.length() > 0);
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 38 with SampleResult

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

the class FlexibleFileWriterTest method testSampleOccurred_var.

@Test
public void testSampleOccurred_var() throws IOException {
    System.out.println("sampleOccurred-var");
    SampleResult res = new SampleResult();
    res.setResponseData("test".getBytes());
    JMeterVariables vars = new JMeterVariables();
    vars.put("TEST1", "TEST");
    SampleEvent e = new SampleEvent(res, "Test", vars);
    FlexibleFileWriter instance = new FlexibleFileWriter();
    instance.setFilename(File.createTempFile("ffw_test_", ".txt").getAbsolutePath());
    System.out.println("prop: " + JMeterUtils.getProperty("sample_variables"));
    System.out.println("count: " + SampleEvent.getVarCount());
    instance.setColumns("variable#0| |variable#| |variable#4t");
    instance.testStarted();
    for (int n = 0; n < 10; n++) {
        String exp = "TEST variable# variable#4t";
        System.out.println(exp);
        instance.sampleOccurred(e);
    // ByteBuffer written = instance.fileEmul.getWrittenBytes();
    // assertEquals(exp, JMeterPluginsUtils.byteBufferToString(written));
    }
    instance.testEnded();
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) SampleResult(org.apache.jmeter.samplers.SampleResult) SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 39 with SampleResult

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

the class FlexibleFileWriterTest method testSampleOccurred_labels.

@Test
public void testSampleOccurred_labels() throws IOException {
    System.out.println("sampleOccurred_labels");
    SampleResult res = new SampleResult();
    res.setResponseData("test".getBytes());
    FlexibleFileWriter instance = new FlexibleFileWriter();
    instance.setFilename(File.createTempFile("ffw_test_", ".txt").getAbsolutePath());
    instance.setColumns("threadName|\\t|sampleLabel");
    instance.testStarted();
    res.setSampleLabel("SAMPLELBL");
    res.setThreadName("THRDNAME");
    SampleEvent e = new SampleEvent(res, "Test");
    instance.sampleOccurred(e);
    // ByteBuffer written = instance.fileEmul.getWrittenBytes();
    // assertEquals(exp, JMeterPluginsUtils.byteBufferToString(written));
    instance.testEnded();
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 40 with SampleResult

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

the class DbMonSampleResultTest method testGetValue_SampleResult.

/**
 * Test of getValue method, of class DbMonSampleResult.
 */
@Test
public void testGetValue_SampleResult() {
    System.out.println("getValue");
    SampleResult res = new SampleResult();
    res.setResponseMessage("0");
    double expResult = 0.0;
    double result = DbMonSampleResult.getValue(res);
    assertEquals(expResult, result, 0.0);
// TODO review the generated test code and remove the default call to fail.
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

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