use of org.springframework.test.web.servlet.MockMvc in project spring-framework by spring-projects.
the class HtmlUnitRequestBuilderTests method mergeHeader.
@Test
public void mergeHeader() throws Exception {
String headerName = "PARENT";
String headerValue = "VALUE";
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new HelloController()).defaultRequest(get("/").header(headerName, headerValue)).build();
assertThat(mockMvc.perform(requestBuilder).andReturn().getRequest().getHeader(headerName), equalTo(headerValue));
}
use of org.springframework.test.web.servlet.MockMvc in project spring-framework by spring-projects.
the class HtmlUnitRequestBuilderTests method mergeCookie.
@Test
public void mergeCookie() throws Exception {
String cookieName = "PARENT";
String cookieValue = "VALUE";
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new HelloController()).defaultRequest(get("/").cookie(new Cookie(cookieName, cookieValue))).build();
Cookie[] cookies = mockMvc.perform(requestBuilder).andReturn().getRequest().getCookies();
assertThat(cookies, notNullValue());
assertThat(cookies.length, equalTo(1));
Cookie cookie = cookies[0];
assertThat(cookie.getName(), equalTo(cookieName));
assertThat(cookie.getValue(), equalTo(cookieValue));
}
use of org.springframework.test.web.servlet.MockMvc in project spring-framework by spring-projects.
the class HtmlUnitRequestBuilderTests method mergeSessionNotInitialized.
@Test
public void mergeSessionNotInitialized() throws Exception {
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new HelloController()).defaultRequest(get("/")).build();
assertThat(mockMvc.perform(requestBuilder).andReturn().getRequest().getSession(false), nullValue());
}
use of org.springframework.test.web.servlet.MockMvc in project spring-framework by spring-projects.
the class DelegatingWebConnectionTests method verifyExampleInClassLevelJavadoc.
@Test
public void verifyExampleInClassLevelJavadoc() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
WebClient webClient = new WebClient();
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(TestController.class).build();
MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc, webClient);
WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");
WebConnection httpConnection = new HttpWebConnection(webClient);
WebConnection webConnection = new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection));
webClient.setWebConnection(webConnection);
Page page = webClient.getPage("http://code.jquery.com/jquery-1.11.0.min.js");
assertThat(page.getWebResponse().getStatusCode(), equalTo(200));
assertThat(page.getWebResponse().getContentAsString(), not(isEmptyString()));
}
use of org.springframework.test.web.servlet.MockMvc in project spring-framework by spring-projects.
the class HtmlUnitRequestBuilderTests method mergeParameter.
@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));
}
Aggregations