org.apache.directory.junit.tools
Class MultiThreadedMultiInvoker

java.lang.Object
  extended by org.apache.directory.junit.tools.MultiThreadedMultiInvoker
All Implemented Interfaces:
org.junit.rules.MethodRule

public class MultiThreadedMultiInvoker
extends Object
implements org.junit.rules.MethodRule

Rule that invokes each test method multiple times using multiple threads. Just put the following two lines to your test.

     @RuleRule
     public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker();
 

Author:
Apache Directory Project

Field Summary
static boolean NOT_THREADSAFE
           
static boolean THREADSAFE
           
 
Constructor Summary
MultiThreadedMultiInvoker(boolean threadSafe)
          Instantiates a new multi threaded invoker.
MultiThreadedMultiInvoker(int numThreads, int numInvocationsPerThread)
          Instantiates a new multi threaded multi invoker.
MultiThreadedMultiInvoker(int numThreads, int numInvocationsPerThread, boolean trace)
          Instantiates a new multi threaded multi invoker.
 
Method Summary
 org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THREADSAFE

public static final boolean THREADSAFE
See Also:
Constant Field Values

NOT_THREADSAFE

public static final boolean NOT_THREADSAFE
See Also:
Constant Field Values
Constructor Detail

MultiThreadedMultiInvoker

public MultiThreadedMultiInvoker(boolean threadSafe)
Instantiates a new multi threaded invoker. The number of threads and invocations per thread are derived from system properties 'threads' and 'invocations'.

Parameters:
threadSafe - whether the tested class is thread safe

MultiThreadedMultiInvoker

public MultiThreadedMultiInvoker(int numThreads,
                                 int numInvocationsPerThread)
Instantiates a new multi threaded multi invoker.

Parameters:
numThreads - the number of threads
numInvocationsPerThread - the number of method invocations per thread

MultiThreadedMultiInvoker

public MultiThreadedMultiInvoker(int numThreads,
                                 int numInvocationsPerThread,
                                 boolean trace)
Instantiates a new multi threaded multi invoker.

Parameters:
numThreads - the number of threads
numInvocationsPerThread - the number of method invocations per thread
trace - the trace flag
Method Detail

apply

public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
                                               org.junit.runners.model.FrameworkMethod method,
                                               Object target)

Specified by:
apply in interface org.junit.rules.MethodRule


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