Search in sources :

Example 6 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 7 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 8 with SampleSaveConfiguration

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, "")));
}
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 9 with SampleSaveConfiguration

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

Aggregations

SampleSaveConfiguration (org.apache.jmeter.samplers.SampleSaveConfiguration)9 SampleResult (org.apache.jmeter.samplers.SampleResult)5 IOException (java.io.IOException)2 SampleEvent (org.apache.jmeter.samplers.SampleEvent)2 StatisticalSampleResult (org.apache.jmeter.samplers.StatisticalSampleResult)2 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 Date (java.util.Date)1 AssertionResult (org.apache.jmeter.assertions.AssertionResult)1 HTTPSampleResult (org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)1 Functor (org.apache.jorphan.reflect.Functor)1 Pattern (org.apache.oro.text.regex.Pattern)1 PatternMatcherInput (org.apache.oro.text.regex.PatternMatcherInput)1 Perl5Matcher (org.apache.oro.text.regex.Perl5Matcher)1 Test (org.junit.Test)1