Examples of SampleSaveConfiguration


Examples of org.apache.jmeter.samplers.SampleSaveConfiguration

  public ResultCollector() {
    // current = -1;
    // serializer = new DefaultConfigurationSerializer();
    setErrorLogging(false);
    setSuccessOnlyLogging(false);
    setProperty(new ObjectProperty(SAVE_CONFIG, new SampleSaveConfiguration()));
  }
View Full Code Here

Examples of org.apache.jmeter.samplers.SampleSaveConfiguration

    SampleResult result = event.getResult();

    if (isSampleWanted(result.isSuccessful())) {
      sendToVisualizer(result);
      if ( out != null) {// no point otherwise
        SampleSaveConfiguration config = getSaveConfig();
        result.setSaveConfig(config);
        try {
          if (config.saveAsXml()) {
            recordResult(event);
          } else {
            String savee = CSVSaveService.resultToDelimitedString(event);
            out.println(savee);
          }
View Full Code Here

Examples of org.apache.jmeter.samplers.SampleSaveConfiguration

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

Examples of org.apache.jmeter.samplers.SampleSaveConfiguration

      dataReader = new BufferedReader(new FileReader(filename));
      dataReader.mark(400);// Enough to read the header column names
      // Get the first line, and see if it is the header
      String line = dataReader.readLine();
      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;
      while ((parts = csvReadFile(dataReader, saveConfig.getDelimiter().charAt(0))).length != 0) {
        lineNumber++;
        SampleEvent event = CSVSaveService.makeResultFromDelimitedString(parts,saveConfig,lineNumber);
        if (event != null){
          final SampleResult result = event.getResult();
          if (resultCollector.isSampleWanted(result.isSuccessful())) {
View Full Code Here

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

Examples of org.apache.jmeter.samplers.SampleSaveConfiguration

      }
     
      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

Examples of org.apache.jmeter.samplers.SampleSaveConfiguration

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

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

Examples of org.apache.jmeter.samplers.SampleSaveConfiguration

    public static String resultToDelimitedString(SampleEvent event,
            final String delimiter) {
        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());
        }

        if (saveConfig.saveIdleTime()) {
            text.append(event.getResult().getIdleTime());
        }

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

Examples of org.apache.jmeter.samplers.SampleSaveConfiguration

   *      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.saveThreadCounts(),NODE_THREAD_COUNT);
        createNode(writer,prop.saveSampleCount(),NODE_SAMPLE_COUNT);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.