import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.web.util.NestedServletException;
import java.net.URI;
import java.util.Optional;
import static org.mockito.AdditionalMatchers.lt;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
.andExpect(status().isBadRequest());
}
+ @Test
+ void test503_WORKING() throws Exception {
+ // MockMvc throws the exception, because it is thrown outside
+ // of the context of the called controller. Catching and handling
+ // of this exception would require, to have a reale servlet container
+ // in place, which would be against the intention of mocking away
+ // everything except the core MVC functionallity.
+ // Hence, throwing exceptions, which are thrown outside of the context
+ // of the controller IS the expected behaviour here!
+ assertThrows(
+ NestedServletException.class,
+ () -> mvc.perform(get(URI.create("http://FOO/?template=foo"))));
+ }
+
@Test
void test503() throws Exception {
mvc