I am working on an ANT target for running tests, but I need to have the app server up and running before the tests start, so I'm using the "waitFor" task to ping a URL until it gets a response. This works great except that I need to not only make sure the URL is simply accessible, but also check that a particular status string is present. This second requirement is simple enough on its own with tasks like get or telnet and then doing a substring search, but the waitfor task doesn't accept any nested elements other than the standard ANT conditions or thing they can wrap (basically things that return booleans). I have tried loading the URL as a resource prior to the waitfor task and the using a resourceconatins condition within, but I found that it just caches the URL's response and doesn't refresh with the lastest response from the app server. Does anyone know of a way to force the URL to be loaded on each loop or some other way to achieve this?
Here is essentially what I want to achieve in pseudo-code:
<waitfor>
<and>
<!-- make sure the URL is accessible at all -->
<http url="theurl.jsp"/>
<!-- load the URL as a resource and make sure it contains a substring -->
<!-- moving the "url" task before the waitfor works if all conditions are met the first time through, but does not refresh the URL if it has to loop over again. having it inside like this, fails because waitfor/and don't support nexted "url" tasks -->
<url id="url.resource" url="url.jsp"/>
<resourcecontains refid="url.resource" substring="status"/>
</and>
<!-- else, keep on trying until timeout -->
</waitfor>
<!-- continue on to the tests to be run -->