org.kuali.rice.test
Class TestUtilities

java.lang.Object
  extended by org.kuali.rice.test.TestUtilities

public final class TestUtilities
extends Object


Method Summary
protected static boolean annotationOverridesSuperClass(Annotation annotation)
          Determines whether an annotation should override the same type of annotation on a superclass, by using reflection to invoke the 'overrideSuperClasses' method on the annotation if it exists.
protected static boolean contains(Class[] list, Class target)
           
static Thread getExceptionThreader()
           
static List<Class> getHierarchyClassesToHandle(Class testClass, Class[] annotationClasses, Set<String> classesHandled)
          This method facilitates using annotations in a unit test class hierarchy.
static void setExceptionThreader(Thread exceptionThreader)
           
static void waitForExceptionRouting()
          Waits "indefinately" for the exception routing thread to terminate.
static void waitForExceptionRouting(long milliseconds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

waitForExceptionRouting

public static void waitForExceptionRouting()
Waits "indefinately" for the exception routing thread to terminate. This actually doesn't wait forever but puts an upper bound of 5 minutes on the time to wait for the exception routing thread to complete. If a document cannot go into exception routing within 5 minutes then we got problems.


waitForExceptionRouting

public static void waitForExceptionRouting(long milliseconds)

getExceptionThreader

public static Thread getExceptionThreader()

setExceptionThreader

public static void setExceptionThreader(Thread exceptionThreader)

contains

protected static boolean contains(Class[] list,
                                  Class target)

getHierarchyClassesToHandle

public static List<Class> getHierarchyClassesToHandle(Class testClass,
                                                      Class[] annotationClasses,
                                                      Set<String> classesHandled)
                                               throws Exception
This method facilitates using annotations in a unit test class hierarchy. We walk up the class hierarchy and on each class, looking for the presence of any of the specified annotation types. If the particular class defines one of the annotation types, it is marked for handling. Once any single target annotation is found on the class, it is marked and no further annotations are inspected. If the annotation defines an 'overrideSuperClasses' method, and this method returns false, then processing continues up the class hierarchy. Otherwise processing stops when the first annotation is found. Note that this feature only makes sense when specifying a single annotation type. After a list of classes in descending hierarchy order is compiled, the list is iterated over (again, in descending hierarchy order) and if the class is not already present in the caller-supplied list of classes already handled by the caller, the class is added to a list of classes that need to be handled by the caller, which is then returned to the caller. It is the caller's responsibility to handle the returned classes, and store them in some internal list which it may give back to this method in the future.

Throws:
Exception - if there is a problem in reflection on an Annotation object

annotationOverridesSuperClass

protected static boolean annotationOverridesSuperClass(Annotation annotation)
                                                throws Exception
Determines whether an annotation should override the same type of annotation on a superclass, by using reflection to invoke the 'overrideSuperClasses' method on the annotation if it exists. If the annotation does not supply this method, the default is true.

Parameters:
annotation - the annotation to inspect
Returns:
whether this annotation overrides any annotations of similar type in super classes
Throws:
Exception - if an error occurs during reflection


Copyright © 2005-2014 The Kuali Foundation. All Rights Reserved.