I switched from using the memory only mode to using Hypersonic in server mode instead. I fired off server mode from the command line, changed the datasource URL, and everything seemed to work fine. I didn't have to change anything regarding the loading of the schema export using ant:sql. Of course, now the issue is that if I want this to be completely automated I have to find a way to get Maven to start up Hypersonic in server mode for me. Here's what I'm trying:

<postGoal name="java:compile">
<!-- Generate schema for the database -->
<ant:path id="schemaexport.classpath">
<ant:path refid="maven.dependency.classpath" />
<ant:pathelement location="${maven.build.dir}/classes" />
</ant:path>
<ant:taskdef name="schemaexport" classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="schemaexport.classpath" />
<ant:schemaexport properties="etc/hibernate-unit-test.properties" delimiter=";" text="yes" output="${maven.build.dir}/${pom.name}.ddl">
<ant:fileset dir="${maven.build.dest}">
<ant:include name="**/*.hbm.xml" />
</ant:fileset>
</ant:schemaexport>
</postGoal>


<preGoal name="test:compile">
<ant:copy file="${maven.war.src}/WEB-INF/applicationContext.xml" todir="${basedir}/target/test-classes/" filtering="on">
<ant:filterset>
<ant:filter token="hibernate.dialect" value="net.sf.hibernate.dialect.HSQLDialect" />
</ant:filterset>
</ant:copy>
</preGoal>


<preGoal name="test:test">
<!-- need to startup the database here -->
<ant:java classpathref="maven.dependency.classpath" fork="true" spawn="true" classname="org.hsqldb.Server">
<arg value="-database" />
<arg value="testdb" />
</ant:java>
<!-- Load schema into hsqldb for unit testing -->
<ant:sql driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:hsql://testdb" userid="sa" password="" src="${maven.build.dir}/${pom.name}.ddl" onerror="continue">
<ant:classpath refid="maven.dependency.classpath" />
</ant:sql>
</preGoal>


I left in the ant:java code which does not work. I seem to remember having this problem before, but I don't think Maven allows for the spawning on a new process properly. How are you firing off Hypersonic?

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
[EMAIL PROTECTED]
OpenPGP key available from:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7977F79C


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



--
Eric W. Hauser
Application Developer
accessIndiana..."linking hoosiers to government"
http://www.IN.gov
10 W. Market St., Suite 600
Indianapolis, IN 46204
Phone: (317) 233-4007
Fax: (317) 233-2011

**********************************************************************
CONFIDENTIALITY NOTICE:
This E-mail and any attachments are confidential. If you are not the intended recipient, you do not have permission to disclose, copy, distribute, or open any attachments. If you have received this E-mail
in error, please notify us immediately by returning it to the sender and delete this copy from your system. Thank you.
accessIndiana, MyLocal.IN.gov, CivicNet
**********************************************************************



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to