- All Implemented Interfaces:
- MonitorReport
public class WebTester
extends Report
WebTester sends requests via a client socket and gets response back.
It supports protocols of http, https and generic tcp sockets.
It provides a test method, testHTTPD() for web servers. This method
throws exceptions if the internal error occurs. Otherwise it returns an
integer indicating the status of the web server.
Status Code Description
0 TESTOK server is OK
1 PROTOCOLERROR protocol error, probably wrong port
2 PATTERNNOHIT pattern not matched, wrong page or server error
3 NOTMULTIPART not a multipart
4 CLIENTERROR client error, such as page not found, broken link
5 SERVERERROR web server internal error
6 READFAILED failure in read, probably server is busy
7 WRITEFAILED failure in write, probably server is busy
8 CONNTIMEOUT connection timeout, probably server is busy
9 CONNREFUSED connection refused, probably server is down
exception TESTFAILED unexpected system errors
One of the client error is 401 error, Not authorized. It will happen when
a password protected page is requested. In order to get the page, the
base64 encoded authentication string should be specified in the argument
hash. For security reason, we do not use the original string. To get the
auth string, try to use the following tool:
echo -n 'USERNAME:PASSWORD' | base64
The output is the base64 encoded username and password, the auth string.
The other method, generateReport(long), returns a report in a Map
that contains the response as a String and status code defined above
except exceptions. It catches all exceptions and returns -1 indicating
internal error. Therefore, generateReport(long) will not throw any
exceptions.
- Author:
- yannanlu@yahoo.com