public abstract class TestUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
AVATICA_VERSION |
| 构造器和说明 |
|---|
TestUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
assertEqualsVerbose(String expected,
String actual) |
static String |
correctRoundedFloat(String s)
Removes floating-point rounding errors from the end of a string.
|
static String |
escapeString(String s)
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 |
fold(String... strings)
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 |
getGuavaMajorVersion()
Returns the Guava major version.
|
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 property
java.version. |
static String |
getJavaVirtualMachineVendor()
Returns the JVM vendor.
|
static boolean |
hasMessage(Throwable t,
String substring)
Checks if exceptions have give substring.
|
static <E extends Comparable<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 |
printStackTrace(Throwable t)
Returns string representation of the given
Throwable. |
static String |
quoteForJava(String s)
Converts a string (which may contain quotes and newlines) into a java
literal.
|
static String |
quotePattern(String s)
Quotes a pattern.
|
static <E extends Throwable> |
rethrow(Throwable e)
Rethrows given exception keeping stacktraces clean and compact.
|
static <E extends Throwable> |
rethrow(Throwable e,
String message)
Rethrows given exception keeping stacktraces clean and compact.
|
static String |
toJavaString(String s)
Converts a string (which may contain quotes and newlines) into a java
literal.
|
public static final String AVATICA_VERSION
public static String quoteForJava(String s)
For example,
string with "quotes" split across lines
becomes
"string with \"quotes\" split" + "\n" + "across lines"
public static String toJavaString(String s)
For example,
{code
string with "quotes" split
across lines}
becomes
TestUtil.fold("string with \"quotes\" split\n", + "across lines")
public static String fold(String... strings)
public static StringBuilder escapeString(StringBuilder buf, String s)
public static String correctRoundedFloat(String s)
12.300000006 becomes 12.3;
-12.37999999991 becomes -12.38.
public static int getJavaMajorVersion()
java.version.public static int getGuavaMajorVersion()
public static String getJavaVirtualMachineVendor()
public static File getBaseDir(Class<?> klass)
public static <E extends Comparable<E>> SortedSet<E> outOfOrderItems(List<E> list)
public static boolean hasMessage(Throwable t, String substring)
public static <E extends Throwable> RuntimeException rethrow(Throwable e) throws E extends Throwable
E extends Throwablepublic static <E extends Throwable> RuntimeException rethrow(Throwable e, String message) throws E extends Throwable
E extends ThrowableCopyright © 2012-2023 Apache Software Foundation. All Rights Reserved.