[ 
https://issues.apache.org/jira/browse/DERBY-2293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12471584
 ] 

Daniel John Debrunner commented on DERBY-2293:
----------------------------------------------

Comments on the decorateSQL() method.

The method is designed to allow the test writer to just implement the SQL DDL 
and any other setup such as inserting rows. Thus it already puts the connection 
into auto commit  false mode, provides a Statement object and commits the 
transaction for you. Thus an implementation of a decorateSQL method need not do 
those things. This is documented in the javadoc for CleanDatabaseTestSetup and 
CleanDatabaseTestSetup.decorateSQL. If the current documentation is unclear or 
could use more information, please improve it.

Performing assertions in a setup method or a decorator setup method is not 
really the JUnit style. setUp methods are for setting up to run a test, the 
test method is for performing the asserts. If a decorator setUp fails then I 
think none of its fixtures will be run. If a test for DDL in a batch is needed 
then have an explicit testDDLInBatch method.

An FYI on connection handling in BaseJDBCTestCase. The getConnection() method 
returns a single connection for the lifetime of an instance of the class 
(assuming the connection is not closed until super.tearDown() is called). Thus 
the connection used in the setUp() method is the same as the connection in the 
fixture method and the same as the one in the tearDown method. Thus, in this 
case, since the setUp method puts the connection in autocommit false mode, 
there is no need for each test fixture to also do it. Though it does not harm.
The BaseJDBCTestCase also provides the abilty for a test class to put all of 
its connections in a consistent initial state, by having the test class 
implement the method initializeConnection. See the javadoc in BaseJDBCTestCase. 
Thus one could perform the setAutoCommit(false) in that method and then be 
assured that every connection used by a test was in auto commit false mode.


> convert batchUpdate.java to junit
> ---------------------------------
>
>                 Key: DERBY-2293
>                 URL: https://issues.apache.org/jira/browse/DERBY-2293
>             Project: Derby
>          Issue Type: Improvement
>          Components: Test
>            Reporter: Myrna van Lunteren
>         Assigned To: Myrna van Lunteren
>            Priority: Minor
>         Attachments: DERBY-2293_20070205.diff, DERBY-2293_20070205.stat, 
> DERBY-2293_20070206.diff, DERBY-2293_20070206.stat, 
> DERBY-2293_20070206_2.diff, DERBY-2293_20070208.diff
>
>
> Convert the test jdbcapi.batchUpdate.java to junit framework

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to