Search in sources :

Example 1 with CSVFileIOException

use of uk.co.automatictester.lightning.exceptions.CSVFileIOException in project lightning by automatictester.

the class JMeterCSVFileReader method getTransactions.

public JMeterTransactions getTransactions(File csvFile) {
    long start = System.currentTimeMillis();
    logger.debug("Reading CSV file - start");
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    try (FileReader fr = new FileReader(csvFile)) {
        jmeterTransactions.addAll(getParser().parseAll(fr));
    } catch (IOException e) {
        throw new CSVFileIOException(e);
    }
    if (jmeterTransactions.isEmpty()) {
        throw new CSVFileNoTransactionsException();
    }
    long finish = System.currentTimeMillis();
    long millisecondsBetween = finish - start;
    logger.debug("Reading CSV file - finish, read {} rows, took {}ms", jmeterTransactions.size(), millisecondsBetween);
    return jmeterTransactions;
}
Also used : FileReader(java.io.FileReader) IOException(java.io.IOException) CSVFileIOException(uk.co.automatictester.lightning.exceptions.CSVFileIOException) CSVFileNoTransactionsException(uk.co.automatictester.lightning.exceptions.CSVFileNoTransactionsException) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) CSVFileIOException(uk.co.automatictester.lightning.exceptions.CSVFileIOException)

Example 2 with CSVFileIOException

use of uk.co.automatictester.lightning.exceptions.CSVFileIOException in project lightning by automatictester.

the class PerfMonS3ObjectDataReader method getDataEntires.

public PerfMonDataEntries getDataEntires(String csvObject) {
    PerfMonDataEntries perfMonDataEntries = new PerfMonDataEntries();
    String csvObjectContent = s3Client.getS3ObjectContent(csvObject);
    try (InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(csvObjectContent.getBytes()))) {
        perfMonDataEntries.addAll(getParser().parseAll(isr));
    } catch (IOException e) {
        throw new CSVFileIOException(e);
    }
    if (perfMonDataEntries.isEmpty()) {
        throw new CSVFileNoTransactionsException();
    }
    return perfMonDataEntries;
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) PerfMonDataEntries(uk.co.automatictester.lightning.data.PerfMonDataEntries) IOException(java.io.IOException) CSVFileIOException(uk.co.automatictester.lightning.exceptions.CSVFileIOException) CSVFileNoTransactionsException(uk.co.automatictester.lightning.exceptions.CSVFileNoTransactionsException) CSVFileIOException(uk.co.automatictester.lightning.exceptions.CSVFileIOException)

Example 3 with CSVFileIOException

use of uk.co.automatictester.lightning.exceptions.CSVFileIOException in project lightning by automatictester.

the class JMeterCSVS3ObjectReader method getTransactions.

public JMeterTransactions getTransactions(String csvObject) {
    long start = System.currentTimeMillis();
    log.debug("Reading CSV file - start");
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    String csvObjectContent = s3Client.getS3ObjectContent(csvObject);
    try (InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(csvObjectContent.getBytes()))) {
        jmeterTransactions.addAll(getParser().parseAll(isr));
    } catch (IOException e) {
        throw new CSVFileIOException(e);
    }
    if (jmeterTransactions.isEmpty()) {
        throw new CSVFileNoTransactionsException();
    }
    long finish = System.currentTimeMillis();
    long millisecondsBetween = finish - start;
    log.debug("Reading CSV file - finish, read {} rows, took {}ms", jmeterTransactions.size(), millisecondsBetween);
    return jmeterTransactions;
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) CSVFileIOException(uk.co.automatictester.lightning.exceptions.CSVFileIOException) CSVFileNoTransactionsException(uk.co.automatictester.lightning.exceptions.CSVFileNoTransactionsException) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) CSVFileIOException(uk.co.automatictester.lightning.exceptions.CSVFileIOException)

Aggregations

IOException (java.io.IOException)3 CSVFileIOException (uk.co.automatictester.lightning.exceptions.CSVFileIOException)3 CSVFileNoTransactionsException (uk.co.automatictester.lightning.exceptions.CSVFileNoTransactionsException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStreamReader (java.io.InputStreamReader)2 JMeterTransactions (uk.co.automatictester.lightning.data.JMeterTransactions)2 FileReader (java.io.FileReader)1 PerfMonDataEntries (uk.co.automatictester.lightning.data.PerfMonDataEntries)1