Package org.apache.axiom.testutils
Class InvocationCounter
- java.lang.Object
-
- org.apache.axiom.testutils.InvocationCounter
-
public class InvocationCounter extends Object
Utility class that counts the number of invocations on one or more objects. It also counts the number of exceptions thrown by these invocations. The class uses dynamic proxies to implement this feature.This class is thread safe.
-
-
Constructor Summary
Constructors Constructor Description InvocationCounter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcreateProxy(Object target)Create a new proxy.intgetExceptionCount()Get the number of exceptions counted by this instance.intgetInvocationCount()Get the number of invocations counted by this instance.voidreset()Reset all counters to zero.
-
-
-
Method Detail
-
createProxy
public Object createProxy(Object target)
Create a new proxy. Every invocation of a method on this proxy increases the invocation count by one unit. If the invocation results in an exception, then the exception counter is also incremented. The returned proxy implements all interfaces of the target instance.- Parameters:
target- the target instance- Returns:
- the proxy instance
-
getInvocationCount
public int getInvocationCount()
Get the number of invocations counted by this instance.- Returns:
- the number of invocations
-
getExceptionCount
public int getExceptionCount()
Get the number of exceptions counted by this instance.- Returns:
- the number of exceptions
-
reset
public void reset()
Reset all counters to zero.
-
-