org.kuali.rice.ken.test
Class ClearDatabaseUtil

java.lang.Object
  extended by org.kuali.rice.ken.test.ClearDatabaseUtil

public class ClearDatabaseUtil
extends Object

Adapted from Rice ClearDatabaseLifecycle. This is a standalone utility class that does not implement or depend on the Rice Lifecycle interface. {clearTables(PlatformTransactionManager, DataSource, String, List, boolean, String) can be called directly on this class, or an instance can be created and used as a command.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
private  DataSource dataSource
          The datasource to use
static String DEFAULT_TEST_TABLE_NAME
           
private  boolean handleConstraints
          Whether we should determine the constraints on tables, and drop them before deleting and then reapply them afterwards.
private static org.apache.log4j.Logger LOG
           
private  String schemaName
          Schema name
private  List<String> tablesToClear
          A list of regular expressions which should match names of tables to be cleared
private  String testTableNamePattern
          The name of a table which serves as a marker to indicate that the database is in fact used for unit testing and that all data can be deleted
private  org.springframework.transaction.PlatformTransactionManager transactionManager
          The PlatformTransactionManager under which to clear tables in a separate transaction
 
Constructor Summary
ClearDatabaseUtil(org.springframework.transaction.PlatformTransactionManager transactionManager, DataSource dataSource, String schema, List<String> tablesToClear)
           
ClearDatabaseUtil(org.springframework.transaction.PlatformTransactionManager transactionManager, DataSource dataSource, String schema, List<String> tablesToClear, boolean handleConstraints)
           
ClearDatabaseUtil(org.springframework.transaction.PlatformTransactionManager transactionManager, DataSource dataSource, String schema, List<String> tablesToClear, boolean handleConstraints, String testTable)
           
 
Method Summary
 void clearTables()
           
static void clearTables(org.springframework.transaction.PlatformTransactionManager transactionManager, DataSource dataSource, String schemaName, List<String> tablesToClear, boolean handleConstraints, String testTable)
           
 DataSource getDataSource()
           
 String getSchemaName()
           
 List<String> getTablesToClear()
           
 String getTestTableNamePattern()
           
 org.springframework.transaction.PlatformTransactionManager getTransactionManager()
           
 boolean isHandleConstraints()
           
private static boolean isTestTableInSchema(DataSource dataSource, String testTableNamePattern)
           
private static void verifyTestEnvironment(DataSource dataSource, String testTableNamePattern)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG

DEFAULT_TEST_TABLE_NAME

public static final String DEFAULT_TEST_TABLE_NAME
See Also:
Constant Field Values

transactionManager

private final org.springframework.transaction.PlatformTransactionManager transactionManager
The PlatformTransactionManager under which to clear tables in a separate transaction


dataSource

private final DataSource dataSource
The datasource to use


schemaName

private final String schemaName
Schema name


tablesToClear

private final List<String> tablesToClear
A list of regular expressions which should match names of tables to be cleared


testTableNamePattern

private final String testTableNamePattern
The name of a table which serves as a marker to indicate that the database is in fact used for unit testing and that all data can be deleted


handleConstraints

private final boolean handleConstraints
Whether we should determine the constraints on tables, and drop them before deleting and then reapply them afterwards.

Constructor Detail

ClearDatabaseUtil

public ClearDatabaseUtil(org.springframework.transaction.PlatformTransactionManager transactionManager,
                         DataSource dataSource,
                         String schema,
                         List<String> tablesToClear)

ClearDatabaseUtil

public ClearDatabaseUtil(org.springframework.transaction.PlatformTransactionManager transactionManager,
                         DataSource dataSource,
                         String schema,
                         List<String> tablesToClear,
                         boolean handleConstraints)

ClearDatabaseUtil

public ClearDatabaseUtil(org.springframework.transaction.PlatformTransactionManager transactionManager,
                         DataSource dataSource,
                         String schema,
                         List<String> tablesToClear,
                         boolean handleConstraints,
                         String testTable)
Method Detail

getTransactionManager

public org.springframework.transaction.PlatformTransactionManager getTransactionManager()

getDataSource

public DataSource getDataSource()

getSchemaName

public String getSchemaName()

getTestTableNamePattern

public String getTestTableNamePattern()

isHandleConstraints

public boolean isHandleConstraints()

getTablesToClear

public List<String> getTablesToClear()

clearTables

public void clearTables()

clearTables

public static void clearTables(org.springframework.transaction.PlatformTransactionManager transactionManager,
                               DataSource dataSource,
                               String schemaName,
                               List<String> tablesToClear,
                               boolean handleConstraints,
                               String testTable)

isTestTableInSchema

private static boolean isTestTableInSchema(DataSource dataSource,
                                           String testTableNamePattern)

verifyTestEnvironment

private static void verifyTestEnvironment(DataSource dataSource,
                                          String testTableNamePattern)


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.