Search in sources :

Example 11 with SampleSaveConfiguration

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;
}
Also used : SampleSaveConfiguration(org.apache.jmeter.samplers.SampleSaveConfiguration)

Example 12 with SampleSaveConfiguration

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);
}
Also used : SampleSaveConfiguration(org.apache.jmeter.samplers.SampleSaveConfiguration) HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)

Example 13 with SampleSaveConfiguration

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

the class CorrectedResultCollector method setupSaving.

private void setupSaving() {
    SampleSaveConfiguration conf = getSaveConfig();
    // please, save the threads... it's so important, but disabled by default
    conf.setThreadCounts(true);
}
Also used : SampleSaveConfiguration(org.apache.jmeter.samplers.SampleSaveConfiguration)

Example 14 with SampleSaveConfiguration

use of org.apache.jmeter.samplers.SampleSaveConfiguration 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 15 with SampleSaveConfiguration

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

the class DbMonCollector method setupSaving.

private void setupSaving(String fileName) {
    SampleSaveConfiguration config = getSaveConfig();
    JMeterPluginsUtils.doBestCSVSetup(config);
    setSaveConfig(config);
    setFilename(fileName);
    log.info("DbMon metrics will be stored in " + new File(fileName).getAbsolutePath());
}
Also used : SampleSaveConfiguration(org.apache.jmeter.samplers.SampleSaveConfiguration) File(java.io.File)

Aggregations

SampleSaveConfiguration (org.apache.jmeter.samplers.SampleSaveConfiguration)19 SampleResult (org.apache.jmeter.samplers.SampleResult)7 File (java.io.File)4 IOException (java.io.IOException)3 SampleEvent (org.apache.jmeter.samplers.SampleEvent)3 StatisticalSampleResult (org.apache.jmeter.samplers.StatisticalSampleResult)3 FileNotFoundException (java.io.FileNotFoundException)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 URL (java.net.URL)1 Date (java.util.Date)1 CorrectedResultCollector (kg.apc.jmeter.vizualizers.CorrectedResultCollector)1 AssertionResult (org.apache.jmeter.assertions.AssertionResult)1 LoopController (org.apache.jmeter.control.LoopController)1 StandardJMeterEngine (org.apache.jmeter.engine.StandardJMeterEngine)1 HTTPSampleResult (org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)1