Search in sources :

Example 56 with SampleEvent

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

the class MergeResultsService method mergeSamples.

public void mergeSamples(CorrectedResultCollector crc, List<SampleResult> samples) {
    SampleEvent event;
    try {
        initializeFileOutput(crc.getFilename(), crc.getSaveConfig());
    } catch (IOException e) {
        log.warn("Error trying to initialize output file " + e.toString());
    }
    for (SampleResult result : samples) {
        SampleSaveConfiguration config = crc.getSaveConfig();
        event = new SampleEvent(result, null);
        try {
            if (config.saveAsXml()) {
                SaveService.saveSampleResult(event, out);
            } else {
                // !saveAsXml
                String savee = CSVSaveService.resultToDelimitedString(event);
                out.println(savee);
            }
        } catch (Exception err) {
            log.error("Error trying to record a sample", err);
        // should throw exception back to caller
        }
    }
    finalizeFileOutput();
}
Also used : SampleSaveConfiguration(org.apache.jmeter.samplers.SampleSaveConfiguration) SampleResult(org.apache.jmeter.samplers.SampleResult) IOException(java.io.IOException) SampleEvent(org.apache.jmeter.samplers.SampleEvent) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 57 with SampleEvent

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

the class PerfMonCollectorTest method testSampleOccurred.

/**
 * Test of sampleOccurred method, of class PerfMonCollector.
 */
@Test
public void testSampleOccurred() {
    System.out.println("sampleOccurred");
    SampleEvent event = new SampleEvent(new PerfMonSampleResult(), "test");
    PerfMonCollector instance = new PerfMonCollector();
    instance.sampleOccurred(event);
// TODO review the generated test code and remove the default call to fail.
}
Also used : SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 58 with SampleEvent

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

the class PerfMonCollector method generateErrorSample.

@Override
public void generateErrorSample(String label, String errorMsg) {
    PerfMonSampleResult res = new PerfMonSampleResult();
    res.setSampleLabel(label);
    res.setValue(-1L);
    res.setResponseMessage(errorMsg);
    res.setSuccessful(false);
    SampleEvent e = new SampleEvent(res, PERFMON);
    super.sampleOccurred(e);
    log.error("Perfmon plugin error: " + errorMsg);
}
Also used : SampleEvent(org.apache.jmeter.samplers.SampleEvent)

Aggregations

SampleEvent (org.apache.jmeter.samplers.SampleEvent)58 SampleResult (org.apache.jmeter.samplers.SampleResult)30 Test (org.junit.Test)17 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 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)3 IOException (java.io.IOException)2 ResultCollector (org.apache.jmeter.reporters.ResultCollector)2 StatisticalSampleResult (org.apache.jmeter.samplers.StatisticalSampleResult)2 ArrivalsThreadGroupTest (com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroupTest)1 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