maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Walding <...@walding.com>
Subject Re: Unit testing with Hypersonic
Date Fri, 06 Aug 2004 10:51:07 GMT
You should find that the system property "baseDir" is the root of the 
active project being built.

eg System.getProperty("baseDir")

Cheers,

Ben

Craig S. Cottingham wrote:

> On Aug 5, 2004, at 10:19, Eric Hauser wrote:
>
>> I running some unit tests with Maven during my build process using 
>> Hypersonic in-memory mode as the datasource.  I generating the schema 
>> from Hibernate and then loading the schema in a preGoal for test:test 
>> using the ant:sql tags.  The problem that I am having is every time 
>> the unit test runs, Hypersonic cannot seem to find the tables that I 
>> just loaded.  Anyone have an example code that does something 
>> similar? Thanks.
>
>
> We don't generate the database schema as part of the test goal; 
> instead, the Hypersonic database script is an original source and 
> stored in version control. Other than that, I think we're doing 
> something similar to what you're trying to do.
>
> The problem we ran into was that Maven has no well-defined current 
> directory from which to specify a relative path to the database 
> script. Normally, this would mean that you'd have to specify an 
> absolute path, which is generally a Bad Idea.
>
> I got around this by modifying the datasource configuration properties 
> file in a pregoal for test:test:
>
>   <preGoal name="test:test">
>     <ant:copy todir="${maven.build.dir}/test-classes" overwrite="true" >
>       <ant:fileset dir="${maven.src.dir}/test/conf">
>         <ant:include name="datasource.properties" />
>       </ant:fileset>
>       <ant:filterset>
>         <ant:filter token="BUILDDIR" value="${maven.build.dir}" />
>       </ant:filterset>
>     </ant:copy>
>   </preGoal>
>
> The datasource configuration properties file contains (in part):
>
>   testPool.jdbc.driver=org.hsqldb.jdbcDriver
>   testPool.jdbc.url=jdbc:hsqldb:@BUILDDIR@/testdb
>
> The glue between the datasource configuration properties and the code 
> that uses the datasource I can't show you, unfortunately. But as long 
> as you're defining the connection parameters in a configuration file 
> (and you should be :-), you should be able to do something similar.
>
> Hope this helps.
>
> -- 
> Craig S. Cottingham
> craig@cottingham.net
> OpenPGP key available from:
> http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7977F79C
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message