ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chappell, Simon P" <Simon.Chapp...@landsend.com>
Subject RE: Using Hsqldb for unit tests
Date Fri, 10 Sep 2004 21:14:03 GMT
I can half answer this now, I'll finish up next week.

I use HSQLDB for unit testing some of my persistence-related personal code. I haven't run
the tests from within ant yet, but I have used the JUnit test facility within Eclipse to run
the unit tests.

Typically I connect using the JDBC string "jdbc:hsqldb:." (with userid "sa" and password "")
and that gives me the in-memory database that I can use for my tests. This is very nice because
when ever I open a connection to an in-memory database, I get a fresh, clean, empty database
suitable for repeatable unit testing (as long as I remember to close the connection when I'm
done with it).

If you remind me, I can share some code samples.

Simon

-----------------------------------------------------------------
Simon P. Chappell                     simon.chappell@landsend.com
Java Programming Specialist                      www.landsend.com
Lands' End, Inc.                                   (608) 935-4526

"Some problems are so complex that you have to be highly intelligent and well-informed just
to be undecided about them." - Laurence J. Peter


>-----Original Message-----
>From: David Durham [mailto:david.durham1@scott.af.mil]
>Sent: Friday, September 10, 2004 4:06 PM
>To: hsqldb-user@lists.sourceforge.net; user@ant.apache.org
>Subject: Using Hsqldb for unit tests
>
>
>I have a couple of questions.
>
>First off, I'm trying to use hsqldb for rapid development/prototyping.
>
>I'm thinking I can do the following in a series of ant tasks:
>
>   1. Connect to Hsqldb using the "mem" subprotocol simply by 
>having the
>      hsqldb jar in a classpath.
>   2. Use XDoclet, and Torque to create tables -- I have this basically
>      setup.
>   3. Run unit tests with classes that use these tables.
>
>Here are my questions:
>
>   1. Can I connect to hsqldb:mem:
>          * using username: sa and password: <empty>
>          * in seperate ant targets (as in, create-db, and tests.run.*)
>
>    * and expect to have access from a tests.run.* target to the tables
>      created in a create-db target.
>
>So far, my work indicates that it's not the case.  I have it setup to 
>create tables, but when unit tests run, they through various 
>SQL errors 
>from "can't find table", to "no such username: sa"
>
>Does anyone who can give me some help have a setup like this 
>working?  I 
>figured this was a common usage of hsqldb, is it not?
>
>
>Thanks,
>
>Dave
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message