import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
import java.util.Date;
/**
* Threaded client to test that the servlet manages to handle
* multiple "simultaneous" requests for the default servlet.
* @author <a href="mailto:mark@mcraig.org">Mark Craig</a>
*/
public class TestClient extends Thread {
String URL;
int Nbr;
WebConversation WC;
WebRequest Req;
WebResponse Res;
TestClient(String url, int nbr) {
URL = url;
Nbr = nbr;
WC = new WebConversation();
}
public void run() {
try {
Date now = new Date();
System.out.println(Nbr + " started : " + now.getTime());
Req = new GetMethodWebRequest(URL);
Res = WC.getResponse(this.Req);
System.out.println(Nbr + " page : " + Res.getTitle());
Date later = new Date();
System.out.println(Nbr + " finished: " + later.getTime());
this.finalize();
} catch (Throwable e) {
System.out.println(e.toString());
}
}
} |