Skip to content

Mock FeignClient not replacing the application Application FeignClient in Spring Boot 2.3.3.RELEASE #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
itsamemarus opened this issue Sep 18, 2020 · 10 comments

Comments

@itsamemarus
Copy link

After upgrading from Spring boot 2.2.2 to 2.3.3 the feign client in tests are not replaced.
The mocked bean seems to be instantiated but it does not replace the actual FeignClient provided by the application.

spring-cloud-starter-openfeign version : 2.2.5.RELEASE

spring boot version: 2.3.3.RELEASE

spring version: 5.2.8.RELEASE

I have found the issues related to this saying that is already fixed but for me it doesn't seem to replace the actual FeignClient.
#336

#337

@SpringBootTest(classes = [SomeApplication.class], webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = [ApplicationTestConfig])
@ActiveProfiles("test")
@TestExecutionListeners([DependencyInjectionTestExecutionListener, TransactionalTestExecutionListener])
@AutoConfigureMockMvc
abstract class AbstractControllerSpecification extends AbstractSpecification {}

And for the ApplicationTestConfig I have something like this

@EntityScan(basePackages = "somepackage")
@ComponentScan(basePackages = "somepackage")
@IntegrationComponentScan(basePackages = "somepackage")
@Profile("test")
class ApplicationTestConfig {

    DetachedMockFactory factory = new DetachedMockFactory()

    @Bean
    SomeResource someResource() {
        factory.Mock(someResource)
    }
}

A work-around I have found is to set the FeignClient(primary = false) and it seems to be working properly but I don't think that is a solution.

Any ideas if this is still a problem in 2.3.3?

@OlgaMaciaszek
Copy link
Collaborator

Hello, @DoniciMarius. Please provide a minimal, complete, verifiable example that reproduces the issue (preferably as a link to GH project).

@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@mark4z
Copy link

mark4z commented Oct 10, 2022

Maybe i will fix it.

@OlgaMaciaszek
Copy link
Collaborator

Hi @mark4z , please feel free to submit a PR.

@OlgaMaciaszek OlgaMaciaszek added bug Something isn't working help wanted Extra attention is needed and removed closeable labels Oct 10, 2022
@mark4z
Copy link

mark4z commented Oct 12, 2022

@OlgaMaciaszek It's fixed on feign 2.2.3.RELEASE, so no need PR anymore.

@apb12
Copy link

apb12 commented Sep 3, 2023

@OlgaMaciaszek It's fixed on feign 2.2.3.RELEASE, so no need PR anymore.

it does not fix yet, ive got same issue. What spring boot starter we should to use to awoid this issue?
You told its fixed on feign 2.2.3, but the guy that started this topic used spring-cloud-starter-openfeign version : 2.2.5.RELEASE
So did you go to past and fix it or just lied to us?

@OlgaMaciaszek
Copy link
Collaborator

Hello, @apb12, please provide a minimal, complete, verifiable example that reproduces the issue (preferably as a link to GH project).

@OlgaMaciaszek OlgaMaciaszek reopened this Sep 4, 2023
@OlgaMaciaszek OlgaMaciaszek added waiting for feedback and removed bug Something isn't working help wanted Extra attention is needed labels Sep 4, 2023
@spring-cloud-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-cloud-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants