Package org.apache.calcite.util
Class TestUtil
java.lang.Object
org.apache.calcite.util.TestUtil
Static utilities for JUnit tests.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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- 
TestUtilpublic TestUtil()
 
- 
- 
Method Details- 
assertEqualsVerbose
- 
assertThatScientific
- 
quoteForJavaConverts 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"
- 
toJavaStringConverts 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")
- 
foldCombines an array of strings, each representing a line, into a single string containing line separators.
- 
escapeStringQuotes a string for Java or JSON.
- 
escapeStringQuotes a string for Java or JSON, into a builder.
- 
quotePatternQuotes a pattern.
- 
correctRoundedFloatRemoves floating-point rounding errors from the end of a string.12.300000006becomes12.3;-12.37999999991becomes-12.38.
- 
getJavaMajorVersionpublic 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.
- 
getGuavaMajorVersionpublic static int getGuavaMajorVersion()Returns the Guava major version.
- 
getJavaVirtualMachineVendorReturns the JVM vendor.
- 
getBaseDirReturns the root directory of the source tree.
- 
outOfOrderItemsGiven a list, returns the number of elements that are not between an element that is less and an element that is greater.
- 
hasMessageChecks if exceptions have give substring. That is handy to prevent logging SQL text twice
- 
rethrowRethrows given exception keeping stacktraces clean and compact.- Throws:
- E extends Throwable
 
- 
rethrowRethrows given exception keeping stacktraces clean and compact.- Throws:
- E extends Throwable
 
- 
printStackTraceReturns string representation of the givenThrowable.
- 
repeatReturns 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.
 
-