Questions tagged [spring-test-mvc]

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

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

spring-test-mvc might be included in the Spring Framework version 3.2.x

Spring One DC 2012 slides

356 questions
2
votes
2 answers

@WithMockUser ignores username, password fields?

I'm using @WithMockUser to test a controller method secured with basic auth in a simple spring boot web service. My annotation looks like: @WithMockUser(username = 'admin', password = 'mypassword', roles = ['ADMIN']) It seems however that the…
2
votes
4 answers

Should Mockito be used with MockMvc's webAppContextSetup in Spring 4?

I'm having difficulties getting Mockito and MockMvc working together when I use the webAppContextSetup together. I'm curious if it's because I'm mixing the two in a way they were never intended. Source:…
Zach Gardner
  • 999
  • 2
  • 10
  • 13
2
votes
2 answers

Spock Framework: How to create a customized Data Provider

I am working with: Spring MVC Spring MVC Test Spock Framework About Spock working with @Unroll I have the following situation about the where block I can have the following: where: "Internal" uriRequestReport <<…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
2
votes
1 answer

Testing Katharsis JsonApi with MockMvc and Mockito

I would like to test the behaviour configured by my Katharsis ResourceRepository (katharsis-spring 2.1.7): import io.katharsis.queryParams.QueryParams; import io.katharsis.repository.ResourceRepository; import…
ppi
  • 86
  • 7
2
votes
0 answers

Spring MVC Test Dirties a *Different* ApplicationContext

I'm working on an Application using Spring MVC 4.0.4 and Hibernate, and we're using Spring Test MVC 1.0.0.M2 to do some integration/unit tests. We use HSQLDB as an in-memory DB during these tests and have Hibernate create the schema…
2
votes
1 answer

How to test a Controller, which retrieves data with Post method, using a MockMvc object?

Hello everyone I'm using Spring MVC framework and I want to test my Controllers. One of them uses the Post method in order to retrieve data from the View and I don't know how to to test it. This is my Controller: @RequestMapping(value="/index",…
nick
  • 1,611
  • 4
  • 20
  • 35
2
votes
2 answers

Spring Security Test and MockMvc supply null custom UserDetails parameter to REST Controller

I'm trying to write an integration test that hits a REST endpoint and gets data for a specific authenticated user (the one I'm setting up in the test). I initially tried my setup with mockMvc =…
2
votes
2 answers

Spring MVC Mixing xml and java @ContextConfiguration in integration test

I am trying to configure a Spring MVC Integration test using a combination of XML config and @Configuration annotated classes. @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @TestPropertySource({"/spring-security.properties", …
2
votes
1 answer

Using RestTemplate in Spring Boot Spock specification with customized Jackson

I have a Spring Boot app that's using a customized Jackson ObjectMapper, and I would like to use the same customized mapper during testing. I used spring boot's method of automatically registering Module Beans, like this: @Configuration public class…
nerdherd
  • 2,508
  • 2
  • 24
  • 40
2
votes
0 answers

How to test non-Spring controllers using Spring test framework

Can anybody please provide me some guidance or code sample on how to do this? HomePageController.java public class HomePageController extends HttpServlet { private static final Logger log = Logger.getLogger(HomePageController.class); …
Nital
  • 5,784
  • 26
  • 103
  • 195
2
votes
0 answers

spring test 406 error

I need to test a method in my controller using spring test framework: @RequestMapping(value="/retrieve", method = RequestMethod.GET) @ResponseBody public Map goRetrieve(){ return retrieveService.retrieveData(); } The test…
roland luo
  • 1,561
  • 4
  • 19
  • 24
2
votes
1 answer

How to pass parameters to post method in Spring MVC controller while doing junit?

I am doing unit testing on my Spring MVC controller methods. Below is my method which I am trying to unit test as it is working fine when I start my server. Whenever I will be hitting index page it will show me three text box on the browser in…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
2
votes
1 answer

Spring-Test-Mvc Controller Tests

I'm using spring-test-mvc (standalone) because my application runs with spring 3.1. I'm basically just trying to test my controller methods and the response HTTP codes.…
vicR
  • 789
  • 4
  • 23
  • 52
2
votes
1 answer

Spring 3.2.5 error "java.lang.AssertionError: No ModelAndView found" for all my controller Unit Test

I'm trying to write some unit tests for my controllers in a Spring MVC and i have already error for my unit test : "java.lang.AssertionError: No ModelAndView found. my app and conrollers works correcty. Does anyone have any ideas ? code controller :…
user3096030
  • 23
  • 1
  • 4
2
votes
0 answers

@EnableJpaRepositories does not obey to @Primary annotated beans

I've simple Spring setup using @Inject, @ComponentScan and @EnableJpaRepositories. There is currently no need to have specific @Configurations for test, integration or production environments. I'm now using the Spring test mvc framework and I'm…
Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110