Package org.apache.calcite.util
Class TestUtil
java.lang.Object
org.apache.calcite.util.TestUtil
Static utilities for JUnit tests.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertEqualsVerbose
(String expected, String actual) static void
assertThatScientific
(String value, org.hamcrest.Matcher<String> matcher) static String
Removes floating-point rounding errors from the end of a string.static String
Quotes a string for Java or JSON.static StringBuilder
escapeString
(StringBuilder buf, String s) Quotes a string for Java or JSON, into a builder.static String
Combines an array of strings, each representing a line, into a single string containing line separators.static File
getBaseDir
(Class<?> klass) Returns the root directory of the source tree.static int
Returns the Guava major version.static int
Returns the Java major version: 7 for JDK 1.7, 8 for JDK 8, 10 for JDK 10, etc.static String
Returns the JVM vendor.static boolean
hasMessage
(Throwable t, String substring) Checks if exceptions have give substring.static <E extends Comparable<E>>
SortedSet<E>outOfOrderItems
(List<E> list) Given a list, returns the number of elements that are not between an element that is less and an element that is greater.static String
Returns string representation of the givenThrowable
.static String
Converts a string (which may contain quotes and newlines) into a java literal.static String
Quotes a pattern.static <E extends Throwable>
RuntimeExceptionRethrows given exception keeping stacktraces clean and compact.static <E extends Throwable>
RuntimeExceptionRethrows given exception keeping stacktraces clean and compact.static String
Converts a string (which may contain quotes and newlines) into a java literal.
-
Field Details
-
AVATICA_VERSION
-
-
Constructor Details
-
TestUtil
public TestUtil()
-
-
Method Details
-
assertEqualsVerbose
-
assertThatScientific
-
quoteForJava
Converts a string (which may contain quotes and newlines) into a java literal.For example,
string with "quotes" split across lines
becomes
"string with \"quotes\" split" + "\n" + "across lines"
-
toJavaString
Converts a string (which may contain quotes and newlines) into a java literal.For example,
{code string with "quotes" split across lines}
becomes
TestUtil.fold("string with \"quotes\" split\n", + "across lines")
-
fold
Combines an array of strings, each representing a line, into a single string containing line separators. -
escapeString
Quotes a string for Java or JSON. -
escapeString
Quotes a string for Java or JSON, into a builder. -
quotePattern
Quotes a pattern. -
correctRoundedFloat
Removes floating-point rounding errors from the end of a string.12.300000006
becomes12.3
;-12.37999999991
becomes-12.38
. -
getJavaMajorVersion
public static int getJavaMajorVersion()Returns the Java major version: 7 for JDK 1.7, 8 for JDK 8, 10 for JDK 10, etc. depending on current system propertyjava.version
. -
getGuavaMajorVersion
public static int getGuavaMajorVersion()Returns the Guava major version. -
getJavaVirtualMachineVendor
Returns the JVM vendor. -
getBaseDir
Returns the root directory of the source tree. -
outOfOrderItems
Given a list, returns the number of elements that are not between an element that is less and an element that is greater. -
hasMessage
Checks if exceptions have give substring. That is handy to prevent logging SQL text twice -
rethrow
Rethrows given exception keeping stacktraces clean and compact.- Throws:
E extends Throwable
-
rethrow
Rethrows given exception keeping stacktraces clean and compact.- Throws:
E extends Throwable
-
printStackTrace
Returns string representation of the givenThrowable
.
-