当前位置: 首页>>代码示例>>Java>>正文


Java WebForm.getRequest方法代码示例

本文整理汇总了Java中com.meterware.httpunit.WebForm.getRequest方法的典型用法代码示例。如果您正苦于以下问题:Java WebForm.getRequest方法的具体用法?Java WebForm.getRequest怎么用?Java WebForm.getRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.meterware.httpunit.WebForm的用法示例。


在下文中一共展示了WebForm.getRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logOn

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
private WebResponse logOn(WebConversation wc, String url, String user, String password)
throws Exception {
    WebRequest req = new GetMethodWebRequest(WEB_ROOT + url);
    WebResponse resp = wc.getResponse(req);
    assertEquals("Got To Log On Page", "Log On", resp.getTitle());

    WebForm form = resp.getForms()[0];
    WebRequest request = form.getRequest();
    request.setParameter("j_username", user);
    request.setParameter("j_password", password);

    return wc.getResponse(request);
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:14,代码来源:JSPGuardsTest.java

示例2: submitform

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
/**
 *  Submit a HTML form using values defined in the specified form Element in the xml configuration file.
 *
 *@param  formElement                form Element
 *@return                            Response Object
 *@exception  MalformedURLException  URL Error
 *@exception  IOException            HTTP Error
 *@exception  SAXException           Error parsing HTML
 *@exception  Exception              Description of Exception
 *@since
 */
public void submitform(Element formElement) throws NoResponseToProcess, MalformedURLException, IOException, SAXException, Exception {
	if (lastResponse == null)
		throw new NoResponseToProcess();
	assertNotNull("No form element defined", formElement);
	String formName = formElement.getAttribute("name");
	assertNotNull("Test data:: Cannot find <form name=\"" + formName + "\">", formElement);
	WebForm form = lastResponse.getFormWithName(formName);
	assertNotNull("No form of name '" + formName + "' found on page: " + lastResponse.getURL(), form);
	int originalIdents[] = dbResource.getAllIdents();
	WebRequest request = form.getRequest();
	NodeList inputElements = formElement.getElementsByTagName("input");
	List names = Arrays.asList(request.getRequestParameterNames());
	for (int i = 0; i < inputElements.getLength(); i++) {
		Element inputElement = (Element) inputElements.item(i);
		if (inputElement.hasAttribute("set")) {
			String value = mapResource.getRegex(inputElement.getAttribute("set"),lastResponse);
			String ipname = inputElement.getAttribute("name");
			assertTrue("No <input name='" + ipname + "' > in <form name='" + formName + "'>", names.contains(ipname));
			request.setParameter(ipname, value);
			debug("Set: " + inputElement.getAttribute("name") + " " + value);
		}
	}
	try {
		lastResponse = conversation.getResponse(request);
	}
	catch (HttpNotFoundException e) {
		fail(e.getMessage());
	}
	lastResponseElement = formElement;
	mapResponses.put(formName, lastResponse);
	if (formElement.hasAttribute("submit"))
		assertEquals(formElement.getAttribute("submit"), request.getURL().getFile());
	int modifiedIdents[] = dbResource.getAllIdents();
	dbResource.compareIdents(originalIdents, modifiedIdents, formElement);
}
 
开发者ID:Amsoft-Systems,项目名称:xmltestsuiteR12,代码行数:47,代码来源:HttpResource.java

示例3: applicationLogin

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
private WebRequest applicationLogin(WebConversation conversation,
		WebResponse response) throws SAXException, Exception {
	WebRequest request;
	WebForm loginForm = response.getForms()[0];
	request = loginForm.getRequest();

	SelectionFormControl asDorianOptions = (SelectionFormControl) response
			.getElementWithID("dorianName");
	request
			.setParameter("dorianName",asDorianOptions.getOptionValues()[1]);

	response = tryGetResponse(conversation, request);
	loginForm = response.getForms()[0];
	request = loginForm.getRequest();

	SelectionFormControl asUrlOptions = (SelectionFormControl) response
			.getElementWithID("authenticationServiceURL");
	String[] urls = asUrlOptions.getOptionValues();
	request.setParameter("authenticationServiceURL", urls[1]);
			
	response = tryGetResponse(conversation, request);
	loginForm = response.getForms()[0];
	request = loginForm.getRequest();

	request.setParameter("username", "jdoe2");
	request.setParameter("password", "K00lM0N$$2");
	return request;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:29,代码来源:AssertWebSSOApplicationStep.java


注:本文中的com.meterware.httpunit.WebForm.getRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。