It's not a secret anymore!*
The moose likes Testing and the fly likes How to automate testing with database/web servers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to automate testing with database/web servers" Watch "How to automate testing with database/web servers" New topic
Author

How to automate testing with database/web servers

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 388
Is there a way my junit test can
(1) check to see if mysql or hsql is running and if not start one?
(2) check to see if tomcat or jetty is running if not start one?
Thanks,
Siegfried
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You could look at Cargo for some help with starting and stopping Tomcat. For the database, I'd suggest starting up an in-memory HSQLDB rather than relying on the underlying system to have such things installed/running.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 388
Don't I have to start and stop HSQL just like any other database (except MSAccess)?

Thanks,
Siegfried
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
It is quite easy to start an in memory HSQLDB instance in the setup of a JUnit test.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 388
It is quite easy to start an in memory HSQLDB instance in the setup of a JUnit test.


Could you elaborate a bit? I assume I could turn it off too?
Thanks,
Siegfried
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Siegfried Heintze:
Could you elaborate a bit? I assume I could turn it off too?

Yes, you can. Check out this section of the documentation for details.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to automate testing with database/web servers