blob: 3f74aef723bb240a7e397b798b6deced0a95412c [file] [log] [blame]
<?xml version="1.0"?>
<project name="isreachable">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<macrodef name="assertHostReachable">
<attribute name="host"/>
<sequential>
<fail message="not reachable: @{host}">
<condition>
<not>
<isreachable host="@{host}"/>
</not>
</condition>
</fail>
</sequential>
</macrodef>
<macrodef name="assertHostNotReachable">
<attribute name="host"/>
<sequential>
<fail message="unexpectedly reachable: @{host}">
<condition>
<isreachable host="@{host}"/>
</condition>
</fail>
</sequential>
</macrodef>
<macrodef name="assertUrlReachable">
<attribute name="url"/>
<sequential>
<fail message="not reachable: @{url}">
<condition>
<not>
<isreachable url="@{url}"/>
</not>
</condition>
</fail>
</sequential>
</macrodef>
<target name="testLocalhost">
<assertHostReachable host="localhost"/>
</target>
<!-- bugs in XPSP2 mean this is the only IPv4 loopback addr allowed -->
<target name="testIpv4localhost">
<assertHostReachable host="127.0.0.1"/>
</target>
<target name="testBoth">
<condition property="both">
<isreachable host="localhost" url="http://localhost"/>
</condition>
<fail>Expected failure before here</fail>
</target>
<target name="testLocalhostURL">
<assertUrlReachable url="http://localhost"/>
</target>
<target name="testIpv4localhostURL">
<assertUrlReachable url="http://127.0.0.1/"/>
</target>
<target name="testFTPURL">
<assertUrlReachable url="ftp://localhost"/>
</target>
<target name="testFile">
<assertUrlReachable url="file://build.xml"/>
</target>
<target name="testBadURL">
<assertUrlReachable url="uuid:3349-4404-0ac0ddee"/>
</target>
<target name="testBadTimeout">
<condition property="testBadTimeout">
<isreachable host="localhost" timeout="-1"/>
</condition>
</target>
<target name="testNoTargets">
<condition property="none">
<isreachable/>
</condition>
</target>
</project>