Package org.jboss.byteman.contrib.bmunit
Class BMUnit
- java.lang.Object
-
- org.jboss.byteman.contrib.bmunit.BMUnit
-
public class BMUnit extends java.lang.ObjectByteman Unit test manager class which provides support for loading and unloading scripts. This version assumes loads the agent as needed (unless inhibited -- see below) using System properties to control what hostname and port it uses for the socket. Other system properties can be used to configure operation of the load/unload operations.
-
-
Constructor Summary
Constructors Constructor Description BMUnit()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.StringfindScript(java.lang.String dir, java.lang.String name)Tries to find dir/name in the working directory.protected static java.lang.StringfindScript(java.lang.String dir, java.lang.String... names)static java.lang.StringgetHost()getter for the host name used to communicate with the agentstatic java.lang.StringgetLoadDirectory()getter for the load directorystatic booleangetPolicy()getter for the security policy settingstatic intgetPort()getter for the port used to communicate with the agentstatic java.lang.StringgetResourceLoadDirectory()getter for the resource load directorystatic booleanisAllowConfigUpdate()getter for the allowAgentConfigUpdate settingstatic booleanisBMUnitVerbose()getter for the BMUnit verbose settingstatic booleanisDebug()getter for the Byteman debug settingstatic booleanisVerbose()getter for the Byteman verbose settingstatic voidloadScriptFile(java.lang.Class<?> clazz, java.lang.String dir)loads a script by calling loadScriptFile(clazz, null, dir)static voidloadScriptFile(java.lang.Class<?> clazz, java.lang.String testName, java.lang.String dir)loads a script from the load directory using the name of a unit test as the root name for the script file and ".btm" or, failing that, ".txt" for the file extensionstatic voidloadScriptText(java.lang.Class<?> clazz, java.lang.String testname, java.lang.String scriptText)loads a script supplied as a text String rather than via a file on diskstatic voidunloadScriptFile(java.lang.Class<?> clazz, java.lang.String testName)loads a script from the load directory using the name of a unit test as the root name for the script file and ".btm" or, failing that, ".txt" for the file extensionstatic voidunloadScriptText(java.lang.Class<?> clazz, java.lang.String testName)unloads a script previously supplied as a text String
-
-
-
Method Detail
-
isAllowConfigUpdate
public static boolean isAllowConfigUpdate()
getter for the allowAgentConfigUpdate setting- Returns:
- the allowAgentConfigUpdate setting
-
isVerbose
public static boolean isVerbose()
getter for the Byteman verbose setting- Returns:
- the Byteman verbose setting
-
isDebug
public static boolean isDebug()
getter for the Byteman debug setting- Returns:
- the Byteman debug setting
-
isBMUnitVerbose
public static boolean isBMUnitVerbose()
getter for the BMUnit verbose setting- Returns:
- the BMUnit verbose setting
-
getLoadDirectory
public static java.lang.String getLoadDirectory()
getter for the load directory- Returns:
- the load directory
-
getResourceLoadDirectory
public static java.lang.String getResourceLoadDirectory()
getter for the resource load directory- Returns:
- the resource load directory
-
getHost
public static java.lang.String getHost()
getter for the host name used to communicate with the agent- Returns:
- the host name
-
getPort
public static int getPort()
getter for the port used to communicate with the agent- Returns:
- the port
-
getPolicy
public static boolean getPolicy()
getter for the security policy setting- Returns:
- the security policy setting
-
loadScriptFile
public static void loadScriptFile(java.lang.Class<?> clazz, java.lang.String dir) throws java.lang.Exceptionloads a script by calling loadScriptFile(clazz, null, dir)- Parameters:
clazz- the test classdir- the directory to load the script from- Throws:
java.lang.Exception- if the script cannot be loaded
-
loadScriptFile
public static void loadScriptFile(java.lang.Class<?> clazz, java.lang.String testName, java.lang.String dir) throws java.lang.Exceptionloads a script from the load directory using the name of a unit test as the root name for the script file and ".btm" or, failing that, ".txt" for the file extension- Parameters:
clazz- the classname of the unit testtestName- the name of the unit test methoddir- the directory in which the scripts are located- Throws:
java.lang.Exception- if the script cannot be loaded
-
unloadScriptFile
public static void unloadScriptFile(java.lang.Class<?> clazz, java.lang.String testName) throws java.lang.Exceptionloads a script from the load directory using the name of a unit test as the root name for the script file and ".btm" or, failing that, ".txt" for the file extension- Parameters:
clazz- the test classtestName- the test name- Throws:
java.lang.Exception- if the script cannot be unloaded
-
loadScriptText
public static void loadScriptText(java.lang.Class<?> clazz, java.lang.String testname, java.lang.String scriptText) throws java.lang.Exceptionloads a script supplied as a text String rather than via a file on disk- Parameters:
clazz- the test classtestname- the test namescriptText- the text of the rule or rules contained in the script- Throws:
java.lang.Exception- if the script text cannot be loaded
-
unloadScriptText
public static void unloadScriptText(java.lang.Class<?> clazz, java.lang.String testName) throws java.lang.Exceptionunloads a script previously supplied as a text String- Parameters:
clazz- the test classtestName- the test name- Throws:
java.lang.Exception- if the script text cannot be unloaded
-
findScript
protected static java.lang.String findScript(java.lang.String dir, java.lang.String name)Tries to find dir/name in the working directory. If not found, tries to add the ".btm", then ".txt" suffixes. If still not found, tries to find the above on the classpath- Parameters:
dir- The name of the directoryname- The file name- Returns:
- The fully qualified name of the file, or null if not found
-
findScript
protected static java.lang.String findScript(java.lang.String dir, java.lang.String... names)
-
-