【发布时间】:2010-11-12 04:21:55
【问题描述】:
我正在开发一个用于运行测试的 Ant 目标,我需要在测试开始之前启动并运行一个应用服务器。我正在使用waitFor 任务来ping 一个URL,直到它得到响应。这可行,除了我不仅需要确保 URL 可以轻松访问,还需要检查是否存在特定的状态字符串。第二个要求本身很简单,有一个get 或telnet 任务,然后是子字符串搜索。但是“waitfor”任务不接受除标准 Ant 条件之外的任何嵌套元素,或者它们可以包装的东西(返回布尔值的东西)。在运行带有resourceconatins 条件的“waitfor”任务之前,我尝试将 URL 作为资源加载,但这会缓存响应,并且不会从服务器刷新。
有没有办法强制在每个循环中加载 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 -->
【问题讨论】:
标签: web-applications ant