ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <>
Subject [PROPOSAL] Start Server task / J2EEUnit test automation
Date Fri, 23 Feb 2001 13:02:37 GMT

I have written a task that does the following :
- call a specified target in another thread. This other target should start
your server (web server or servlet engine) using the java task for example
and should be blocking (otherwise, there is no need for the current task !),
- wait until that server is started by trying to connect to it using a
specified URL

The format of this task is as follows :

<startserver startTarget="name of target that starts the server"
testURL="url to test"/>

It is very useful for example to help start servlet engine, run J2EEUnit
( and for the developer site) tests and
stop the running servlet engine. Here is an example :

    <!-- Run Tomcat 3.2 tests -->
    <target name="tests_tomcat_32" depends="prepare_tests_tomcat_32">

        <!-- Start the Tomcat server in another thread and waits until it
is -->
        <startserver testURL="http://localhost:8080"

        <!-- Start the JUnit test runner -->
        <antcall target="tests"/>

        <!-- Stop the Tomcat server -->
        <antcall target="stop_tomcat_32"/>


With the following targets :
- prepare_tests_tomcat_32 : prepares the directory for testing with tomcat :
make war file, copy it, copy tomcat config files, ...
- start_tomcat_32 : target that uses the java task to start Tomcat
- stop_tomcat_32 : target that uses the java task to stop Tomcat

For a full Ant build script that uses this, check

I include in this mail the java code for the Start Server task.

Note : I have not finalized the StopServer task as it does not seem to work
very well. The idea was to force a servlet engine to stop if it did not
provide any way to stop itself (for example Resin - It may exist but I have
not found how to do it yet). However, I use the stop() method to kill the
thread but it does not seem to stop the running servlet engine. However
maybe we don"t need a Stop Server task for the moment. In that case, I'll
remove the ThreadManager class which was just used as a placeholder  for
storing a reference to the thread so that the stop server task could call
the stop() method on that thread.

Do you think this Start Server task should be part of the optional Ant tasks
? (for the moment I deliver it as part of the J2EEUnit jar).

Thanks a lot.
Vincent Massol
J2EEUnit author.

View raw message