001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.test.web.servlet; 018 019/** 020 * A {@code ResultMatcher} matches the result of an executed request against 021 * some expectation. 022 * 023 * <p>See static factory methods in 024 * {@link org.springframework.test.web.servlet.result.MockMvcResultMatchers 025 * MockMvcResultMatchers}. 026 * 027 * <h3>Example Using Status and Content Result Matchers</h3> 028 * 029 * <pre class="code"> 030 * import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; 031 * import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; 032 * import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*; 033 * 034 * // ... 035 * 036 * WebApplicationContext wac = ...; 037 * 038 * MockMvc mockMvc = webAppContextSetup(wac).build(); 039 * 040 * mockMvc.perform(get("/form")) 041 * .andExpect(status().isOk()) 042 * .andExpect(content().mimeType(MediaType.APPLICATION_JSON)); 043 * </pre> 044 * 045 * @author Rossen Stoyanchev 046 * @author Sam Brannen 047 * @since 3.2 048 */ 049public interface ResultMatcher { 050 051 /** 052 * Assert the result of an executed request. 053 * @param result the result of the executed request 054 * @throws Exception if a failure occurs 055 */ 056 void match(MvcResult result) throws Exception; 057 058}