Anteater
 
   

Example scripts

printer
print-friendly
PDF

by Jeff Turner

Example scripts

These scripts are part of the standard Anteater distribution.

ScriptDescription
website.xml
Downloads index.html from the Anteater website and validates it's contents. Simplest example of client-side Anteater action, validating one file from an external HTTP server.
postxml.xml
An example of how to POST an XML file (to a listener which then prints it).
uses.xml
Demonstrates the 'uses' tag to ensure the XHTML schemas are downloaded, before trying to validate the XHTML on the w3.org site.
w3.xml
This test downloads an XML spec from the W3C and tests it with XPath and regexp expressions. Regression test for Anteater's ability to resolve relative DTDs.
haltonerror.xml
Demonstrates haltonerror flag. This flag governs whether a failed action will stop the whole script. By default, it is set to true (see src/META-INF/default.properties). Here we define a group, 'somegroup' which lets us try commandlines like: anteater -f haltonerror.xml -Dsomegroup.haltonerror=false Which will stop a failing task from halting the build. Specifying -Ddefault.haltonerror=false won't have the same effect, because somegroup descends from 'default' and overrides haltonerror.
catchallcontent.xml
Demonstrates how you can use matcher 'assign's to store the contents of a URL
nomatchers.xml
Demonstrates that if we don't specify any matchers, the test succeeds. This ought to migrate to the regression testing directory.
fileformat.xml
Demonstration of a custom XML log file format, and the ability to not clobber old log files. Also a regression test against www.bibleportalproject.com, checking that XML log files are written on both passes and failures.
report.xml
Demonstrates how to generate a HTML report from a directory full of XML logs.
xpath_regexp.xml
Tests to make sure that the regexp support on the XPath matcher works as advertised.
header.xml
Demonstrates using regexps on the 'header' matcher, and then doing some conditional logic based on the mime type.
session.xml
Template client/server Anteater script. Copy this and customize.
website-https.xml
Demonstrates Anteater's HTTPS support by testing the url 'https://www.verisign.com'. Requires jsse.jar and friends.
image_public.xml
Tests a Jakarta image with the 'image' matcher.
postfile.xml
This is a demonstration of how to upload forms via POSTING content of type multipart/form-data. It may even work.
geocoder.xml
A hypothetical geocoder service, accepting an address and returning XML containing latitude and longitude addresses.
utils.xml
This script is a library of targets which other scripts can call, eg:
soap.xml
Demonstrates how to do a SOAP query
groups.xml
Grouping demonstration from the docs
regexp.xml
Some examples of how to use the regexp matcher, illustrating negation, grouping, and use of singleLine attribute.
logic_listeners.xml
xpath.xml
Client/server XPath demo. Demonstrates use of namespace declarations
deploy.xml
Demonstrates the 'deploy' task. Deploys resources/sessiondemo.war to the root context, and checks that the testfile.txt file with a few regexp matchers.
book.xml
content-check.xml
Basic demonstration of Anteater acting as both a HTTP client and server. 1. A Listener is used to serve a file, resources/responses/good.html 2. A httpRequest then requests the file. 3. The listener serves it up. 4. The httpRequest validates the contents against the original file
image.xml
Demonstrates the various binary formats that can be (slightly) validated. Currently (2002-09-28), we can validate: application/x-shockwave-flash image/bmp image/gif image/iff image/jpeg image/pcx image/png image/psd image/ras image/x-portable-bitmap image/x-portable-graymap image/x-portable-pixmap
website-https-bad-cert.xml
Demonstrates Anteater's HTTPS support for sites with invalid certificates by testing the url 'https://www.caserver.com'. Requires jsse.jar and friends.
template.xml
Template client/server Anteater script. Copy this and customize.
contentequals.xml
Demonstrates basic usage of the 'contentEquals' matcher.
redirect.xml
Demonstrates redirect (302) handling
jelly.xml
Demonstrates Anteater's support for dynamically creating element bodies with Jelly
groups_simple.xml
Grouping demo ------------- In this demo, groups are used to simplify the test script. Please see the source for details.
logic_online.xml
Script which exercises the 'match' element's assign attribute, in order to perform conditional logic based on whether the match task succeeded. In this example, first we 'check' if the site is online (return HTTP 200 responses to '/' request), and if so, check whether the 'Server' header indicates the server is Apache. If so, print a message, if not, print another.
httppost.xml
Demonstrates the ways in which matchers can be used, for setting and testing HTTP requests and responses.
filerequest.xml
Demonstrates a 'fileRequest' action task, which tests a local file (not requiring a servletContainer
ant15_broken_example.xml
An attempt at getting Anteater running under vanilla Ant 1.5.
interactive.xml
Demonstrates various ways to use listeners. These tests require user interaction, ie telnetting to a port. Instructions are provided interactively.
logger.xml
logic_conditional.xml
Simple demonstration of using <match assign=".."> in a httpRequest, and then doing some conditional logic. In this case, we flag if the server is online, and then print a message indicating if it is or not.
logic_servertest.xml
Script which exercises the 'match' element's assign attribute, in order to perform conditional logic based on whether the match task succeeded. Also demonstrates regexps in the 'header' matcher. In this example, first we 'check' if the site is online (return HTTP 200 responses to '/' request), and if so, we run a set of matchers to determine what HTTP server the site is running:
relaxng.xml
Demonstration of the 'relaxng' matcher.
Forrest logo