public final class Utils extends Object
Modifier and Type | Field and Description |
---|---|
static char |
CHAR_REPLACEMENT |
static char[] |
SPECIAL_CHARACTERS |
static char |
UNICODE_REPLACEMENT |
Modifier and Type | Method and Description |
---|---|
static String |
arrayToString(String[] strings) |
static int |
calculateInvokedMethodCount(ITestNGMethod[] methods) |
static void |
checkInstanceOrStatic(Object instance,
Method method)
Make sure that either we have an instance or if not, that the method is static
|
static void |
checkReturnType(Method method,
Class<?>... returnTypes) |
static XmlClass[] |
classesToXmlClasses(Class<?>[] classes) |
static void |
copyFile(File from,
File to) |
static File |
createTempFile(String content) |
static String |
defaultIfStringEmpty(String s,
String defaultValue) |
static String[] |
dependentGroupsForThisMethodForConfiguration(Method m,
IAnnotationFinder finder) |
static String[] |
dependentGroupsForThisMethodForTest(Method m,
IAnnotationFinder finder) |
static String |
detailedMethodName(ITestNGMethod method,
boolean fqn) |
static void |
dumpMap(Map<?,?> result) |
static void |
dumpMethods(List<ITestNGMethod> allMethods) |
static void |
error(String errorMessage) |
static String |
escapeHtml(String s) |
static String |
escapeUnicode(String s) |
static String[] |
groupsForThisMethodForConfiguration(Method m,
IAnnotationFinder finder) |
static String[] |
groupsForThisMethodForTest(Method m,
IAnnotationFinder finder) |
static void |
initLogger(Logger logger,
String outputLogPath) |
static boolean |
isStringBlank(String s) |
static boolean |
isStringEmpty(String s) |
static boolean |
isStringNotBlank(String s) |
static boolean |
isStringNotEmpty(String s) |
static <T> String |
join(List<T> objects,
String separator) |
static void |
log(String msg) |
static void |
log(String cls,
int level,
String msg)
Logs the the message to System.out if level is greater than
or equal to TestRunner.getVerbose().
|
static void |
logInvocation(String reason,
Method thisMethod,
Object[] parameters) |
static BufferedWriter |
openWriter(String outputDir,
String fileName)
Open a BufferedWriter for the specified file.
|
static String[] |
parseMultiLine(String line) |
static String |
replaceSpecialCharacters(String fileName)
If the file name contains special characters like *,/,\ and so on,
exception will be thrown and report file will not be created.
Special characters are platform specific and they are not same for example on Windows and Macintosh. |
static String[] |
split(String string,
String sep)
Tokenize the string using the separator.
|
static String[] |
stackTrace(Throwable t,
boolean toHtml) |
static String[] |
stringToArray(String s)
Splits the given String s into tokens where the separator is
either the space character or the comma character.
|
static String |
toString(Object obj)
Returns the string representation of the specified object, transparently
handling null references and arrays.
|
static String |
toString(Object object,
Class<?> objectClass) |
static void |
writeFile(String outputDir,
String fileName,
String sb)
Writes the content of the sb string to the file named filename in outDir.
|
static void |
writeResourceToFile(File file,
String resourceName,
Class<?> clasz) |
static void |
writeUtf8File(String outputDir,
String fileName,
String sb)
Writes the content of the sb string to the file named filename in outDir encoding the output as UTF-8.
|
static void |
writeUtf8File(String outputDir,
String fileName,
XMLStringBuffer xsb,
String prefix) |
public static final char[] SPECIAL_CHARACTERS
public static final char CHAR_REPLACEMENT
public static final char UNICODE_REPLACEMENT
public static String[] stringToArray(String s)
s
- the string to splitpublic static void writeUtf8File(String outputDir, String fileName, XMLStringBuffer xsb, String prefix)
public static void writeUtf8File(String outputDir, String fileName, String sb)
outputDir
- the output directory (may not exist). If null then current directory is used.fileName
- the filenamesb
- the file contentpublic static void writeFile(String outputDir, String fileName, String sb)
outputDir
- the output directory (may not exist). If null then current directory is used.fileName
- the filenamesb
- the file contentpublic static BufferedWriter openWriter(String outputDir, String fileName) throws IOException
outputDir
- output directory. If null, then current directory is usedfileName
- file nameIOException
- if anything goes wrong while creating files.public static void dumpMap(Map<?,?> result)
result
- public static void dumpMethods(List<ITestNGMethod> allMethods)
allMethods
- public static String[] dependentGroupsForThisMethodForTest(Method m, IAnnotationFinder finder)
public static String[] groupsForThisMethodForTest(Method m, IAnnotationFinder finder)
public static String[] groupsForThisMethodForConfiguration(Method m, IAnnotationFinder finder)
public static String[] dependentGroupsForThisMethodForConfiguration(Method m, IAnnotationFinder finder)
public static void log(String msg)
public static void log(String cls, int level, String msg)
"[cls] msg"
cls
- the class name to prefix the log message.level
- the logging level of the message.msg
- the message to log to System.out.public static void error(String errorMessage)
public static int calculateInvokedMethodCount(ITestNGMethod[] methods)
public static String[] split(String string, String sep)
public static void logInvocation(String reason, Method thisMethod, Object[] parameters)
public static void writeResourceToFile(File file, String resourceName, Class<?> clasz) throws IOException
IOException
public static boolean isStringBlank(String s)
public static boolean isStringEmpty(String s)
public static boolean isStringNotBlank(String s)
public static boolean isStringNotEmpty(String s)
public static String[] stackTrace(Throwable t, boolean toHtml)
public static String detailedMethodName(ITestNGMethod method, boolean fqn)
public static String replaceSpecialCharacters(String fileName)
fileName
- file name that could contain special characters.public static File createTempFile(String content)
public static void checkInstanceOrStatic(Object instance, Method method)
Copyright © 2016. All rights reserved.