public class TestResultSetUtil extends Object
#printThrowable(Throwable, PrintStream)
method
in order to call out.print instead of out.println
This is because the println adds a line terminator, and when the result file is in turn used for
comparison it fails because of the line terminator.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_COL_WIDTH |
Constructor and Description |
---|
TestResultSetUtil() |
Modifier and Type | Method and Description |
---|---|
static List |
compareThrowable(Throwable t,
String query,
File expectedResultsFile,
boolean printToConsole) |
static PrintStream |
getPrintStream(OutputStream resultsOutput,
BufferedReader expectedResultsInput,
PrintStream defaultPrintStream)
Gets a PrintStream implementation that uses the input parameters as underlying streams
|
static List |
getUnequalLines(PrintStream out) |
static void |
printBatchedUpdateCounts(int[] counts,
PrintStream out) |
static void |
printResultSet(ResultSet rs,
String query,
int maxColWidth,
boolean printMetadata,
PrintStream out)
Prints the ResultSet (and optionally the ResultSetMetaData) to a stream.
|
static void |
printResultSetMetadata(ResultSetMetaData rsmd,
PrintStream out)
Prints the ResultSetMetaData values for each column
|
static void |
printThrowable(Throwable t,
String sql,
PrintStream out) |
static void |
printUpdateCount(int updateCount,
PrintStream out) |
static List |
writeAndCompareResultSet(ResultSet rs,
String query,
int maxColWidth,
boolean printMetadata,
File resultsFile,
File expectedResultsFile,
boolean printToConsole)
Compares the actual results with the expected results.
|
static List |
writeAndCompareResultSet(ResultSet rs,
String query,
int maxColWidth,
boolean printMetadata,
OutputStream resultsOutput,
BufferedReader expectedResultsInput,
PrintStream defaultPrintStream)
Compares the actual results with the expected results.
|
public static final int DEFAULT_MAX_COL_WIDTH
public static List compareThrowable(Throwable t, String query, File expectedResultsFile, boolean printToConsole) throws IOException
IOException
public static void printThrowable(Throwable t, String sql, PrintStream out)
public static PrintStream getPrintStream(OutputStream resultsOutput, BufferedReader expectedResultsInput, PrintStream defaultPrintStream)
resultsOutput
- an output file for result data. If null, results will only be written to the defaul stream.expectedResultsInput
- the reader for expected data. If null, actual data is never compared against expected results.defaultPrintStream
- if not null, this utility will always write to this stream. Typically this is System.outpublic static List writeAndCompareResultSet(ResultSet rs, String query, int maxColWidth, boolean printMetadata, File resultsFile, File expectedResultsFile, boolean printToConsole) throws IOException, SQLException
rs
- the result of the executionmaxColWidth
- the max width a column is allowed to haveprintMetadata
- writes the metadata if trueresultsFile
- output file to which the results will be written. Can be null.expectedResultsFile
- expected results file with which to compare the results. Can be null.printToConsole
- writes to System.out if trueIOException
SQLException
public static List writeAndCompareResultSet(ResultSet rs, String query, int maxColWidth, boolean printMetadata, OutputStream resultsOutput, BufferedReader expectedResultsInput, PrintStream defaultPrintStream) throws SQLException
rs
- the result of the executionmaxColWidth
- the max width a column is allowed to haveprintMetadata
- writes the metadata if trueresultsOutput
- OutputStream to which the results will be written. Can be null.expectedResultsInput
- reader with which the expected results are read. Can be null.defaultPrintStream
- the default stream to which to write the results. Can be null.SQLException
public static List getUnequalLines(PrintStream out)
public static void printUpdateCount(int updateCount, PrintStream out)
public static void printBatchedUpdateCounts(int[] counts, PrintStream out)
public static void printResultSet(ResultSet rs, String query, int maxColWidth, boolean printMetadata, PrintStream out) throws SQLException
rs
- maxColWidth
- the max width a column is allowed to have. The column will be wider than this value only if the column name is longer.printMetadata
- out
- SQLException
public static void printResultSetMetadata(ResultSetMetaData rsmd, PrintStream out) throws SQLException
rsmd
- out
- SQLException
Copyright © 2018 JBoss by Red Hat. All rights reserved.