public class CommonTestUtils extends Object
Constructor and Description |
---|
CommonTestUtils() |
Modifier and Type | Method and Description |
---|---|
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.IOException
public 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.IOException
public static void blockForeverNonInterruptibly()
Thread.interrupt()
.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–2020 The Apache Software Foundation. All rights reserved.