tags:

views:

158

answers:

5

Anyone know any? I need to send in a http request and make sure the http response i got back is not http 500

A: 

You could use httpunit - web-centric unit testing

Steve B.
But, he's not unit testing. He clearly says that he's monitoring here. Why wouldn't you use a monitoring tool like Big Sister, Hyperic, Monit, etc.?
John Munsch
+2  A: 

I believe Hyperic HQ meets all of your criteria. It is open source, I believe it is written at least partially in Java, and it is designed to do all kinds of server monitoring.

It should be able to handle not only the kind of monitoring you requested but other necessary monitoring like memory, CPU usage, and disk space on your servers as well.

John Munsch
A: 

http-unit or html-unit.

Maurice Perry
A: 

If you want to do this yourself, Apache HttpClient is an option:

GetMethod get = new GetMethod("http://www.stackoverflow.com");
try
{
    int resultCode = client.executeMethod(get);
    if (resultCode == 500)
    {
     //do something meaningful here

    } // if
} // try
catch (Exception e)
{
    e.printStackTrace();
}
finally
{
    get.releaseConnection();
}
jt
A: 

While you find it you can use this:

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.IOException;

public class SimplisticMonitor { 

    public static void main( String [] args ) throws IOException { 

        HttpURLConnection c = ( HttpURLConnection ) 
                      new URL( "http://stackoverflow.com" ).openConnection();

        System.out.println( c.getResponseCode() );
    }
}
OscarRyz