Questions tagged [spring-mvc-test]

241 questions
0
votes
2 answers

Simple WebMvcTest fails with Spring Boot Missing SpringBootConfiguration

Test 1 package test.java.rest.springframework.test; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import…
JayC
  • 2,144
  • 8
  • 42
  • 77
0
votes
0 answers

How to achive on the fly bytecode instrumentation at runtime using jacoco

I am working on a Spring MVC + maven based project which contain good number of scenarios to be tested, analysed and recorded in reports (like Code coverage, static code analysis etc.). The scenarios are more challenging so we cannot do the code…
0
votes
1 answer

SpringMVC testing post method with params

I'm writing test for SpringMvc app, and i've run into some issue. here is my controller method for test: @RequestMapping(value = "submit", method = RequestMethod.POST, params = "delete") public String delete(@ModelAttribute("inputBean") InputBean…
egzaell
  • 195
  • 3
  • 16
0
votes
1 answer

Exclude a configuration when @WebMvcTest in Spring Boot 1.4

I have a @SpringBootApplication class in java/ directory(same package) and another @SpringBootApplication class in test/ for mocking some auto-wired beans. There are several tests and which configuration is used varies from test to test. And in a…
margincall
  • 483
  • 1
  • 6
  • 24
0
votes
1 answer

How to pass in parameters in spring-mvc-test?

I have to test this; /** Displays the balance us page. */ @RequestMapping(value = "/profile/balance") public ModelAndView balance(Principal principal) { ModelAndView model = new ModelAndView("balance"); String username =…
Mattia
  • 179
  • 15
0
votes
1 answer

Spring MVC Test & AOP: Around advice is not executed how is expected for rest controller (just for invalid data)

I am working with Spring Framework 4.3.3 AspectJ 1.8.9 I have two @Controllers one for mvc and other for rest. Each one uses how a dependency a @Service. I have the following Rest method package…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
0
votes
2 answers

How to mock rest controller with ResponseEntity as return object?

Im making a unit test in a rest controller and this is the return: return ResponseEntity.status(HttpStatus.OK).body(result); Im getting this error: Required request body is missing This is my current test: def "Signup"() { given: …
Daniel Bristol
  • 87
  • 3
  • 12
0
votes
1 answer

Spring Boot 1.4 MVC testing with Thymeleaf results in TemplateProcessingException

I'm trying to test a Spring Boot 1.4.0.M3 MVC slice. The controller is this. @Controller public class ProductController { private ProductService productService; @Autowired public void setProductService(ProductService productService) { …
user2693135
  • 1,206
  • 5
  • 21
  • 44
0
votes
0 answers

Junit Integration testing based on Maven Profiles

Using Spring mvc test and mockMvc to test Spring rest controller and its output in form of JSON and its JSON structure and JSON value. I have two questions :) We have configured multiple profile in our application like dev, qa and prod and every…
Sagar Rout
  • 651
  • 1
  • 12
  • 29
0
votes
5 answers

Spring @ResponseBody JSON

I have a Spring 3 controller that returns a JSON object. I am using @ResponseBody annotation, and jackson-mapper-asl jar, with which the Spring will handle the JSON conversion automatically. The 3 return statements returns different JSON format. Can…
0
votes
1 answer

spring boot controller test, mockMov doesn't mock

I use Spring MVC and Spring boot to write a Restful service. This code works fine through postman.While when I do the unit test for the controller to accept a post request, the mocked myService will always initialize itself instead of return a…
Nico
  • 21
  • 4
0
votes
2 answers

Error Unit Testing of Spring MVC Controllers calling REST API

I am unit testing the spring MVC controller in my small app, but getting the following error: INFO: **Initializing Spring FrameworkServlet ''** Oct 30, 2015 5:37:38 PM org.springframework.test.web.servlet.TestDispatcherServlet initServletBean INFO:…
0
votes
1 answer

BindingResult.getFieldValue() returning null in test context for a formatted value

In a spring mvc app, I submit id's and use a formatter to convert that id to an object. It works well in the container. But in the unit test environment, I'm seeing a problem. I mock the formatter to always return my test value, this is fine it gets…
Richard G
  • 5,243
  • 11
  • 53
  • 95
0
votes
1 answer

HDIV config to set parameters in hidden fields instead of URL

I am using Spring MVC 4.1.7.RELEASE and HDIV 2.1.11. I have set HdivRequestDataValueProcessor to intercept internal redirects in Controller code as below. return "redirect:"+"/user/account" This is resulting in the HDIV state parameter getting set…
Happy_coding
  • 19
  • 1
  • 5
0
votes
1 answer

Inject data into session from JUnit test

I need to run a JUnit vs Spring MVC test case in which preconditions include that certain data is present in the HTTP Session. Most important is that I cannot wire a session-scoped bean: I must access httpServletContext.getSession(). Before showing…
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305