gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Existence of a database?
Date Mon, 24 May 2004 07:33:20 GMT
On Wed, 19 May 2004, Ceki Gülc <ceki@qos.ch> wrote:

> I wonder if it possible to group tasks and invoke them as a function
> or a method call.

Rather "as a macro".  Let me see whether I can find a macrodef
solution for you.

The target running the test would be easy:

<macrodef name="rundbtest">
  <attribute name="dbtype"/>
  <sequential>
    <delete file="./input/db/db.properties"/>
    <echo message="@{dbtype} available"/>
    <copy file="./input/db/@{dbtype}.properties" 
          tofile="./input/db/db.properties"/>

    <junit printsummary="yes" fork="no" haltonfailure="yes">
      <sysproperty key="runLen" value="100"/>
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.db.FullCycleDBTest" />
    </junit>
  </sequential>
</macrodef>

and

<target name="mysql" depends="mysqlCheck, build" if="mysql-present">
  <rundbtest dbtype="mysql"/>
</target>
<target name="postgresql" depends="postgresqlCheck, build" 
        if="postgresql-present">
  <rundbtest dbtype="postgresql"/>
</target>

The checking part may be more difficult than the tests you've shown,
you could also <macrodef> them if they really are that similar for all
databases.

The whole check-then-test logic could be streamlined into a single
macro with Ant-Contrib's <if> if you feel that inclined.   A pure Ant
solution would probably look like:

* write a build file that contains check and test targets much like
  your old build file did and use properties for all DB specific things
  (JDBC driver, property file).  No macros, plain old targets.

* for each database you intend to support write a tiny little build
  file that <import>s the build file above and sets the properties.
  If you ever encounter a database that needs more complicated checks
  than the ones you have so far, you can override the check target
  (<import> supports "target inheritance").

* In you master build file, <subant> over your database specific build
  files.

But we are really getting off Gump-topic here 8-)

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@gump.apache.org
For additional commands, e-mail: general-help@gump.apache.org


Mime
View raw message