Codota Logo
MockHttpServletRequestBuilder.param
Code IndexAdd Codota to your IDE (free)

How to use
param
method
in
org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder

Best Java code snippets using org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder.param (Showing top 20 results out of 423)

  • Common ways to obtain MockHttpServletRequestBuilder
private void myMethod () {
MockHttpServletRequestBuilder m =
  • Codota IconMockMvcRequestBuilders.get("<changeme>")
  • Codota IconString httpMethod;URI url;new MockHttpServletRequestBuilder(httpMethod, url)
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-framework

@Test
public void requestParameter() {
  this.builder.param("foo", "bar", "baz");
  MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
  Map<String, String[]> parameterMap = request.getParameterMap();
  assertArrayEquals(new String[] {"bar", "baz"}, parameterMap.get("foo"));
}
origin: spring-projects/spring-framework

@Test
public void mergeParameter() throws Exception {
  String paramName = "PARENT";
  String paramValue = "VALUE";
  String paramValue2 = "VALUE2";
  MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new HelloController())
      .defaultRequest(get("/").param(paramName, paramValue, paramValue2))
      .build();
  MockHttpServletRequest performedRequest = mockMvc.perform(requestBuilder).andReturn().getRequest();
  assertThat(asList(performedRequest.getParameterValues(paramName)), contains(paramValue, paramValue2));
}
origin: spring-projects/spring-framework

@Test
public void filterWithExactMapping() throws Exception {
  standaloneSetup(new PersonController())
    .addFilter(new RedirectFilter(), "/p", "/persons").build()
    .perform(post("/persons").param("name", "Andy"))
      .andExpect(redirectedUrl("/login"));
}
origin: spring-projects/spring-framework

@Test
public void filterMappedBySuffix() throws Exception {
  standaloneSetup(new PersonController())
    .addFilter(new RedirectFilter(), "*.html").build()
    .perform(post("/persons.html").param("name", "Andy"))
      .andExpect(redirectedUrl("/login"));
}
origin: spring-projects/spring-framework

@Test
public void filtersProcessRequest() throws Exception {
  standaloneSetup(new PersonController())
    .addFilters(new ContinueFilter(), new RedirectFilter()).build()
    .perform(post("/persons").param("name", "Andy"))
      .andExpect(redirectedUrl("/login"));
}
origin: spring-projects/spring-framework

@Test
public void streaming() throws Exception {
  this.mockMvc.perform(get("/1").param("streaming", "true"))
      .andExpect(request().asyncStarted())
      .andDo(MvcResult::getAsyncResult) // fetch async result similar to "asyncDispatch" builder
      .andExpect(status().isOk())
      .andExpect(content().string("name=Joe"));
}
origin: spring-projects/spring-framework

@Test
public void streamingSlow() throws Exception {
  this.mockMvc.perform(get("/1").param("streamingSlow", "true"))
      .andExpect(request().asyncStarted())
      .andDo(MvcResult::getAsyncResult)
      .andExpect(status().isOk())
      .andExpect(content().string("name=Joe&someBoolean=true"));
}
origin: spring-projects/spring-framework

@Test  // SPR-13079
public void deferredResultWithDelayedError() throws Exception {
  MvcResult mvcResult = this.mockMvc.perform(get("/1").param("deferredResultWithDelayedError", "true"))
      .andExpect(request().asyncStarted())
      .andReturn();
  this.mockMvc.perform(asyncDispatch(mvcResult))
      .andExpect(status().is5xxServerError())
      .andExpect(content().string("Delayed Error"));
}
origin: spring-projects/spring-framework

@Before
public void setup() {
  CookieLocaleResolver localeResolver = new CookieLocaleResolver();
  localeResolver.setCookieDomain("domain");
  localeResolver.setCookieHttpOnly(true);
  this.mockMvc = standaloneSetup(new SimpleController())
      .addInterceptors(new LocaleChangeInterceptor())
      .setLocaleResolver(localeResolver)
      .defaultRequest(get("/").param("locale", "en_US"))
      .alwaysExpect(status().isOk())
      .build();
}
origin: spring-projects/spring-framework

@Test
public void requestParametersAreClearedBetweenInvocations() throws Exception {
  this.mvc.perform(get("/"))
    .andExpect(content().string(HELLO));
  this.mvc.perform(get("/").param(ENIGMA, ""))
    .andExpect(content().string(ENIGMA));
  this.mvc.perform(get("/"))
    .andExpect(content().string(HELLO));
}
origin: spring-projects/spring-framework

@Test
public void streamingJson() throws Exception {
  this.mockMvc.perform(get("/1").param("streamingJson", "true"))
      .andExpect(request().asyncStarted())
      .andDo(MvcResult::getAsyncResult)
      .andExpect(status().isOk())
      .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
      .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.5}"));
}
origin: spring-projects/spring-framework

@Test  // SPR-12597
public void completableFutureWithImmediateValue() throws Exception {
  MvcResult mvcResult = this.mockMvc.perform(get("/1").param("completableFutureWithImmediateValue", "true"))
      .andExpect(request().asyncStarted())
      .andReturn();
  this.mockMvc.perform(asyncDispatch(mvcResult))
      .andExpect(status().isOk())
      .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
      .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
origin: spring-projects/spring-framework

@Test
public void deferredResult() throws Exception {
  MvcResult mvcResult = this.mockMvc.perform(get("/1").param("deferredResult", "true"))
      .andExpect(request().asyncStarted())
      .andReturn();
  this.asyncController.onMessage("Joe");
  this.mockMvc.perform(asyncDispatch(mvcResult))
      .andExpect(status().isOk())
      .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
      .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
origin: spring-projects/spring-framework

@Test
public void listenableFuture() throws Exception {
  MvcResult mvcResult = this.mockMvc.perform(get("/1").param("listenableFuture", "true"))
      .andExpect(request().asyncStarted())
      .andReturn();
  this.asyncController.onMessage("Joe");
  this.mockMvc.perform(asyncDispatch(mvcResult))
      .andExpect(status().isOk())
      .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
      .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
origin: spring-projects/spring-framework

@Test
public void saveSpecial() throws Exception {
  this.mockMvc.perform(post("/people").param("name", "Andy"))
      .andExpect(status().isFound())
      .andExpect(redirectedUrl("/persons/Joe"))
      .andExpect(model().size(1))
      .andExpect(model().attributeExists("name"))
      .andExpect(flash().attributeCount(1))
      .andExpect(flash().attribute("message", "success!"));
}
origin: spring-projects/spring-framework

@Test
public void save() throws Exception {
  this.mockMvc.perform(post("/persons").param("name", "Andy"))
    .andExpect(status().isFound())
    .andExpect(redirectedUrl("/persons/Joe"))
    .andExpect(model().size(1))
    .andExpect(model().attributeExists("name"))
    .andExpect(flash().attributeCount(1))
    .andExpect(flash().attribute("message", "success!"));
}
origin: spring-projects/spring-framework

@Test
public void deferredResultWithImmediateValue() throws Exception {
  MvcResult mvcResult = this.mockMvc.perform(get("/1").param("deferredResultWithImmediateValue", "true"))
      .andExpect(request().asyncStarted())
      .andExpect(request().asyncResult(new Person("Joe")))
      .andReturn();
  this.mockMvc.perform(asyncDispatch(mvcResult))
      .andExpect(status().isOk())
      .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
      .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
origin: spring-projects/spring-framework

@Test
public void callable() throws Exception {
  MvcResult mvcResult = this.mockMvc.perform(get("/1").param("callable", "true"))
      .andExpect(request().asyncStarted())
      .andExpect(request().asyncResult(new Person("Joe")))
      .andReturn();
  this.mockMvc.perform(asyncDispatch(mvcResult))
      .andExpect(status().isOk())
      .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
      .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
origin: spring-projects/spring-framework

@Test
public void whenFiltersCompleteMvcProcessesRequest() throws Exception {
  standaloneSetup(new PersonController())
    .addFilters(new ContinueFilter()).build()
    .perform(post("/persons").param("name", "Andy"))
      .andExpect(status().isFound())
      .andExpect(redirectedUrl("/person/1"))
      .andExpect(model().size(1))
      .andExpect(model().attributeExists("id"))
      .andExpect(flash().attributeCount(1))
      .andExpect(flash().attribute("message", "success!"));
}
origin: spring-projects/spring-framework

@Test
public void filterSkipped() throws Exception {
  standaloneSetup(new PersonController())
    .addFilter(new RedirectFilter(), "/p", "/person").build()
    .perform(post("/persons").param("name", "Andy"))
      .andExpect(status().isFound())
      .andExpect(redirectedUrl("/person/1"))
      .andExpect(model().size(1))
      .andExpect(model().attributeExists("id"))
      .andExpect(flash().attributeCount(1))
      .andExpect(flash().attribute("message", "success!"));
}
org.springframework.test.web.servlet.requestMockHttpServletRequestBuilderparam

Javadoc

Add a request parameter to the MockHttpServletRequest.

If called more than once, new values get added to existing ones.

Popular methods of MockHttpServletRequestBuilder

  • contentType
    Set the 'Content-Type' header of the request.
  • content
    Set the request body.
  • accept
    Set the 'Accept' header to the given media type(s).
  • header
    Add a header to the request. Values are always added.
  • with
    An extension point for further initialization of MockHttpServletRequestin ways not built directly in
  • requestAttr
    Set a request attribute.
  • buildRequest
    Build a MockHttpServletRequest.
  • contextPath
    Specify the portion of the requestURI that represents the context path. The context path, if specifi
  • principal
    Set the principal of the request.
  • flashAttr
    Set an "input" flash attribute.
  • headers
    Add all headers to the request. Values are always added.
  • session
    Set the HTTP session to use, possibly re-used across requests.Individual attributes provided via #se
  • headers,
  • session,
  • sessionAttr,
  • cookie,
  • params,
  • servletPath,
  • <init>,
  • characterEncoding,
  • locale

Popular in Java

  • Reactive rest calls using spring rest template
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now