Java Doc for DatabaseModule.java in  » Testing » unitils » org » unitils » database » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » unitils » org.unitils.database 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.unitils.database.DatabaseModule

DatabaseModule
public class DatabaseModule implements Module(Code)
todo add javadoc explaining transaction behavior.

Module that provides basic support for database testing such as the creation of a datasource that connectes to the test database and the maintaince of the test database structure.

A datasource will be created the first time one is requested. Which type of datasource will be created depends on the configured DataSourceFactory . By default this will be a pooled datasource that gets its connection-url and username and password from the unitils configuration.

The created datasource can be injected into a field of the test by annotating the field with TestDataSource . It can then be used to install it in your DAO or other class under test. See the javadoc of the annotation for more info on how you can use it.

If the DbMaintainer is enabled (by setting DatabaseModule.PROPKEY_UPDATEDATABASESCHEMA_ENABLED to true), the test database schema will automatically be updated if needed. This check will be performed once during your test-suite run, namely when the data source is created. See DBMaintainer javadoc for more information on how this update is performed.
author:
   Filip Neven
author:
   Tim Ducheyne


Inner Class :protected class DatabaseTestListener extends TestListener

Field Summary
final public static  StringPROPKEY_UPDATEDATABASESCHEMA_ENABLED
    


Method Summary
public  voidcleanSchemas()
     Cleans all configured schema's.
public  voidclearSchemas()
     Clears all configured schema's.
protected  TransactionalDataSourcecreateDataSource()
    
public  TestListenercreateTestListener()
    
protected  TransactionManagercreateTransactionManager()
    
public  voiddisableConstraints()
     Disables all foreigh key and not-null constraints on the configured schema's.
protected  voidendTransaction(Object testObject)
    
public  voidflushDatabaseUpdates(Object testObject)
     Flushes all pending updates to the database.
public  voidgenerateDatasetDefinition()
     Generates a definition file that defines the structure of dataset's, i.e.
public  TransactionalDataSourcegetDataSource()
     Returns the DataSource that provides connection to the unit test database.
protected  SQLHandlergetDefaultSqlHandler()
    
public  TransactionManagergetTransactionManager()
     Gets the transaction manager or creates one if it does not exist yet.
protected  TransactionModegetTransactionMode(Object testObject)
    
public  voidinit(Properties configuration)
    
public  voidinjectDataSource(Object testObject)
    
public  voidsetDatabaseToCurrentVersion()
     Updates the database version to the current version, without issuing any other updates to the database. This method can be used for example after you've manually brought the database to the latest version, but the database version is not yet set to the current one.
public  voidsetDatabaseToCurrentVersion(SQLHandler sqlHandler)
     Updates the database version to the current version, without issuing any other updates to the database. This method can be used for example after you've manually brought the database to the latest version, but the database version is not yet set to the current one.
public  voidstartTransaction(Object testObject)
     Starts a transaction.
public  voidupdateDatabase()
     Determines whether the test database is outdated and, if that is the case, updates the database with the latest changes.
public  voidupdateDatabase(SQLHandler sqlHandler)
     todo make configurable using properties

Determines whether the test database is outdated and, if that is the case, updates the database with the latest changes.

public  voidupdateSequences()
    

Field Detail
PROPKEY_UPDATEDATABASESCHEMA_ENABLED
final public static String PROPKEY_UPDATEDATABASESCHEMA_ENABLED(Code)





Method Detail
cleanSchemas
public void cleanSchemas()(Code)
Cleans all configured schema's. I.e. removes all data from its database tables.



clearSchemas
public void clearSchemas()(Code)
Clears all configured schema's. I.e. drops all tables, views and other database objects.



createDataSource
protected TransactionalDataSource createDataSource()(Code)
Creates a datasource by using the factory that is defined by the dataSourceFactory.className property the datasource



createTestListener
public TestListener createTestListener()(Code)
The TestListener associated with this module



createTransactionManager
protected TransactionManager createTransactionManager()(Code)
An instance of the transactionManager, as configured in the Unitils configuration



disableConstraints
public void disableConstraints()(Code)
Disables all foreigh key and not-null constraints on the configured schema's.



endTransaction
protected void endTransaction(Object testObject)(Code)
Commits or rollbacks the current transaction, if transactions are enabled and a transactionManager is active for the given testObject
Parameters:
  testObject - The test object, not null



flushDatabaseUpdates
public void flushDatabaseUpdates(Object testObject)(Code)
Flushes all pending updates to the database. This method is useful when the effect of updates needs to be checked directly on the database.

This will look for modules that implement Flushable and call flushDatabaseUpdates on these module.
Parameters:
  testObject - TODO




generateDatasetDefinition
public void generateDatasetDefinition()(Code)
Generates a definition file that defines the structure of dataset's, i.e. a XSD of DTD that describes the structure of the database.



getDataSource
public TransactionalDataSource getDataSource()(Code)
Returns the DataSource that provides connection to the unit test database. When invoked the first time, the DBMaintainer is invoked to make sure the test database is up-to-date (if database updating is enabled) The DataSource



getDefaultSqlHandler
protected SQLHandler getDefaultSqlHandler()(Code)
The default SQLHandler, which simply executes the sql statements on the unitils-configuredtest database



getTransactionManager
public TransactionManager getTransactionManager()(Code)
Gets the transaction manager or creates one if it does not exist yet. The transaction manager, not null



getTransactionMode
protected TransactionMode getTransactionMode(Object testObject)(Code)

Parameters:
  testObject - The test object, not null The TransactionMode for the given object



init
public void init(Properties configuration)(Code)
Initializes this module using the given Configuration
Parameters:
  configuration - the config, not null



injectDataSource
public void injectDataSource(Object testObject)(Code)
Assigns the TestDataSource to every field annotated with TestDataSource and calls all methods annotated with TestDataSource
Parameters:
  testObject - The test instance, not null



setDatabaseToCurrentVersion
public void setDatabaseToCurrentVersion()(Code)
Updates the database version to the current version, without issuing any other updates to the database. This method can be used for example after you've manually brought the database to the latest version, but the database version is not yet set to the current one. This method can also be useful for example for reinitializing the database after having reorganized the scripts folder.



setDatabaseToCurrentVersion
public void setDatabaseToCurrentVersion(SQLHandler sqlHandler)(Code)
Updates the database version to the current version, without issuing any other updates to the database. This method can be used for example after you've manually brought the database to the latest version, but the database version is not yet set to the current one. This method can also be useful for example for reinitializing the database after having reorganized the scripts folder.
Parameters:
  sqlHandler - The SQLHandler to which all commands are issued



startTransaction
public void startTransaction(Object testObject)(Code)
Starts a transaction. If the Unitils DataSource was not loaded yet, we simply remember that a transaction was started but don't actually start it. If the DataSource is loaded within this test, the transaction will be started immediately after loading the DataSource.
Parameters:
  testObject - The test object, not null



updateDatabase
public void updateDatabase()(Code)
Determines whether the test database is outdated and, if that is the case, updates the database with the latest changes. See DBMaintainer for more information.



updateDatabase
public void updateDatabase(SQLHandler sqlHandler)(Code)
todo make configurable using properties

Determines whether the test database is outdated and, if that is the case, updates the database with the latest changes. See DBMaintainer for more information.
Parameters:
  sqlHandler - SQLHandler that needs to be used for the database updates




updateSequences
public void updateSequences()(Code)
Updates all sequences that have a value below a certain configurable treshold to become equal to this treshold



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.