spring-mvc-test Questions
1
None of these solutions helped here: Spring mockMvc doesn't consider validation in my test. Added all of these dependencies, nothing helps.
I use Spring Boot 2.1.2, pom.xml:
<parent>
&...
Beerbohm asked 10/3, 2019 at 14:16
7
I have the following simple controller to catch any unexpected exceptions:
@ControllerAdvice
public class ExceptionController {
@ExceptionHandler(Throwable.class)
@ResponseStatus(value = HttpSt...
Santee asked 21/5, 2013 at 11:52
9
I want to write a test case to check my controller (getPersons). This is a server side code. I have confusion what should i put inside @ContextConfiguration(locations={"file:src/main/webapp/WEB-INF...
Opulence asked 20/6, 2013 at 17:50
3
Solved
I'm trying to test (through Spring test (mvc)) a controller that uses servletRequest.getParts()
All I've read so far is that MockMvcRequestBuilders.fileUpload().file() is the solution. However I ...
Flyblow asked 3/5, 2016 at 9:30
26
Solved
I have the following code in one of my controllers:
@Controller
@RequestMapping("/preference")
public class PreferenceController {
@RequestMapping(method = RequestMethod.GET, produces = "text/ht...
Pattern asked 15/9, 2013 at 14:42
6
Solved
I have written a test and it succeeded before but now I get an AssertionError: No value for JSON Path.
@Test
public void testCreate() throws Exception {
Wine wine = new Wine();
wine.setName("Bor...
Duramen asked 11/11, 2015 at 20:57
2
I have created custom login form for my spring boot app.
In my form integration test, I want to check that received cookies contain JSESSIONID and XSRF-TOKEN.
But, I received only XSRF-TOKEN.
H...
Riess asked 13/4, 2016 at 14:1
4
I have few working code to set up MockMVc in different ways with the new Spring Boot 1.4 @WebMvcTest. I understand the standaloneSetup approach. What I want to know is the difference between settin...
Beverlee asked 3/7, 2016 at 8:33
2
Solved
I'm trying to use Junit 5 on a spring-boot 2.x project to test a Controller.
The following works fine
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import...
Alluring asked 14/4, 2018 at 17:17
3
Solved
I am having trouble while trying to make MockMvc to include the exception message in the response body. I have a controller as follows:
@RequestMapping("/user/new")
public AbstractResponse create(...
Hydrotherapeutics asked 4/2, 2015 at 15:24
3
Solved
I am using spring 3.2 mock mvc to test my controller.My code is
@Autowired
private Client client;
@RequestMapping(value = "/user", method = RequestMethod.GET)
public String initUser...
Impresario asked 31/7, 2013 at 13:55
4
I am trying to create spring-mvc tests using Spring 3.2.1. Following some tutorials, I thought this would be straight-forward.
Here is my test:
@RunWith( SpringJUnit4ClassRunner.class )
@ContextCon...
Identical asked 21/4, 2013 at 21:24
3
Recently we have introduced CSRF protection for our project which uses spring security 3.2.
After enabling CSRF some of the unit tests are failing because of the csrf token is not present in reque...
Resilient asked 1/9, 2014 at 11:57
2
Solved
I write my API documentation with Spring REST Docs.
Code example:
@Override
public void getById(String urlTemplate, PathParametersSnippet pathParametersSnippet, Object... urlVariables) throws Exc...
Ridicule asked 30/1, 2019 at 14:33
1
I have a controller like this one:
@RestController
@RequestMapping('/v1/document')
class DocumentV1Controller {
@PutMapping
HttpEntity<Document> newdoc(
@RequestHeader Map<String, Stri...
Shofar asked 18/5, 2016 at 16:19
1
Solved
Since I migrated to Spring Boot 2.0.5 from 1.x, with no mean to disable security, I can't get test roles to work on mock MVC tests :
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMock...
Thaliathalidomide asked 2/10, 2018 at 7:57
3
Solved
I have a Spring MVC Controller which uses Pagination Support of Spring-Data:
@Controller
public class ModelController {
private static final int DEFAULT_PAGE_SIZE = 50;
@RequestMapping(value =...
Jeffiejeffrey asked 4/3, 2014 at 14:27
2
I'm implementing long polling as per the Spring blog from some time ago.
Here my converted method with same response signature as before, but instead of responding immediately, it now uses long po...
Blearyeyed asked 17/12, 2015 at 19:58
1
Solved
I have gone through https://github.com/spring-projects/spring-boot/issues/424 but my project structure contains .html files at the /templates diretory as shown below
.
|-- java
| `-- com
| `-- pr...
Hickman asked 5/9, 2014 at 9:41
1
Solved
In a Spring Boot application, I have two POJOs, Foo and Bar, and a BarToFooConverter, which looks like:
@Component
public class BarToFooConverter implements Converter<Bar, Foo> {
@Override
...
Madwort asked 18/1, 2018 at 17:26
2
I'm trying to run a test for testing a Spring MVC controller. The test compile and runs, but my problem is that I got a PageNotFound warning:
WARN PageNotFound - No mapping found for HTTP request ...
Ivo asked 9/7, 2013 at 7:53
1
Solved
I have an API that returns a JSON object that will be displayed in a UI. The order of the fields in the object matters because the UI wants to display the fields in that order. I want to write a un...
Irreformable asked 8/12, 2017 at 17:4
3
How do i validate/test the 500 internal server error in MockMvc, when my controller is of Async servlet nature?
I am writing unit test cases for my REST endpoint as part of a test cases i need to ...
Russelrussell asked 8/8, 2015 at 12:51
1
I'm building very basic web application using Spring Boot 1.5.1 and wanted to create integration tests for checking REST endpoints.
As recomended by documentation, MockMvc might be used for it.
He...
Jerrome asked 9/3, 2017 at 11:9
2
Solved
I recently added the Cobertura plugin to my Java/Spring-MVC project. The strange thing is that all my unit tests were passing, and they still pass when Maven does its initial test run, but then whe...
Jillianjillie asked 6/8, 2013 at 15:30
1 Next >
© 2022 - 2025 — McMap. All rights reserved.