import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* HttpUnit mechanism to test that the servlet manages to handle
* a couple of correctly formed requests for the default servlet.
* This mechanism only works when the servlet is running in the
* container and is reachable under
* http://localhost:8080/refentry
* <p>The test is then run by hand. Ideally, it would be integrated
* into an automated framework such as Cactus.
* @author <a href="mailto:mark@mcraig.org">Mark Craig</a>
*/
public class TestOkayRequests extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
public static TestSuite suite() {
return new TestSuite(TestOkayRequests.class);
}
public TestOkayRequests(String str) {
super(str);
}
public void testOkayRequests() throws Exception {
WebConversation wc = new WebConversation();
WebRequest request =
new GetMethodWebRequest(
"http://localhost:8080/refentry");
WebResponse response = wc.getResponse(request);
String title = response.getTitle();
assertEquals(title, "webman(1) - a RefEntry client viewer");
WebRequest request1 =
new GetMethodWebRequest(
"http://localhost:8080/refentry?SrchString=refentry");
WebResponse respons1 = wc.getResponse(request1);
assertEquals(respons1.getTitle(), "Search Results");
}
} |