I’m creating a test which will perform some stress testing of the app which talks to a Postgres database. In order to make it replicable I’d like to recreate the database on every run. Startup method decorated with org.junit.Before annotation will drop the database (if it exists) and restore it from a dump file. Doing this form shell/command is trivial:
psql -f db.out newdb
or something along these lines. Since the test may be performed on a JVM that’s not running on the same machine which hosts the database I’m wondering if it’s possible to invoke shell/batch script on remote machine from Java programmaticaly.
Thanks
If you have knowledge of the machine details (hostname, login, password) the only thing I can think of at the moment is using a Java SSH library to login to the box and run that command.
Or you could write a script on your local machine which ran the script on the remote machine given the correct parameters.
That’s the simplest way I can think of anyway!