use of org.springframework.mock.web.MockHttpServletResponse in project spring-framework by spring-projects.
the class XpathResultMatchers method exists.
/**
* Evaluate the XPath and assert that content exists.
*/
public ResultMatcher exists() {
return new ResultMatcher() {
@Override
public void match(MvcResult result) throws Exception {
MockHttpServletResponse response = result.getResponse();
xpathHelper.exists(response.getContentAsByteArray(), getDefinedEncoding(response));
}
};
}
use of org.springframework.mock.web.MockHttpServletResponse in project spring-framework by spring-projects.
the class XpathResultMatchers method number.
/**
* Evaluate the XPath and assert the {@link Double} value found.
*/
public ResultMatcher number(final Double expectedValue) {
return new ResultMatcher() {
@Override
public void match(MvcResult result) throws Exception {
MockHttpServletResponse response = result.getResponse();
xpathHelper.assertNumber(response.getContentAsByteArray(), getDefinedEncoding(response), expectedValue);
}
};
}
use of org.springframework.mock.web.MockHttpServletResponse in project spring-framework by spring-projects.
the class XpathResultMatchers method nodeCount.
/**
* Evaluate the XPath and assert the number of nodes found with the given
* Hamcrest {@link Matcher}.
*/
public ResultMatcher nodeCount(final Matcher<Integer> matcher) {
return new ResultMatcher() {
@Override
public void match(MvcResult result) throws Exception {
MockHttpServletResponse response = result.getResponse();
xpathHelper.assertNodeCount(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);
}
};
}
use of org.springframework.mock.web.MockHttpServletResponse in project spring-boot by spring-projects.
the class FreeMarkerAutoConfigurationTests method customSuffix.
@Test
public void customSuffix() throws Exception {
registerAndRefreshContext("spring.freemarker.suffix:.freemarker");
MockHttpServletResponse response = render("suffixed");
String result = response.getContentAsString();
assertThat(result).contains("suffixed");
}
use of org.springframework.mock.web.MockHttpServletResponse in project spring-boot by spring-projects.
the class FreeMarkerAutoConfigurationTests method defaultViewResolution.
@Test
public void defaultViewResolution() throws Exception {
registerAndRefreshContext();
MockHttpServletResponse response = render("home");
String result = response.getContentAsString();
assertThat(result).contains("home");
assertThat(response.getContentType()).isEqualTo("text/html;charset=UTF-8");
}
Aggregations