use of org.apache.jmeter.samplers.SampleSaveConfiguration in project jmeter by apache.
the class SampleSaveConfigurationConverter method unmarshal.
/** {@inheritDoc} */
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
final Class<SampleSaveConfiguration> thisClass = SampleSaveConfiguration.class;
final Class<?> requiredType = context.getRequiredType();
if (requiredType != thisClass) {
throw new IllegalArgumentException("Unexpected class: " + requiredType.getName());
}
// The default for missing tags is false, so preset all the fields accordingly
SampleSaveConfiguration result = new SampleSaveConfiguration(false);
// Now pick up any tags from the input file
while (reader.hasMoreChildren()) {
reader.moveDown();
String nn = reader.getNodeName();
if (!"formatter".equals(nn)) {
// Skip formatter (if present) bug 42674 $NON-NLS-1$
String fieldName = mapper.realMember(thisClass, nn);
java.lang.reflect.Field field = reflectionProvider.getField(thisClass, fieldName);
Class<?> type = field.getType();
Object value = unmarshallField(context, result, type, field);
reflectionProvider.writeField(result, nn, value, thisClass);
}
reader.moveUp();
}
return result;
}
use of org.apache.jmeter.samplers.SampleSaveConfiguration in project jmeter by apache.
the class HTTPResultConverter method marshal.
/** {@inheritDoc} */
@Override
public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) {
HTTPSampleResult res = (HTTPSampleResult) obj;
SampleSaveConfiguration save = res.getSaveConfig();
setAttributes(writer, context, res, save);
saveAssertions(writer, context, res, save);
saveSubResults(writer, context, res, save);
saveResponseHeaders(writer, context, res, save);
saveRequestHeaders(writer, context, res, save);
saveResponseData(writer, context, res, save);
saveSamplerData(writer, context, res, save);
}
use of org.apache.jmeter.samplers.SampleSaveConfiguration 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.SampleSaveConfiguration in project jmeter by apache.
the class ResultCollector method sampleOccurred.
/**
* When a test result is received, display it and save it.
*
* @param event
* the sample event that was received
*/
@Override
public void sampleOccurred(SampleEvent event) {
SampleResult result = event.getResult();
if (isSampleWanted(result.isSuccessful())) {
sendToVisualizer(result);
if (out != null && !isResultMarked(result) && !this.isStats) {
SampleSaveConfiguration config = getSaveConfig();
result.setSaveConfig(config);
try {
if (config.saveAsXml()) {
SaveService.saveSampleResult(event, out);
} else {
// !saveAsXml
String savee = CSVSaveService.resultToDelimitedString(event);
out.println(savee);
}
} catch (Exception err) {
// should throw exception back to caller
log.error("Error trying to record a sample", err);
}
}
}
if (summariser != null) {
summariser.sampleOccurred(event);
}
}
Aggregations