001/* 002 * Copyright 2002-2015 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 ResultHandler} performs a generic action on the result of an 021 * executed request — for example, printing debug information. 022 * 023 * <p>See static factory methods in 024 * {@link org.springframework.test.web.servlet.result.MockMvcResultHandlers 025 * MockMvcResultHandlers}. 026 * 027 * <h3>Example</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.MockMvcResultHandlers.*; 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")).andDo(print()); 041 * </pre> 042 * 043 * @author Rossen Stoyanchev 044 * @author Sam Brannen 045 * @since 3.2 046 */ 047public interface ResultHandler { 048 049 /** 050 * Perform an action on the given result. 051 * 052 * @param result the result of the executed request 053 * @throws Exception if a failure occurs 054 */ 055 void handle(MvcResult result) throws Exception; 056 057}