Example usage for org.springframework.mock.web MockHttpServletRequest addParameter

List of usage examples for org.springframework.mock.web MockHttpServletRequest addParameter

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpServletRequest addParameter.

Prototype

public void addParameter(String name, String... values) 

Source Link

Document

Add an array of values for the specified HTTP parameter.

Usage

From source file:org.esgf.web.LiveSearchController.java

public static void main(String[] args) {
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest();

    String queryStr = "model=kkk1&project=jjj&institute=ll&search=true&variable";
    String searchConstraints = "&offset=0&type=Dataset&project=CMIP5&institute=INM&latest=true&replica=false&distrib=false";

    mockRequest.addParameter("facet_param_list", queryStr);
    mockRequest.addParameter("search_constraint_list", searchConstraints);
    mockRequest.addParameter("useURLParams", "true");

    LiveSearchController fc = new LiveSearchController();

    fc.getFacetListHelper(mockRequest);/*from w w w. ja  v a  2  s  .  co  m*/

    //fc.getDocElement(mockRequest);

}

From source file:org.piraso.server.CommonMockObjects.java

public static User createUser(String remoteAddr, String activityId) {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr(remoteAddr);/*from  www  . ja va 2s  . c o m*/

    if (activityId != null) {
        request.addParameter("activity_uuid", activityId);
    }

    return new User(new TestPirasoRequest(request));
}

From source file:org.piraso.server.CommonMockObjects.java

public static MockHttpServletRequest mockRequest(String monitoredAddr, String activityId) {
    MockHttpServletRequest request = spy(new MockHttpServletRequest());
    request.setRemoteAddr(monitoredAddr);

    if (activityId != null) {
        request.addParameter("activity_uuid", activityId);
    }/*from www .j av  a2s  .c  om*/

    return request;
}

From source file:org.jasig.cas.TestUtils.java

public static Service getService(final String name) {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", name);
    return SimpleWebApplicationServiceImpl.createServiceFrom(request);
}

From source file:org.jasig.cas.ticket.registry.AbstractTicketRegistryTests.java

public static Service getService() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", "test");
    return SimpleWebApplicationServiceImpl.createServiceFrom(request);
}

From source file:com.google.code.rees.scope.struts2.test.ScopeTestUtil.java

/**
 * For unit testing, sets the conversation IDs of the conversations in the
 * current thread//  ww  w  . j  a  v  a 2 s. c o  m
 * onto a given mock request.
 * 
 * @param request
 */
public static void setConversationIdsOnRequest(MockHttpServletRequest request, Class<?> actionClass) {
    ActionContext actionContext = ActionContext.getContext();
    @SuppressWarnings("unchecked")
    Map<String, String> convoIdMap = ((Map<String, String>) actionContext.getValueStack()
            .findValue(StrutsScopeConstants.CONVERSATION_ID_MAP_STACK_KEY));
    if (convoIdMap != null) {
        for (Entry<String, String> entry : convoIdMap.entrySet()) {
            request.addParameter(entry.getKey(), new String[] { entry.getValue() });
        }
    } else {
        for (String conversationName : arbitrator.getConversations(actionClass, getActionSuffix())) {
            request.addParameter(ConversationUtil.sanitizeName(conversationName)
                    + ConversationConstants.CONVERSATION_NAME_SUFFIX, conversationName + "-test-id");
        }
    }
}

From source file:com.gisgraphy.test.GeolocTestHelper.java

public static MockHttpServletRequest createMockHttpServletRequestForGeoloc() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(GisgraphyServlet.FROM_PARAMETER, "3");
    request.addParameter(GisgraphyServlet.TO_PARAMETER, GeolocServlet.DEFAULT_MAX_RESULTS + 20 + "");
    request.addParameter(GisgraphyServlet.FORMAT_PARAMETER, "XML");
    request.addParameter(GeolocServlet.PLACETYPE_PARAMETER, "city");
    request.addParameter(GeolocServlet.LAT_PARAMETER, "1.0");
    request.addParameter(GeolocServlet.LONG_PARAMETER, "2.0");
    request.addParameter(GeolocServlet.LONG_PARAMETER, "3.0");
    return request;
}

From source file:com.gisgraphy.test.GeolocTestHelper.java

public static MockHttpServletRequest createMockHttpServletRequestForStreetGeoloc() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(GisgraphyServlet.FROM_PARAMETER, "3");
    request.addParameter(GisgraphyServlet.TO_PARAMETER, StreetServlet.DEFAULT_MAX_RESULTS + 10 + "");
    request.addParameter(GisgraphyServlet.FORMAT_PARAMETER, "XML");
    request.addParameter(GeolocServlet.PLACETYPE_PARAMETER, "city");
    request.addParameter(GeolocServlet.LAT_PARAMETER, "1.0");
    request.addParameter(GeolocServlet.LONG_PARAMETER, "2.0");
    request.addParameter(GeolocServlet.LONG_PARAMETER, "3.0");
    return request;
}

From source file:com.gisgraphy.test.GeolocTestHelper.java

public static MockHttpServletRequest createMockHttpServletRequestForFullText() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(FulltextServlet.COUNTRY_PARAMETER, "FR");
    request.addParameter(FulltextServlet.FROM_PARAMETER, "3");
    request.addParameter(FulltextServlet.TO_PARAMETER, FulltextServlet.DEFAULT_MAX_RESULTS + 20 + "");
    request.addParameter(FulltextServlet.FORMAT_PARAMETER, "XML");
    request.addParameter(FulltextServlet.STYLE_PARAMETER, "FULL");
    request.addParameter(FulltextServlet.LANG_PARAMETER, "fr");
    request.addParameter(GisgraphyServlet.INDENT_PARAMETER, "XML");
    request.addParameter(FulltextServlet.PLACETYPE_PARAMETER, "city");
    request.addParameter(FulltextServlet.QUERY_PARAMETER, "query");
    request.addParameter(FulltextServlet.SPELLCHECKING_PARAMETER, "true");
    return request;
}

From source file:org.openmrs.contrib.metadatarepository.webapp.controller.PasswordHintControllerTest.java

@Test
public void testExecute() throws Exception {
    MockHttpServletRequest request = newGet("/passwordHint.html");
    request.addParameter("username", "user");

    // start SMTP Server
    Wiser wiser = new Wiser();
    wiser.setPort(getSmtpPort());//from  w  w w  .j  av a 2  s.  c o m
    wiser.start();

    c.handleRequest(request);

    // verify an account information e-mail was sent
    wiser.stop();
    assertTrue(wiser.getMessages().size() == 1);

    // verify that success messages are in the session
    assertNotNull(request.getSession().getAttribute(BaseFormController.MESSAGES_KEY));
}