Package org.jboss.byteman.contrib.bmunit
Class BMUnitConfigState
- java.lang.Object
-
- org.jboss.byteman.contrib.bmunit.BMUnitConfigState
-
public class BMUnitConfigState extends Object
class used to model a specific BMUnit configuration
-
-
Field Summary
Fields Modifier and Type Field Description static String
AGENT_HOST
System property specifying the host to be used when starting the agent and when submitting rules to it.static String
AGENT_INHIBIT
System property which inhibits automatic loading of the agent.static String
AGENT_POLICY
System property specifying whether to set a security policy when loading the agent.static String
AGENT_PORT
System property specifying the port to be used when starting the agent and when submitting rules to it.static String
BMUNIT_VERBOSE
System property which enables tracing of bmunit activitystatic String
BYTEMAN_ALLOW_CONFIG_UPDATE
System property which enables tracing of Byteman activitystatic String
BYTEMAN_DEBUG
System property which enables printing of Byteman rule debug statementsstatic String
BYTEMAN_DUMP_GENERATED_CLASSES
System property which enables dumping of generated classesstatic String
BYTEMAN_DUMP_GENERATED_CLASSES_DIRECTORY
System property which configures directory path for files used for dumping of generated classesstatic String
BYTEMAN_DUMP_GENERATED_CLASSES_INTERMEDIATE
System property which configures dumping of intermediate versions of generated classesstatic String
BYTEMAN_VERBOSE
System property which enables tracing of Byteman activitystatic BMUnitConfigState
defaultConfigState
a default configuration state used when a test class does not specify a configuration state.static String
LOAD_DIRECTORY
System property which identifies the directory from which to start searching for rule script.static String
RESOURCE_LOAD_DIRECTORY
System property which identifies the resource load directory from which to start searching for rule script.static String
VERBOSE
this is only provided for backward compatibility in case some app was using this constant string to configure the required property.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BMUnitConfigState
currentConfigState()
static BMUnitConfigState
getCurrentConfigState()
the global configuration state which configures the operation of BMUnit when running tests in a specific class or a method in that class.String
getDumpGeneratedClassesDirectory()
smart getter for current dumpGeneratedClassesDirectory setting which only returns a directory when dumpGeneratedClasses is set in which case it uses any current setting but delegates to previous if no value has been set.String
getHost()
getter for currently configured agent host settingString
getLoadDirectory()
getter for currently configured load directory settingint
getPort()
getter for currently configured agent port settingString
getResourceLoadDirectory()
getter for currently configured resource directory settingboolean
isAllowConfigUpdate()
smart getter for currently configured allowAgentConfigUpdate setting which redirects through to the previous config to ensure that we employ the setting used for the initial agent loadboolean
isBMUnitVerbose()
getter for currently configured BMUnit verbose settingboolean
isDebug()
smart getter for currently configured Byteman debug setting which redirects through to the previous config if config updates are not allowed but otherwise returns the currently configured Byteman debug settingboolean
isDumpGeneratedClasses()
getter for current dumpGeneratedClasses settingboolean
isDumpGeneratedClassesIntermediate()
smart getter for current dumpGeneratedClassesIntermediate setting which only returns the attribute setting if dumpGeneratedClasses has also been set.boolean
isInhibitAgentLoad()
smart getter for currently configured inhibitAgentLoad setting which redirects through to the previous config to ensure that we employ the setting used for the initial agent loadboolean
isPolicy()
smart getter for currently configured policy setting which redirects through to the previous config to ensure that we employ the setting used for the initial agent loadboolean
isVerbose()
smart getter for currently configured Byteman verbose setting which redirects through to the previous config if config updates are not allowed but otherwise returns the currently configured Byteman verbose settingstatic void
popConfigurationState(Class<?> testClass)
static void
popConfigurationState(Method method)
static void
pushConfigurationState(BMUnitConfig config, Class<?> testClass)
install the configuration for a specific test class, possibly also adopting it as the default configuration this method is not thread-safe.static void
pushConfigurationState(BMUnitConfig config, Method method)
static void
resetConfigurationState(Class<?> testClass)
static void
resetConfigurationState(Method method)
-
-
-
Field Detail
-
defaultConfigState
public static BMUnitConfigState defaultConfigState
a default configuration state used when a test class does not specify a configuration state. this state is initialised using the state associated with the first test class processed during the test run. it is also the state used to define parameters which configure autoload of the Byteman agent.
-
LOAD_DIRECTORY
public static final String LOAD_DIRECTORY
System property which identifies the directory from which to start searching for rule script. If unset the current working directory of the test is used.- See Also:
- Constant Field Values
-
RESOURCE_LOAD_DIRECTORY
public static final String RESOURCE_LOAD_DIRECTORY
System property which identifies the resource load directory from which to start searching for rule script.- See Also:
- Constant Field Values
-
AGENT_PORT
public static final String AGENT_PORT
System property specifying the port to be used when starting the agent and when submitting rules to it. You can normally just use the default port.- See Also:
- Constant Field Values
-
AGENT_HOST
public static final String AGENT_HOST
System property specifying the host to be used when starting the agent and when submitting rules to it. You can normally just use the default host.- See Also:
- Constant Field Values
-
AGENT_POLICY
public static final String AGENT_POLICY
System property specifying whether to set a security policy when loading the agent.- See Also:
- Constant Field Values
-
AGENT_INHIBIT
public static final String AGENT_INHIBIT
System property which inhibits automatic loading of the agent. If you set this then you have to load the agent yourself using the Install API or ensure JUnit loads by forking a JVM and passing the necessary -javaagent options on the command line. You may also want to set this if you you have loaded the agent into a remote service in another JVM driven by your unit test.- See Also:
- Constant Field Values
-
BYTEMAN_ALLOW_CONFIG_UPDATE
public static final String BYTEMAN_ALLOW_CONFIG_UPDATE
System property which enables tracing of Byteman activity- See Also:
- Constant Field Values
-
BYTEMAN_VERBOSE
public static final String BYTEMAN_VERBOSE
System property which enables tracing of Byteman activity- See Also:
- Constant Field Values
-
BYTEMAN_DEBUG
public static final String BYTEMAN_DEBUG
System property which enables printing of Byteman rule debug statements- See Also:
- Constant Field Values
-
BMUNIT_VERBOSE
public static final String BMUNIT_VERBOSE
System property which enables tracing of bmunit activity- See Also:
- Constant Field Values
-
BYTEMAN_DUMP_GENERATED_CLASSES
public static final String BYTEMAN_DUMP_GENERATED_CLASSES
System property which enables dumping of generated classes- See Also:
- Constant Field Values
-
BYTEMAN_DUMP_GENERATED_CLASSES_DIRECTORY
public static final String BYTEMAN_DUMP_GENERATED_CLASSES_DIRECTORY
System property which configures directory path for files used for dumping of generated classes- See Also:
- Constant Field Values
-
BYTEMAN_DUMP_GENERATED_CLASSES_INTERMEDIATE
public static final String BYTEMAN_DUMP_GENERATED_CLASSES_INTERMEDIATE
System property which configures dumping of intermediate versions of generated classes- See Also:
- Constant Field Values
-
VERBOSE
public static final String VERBOSE
this is only provided for backward compatibility in case some app was using this constant string to configure the required property.- See Also:
- Constant Field Values
-
-
Method Detail
-
pushConfigurationState
public static void pushConfigurationState(BMUnitConfig config, Class<?> testClass) throws Exception
install the configuration for a specific test class, possibly also adopting it as the default configuration this method is not thread-safe. BMUnit assumes that only one JUnit/TestNG test is run at a time.- Parameters:
config
- the config to install or null if no config is availabletestClass
- the test class which may or may not have an associated config- Throws:
Exception
- if the config cannot be installed or an agent load error occurs
-
popConfigurationState
public static void popConfigurationState(Class<?> testClass) throws Exception
- Throws:
Exception
-
pushConfigurationState
public static void pushConfigurationState(BMUnitConfig config, Method method) throws Exception
- Throws:
Exception
-
popConfigurationState
public static void popConfigurationState(Method method) throws Exception
- Throws:
Exception
-
resetConfigurationState
public static void resetConfigurationState(Method method) throws Exception
- Throws:
Exception
-
resetConfigurationState
public static void resetConfigurationState(Class<?> testClass) throws Exception
- Throws:
Exception
-
getCurrentConfigState
public static BMUnitConfigState getCurrentConfigState()
the global configuration state which configures the operation of BMUnit when running tests in a specific class or a method in that class. this value is set by BMUnitRunner before it starts running the tests in a test class. it may be reset temporarily by BMUnitRunner before executing a specific test method but should then be set back to the previous configuration.- Returns:
- the current configuration
-
currentConfigState
public BMUnitConfigState currentConfigState()
-
getHost
public String getHost()
getter for currently configured agent host setting- Returns:
- the current host setting
-
getPort
public int getPort()
getter for currently configured agent port setting- Returns:
- the current port setting
-
getLoadDirectory
public String getLoadDirectory()
getter for currently configured load directory setting- Returns:
- the current load directory setting
-
getResourceLoadDirectory
public String getResourceLoadDirectory()
getter for currently configured resource directory setting- Returns:
- the current resource directory setting
-
isAllowConfigUpdate
public boolean isAllowConfigUpdate()
smart getter for currently configured allowAgentConfigUpdate setting which redirects through to the previous config to ensure that we employ the setting used for the initial agent load- Returns:
- the current allowAgentConfigUpdate setting
-
isVerbose
public boolean isVerbose()
smart getter for currently configured Byteman verbose setting which redirects through to the previous config if config updates are not allowed but otherwise returns the currently configured Byteman verbose setting- Returns:
- the current Byteman verbose setting
-
isDebug
public boolean isDebug()
smart getter for currently configured Byteman debug setting which redirects through to the previous config if config updates are not allowed but otherwise returns the currently configured Byteman debug setting- Returns:
- the current Byteman debug setting
-
isBMUnitVerbose
public boolean isBMUnitVerbose()
getter for currently configured BMUnit verbose setting- Returns:
- the current BMUnit verbose setting
-
isInhibitAgentLoad
public boolean isInhibitAgentLoad()
smart getter for currently configured inhibitAgentLoad setting which redirects through to the previous config to ensure that we employ the setting used for the initial agent load- Returns:
- the current inhibitAgentLoad setting
-
isPolicy
public boolean isPolicy()
smart getter for currently configured policy setting which redirects through to the previous config to ensure that we employ the setting used for the initial agent load- Returns:
- the current policy setting
-
isDumpGeneratedClasses
public boolean isDumpGeneratedClasses()
getter for current dumpGeneratedClasses setting- Returns:
- the current dumpGeneratedClasses setting
-
getDumpGeneratedClassesDirectory
public String getDumpGeneratedClassesDirectory()
smart getter for current dumpGeneratedClassesDirectory setting which only returns a directory when dumpGeneratedClasses is set in which case it uses any current setting but delegates to previous if no value has been set.- Returns:
- the current dumpGeneratedClasseDirectory setting
-
isDumpGeneratedClassesIntermediate
public boolean isDumpGeneratedClassesIntermediate()
smart getter for current dumpGeneratedClassesIntermediate setting which only returns the attribute setting if dumpGeneratedClasses has also been set.- Returns:
- the current dumpGeneratedClassesIntermediate
-
-