我正在编写一个Ant目标,用于运行测试,在测试开始之前需要运行一个应用服务器。我使用
有没有办法强制在每次循环中加载URL?还是其他实现方式?
以下是我想要实现的伪代码:
waitFor
任务来ping URL,直到它得到响应。这很有效,但我不仅需要确保URL可以访问,还需要检查特定状态字符串是否存在。这第二个要求本身很简单,可以用get
或telnet
任务,然后进行子字符串搜索。但是'waitfor'任务除了标准Ant条件或可包装的东西(返回布尔值的东西)之外,不接受任何嵌套元素。我尝试在运行'waitfor'任务之前将URL加载为资源,并使用resourcecontains
条件,但那会缓存响应,并且不会从服务器刷新。有没有办法强制在每次循环中加载URL?还是其他实现方式?
以下是我想要实现的伪代码:
<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 -->