Package org.apache.jmeter.samplers

Examples of org.apache.jmeter.samplers.SampleSaveConfiguration


        if (parts == null) {
            return null; // failed to recognise the header
        }

        // We know the column names all exist, so create the config
        SampleSaveConfiguration saveConfig=new SampleSaveConfiguration(false);

        int varCount = 0;
        for(int i=0;i<parts.length;i++){
            String label = parts[i];
            if (isVariableName(label)){
                varCount++;
            } else {
                Functor set = (Functor) headerLabelMethods.get(label);
                set.invoke(saveConfig,new Boolean[]{Boolean.TRUE});
            }
        }

        if (delim != null){
            log.warn("Default delimiter '"+_saveConfig.getDelimiter()+"' did not work; using alternate '"+delim+"' for reading "+filename);
            saveConfig.setDelimiter(delim);
        }

        saveConfig.setVarCount(varCount);

        return saveConfig;
    }
View Full Code Here


        }

        StringQuoter text = new StringQuoter(delimiter.charAt(0));

        SampleResult sample = event.getResult();
        SampleSaveConfiguration saveConfig = sample.getSaveConfig();

        if (saveConfig.saveTimestamp()) {
            if (saveConfig.printMilliseconds()){
                text.append(sample.getTimeStamp());
            } else if (saveConfig.formatter() != null) {
                String stamp = saveConfig.formatter().format(new Date(sample.getTimeStamp()));
                text.append(stamp);
            }
        }

        if (saveConfig.saveTime()) {
            text.append(sample.getTime());
        }

        if (saveConfig.saveLabel()) {
            text.append(sample.getSampleLabel());
        }

        if (saveConfig.saveCode()) {
            text.append(sample.getResponseCode());
        }

        if (saveConfig.saveMessage()) {
            text.append(sample.getResponseMessage());
        }

        if (saveConfig.saveThreadName()) {
            text.append(sample.getThreadName());
        }

        if (saveConfig.saveDataType()) {
            text.append(sample.getDataType());
        }

        if (saveConfig.saveSuccess()) {
            text.append(sample.isSuccessful());
        }

        if (saveConfig.saveAssertionResultsFailureMessage()) {
            String message = null;
            AssertionResult[] results = sample.getAssertionResults();

            if (results != null) {
                // Find the first non-null message
                for (int i = 0; i < results.length; i++){
                    message = results[i].getFailureMessage();
                    if (message != null) {
                        break;
                    }
                }
            }

            if (message != null) {
                text.append(message);
            } else {
                text.append(""); // Need to append something so delimiter is added
            }
        }

        if (saveConfig.saveBytes()) {
            text.append(sample.getBytes());
        }

        if (saveConfig.saveThreadCounts()) {
            text.append(sample.getGroupThreads());
            text.append(sample.getAllThreads());
        }
        if (saveConfig.saveUrl()) {
            text.append(sample.getURL());
        }

        if (saveConfig.saveFileName()) {
            text.append(sample.getResultFileName());
        }

        if (saveConfig.saveLatency()) {
            text.append(sample.getLatency());
        }

        if (saveConfig.saveEncoding()) {
            text.append(sample.getDataEncodingWithDefault());
        }

        if (saveConfig.saveSampleCount()) {// Need both sample and error count to be any use
            text.append(sample.getSampleCount());
            text.append(sample.getErrorCount());
        }

        if (saveConfig.saveHostname()) {
            text.append(event.getHostname());
        }

        for (int i=0; i < SampleEvent.getVarCount(); i++){
            text.append(event.getVarValue(i));
View Full Code Here

    }

    public ResultCollector(Summariser summer) {
        setErrorLogging(false);
        setSuccessOnlyLogging(false);
        setProperty(new ObjectProperty(SAVE_CONFIG, new SampleSaveConfiguration()));
        summariser = summer;
    }
View Full Code Here

        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);
                    }
View Full Code Here

     */
    public SampleSaveConfiguration getSaveConfig() {
        try {
            return (SampleSaveConfiguration) getProperty(SAVE_CONFIG).getObjectValue();
        } catch (ClassCastException e) {
            setSaveConfig(new SampleSaveConfiguration());
            return getSaveConfig();
        }
    }
View Full Code Here

            String line = dataReader.readLine();
            if (line == null){
                throw new IOException(filename+": unable to read header line");
            }
            long lineNumber=1;
            SampleSaveConfiguration saveConfig = CSVSaveService.getSampleSaveConfiguration(line,filename);
            if (saveConfig == null) {// not a valid header
                log.info(filename+" does not appear to have a valid header. Using default configuration.");
                saveConfig = (SampleSaveConfiguration) resultCollector.getSaveConfig().clone(); // may change the format later
                dataReader.reset(); // restart from beginning
                lineNumber = 0;
            }
            String [] parts;
            final char delim = saveConfig.getDelimiter().charAt(0);
            // TODO: does it matter that an empty line will terminate the loop?
            // CSV output files should never contain empty lines, so probably not
            // If so, then need to check whether the reader is at EOF
            while ((parts = csvReadFile(dataReader, delim)).length != 0) {
                lineNumber++;
View Full Code Here

        if (parts == null) {
            return null; // failed to recognise the header
        }

        // We know the column names all exist, so create the config
        SampleSaveConfiguration saveConfig=new SampleSaveConfiguration(false);

        int varCount = 0;
        for(int i=0;i<parts.length;i++){
            String label = parts[i];
            if (isVariableName(label)){
                varCount++;
            } else {
                Functor set = (Functor) headerLabelMethods.get(label);
                set.invoke(saveConfig,new Boolean[]{Boolean.TRUE});
            }
        }

        if (delim != null){
            log.warn("Default delimiter '"+_saveConfig.getDelimiter()+"' did not work; using alternate '"+delim+"' for reading "+filename);
            saveConfig.setDelimiter(delim);
        }

        saveConfig.setVarCount(varCount);

        return saveConfig;
    }
View Full Code Here

        }

        StringQuoter text = new StringQuoter(delimiter.charAt(0));

        SampleResult sample = event.getResult();
        SampleSaveConfiguration saveConfig = sample.getSaveConfig();

        if (saveConfig.saveTimestamp()) {
            if (saveConfig.printMilliseconds()){
                text.append(sample.getTimeStamp());
            } else if (saveConfig.formatter() != null) {
                String stamp = saveConfig.formatter().format(new Date(sample.getTimeStamp()));
                text.append(stamp);
            }
        }

        if (saveConfig.saveTime()) {
            text.append(sample.getTime());
        }

        if (saveConfig.saveLabel()) {
            text.append(sample.getSampleLabel());
        }

        if (saveConfig.saveCode()) {
            text.append(sample.getResponseCode());
        }

        if (saveConfig.saveMessage()) {
            text.append(sample.getResponseMessage());
        }

        if (saveConfig.saveThreadName()) {
            text.append(sample.getThreadName());
        }

        if (saveConfig.saveDataType()) {
            text.append(sample.getDataType());
        }

        if (saveConfig.saveSuccess()) {
            text.append(sample.isSuccessful());
        }

        if (saveConfig.saveAssertionResultsFailureMessage()) {
            String message = null;
            AssertionResult[] results = sample.getAssertionResults();

            if (results != null) {
                // Find the first non-null message
                for (int i = 0; i < results.length; i++){
                    message = results[i].getFailureMessage();
                    if (message != null) {
                        break;
                    }
                }
            }

            if (message != null) {
                text.append(message);
            } else {
                text.append(""); // Need to append something so delimiter is added
            }
        }

        if (saveConfig.saveBytes()) {
            text.append(sample.getBytes());
        }

        if (saveConfig.saveThreadCounts()) {
            text.append(sample.getGroupThreads());
            text.append(sample.getAllThreads());
        }
        if (saveConfig.saveUrl()) {
            text.append(sample.getURL());
        }

        if (saveConfig.saveFileName()) {
            text.append(sample.getResultFileName());
        }

        if (saveConfig.saveLatency()) {
            text.append(sample.getLatency());
        }

        if (saveConfig.saveEncoding()) {
            text.append(sample.getDataEncodingWithDefault());
        }

        if (saveConfig.saveSampleCount()) {// Need both sample and error count to be any use
            text.append(sample.getSampleCount());
            text.append(sample.getErrorCount());
        }

        if (saveConfig.saveHostname()) {
            text.append(event.getHostname());
        }

        for (int i=0; i < SampleEvent.getVarCount(); i++){
            text.append(event.getVarValue(i));
View Full Code Here

     *      com.thoughtworks.xstream.converters.MarshallingContext)
     */
    public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) {
        super.marshal(obj, writer, context); // Save most things

        SampleSaveConfiguration prop = (SampleSaveConfiguration) obj;

        // Save the new fields - but only if they are not the default
        createNode(writer,prop.saveBytes(),NODE_BYTES);
        createNode(writer,prop.saveUrl(),NODE_URL);
        createNode(writer,prop.saveFileName(),NODE_FILENAME);
        createNode(writer,prop.saveHostname(),NODE_HOSTNAME);
        createNode(writer,prop.saveThreadCounts(),NODE_THREAD_COUNT);
        createNode(writer,prop.saveSampleCount(),NODE_SAMPLE_COUNT);
    }
View Full Code Here

        final Class thisClass = SampleSaveConfiguration.class;
        final Class requiredType = context.getRequiredType();
        if (requiredType != thisClass) {
            throw new IllegalArgumentException("Unexpected class: "+requiredType.getName());
        }
        SampleSaveConfiguration result = new SampleSaveConfiguration();
        result.setBytes(false); // Maintain backward compatibility (bytes was not in the JMX 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);
View Full Code Here

TOP

Related Classes of org.apache.jmeter.samplers.SampleSaveConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.