This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about testing the update method in database layer  RSS feed

 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Currently testing the database layer functionality in my application(hopefully for last time), Just wondering is this acceptable for exception handling? If an exception occurs say in my update method, for example, a null array parameter is passed, I throw an exception. Clearly in my code though, if this occurs, I have obtained the lock already on the record number, but if the exception is thrown I have no way of then unlocking the recordNumber. Is the following acceptable say for testing the update method.

or does the following have to work automatically considering SUN's tests?

Thanks, hope my question is clear.
 
Roel De Nijs
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

Have you ever heard about the finally-block when handling exceptions?

Kind regards,
Roel
 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, lapse of concentration, actually have that in my business methods.
Cheers, apologises.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!