Top "Spring-test-mvc" questions

spring-test-mvc based on spring-test provides a unit testing framework for spring-mvc services.

How to check String in response body with mockMvc

I have simple integration test @Test public void shouldReturnErrorMessageToAdminWhenCreatingUserWithUsedUserName() throws Exception { mockMvc.perform(post("/api/users").header("Authorization", base64ForTestUser).…

java spring mocking spring-test-mvc
How to write a unit test for a Spring Boot Controller endpoint

I have a sample Spring Boot app with the following Boot main class @SpringBootApplication public class DemoApplication { public static void …

java unit-testing junit spring-boot spring-test-mvc
How to check JSON in response body with mockMvc

This is my method inside my controller which is annotated by @Controller @RequestMapping(value = "/getServerAlertFilters/{serverName}/", produces = "application/json; charset=…

java spring junit mocking spring-test-mvc
count members with jsonpath?

Is it possible to count the number of members using JsonPath? Using spring mvc test I'm testing a controller that …

java spring testing jsonpath spring-test-mvc
Using Spring mockMvc to test optional path variables

I have a method in Spring MVC with optional path variable. I am trying to test it for a scenario …

java spring spring-mvc spring-test spring-test-mvc
java.lang.AssertionError: Content type not set while junit Spring MVC Controller?

I am using JUnit to test my Spring MVC controller. Below is my method which returns a index.jsp page …

java spring spring-mvc junit spring-test-mvc
Spring MVC integration tests with Spring Security

I'm trying to test my login page using mvc-test. I was working pretty good before I added spring security. My …

spring-mvc spring-security spring-test-mvc
How to Mock the security context in Spring MVC for testing

I need to test some protected urls, therefore I need to set up a mock security context in my tests (…

spring spring-mvc junit spring-security spring-test-mvc
Use @WithMockUser (with @SpringBootTest) inside an oAuth2 Resource Server Application

Environment: I have a spring boot based microservice architecture application consisting of multiple infrastructural services and resource services (containing the …

java spring-mvc spring-boot spring-security spring-test-mvc
Issue with testing Spring MVC slice in SpringBoot 1.4

I'm trying out the new Spring Boot 1.4 MVC testing features. I have the following controller. @Controller public class ProductController { private …

spring-mvc spring-boot spring-test-mvc