Use antcall to call the target with the db specific properties, this way you can merge the postresql and the mysql targets. You can eg add a commandline parameter for the people who eg just want to run the postgressql target eg ant -Ddbtest=mysql.
Mvgr, Martin On Wed, 2004-05-19 at 14:01, Ceki Gülcü wrote: > Thanks everyone for answering. > > At 01:27 PM 5/19/2004, Eric Pugh wrote: > >I find that depending on an external database makes the unit tests very > >brittle.. Unless you are specifically testing something that requires a > >specific type of database, I find that using hsqldb or axion works fine.. > > I agree that having tests run all several databases makes things > complicated and brittle. We currently have tests unit tests that work on > mysql and postgres. The Junit test case plus the related log4j config files > import a DB specific property file at runtime if it is available on the > local system, otherwise the test for that db are skipped. Adding tests for > other databases should be easy, except that it would result in duplication > of targets in the Ant build file. > > The build file is available here: > > http://cvs.apache.org/viewcvs.cgi/logging-log4j/tests/build.xml?rev=1.54 > > The relevant part is reproduced below. > > <!-- ================================================================= --> > <!-- ========================= DB Tests ======================= --> > <!-- ================================================================= --> > > <!-- These tests follow the same pattern. They will be run if a property > file > defining access as well as necessary class files are available. > Otherwise, > the test is skipped. > --> > > <target name="mysqlCheck"> > <condition property="mysql-present"> > <and> > <available file="./input/db/mysql.properties" /> > <available classname="com.mysql.jdbc.Driver"> > <classpath refid="tests.classpath"/> > </available> > </and> > </condition> > </target> > > > <target name="mysql" depends="mysqlCheck, build" if="mysql-present"> > > <delete file="./input/db/db.properties"/> > <echo message="MySQL available"/> > <copy file="./input/db/mysql.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> > </target> > > > <target name="postgresqlCheck"> > <condition property="postgresql-present"> > <and> > <available file="./input/db/postgresql.properties" /> > <available classname="org.postgresql.Driver"> > <classpath refid="tests.classpath"/> > </available> > </and> > </condition> > </target> > > <target name="postgresql" depends="postgresqlCheck, build" > if="postgresql-present"> > <delete file="./input/db/db.properties"/> > <echo message="PostgreSQL available"/> > <copy file="./input/db/postgresql.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> > </target> > > > > As you can see there is almost complete duplication of the tasks for mysql > and postgresql. I wonder if it possible to group tasks and invoke them as a > function or a method call. > > Anyway, I am digressing. Thanks for your help. > > > >Eric > > > > > -----Original Message----- > > > From: Stefan Bodewig [mailto:[EMAIL PROTECTED] > > > Sent: Wednesday, May 19, 2004 9:24 AM > > > To: [EMAIL PROTECTED] > > > Subject: Re: Existence of a database? > > > > > > > > > On Sat, 15 May 2004, Ceki Gülc <[EMAIL PROTECTED]> wrote: > > > > > > > Could we assume that gump machines have a database that these test > > > > cases can connect to? > > > > > > You can savely assume that hsqldb is around[1] but not "installed" in > > > any way. I.e. you could make your tests depend on hsqldb and they'd > > > work in Gump. > > > > > > Even if some Gump machine may use some kind of DB in the future (to > > > gather historical data or whatever else we come up with), there'll be > > > no guarantee that all machines have one. > > > > > > Stefan > > > > > > Footnotes: > > > [1] http://brutus.apache.org/gump/public/hsqldb/hsqldb/index.html > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] -- Mvgr, Martin --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
