本文整理汇总了Java中com.meterware.httpunit.WebRequest.setParameter方法的典型用法代码示例。如果您正苦于以下问题:Java WebRequest.setParameter方法的具体用法?Java WebRequest.setParameter怎么用?Java WebRequest.setParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.meterware.httpunit.WebRequest
的用法示例。
在下文中一共展示了WebRequest.setParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
//Prepare the environment..
ProxymaFacade proxyma = new ProxymaFacade();
ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
ServletRunner sr = new ServletRunner();
sr.registerServlet( "myServlet", TestServlet.class.getName() );
ServletUnitClient sc = sr.newClient();
WebRequest wreq = new GetMethodWebRequest( "http://test.meterware.com/myServlet?a=1&b=2" );
wreq.setParameter( "color", "red" );
WebResponse wres = sc.getResponse( wreq );
InvocationContext ic = sc.newInvocation( wreq );
request = ic.getRequest();
response = ic.getResponse();
}
示例2: doTest
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
/**
* Check sorted column.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
ParamEncoder pe = new ParamEncoder("table");
request.setParameter(pe.encodeParameterName(TableTagParameters.PARAMETER_PAGE), "2");
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug("RESPONSE: " + response.getText());
}
// <span class="pagebanner">3 items found, displaying 1 to 1.</span>
HTMLElement pagebanner = response.getElementWithID("pagebanner");
Assert.assertEquals("Wrong page banner", "4|3|4", pagebanner.getText());
}
示例3: setUp
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
//Prepare the environment..
ProxymaFacade proxyma = new ProxymaFacade();
ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
ServletRunner sr = new ServletRunner();
sr.registerServlet( "myServlet", TestServlet.class.getName() );
ServletUnitClient sc = sr.newClient();
WebRequest wreq = new GetMethodWebRequest( "http://test.meterware.com/myServlet?a=1&b=2" );
wreq.setParameter( "color", "red" );
WebResponse wres = sc.getResponse( wreq );
InvocationContext ic = sc.newInvocation( wreq );
request = ic.getRequest();
response = ic.getResponse();
}
示例4: setUp
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
//Prepare the environment..
ProxymaFacade proxyma = new ProxymaFacade();
ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
ServletRunner sr = new ServletRunner();
sr.registerServlet( "myServlet", TestServlet.class.getName() );
ServletUnitClient sc = sr.newClient();
WebRequest wreq = new GetMethodWebRequest( "http://test.meterware.com/myServlet" );
wreq.setParameter( "color", "red" );
WebResponse wres = sc.getResponse( wreq );
InvocationContext ic = sc.newInvocation( wreq );
request = ic.getRequest();
response = ic.getResponse();
}
示例5: doTest
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
/**
* Check that model modifications made by table decorator specified with in the decorator property the table tag
* show up in the csv export.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
ParamEncoder encoder = new ParamEncoder("table");
String mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
request.setParameter(mediaParameter, Integer.toString(this.getCode()));
WebResponse response = runner.getResponse(request);
Assert.assertEquals("Expected a different content type.", this.getMimeType(), response.getContentType());
String responseText = response.getText();
String[] rows = StringUtils.split(responseText, "\n");
Assert.assertEquals("Wrong number of rows exported", 4, rows.length);
}
示例6: doTest
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
/**
* Test that headers are correctly removed.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
ParamEncoder encoder = new ParamEncoder("table");
String mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);
// test keep
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
request.setParameter(mediaParameter, Integer.toString(MediaTypeEnum.XML.getCode()));
// this will enable the filter!
request.setParameter(TableTagParameters.PARAMETER_EXPORTING, "1");
WebResponse response = runner.getResponse(request);
Assert.assertNull("Header Cache-Control not overwritten", response.getHeaderField("Cache-Control"));
Assert.assertNull("Header Expires not overwritten", response.getHeaderField("Expires"));
Assert.assertNull("Header Pragma not overwritten", response.getHeaderField("Pragma"));
}
示例7: setUp
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
//Prepare the environment..
ProxymaFacade proxyma = new ProxymaFacade();
ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
ServletRunner sr = new ServletRunner();
sr.registerServlet( "myServlet/style.css", TestServlet.class.getName() );
ServletUnitClient sc = sr.newClient();
WebRequest wreq = new GetMethodWebRequest( "http://test.meterware.com/myServlet/style.css" );
wreq.setParameter( "color", "red" );
WebResponse wres = sc.getResponse( wreq );
InvocationContext ic = sc.newInvocation( wreq );
request = ic.getRequest();
response = ic.getResponse();
}
示例8: doTest
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
/**
* Last page should be loaded.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
ParamEncoder encoder = new ParamEncoder("table");
request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_PAGE), "3");
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug(response.getText());
}
HTMLElement pagination = response.getElementWithID("pagination");
Assert.assertNotNull("Paging banner not found.", pagination);
Assert.assertEquals("Pagination links are not as expected.", "1, [2]", pagination.getText());
}
示例9: doTest
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
/**
* Test link generated using href="".
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
ParamEncoder encoder = new ParamEncoder("table");
request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_ORDER), "2");
request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_SORT), "0");
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug(response.getText());
}
WebTable[] tables = response.getTables();
Assert.assertEquals("Wrong number of table in result.", 2, tables.length);
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of links in result.", 2, links.length);
URLAssert.assertEquals("?d-148916-s=0&d-148916-o=1", links[0].getURLString());
URLAssert.assertEquals("?more=true&d-148916-s=0&d-148916-o=1", links[1].getURLString());
}
示例10: doTest
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
/**
* No exception when an invalid page is requested.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
ParamEncoder encoder = new ParamEncoder("table");
request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_PAGE), "9");
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug(response.getText());
}
HTMLElement pagination = response.getElementWithID("pagination");
Assert.assertNotNull("Paging banner not found.", pagination);
Assert.assertEquals("Pagination links are not as expected.", "7, 8, [9], 10, 11", pagination.getText());
}
示例11: testSetSingleValuedParameter
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
public void testSetSingleValuedParameter() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "age parameter", "12", request.getParameter( "age" ) );
assertNull( "unset parameter should be null", request.getParameter( "unset" ) );
}
示例12: testSetMultiValuedParameter
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
public void testSetMultiValuedParameter() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertMatchingSet( "age parameter", new String[] { "12" }, request.getParameterValues( "age" ) );
assertMatchingSet( "color parameter", new String[] { "red", "blue" }, request.getParameterValues( "color" ) );
assertNull( "unset parameter should be null", request.getParameterValues( "unset" ) );
}
示例13: testParameterMap
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
public void testParameterMap() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
Map map = request.getParameterMap();
assertMatchingSet( "age parameter", new String[] { "12" }, (Object[]) map.get( "age" ) );
assertMatchingSet( "color parameter", new String[] { "red", "blue" }, (Object[]) map.get( "color" ) );
assertNull( "unset parameter should be null", map.get( "unset" ) );
}
示例14: testSetQueryString
import com.meterware.httpunit.WebRequest; //导入方法依赖的package包/类
public void testSetQueryString() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "query string", "color=red&color=blue&age=12", request.getQueryString() );
}
示例15: logOn
import com.meterware.httpunit.WebRequest; //导入方法依赖的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);
}