Search in sources :

Example 31 with SampleEvent

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

the class AggregateReportGuiTest method testAdd.

/**
 * Test of add method, of class StatVisualizerAccessorGui.
 */
@Test
public void testAdd() throws IOException {
    System.out.println("add");
    AggregateReportGui instance = new AggregateReportGui();
    SampleResult res = new SampleResult();
    instance.add(res);
    SampleResult res2 = new SampleResult();
    instance.add(res2);
    ResultCollector rc = new ResultCollector();
    rc.setListener(instance);
    rc.sampleOccurred(new SampleEvent(res, ""));
    rc.sampleOccurred(new SampleEvent(res2, ""));
    File f = File.createTempFile("test", ".csv");
    instance.getGraphPanelChart().saveGraphToCSV(f);
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) ResultCollector(org.apache.jmeter.reporters.ResultCollector) File(java.io.File) SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 32 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 33 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent in project jmeter by apache.

the class TestResultSaver method testSuccess.

@Test
public void testSuccess() {
    sampleResult.setSuccessful(true);
    resultSaver.setProperty(ResultSaver.NUMBER_PAD_LENGTH, "5");
    resultSaver.testStarted();
    resultSaver.sampleOccurred(new SampleEvent(sampleResult, "JUnit-TG"));
    String fileName = sampleResult.getResultFileName();
    assertNotNull(fileName);
    assertEquals("00001.unknown", fileName);
    File file = new File(FileServer.getDefaultBase(), fileName);
    assertTrue(file.exists());
    assertTrue(file.delete());
}
Also used : File(java.io.File) SampleEvent(org.apache.jmeter.samplers.SampleEvent) JMeterSerialTest(org.apache.jorphan.test.JMeterSerialTest) Test(org.junit.jupiter.api.Test)

Example 34 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent in project jmeter by apache.

the class TestResultSaver method testFailureSaveErrorsOnly.

@Test
public void testFailureSaveErrorsOnly() {
    sampleResult.setSuccessful(true);
    resultSaver.setProperty(ResultSaver.NUMBER_PAD_LENGTH, "5");
    resultSaver.setProperty(ResultSaver.VARIABLE_NAME, "myVar");
    resultSaver.setProperty(ResultSaver.ERRORS_ONLY, "true");
    resultSaver.testStarted();
    sampleResult.setSuccessful(false);
    resultSaver.sampleOccurred(new SampleEvent(sampleResult, "JUnit-TG"));
    String fileName = sampleResult.getResultFileName();
    assertNotNull(fileName);
    assertEquals("00001.unknown", fileName);
    File file = new File(FileServer.getDefaultBase(), fileName);
    assertTrue(file.exists());
    assertTrue(file.delete());
    assertEquals("00001.unknown", vars.get("myVar"));
}
Also used : File(java.io.File) SampleEvent(org.apache.jmeter.samplers.SampleEvent) JMeterSerialTest(org.apache.jorphan.test.JMeterSerialTest) Test(org.junit.jupiter.api.Test)

Example 35 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent in project jmeter by apache.

the class JMeterThread method notifyListeners.

private void notifyListeners(List<SampleListener> listeners, SampleResult result) {
    SampleEvent event = new SampleEvent(result, threadGroup.getName(), threadVars);
    notifier.notifyListeners(event, listeners);
}
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