public class CommonTestUtils extends Object
| Constructor and Description |
|---|
CommonTestUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
assumeJava8()
Checks whether this code runs in a Java 8 (Java 1.8) JVM.
|
static void |
blockForeverNonInterruptibly()
Permanently blocks the current thread.
|
static boolean |
containsCause(Throwable throwable,
Class<? extends Throwable> cause)
Checks whether the given throwable contains the given cause as a cause.
|
static Class<? extends Serializable> |
createClassNotInClassPath(ClassLoader targetClassLoader)
Creates a new class that is not part of the classpath that the current JVM uses.
|
static <T extends Serializable> |
createCopySerializable(T original)
Creates a copy of an object via Java Serialization.
|
static Serializable |
createObjectForClassNotInClassPath(ClassLoader targetClassLoader)
Creates a new class that is not part of the classpath that the current JVM uses, and
instantiates it.
|
static String |
createTempFile(String contents)
Creates a temporary file that contains the given string.
|
static String |
getTempDir()
Reads the path to the directory for temporary files from the configuration and returns it.
|
static void |
setEnv(Map<String,String> newenv) |
static void |
setEnv(Map<String,String> newenv,
boolean clearExisting) |
public static String getTempDir()
public static <T extends Serializable> T createCopySerializable(T original) throws IOException
original - The original object.IOExceptionpublic static String createTempFile(String contents) throws IOException
The temp file is automatically deleted on JVM exit.
contents - The contents to be written to the file.IOExceptionpublic static void blockForeverNonInterruptibly()
Thread.interrupt().public static void assumeJava8()
AssumptionViolatedException, which causes JUnit to skip the test that
called this method.public static Serializable createObjectForClassNotInClassPath(ClassLoader targetClassLoader)
This method uses createClassNotInClassPath(ClassLoader) to define the new class.
targetClassLoader - The class loader to attach the class topublic static Class<? extends Serializable> createClassNotInClassPath(ClassLoader targetClassLoader)
targetClassLoader - The class loader to attach the class topublic static boolean containsCause(Throwable throwable, Class<? extends Throwable> cause)
throwable - Throwable to check for the causecause - Cause to look forCopyright © 2014–2017 The Apache Software Foundation. All rights reserved.