org.kuali.rice.kew.test
Class TestUtilities

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

public final class TestUtilities
extends Object

Defines utilities for unit testing


Method Summary
static void assertApprovals(String docId, String[] users, boolean shouldHaveApproval)
          Asserts that the specified users do or do not have outstanding approvals
static void assertAtNode(String message, WorkflowDocument document, String nodeNameToAssert)
          Checks that the document is at a node with the given name.
static void assertAtNode(WorkflowDocument document, String nodeName)
           
static void assertAtNodeNew(String message, WorkflowDocument document, String nodeName)
          Checks that the document is at a node with the given name.
static void assertAtNodeNew(WorkflowDocument document, String nodeName)
           
static void assertInActionList(String principalId, String documentId)
          Asserts that the given document id is in the given user's action list.
static void assertNotInActionList(String principalId, String documentId)
          Asserts that the given document id is NOT in the given user's action list.
static void assertNumberOfPendingRequests(String documentId, int numberOfPendingRequests)
           
static void assertUserHasPendingRequest(String documentId, String principalName)
          Asserts that the user with the given network id has a pending request on the given document
static void cleanupPluginDirectories()
           
static void clearTables(org.springframework.transaction.PlatformTransactionManager transactionManager, DataSource dataSource, String edenSchemaName, List<String> dontClear)
           
static Set<String> createNodeInstanceNameSet(Collection nodeInstances)
           
static File createTempDir()
           
static
<T extends Throwable>
T
findExceptionInStack(Throwable topLevelException, Class<T> exceptionClass)
          This method searches for an exception of the specified type in the exception stack
static Thread getExceptionThreader()
           
static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
           
static File getPluginsDirectory()
           
static String getTestPlatform()
          Attempts to derive the database "platform" to use for unit tests by inspected Ant build.properties files in typical locations.
static org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()
           
static void initializePluginDirectories()
           
static InputStream loadResource(Class packageClass, String resourceName)
           
static void logActionRequests(String docId)
           
static void setExceptionThreader(Thread exceptionThreader)
           
static WorkflowDocument switchByPrincipalName(String principalName, WorkflowDocument document)
           
static WorkflowDocument switchPrincipalId(String principalId, WorkflowDocument document)
           
static void verifyTestEnvironment(DataSource dataSource)
           
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

loadResource

public static InputStream loadResource(Class packageClass,
                                       String resourceName)

getTransactionTemplate

public static org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()

verifyTestEnvironment

public static void verifyTestEnvironment(DataSource dataSource)

clearTables

public static void clearTables(org.springframework.transaction.PlatformTransactionManager transactionManager,
                               DataSource dataSource,
                               String edenSchemaName,
                               List<String> dontClear)

createNodeInstanceNameSet

public static Set<String> createNodeInstanceNameSet(Collection nodeInstances)

assertAtNode

public static void assertAtNode(String message,
                                WorkflowDocument document,
                                String nodeNameToAssert)
Checks that the document is at a node with the given name. This does not check that the document is at the given node and only the given node, the document can be at other nodes as well and this assertion will still pass.


assertAtNode

public static void assertAtNode(WorkflowDocument document,
                                String nodeName)
                         throws WorkflowException
Throws:
WorkflowException

assertAtNodeNew

public static void assertAtNodeNew(String message,
                                   WorkflowDocument document,
                                   String nodeName)
                            throws WorkflowException
Checks that the document is at a node with the given name. This does not check that the document is at the given node and only the given node, the document can be at other nodes as well and this assertion will still pass.

Throws:
WorkflowException

assertAtNodeNew

public static void assertAtNodeNew(WorkflowDocument document,
                                   String nodeName)
                            throws WorkflowException
Throws:
WorkflowException

assertInActionList

public static void assertInActionList(String principalId,
                                      String documentId)
Asserts that the given document id is in the given user's action list.


assertNotInActionList

public static void assertNotInActionList(String principalId,
                                         String documentId)
Asserts that the given document id is NOT in the given user's action list.


assertNumberOfPendingRequests

public static void assertNumberOfPendingRequests(String documentId,
                                                 int numberOfPendingRequests)

assertUserHasPendingRequest

public static void assertUserHasPendingRequest(String documentId,
                                               String principalName)
                                        throws WorkflowException
Asserts that the user with the given network id has a pending request on the given document

Throws:
WorkflowException

assertApprovals

public static void assertApprovals(String docId,
                                   String[] users,
                                   boolean shouldHaveApproval)
                            throws WorkflowException
Asserts that the specified users do or do not have outstanding approvals

Parameters:
docId - the id of the document
users - the list of users
shouldHaveApproval - whether they should have an approval outstanding
Throws:
WorkflowException

switchByPrincipalName

public static WorkflowDocument switchByPrincipalName(String principalName,
                                                     WorkflowDocument document)
                                              throws WorkflowException
Throws:
WorkflowException

switchPrincipalId

public static WorkflowDocument switchPrincipalId(String principalId,
                                                 WorkflowDocument document)
                                          throws WorkflowException
Throws:
WorkflowException

logActionRequests

public static void logActionRequests(String docId)

getJdbcTemplate

public static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()

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)

getTestPlatform

public static String getTestPlatform()
                              throws IOException
Attempts to derive the database "platform" to use for unit tests by inspected Ant build.properties files in typical locations.

Returns:
the test platform if so defined in Ant build.properties file(s), or the DEFAULT_TEST_PLATFORM otherwise
Throws:
IOException - if anything goes awry
See Also:
DEFAULT_TEST_PLATFORM

createTempDir

public static File createTempDir()
                          throws Exception
Throws:
Exception

getPluginsDirectory

public static File getPluginsDirectory()

initializePluginDirectories

public static void initializePluginDirectories()
                                        throws Exception
Throws:
Exception

cleanupPluginDirectories

public static void cleanupPluginDirectories()
                                     throws Exception
Throws:
Exception

findExceptionInStack

public static <T extends Throwable> T findExceptionInStack(Throwable topLevelException,
                                                           Class<T> exceptionClass)
This method searches for an exception of the specified type in the exception stack

Parameters:
topLevelException - the exception whose stack to traverse
exceptionClass - the exception class to look for
Returns:
the first instance of an exception of the specified class if found, or null otherwise


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