Package org.jboss.byteman.contrib.dtest
Class InstrumentedClass
java.lang.Object
org.jboss.byteman.contrib.dtest.InstrumentedClass
- All Implemented Interfaces:
Remote
,RemoteInterface
InstrumentedClass instances serve two purposes:
Internally to the framework they provide a communication endpoint for
receiving information from the remote, Byteman instrumented code execution.
To the framework user, they provide utility methods for verifying expectations relating
to that remote execution e.g. the number of method calls made.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
private final Map
<Integer, InstrumentedInstance> private static final Integer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
assertKnownInstances
(int count) Checks that the number of known, distinct object instances of this class is as stated.void
assertMethodCallCount
(String methodName, int callCount) Checks that the number of known invocations of the given method is specified count.void
assertMethodCallCount
(String message, String methodName, int callCount) Checks that the number of known invocations of the given method is specified count.void
assertMethodCallCount
(String message, String methodName, CallCount callCount) Checks that the number of known invocations of the given method falls within the specified range for each known instances of the class.void
assertMethodCalled
(String methodName) Checks that the given method has been called at least once on each known instance of the class.void
assertMethodNotCalled
(String methodName) Checks that the given method has not been seen to be called on any known instance of the class.void
assertSumMethodCallCount
(String method, int callCount) Check that number of known invocations of the given method of all known instances is specified count.
Difference againstassertMethodCallCount(String, int)
is that here we query against all know instances.Returns the set of known instances of the class.int
getInvocationCount
(String methodName) Returns number of method calls for the class.
Sum number of method calls on all instrumented instances belonging to this instrumented class.void
Receiving side of the remote communication between the test code and the BytemanTestHelper.
-
Field Details
-
STATIC_INSTANCE_ID
-
className
-
instrumentedInstances
-
-
Constructor Details
-
InstrumentedClass
InstrumentedClass(String className)
-
-
Method Details
-
trace
Receiving side of the remote communication between the test code and the BytemanTestHelper.- Specified by:
trace
in interfaceRemoteInterface
- Parameters:
methodName
- the method name that was traced.args
- the arguments to the method invocation, in String form.- Throws:
RemoteException
- in case of communication failure.- See Also:
-
getInstances
Returns the set of known instances of the class.- Returns:
- a Set of Objects representing instances of the class.
-
getInvocationCount
Returns number of method calls for the class.
Sum number of method calls on all instrumented instances belonging to this instrumented class. It's sum of all method calls for all known instrumented instances.- Parameters:
methodName
- name of method which we are interested in how many times was called- Returns:
- number of method calls on the class (sum of method calls of all instances)
-
assertKnownInstances
public void assertKnownInstances(int count) Checks that the number of known, distinct object instances of this class is as stated.- Parameters:
count
- the expected number of instances of the class.
-
assertMethodCallCount
Checks that the number of known invocations of the given method falls within the specified range for each known instances of the class.- Parameters:
message
- the message to print in case of assertion failure.methodName
- the method name to look for.callCount
- the expected range for the invocation count.
-
assertMethodCallCount
Checks that the number of known invocations of the given method is specified count.- Parameters:
message
- the message to print in case of assertion failure.methodName
- the method name to look for.callCount
- the expected number of the invocation count.
-
assertMethodCallCount
Checks that the number of known invocations of the given method is specified count.- Parameters:
methodName
- the method name to look for.callCount
- the expected number of the invocation count.
-
assertSumMethodCallCount
Check that number of known invocations of the given method of all known instances is specified count.
Difference againstassertMethodCallCount(String, int)
is that here we query against all know instances. The other method query each instance to be called by the specific number times.- Parameters:
method
- the method name to look forcallCount
- the expected number of the invocation count summed on all instances
-
assertMethodCalled
Checks that the given method has been called at least once on each known instance of the class. Uses junit internally, hence expect the normal exception throwing in case of failure.- Parameters:
methodName
- the method name to look for.
-
assertMethodNotCalled
Checks that the given method has not been seen to be called on any known instance of the class. Uses junit internally, hence expect the normal exception throwing in case of failure.- Parameters:
methodName
- the method name to look for.
-