ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Durham <david.durh...@scott.af.mil>
Subject Re: Using Hsqldb for unit tests
Date Fri, 10 Sep 2004 21:31:24 GMT
Chappell, Simon P wrote:

> 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).

Ok, that's the issue:  I'm using one connection to create the tables and 
another connection is trying to insert into those tables.

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

Well, from what you've said, it's looks like I'd need something like

setup() {
    //create tables
}

testSomething() {
    // create object that inserts into table(s)
    // check select object from table(s)
}

tearDown() {
    // close connection perhaps (*)
}

* I use OJB, so perhaps I can get around the "only use a single 
connection problem" by using a pool of 1 connection.  Still, I'm using 
torque to create the tables based on an XDoclet generated 
project-schema.xml.  Getting all of this into connection seems like a 
problem.

What do you think?


- Dave


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


Mime
View raw message