Java源码示例:com.meterware.httpunit.HttpInternalErrorException

示例1
public void testFormUnregister() throws Exception {
  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/General/testFormUnregister.jsp");
  WebForm form = resp.getForms()[0];
  Button button = form.getButtonWithID("testFormUnregister");
  
  String requestId = form.getParameterValue(Constants.RP_REQUEST_ID);
  wc.getResponse(webedTestLocation + "/unregister?requestid=" + requestId);
  
  try {
    button.click();
    fail("Failed to unregister form action data.");
  } catch (HttpInternalErrorException e) {
  }
}
 
示例2
public void testTimedExpiryOfActionData() throws Exception {
  WebResponse resp1, resp2;
  WebForm form1, form2;
  
  // Set expiry age low.
  wc.getResponse(webedTestLocation
      + "/test/General/setBundleExpiryAge.jsp?bundleExpiryAge=0");

  // Test that form action data are expired after a short time.
  resp1 = wc.getResponse(webedTestLocation
      + "/test/General/testTimedExpiryOfActionData.jsp");
  form1 = resp1.getForms()[0];
  resp2 = wc.getResponse(webedTestLocation
      + "/test/General/testTimedExpiryOfActionData.jsp");
  form2 = resp2.getForms()[0];
  form2.submit();
  try {
    form1.submit();
    fail("Failed to expire form action data after set expiry time.");
  } catch (HttpInternalErrorException e) {
  }
  
  // Reset expiry.
  wc.getResponse(webedTestLocation
      + "/test/General/setBundleExpiryAge.jsp");

  // Test that form action data are _not_ expired after a short time.
  resp1 = wc.getResponse(webedTestLocation
      + "/test/General/testTimedExpiryOfActionData.jsp");
  form1 = resp1.getForms()[0];
  resp2 = wc.getResponse(webedTestLocation
      + "/test/General/testTimedExpiryOfActionData.jsp");
  form2 = resp2.getForms()[0];
  form2.submit();
  form1.submit();
}