Search in sources :

Example 11 with SampleEvent

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

the class TestCSVSaveService method testSample.

@Test
public // if this test fails, check whether the default was intentionally changed or not
void testSample() {
    final String RESULT = "1,2,3,4,5,6,7,true,,8,9,10,11,12,13,14";
    SampleResult result = new SampleResult();
    result.setSaveConfig(new SampleSaveConfiguration());
    result.setStampAndTime(1, 2);
    result.setSampleLabel("3");
    result.setResponseCode("4");
    result.setResponseMessage("5");
    result.setThreadName("6");
    result.setDataType("7");
    result.setSuccessful(true);
    result.setBytes(8L);
    result.setSentBytes(9);
    result.setGroupThreads(10);
    result.setAllThreads(11);
    result.setLatency(12);
    result.setIdleTime(13);
    result.setConnectTime(14);
    assertEquals("Result text has changed", RESULT, CSVSaveService.resultToDelimitedString(new SampleEvent(result, "")));
}
Also used : SampleSaveConfiguration(org.apache.jmeter.samplers.SampleSaveConfiguration) SampleResult(org.apache.jmeter.samplers.SampleResult) SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 12 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();
    Assert.assertNotNull(fileName);
    Assert.assertEquals("00001.unknown", fileName);
    File file = new File(FileServer.getDefaultBase(), fileName);
    Assert.assertTrue(file.exists());
    Assert.assertTrue(file.delete());
    Assert.assertEquals("00001.unknown", vars.get("myVar"));
}
Also used : File(java.io.File) SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 13 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();
    Assert.assertNotNull(fileName);
    Assert.assertEquals("00001.unknown", fileName);
    File file = new File(FileServer.getDefaultBase(), fileName);
    Assert.assertTrue(file.exists());
    Assert.assertTrue(file.delete());
}
Also used : File(java.io.File) SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 14 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)

Example 15 with SampleEvent

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

the class TestResultAction method testOnFailureStopTest.

@Test
public void testOnFailureStopTest() {
    sampleResult.setSuccessful(false);
    resultAction.setErrorAction(ResultAction.ON_ERROR_STOPTEST);
    resultAction.sampleOccurred(new SampleEvent(sampleResult, "JUnit-TG"));
    Assert.assertTrue(sampleResult.isStopTest());
    Assert.assertFalse(sampleResult.isStopTestNow());
    Assert.assertFalse(sampleResult.isStopThread());
    Assert.assertFalse(sampleResult.isStartNextThreadLoop());
}
Also used : SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Aggregations

SampleEvent (org.apache.jmeter.samplers.SampleEvent)17 Test (org.junit.Test)10 File (java.io.File)3 SampleResult (org.apache.jmeter.samplers.SampleResult)3 SampleSaveConfiguration (org.apache.jmeter.samplers.SampleSaveConfiguration)2 StatisticalSampleResult (org.apache.jmeter.samplers.StatisticalSampleResult)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 Date (java.util.Date)1 Arguments (org.apache.jmeter.config.Arguments)1 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)1 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)1