ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank E. Weiss" <fra...@well.com>
Subject Re: How to set a property from a custom task? (LONG)
Date Thu, 20 Sep 2001 18:33:43 GMT
I'm wondering if you've ruled out using dependency instead of a property.
Something like:

<JUnit name="testmail" depends="mailserverup">
   ...
</JUnit>

<script name="mailserverup">
    // start mail server, check if up
    // fail task otherwise (can this be done in ant, or does it need a custom
task?)
</script>

Hope this helps. -- Frank Weiss

Paul Michali wrote:

> Thomas Tuft Muller wrote:
> >
> > You can always set a system property and access it from other tasks, but it
> > seems a little akward to make a custom task for what you want. You can get
> > away with a combination of default tasks. There are many solutions.
> >
> > The simplest is to leave it to the actual JUnit test to check if the
> > resource is available to conduct the test.
>
> Since I'm new to Ant (and Java), can you elaborate more on what the
> solutions
> are?
>
> To be more specific, let me detail more of what I'm doing...
>
> I have an app that part of it's job is to send email messages to various
> users.
> In the JUnit tests that I have, I included a few tests that verify that
> the
> message is sent correctly. I did this by using DixieMail, which is a
> freeware
> mail server. I setup a dummy account, have my application send the mail
> message
> (after it does its thing) and then the JUnit test polls the mail server
> to see
> if the message arrives and verifies the contents are correct. It could
> be
> argued that this is more of a Functional than Unit test, but want to
> check this
> functionality.
>
> So, when I run Ant, if I forget to start the mail server up ahead of
> time, then
> the JUnit test fails. After this happened a few times, I decided to try
> to
> tackle fixing this.
>
> Now the mail server is a Java application, so I can start it from Ant.
> However,
> there's no easy way to tell if the mail server is running or to stop the
> mail
> server.
>
> I could modify the JUnit tests to check and start the server, if it is
> not running.
> However, I was interested in trying to divorce the setup of the mail
> server from
> the Unit tests and I wanted to get a little feel for how to customize
> Ant as well.
>
> Along those lines, what things should I consider doing? One idea that
> I've been
> discussing with others, is to use a custom task to check the server
> (flush any
> pending messages) and then set a property to indicate whether or not the
> server is
> running. The build.xml could then use that property to decide whether to
> start the
> server (using <java classname="dixie"...) and whether or not to allow
> the tests to
> run (in case we cannot start the server).
>
> Is this a reasonable approach? Is it going to be way more work than just
> modifying
> the Unit tests? Are there other, easier ways to do this?
>
> Another idea was to check and start the server as part of the custom
> task, rather
> than using several targets to check, start the server, and re-check.
>
> PCM (Paul Michali)
>
> Carrier Voice Gateway Business Unit (CVGBU)
> Cisco Systems, Inc.
> 250 Apollo Drive
> Chelmsford, MA 01824
>
> Phone : (800) 572-6771 x 45817  (978) 244-5817 [direct]
> Paging: (800) 365-4578 [voice]  pcm@epage.cisco.com [email page]


Mime
View raw message