org.apache.jmeter.save.CSVSaveService Java Examples

The following examples show how to use org.apache.jmeter.save.CSVSaveService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RandomCSVReader.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
private void initOffsets() throws IOException {
    offsets = new ArrayList<>();
    if (!isSkipFirstLine) {
        offsets.add(0);
    }
    LOGGER.info("Start reading the file: " + file.getAbsolutePath());
    try (BufferedReaderExt reader = new BufferedReaderExt(createReader(), encoding)) {
        long fileSize = file.length();
        while (reader.getPos() < fileSize) {
            CSVSaveService.csvReadFile(reader, delim);
            if (reader.getPos() < fileSize) {
                offsets.add(reader.getPos());
            }
        }
    }
    LOGGER.info("Reading finished. Found " + offsets.size() + " records in your csv file");
}
 
Example #2
Source File: MergeResultsService.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private static void writeFileStart(PrintWriter writer,
        SampleSaveConfiguration saveConfig) {
    if (saveConfig.saveAsXml()) {
        writer.print(XML_HEADER);
        // Write the EOL separately so we generate LF line ends on Unix and
        // Windows
        writer.print("\n"); 
        String pi = saveConfig.getXmlPi();
        if (pi.length() > 0) {
            writer.println(pi);
        }
        writer.print(TESTRESULTS_START_V1_1_PREVER);
        writer.print(SaveService.getVERSION());
        writer.print(TESTRESULTS_START_V1_1_POSTVER);
        // Write the EOL separately so we generate LF line ends on Unix and
        // Windows
        writer.print("\n"); 
    } else if (saveConfig.saveFieldNames()) {
        writer.println(CSVSaveService
                .printableFieldNamesToString(saveConfig));
    }
}
 
Example #3
Source File: SynthesisReportGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    if (ev.getSource() == saveTable) {
        JFileChooser chooser = FileDialoger
                .promptToSaveFile("synthesis.csv");
        if (chooser == null) {
            return;
        }
        FileWriter writer = null;
        try {
            writer = new FileWriter(chooser.getSelectedFile()); // TODO
            // Charset ?
            CSVSaveService.saveCSVStats(getAllDataAsTable(model, FORMATS, getLabels(COLUMNS)), writer, saveHeaders.isSelected());
        } catch (IOException e) {
            log.warn(e.getMessage());
        } finally {
            JOrphanUtils.closeQuietly(writer);
        }
    }
}
 
Example #4
Source File: SynthesisReportGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void saveGraphToCSV(File file) throws IOException {
    log.info("Saving CSV to " + file.getAbsolutePath());

    FileWriter writer = null;
    try {
        writer = new FileWriter(file);
        CSVSaveService.saveCSVStats(getAllDataAsTable(model, FORMATS, getLabels(COLUMNS)), writer, saveHeaders.isSelected());
    } catch (IOException e) {
        log.warn(e.getMessage());
    } finally {
        try {
            if (writer != null) {
                writer.close();
            }
        } catch (IOException ex) {
            log.warn("There was problem closing file stream", ex);
        }
    }
}
 
Example #5
Source File: AggregateReportGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void saveGraphToCSV(File file) throws IOException {
    log.info("Saving CSV to " + file.getAbsolutePath());

    FileWriter writer = null;
    try {
        writer = new FileWriter(file);
        CSVSaveService.saveCSVStats(SynthesisReportGui.getAllDataAsTable(statModel, FORMATS, getLabels(COLUMNS)), writer, saveHeaders.isSelected());
    } catch (IOException e) {
        log.warn(e.getMessage());
    } finally {
        try {
            writer.close();
        } catch (IOException ex) {
            log.warn("There was problem closing file stream", ex);
        }
    }
}
 
Example #6
Source File: RandomCSVReader.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private void initHeader() {
    try (BufferedReader reader = new BufferedReader(createReader())) {
        header = CSVSaveService.csvReadFile(reader, delim);
    } catch (IOException ex) {
        LOGGER.error("Cannot read CSV header ", ex);
        throw new RuntimeException("Cannot read CSV header: " + ex.getMessage(), ex);
    }
}
 
Example #7
Source File: RandomCSVReader.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
public String[] readNextLine() {
    try {
        curPos++;
        return CSVSaveService.csvReadFile(consistentReader, delim);
    } catch (IOException ex) {
        LOGGER.error("Cannot get next record from csv file: ", ex);
        throw new RuntimeException("Cannot get next record from csv file: " + ex.getMessage(), ex);
    }
}