org.apache.axiom.testutils
Class InvocationCounter

java.lang.Object
  extended by org.apache.axiom.testutils.InvocationCounter

public class InvocationCounter
extends java.lang.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.

Author:
Andreas Veithen

Constructor Summary
InvocationCounter()
           
 
Method Summary
 java.lang.Object createProxy(java.lang.Object target)
          Create a new proxy.
 int getExceptionCount()
          Get the number of exceptions counted by this instance.
 int getInvocationCount()
          Get the number of invocations counted by this instance.
 void reset()
          Reset all counters to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InvocationCounter

public InvocationCounter()
Method Detail

createProxy

public java.lang.Object createProxy(java.lang.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.



Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.