Skip to content
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

WebMvcTest and WebFluxTest ignore user-provided Thymeleaf IDialect beans #24149

Closed
jnizet opened this issue Nov 13, 2020 · 8 comments
Closed
Assignees
Labels
type: bug A general bug
Milestone

Comments

@jnizet
Copy link
Contributor

jnizet commented Nov 13, 2020

Beans implementing Thymeleaf's IDialect interface are automatically registered by Spring Boot as dialects for Thymeleaf templates.
But this doesn't happen in WebMvcTests, where IDialect beans are not included. It seems to me that they belong to the web MVC layer, and should thus be added to the WebMvcTest slice.

The workaround is of course easy enough:

@Import(MyCustomDialect.class)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 13, 2020
@wilkinsona
Copy link
Member

Thanks, @jnizet. This feels like a bug to me. It doesn't really make sense to include an auto-configuration while excluding user-provided beans that it would normally consume.

@wilkinsona wilkinsona changed the title Consider adding Thymeleaf IDialect beans to WebMvcTest slice WebMvcTest ignores user-provided Thymeleaf IDialect beans Nov 13, 2020
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 13, 2020
@wilkinsona wilkinsona added this to the 2.2.x milestone Nov 13, 2020
@sadath42
Copy link

sadath42 commented Dec 6, 2020

Hi @wilkinsona is this bug available to work , I would be interested to work on it.

@wilkinsona
Copy link
Member

@sadath42 Thanks for the offer. A contribution that fixes this would be much appreciated. Please let us know if you have any questions.

@sadath42
Copy link

sadath42 commented Dec 14, 2020

@wilkinsona No questions as if now. I am analyzing the bug if there any questions will let you know .

@philwebb philwebb modified the milestones: 2.2.x, 2.3.x Dec 16, 2020
@wilkinsona
Copy link
Member

How's it going, @sadath42? It's been a while now. If you no longer have time to work on a fix, please just let us know and we can take care of it. Equally, please let us know if you have any questions.

@sadath42
Copy link

sadath42 commented Feb 1, 2021

Hi ,
Please assign it someone else.

@wilkinsona wilkinsona assigned wilkinsona and unassigned sadath42 Feb 1, 2021
@wilkinsona wilkinsona changed the title WebMvcTest ignores user-provided Thymeleaf IDialect beans WebMvcTest and WebFluxTest ignore user-provided Thymeleaf IDialect beans Feb 1, 2021
@wilkinsona wilkinsona modified the milestones: 2.3.x, 2.3.9 Feb 1, 2021
@priiduneemre
Copy link

Sorry for thread necromancy.

Is there a nice way to achieve the "old" behavior, i.e. exclude custom dialects from the @WebMvcTest slice, specifically?
I suppose excludeFilters is the only way?

EDIT: To clarify the usecase, suppose you have a bunch of @WebMvcTest-s for REST controllers and then use Thymeleaf for templating in javax.mail domain. Ideally, you would like to avoid dealing with the mail-related stuff (incl. dialects) in any old controller test.

@wilkinsona
Copy link
Member

Yes, an exclude filter would be the best way to filter out unwanted beans found via component scanning.

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

No branches or pull requests

6 participants