spring-boot-test Questions

4

Solved

I am having an issue with injecting MockMvc to my test class. I tried a few options, but none of them works. 1 option: basically the same as here, manually creating MockMvc @Autowire MockMvc - Spri...
Munch asked 8/8, 2020 at 3:6

2

Solved

I'm trying to leverage H2 for testing and have the following configuration in src/test/resources/application.yaml: spring: r2dbc: url: r2dbc:h2:file://testdb I have an empty test annotated wit...

0

I have POST method in spring controller and I am trying to run test method on the controller using Test Rest template exchange. Controller.java @RequestMapping(path = "/rest/projects") ...

1

Solved

I'm trying to use H2 with Oracle mode since I'm using Oracle 11G on my application but I'm getting an error because when I use pagination the query puts limit and offset on sql. application.propert...
Germaun asked 11/7, 2022 at 1:0

3

Solved

The before and after methods not working in JUnitPlatform. The code is below. import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.platform.runner.JUnit...

2

Solved

I'm writing a few unit tests for a Spring application that can be run with two different configurations. The two different configurations are given by two application.properties file. I need to wri...
Preacher asked 1/6, 2022 at 9:14

2

we are trying to do an intergration test our interceptors in our spring boot application using spring boot version 1.4.0, but not sure how; here is our application setting @Configuration @EnableAu...
Stemma asked 2/10, 2017 at 18:9

3

Solved

Is it possible to somehow have in the same test class @MockBean and @Autowired of the same service? In other words, I would like to have @MockBean service only for one test, while for others tests...
Unhandsome asked 21/4, 2020 at 7:40

4

Solved

I've a @RestController which has only one dependency in field @Autowire that dependency is @component, that component Class definition has some autowired fields which are @service and those service...
Distill asked 26/10, 2020 at 16:16

3

I have been trying to follow the instructions in the link below to try to add an automatically configured Embedded MongoDB Instance for Cucumber Integration testing. This is currently not working, ...

3

Solved

I would like to run my integration tests but I don't know how to disable @EnableKafka. My app looks like that: @SpringBootApplication @EnableKafka public class MyApplication {
Carditis asked 18/10, 2019 at 10:10

2

Great thx for viewing my question) I have some strange subject: my spring boot tests don't work. They start successfully but always throwing 403 HTTP status when making the requests to any controll...

1

First of all, its important to specify that the app is already deployed and our spring security configuration works. If an unauthenticated user tries to access to any endpoint of the API it returns...
Quotient asked 10/2, 2022 at 16:1

0

I have my custom properties defined in application.properties file located in src/main/resources folder. I want to add test cases for my application hence I added application-integration.properties...

2

Solved

I have an application in which I use Spring Social Security for authentication and authorization. Unfortunately I am having some problems with mocking Spring Security. It seems that it does not wor...

4

I want to set active profile host dependent for any envrionment and cannot find an environment independent hook. Following factory will set the active profile before application context will build...

7

I am running Spring Boot 2.0.1 and Junit 5. I am trying to get port within an integration test . However the port value is always zero. I am not sure what could be causing it. I have tried changing...
Jabez asked 8/5, 2018 at 17:38

2

Solved

Given a test class like: @WebMvcTest @RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.profiles.active=test") public class MyControllerTest { ... some tests } I get the error: ...

2

Solved

I am trying to implement unit test for a Websocket in Springboot with JUnit. I am following this link and it runs fine but gets null in the result, when i test my websocket with a browser it sends ...

3

Solved

According to the spring docs, string property values such as 10s will be properly converted into a java.time.Duration. Indeed this works for me with the main application properties. But it fails in...
Parenthesis asked 27/5, 2021 at 13:15

2

Solved

In My Spring 2.5 web application, I am trying to write a test in which I disable the fact that it's a web application : this is because the application also contains some scheduled task(s) that use...
Ailsa asked 12/11, 2021 at 15:15

2

I'm writing a controller test where controller looks like @RestController public class VehicleController { @Autowired private VehicleService vehicleService = null; ... } While the test c...
Emancipate asked 19/10, 2018 at 6:21

4

Solved

My problem: if my test refers to an @Bean declaration in the class listed in @SpringBootTest, autowire works. If it refers to a class automatically @ComponentScanned by the class listed in @SpringB...
Grigri asked 19/9, 2018 at 12:45

2

I want to disable csrf when doing integration tests for my springboot application. I have already tried security.enable-csrf=false but that doesn't seem to have any effect. I have also tried passin...

2

Confident this hasn't been asked but reading through the Spring docs and testing utilities I found this annotation and thought I'd start using it. Reading through the fine print I read: Regular @...
Asaph asked 25/7, 2017 at 16:52

© 2022 - 2024 — McMap. All rights reserved.