Package org.springframework.test.web.servlet

Examples of org.springframework.test.web.servlet.ResultMatcher


   * mockMvc.perform(get("/path"))
   *   .andExpect(content(containsString("text")));
   * </pre>
   */
  public ResultMatcher string(final Matcher<? super String> matcher) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        assertThat("Response content", result.getResponse().getContentAsString(), matcher);
      }
    };
View Full Code Here


  /**
   * Assert the response body content as a String.
   */
  public ResultMatcher string(final String expectedContent) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        assertEquals("Response content", expectedContent, result.getResponse().getContentAsString());
      }
    };
View Full Code Here

  /**
   * Assert the response body content as a byte array.
   */
  public ResultMatcher bytes(final byte[] expectedContent) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        assertEquals("Response content", expectedContent, result.getResponse().getContentAsByteArray());
      }
    };
View Full Code Here

   * @param xmlContent the expected XML content
   * @see MockMvcResultMatchers#xpath(String, Object...)
   * @see MockMvcResultMatchers#xpath(String, Map, Object...)
   */
  public ResultMatcher xml(final String xmlContent) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xmlHelper.assertXmlEqual(xmlContent, content);
      }
View Full Code Here

  /**
   * Parse the response content as {@link Node} and apply the given Hamcrest
   * {@link Matcher}.
   */
  public ResultMatcher node(final Matcher<? super Node> matcher) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xmlHelper.assertNode(content, matcher);
      }
View Full Code Here

   * Hamcrest {@link Matcher}.
   *
   * @see <a href="http://code.google.com/p/xml-matchers/">xml-matchers</a>
   */
  public ResultMatcher source(final Matcher<? super Source> matcher) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xmlHelper.assertSource(content, matcher);
      }
View Full Code Here

   *
   * @param jsonContent the expected JSON content
   * @since 4.1
   */
  public ResultMatcher json(final String jsonContent) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        jsonHelper.assertJsonEqual(jsonContent, content);
View Full Code Here

   * Neither a {@code Callable} nor a {@code DeferredResult} will complete
   * processing all the way since a {@link MockHttpServletRequest} does not
   * perform asynchronous dispatches.
   */
  public ResultMatcher asyncStarted() {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) {
        HttpServletRequest request = result.getRequest();
        assertEquals("Async started", true, request.isAsyncStarted());
      }
View Full Code Here

  /**
   * Assert that asynchronous processing was not start.
   * @see #asyncStarted()
   */
  public ResultMatcher asyncNotStarted() {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) {
        HttpServletRequest request = result.getRequest();
        assertEquals("Async started", false, request.isAsyncStarted());
      }
View Full Code Here

  /**
   * Assert the result from asynchronous processing with the given matcher.
   */
  public <T> ResultMatcher asyncResult(final Matcher<T> matcher) {
    return new ResultMatcher() {
      @Override
      @SuppressWarnings("unchecked")
      public void match(MvcResult result) {
        HttpServletRequest request = result.getRequest();
        assertEquals("Async started", true, request.isAsyncStarted());
View Full Code Here

TOP

Related Classes of org.springframework.test.web.servlet.ResultMatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.