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, "")));
}
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"));
}
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());
}
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);
}
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());
}
Aggregations