Package org.apache.calcite.util
Class TestUtil
java.lang.Object
org.apache.calcite.util.TestUtil
Static utilities for JUnit tests.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertEqualsVerbose(String expected, String actual) static voidassertThatScientific(String value, org.hamcrest.Matcher<String> matcher) static StringRemoves floating-point rounding errors from the end of a string.static StringQuotes a string for Java or JSON.static StringBuilderescapeString(StringBuilder buf, String s) Quotes a string for Java or JSON, into a builder.static StringCombines an array of strings, each representing a line, into a single string containing line separators.static FilegetBaseDir(Class<?> klass) Returns the root directory of the source tree.static intReturns the Guava major version.static intReturns the Java major version: 7 for JDK 1.7, 8 for JDK 8, 10 for JDK 10, etc.static StringReturns the JVM vendor.static booleanhasMessage(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 StringReturns string representation of the givenThrowable.static StringConverts a string (which may contain quotes and newlines) into a java literal.static StringQuotes a pattern.static CharSequenceReturns aCharSequencethat contains a given string repeatedcounttimes.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 StringConverts 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 linesbecomes
"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.300000006becomes12.3;-12.37999999991becomes-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. -
repeat
Returns aCharSequencethat contains a given string repeatedcounttimes. Unlike a String with the same contents, it is virtual, and only becomes real when, say, someone callsStringBuilder.append(CharSequence)with it.
-