Search in sources :

Example 1 with SampleEvent

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

the class JMXMonCollector method generateSample.

@Override
public void generateSample(double value, String label) {
    JMXMonSampleResult res = new JMXMonSampleResult();
    res.setSampleLabel(label);
    res.setValue(value);
    res.setSuccessful(true);
    SampleEvent e = new SampleEvent(res, JMXMON);
    jmxMonSampleOccurred(e);
}
Also used : SampleEvent(org.apache.jmeter.samplers.SampleEvent)

Example 2 with SampleEvent

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

the class MonitoringResultsCollector method generateSample.

@Override
public void generateSample(double value, String label) {
    MonitoringSampleResult res = new MonitoringSampleResult();
    res.setSampleLabel(label);
    res.setValue(value);
    res.setSuccessful(true);
    SampleEvent e = new SampleEvent(res, getPrefix());
    monitoringSampleOccurred(e);
}
Also used : SampleEvent(org.apache.jmeter.samplers.SampleEvent)

Example 3 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent 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 4 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent 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 5 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent 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)

Aggregations

SampleEvent (org.apache.jmeter.samplers.SampleEvent)57 SampleResult (org.apache.jmeter.samplers.SampleResult)30 Test (org.junit.Test)16 CorrectedResultCollector (kg.apc.jmeter.vizualizers.CorrectedResultCollector)12 Test (org.junit.jupiter.api.Test)10 File (java.io.File)5 JMeterSerialTest (org.apache.jorphan.test.JMeterSerialTest)4 SampleSaveConfiguration (org.apache.jmeter.samplers.SampleSaveConfiguration)3 IOException (java.io.IOException)2 ResultCollector (org.apache.jmeter.reporters.ResultCollector)2 StatisticalSampleResult (org.apache.jmeter.samplers.StatisticalSampleResult)2 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 URL (java.net.URL)1