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


Java WebRequest.setParameter方法代码示例

本文整理汇总了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();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:18,代码来源:URLRewriteEngineTest.java

示例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());
}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:27,代码来源:Displ304Test.java

示例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();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:17,代码来源:ProxymaServletRequestTest.java

示例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();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:18,代码来源:HtmlUrlRewriteTransformerTest.java

示例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);

}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:27,代码来源:Displ292Test.java

示例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"));
}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:26,代码来源:ExportHeadersFilterTest.java

示例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();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:18,代码来源:CssUrlRewriteTransformerTest.java

示例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());

}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:26,代码来源:Displ212Test.java

示例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());
}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:31,代码来源:Displ112Test.java

示例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());

}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:26,代码来源:Displ109Test.java

示例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" ) );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:HttpServletRequestTest.java

示例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" ) );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:11,代码来源:HttpServletRequestTest.java

示例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" ) );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:12,代码来源:HttpServletRequestTest.java

示例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() );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:9,代码来源:HttpServletRequestTest.java

示例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);
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:14,代码来源:JSPGuardsTest.java


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