-
Notifications
You must be signed in to change notification settings - Fork 22
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
Quarkus support in testbench #1655
Comments
Thank you @ErrorProne for the ticket. The TestBench team, I'm sure, will address the technical feasibility of the proposed solution. But as the product manager, my sincere apologies for any false promises made regarding TestBench support with Quarkus. It is indeed reasonable to expect TestBench to work with Quarkus without the need to resort to any workarounds. And if, for some reason, this support turns out to be impossible or prohibitively expensive to implement, we should clearly emphasize that in the Quarkus and TestBench documentation pages. In all cases, we will aim to investigate possible ways of improving TestBench + Quarkus support. |
Thanks for your reply @tarekoraby - it would be really awesome to see some of our workarounds to make their way into the official Vaadin Testbench implementation. I forked the afaik official starter project for Quarkus + Vaadin and extended it with workarounds for all of the issues we identified and fixed so far. You find it here: https://github.com/AliceAndTheBuilders/pro-starter-flow-quarkus If some comments reads as offense - lets make me clear that this is not my intention and just read them with positive vibes. We adressed the following issues so far:
|
Thanks for sharing the workarounds 🙏 That's very helpful. It's the summer holiday season here in Finland, but we will get back to you as soon as we can once the bulk of our developers return and had the opportunity to examine the issue. |
TestBench End-To-End is also not working. Some of the problems seem to be related to how quarkus handles isolation of extensions with different classloaders. It looks like you guys should talk to your quarkus folks about that. I think that we figured out a workaround. We will update the starter later with the new workaround and keep you posted. |
In the starter @benjaminrau mentioned, why is needed for the injected properties to be use in @PostConstruct? it is possible to use them outside of the postconstruct? |
I'm not sure if I understand the question. But I guess you are referring to this? He is using the |
Yes, that was my question, sorry i worded it poorly, so this should work rigth? I'm having trouble formatting it properly, but i think it gets the point across |
Yes, as per https://quarkus.io/guides/cdi-reference#simplified-constructor-injection this should work (given that all other things are right). For the starter example this would be transient SecurityIdentityAssociation identity;
public ProtectedView(SecurityIdentityAssociation identity) {
this.identity = identity;
textField.setValue(identity.getIdentity().getPrincipal().getName());
} |
Thanks! i tested it yesterday and it works correctly with JPA-security, what is the reason the field injection needs to be used at post construct with vaadin? |
This is not really a vaadin specific thing. Field injection works in a way where the container (I guess Quarkus ArC in this case) first instantiates your class through the no args constructor and than sets the injects fields via setters. This basically means that the fields will be injected after the constructor has finished. So when field injection is used you have to opt-in for the Both are valid methods for injection and have a long history of discussions of pros/cons. As far as I'm aware constructor injection is more favoured by tools like sonarqube etc. since they make the classes for example "easier" testable. But you will find people who vote for each variant. Do you have anything specific in mind regarding logouts? Also feel free to create an issue on our starter fork (https://github.com/AliceAndTheBuilders/pro-starter-flow-quarkus) so we can keep this issue on topic =) |
Issue Created! |
@fjasis I created a pull request which adds a logout example: AliceAndTheBuilders/pro-starter-flow-quarkus#2 And from what i see, is Vaadin on Quarkus not managing any sessions itself, which would require cleanup. Assuming that, the example should be sufficient. |
For End-To-End tests a workaround is to change the lookup method for required modules in the tests application.properties (important, it requires .properties even if yaml is used!). For example: quarkus.class-loading.parent-first-artifacts=com.vaadin:vaadin-testbench-core-junit5,com.vaadin:vaadin-testbench-shared,org.seleniumhq.selenium:selenium-api For vaadin devs workin on this, please see https://quarkus.io/guides/class-loading-reference#isolated-classloaders I'lltry to push an example to our forked starter later this week |
My observations on the issue which is worked around as @ErrorProne mentioned are the following per example:
By instructing Quarkus to NOT use the isolated class loader the check for The following comment on the docs at https://quarkus.io/guides/writing-extensions#using-threads-context-class-loader seems related:
Sidenote related to the autodiscover routes feature on Testbench Unit Tests: |
Thanks @benjaminrau , @ErrorProne for providing your codes and all who commented on this issue. |
It took a while for me to triage this ticket and split into smaller parts, here what I eventually get (in priority order):
Two other issues regarding Vaadin Flow team will work on fixing these issue during normal maintenance one by one, I believe they can be done separately. I'll keep you posted about results. Thanks again for the workarounds, much helpful! |
Currently classes are loaded with Class.forName, that uses the classloader from the calling class. However, this might not work on all environments because of different class loading setup (e.g in Quarkus testing). This change uses the current thread context class loader as fallback when Class.forName is not able to load a class. Fixes #vaadin/quarkus#139 Part of #1655
Currently classes are loaded with Class.forName, that uses the classloader from the calling class. However, this might not work on all environments because of different class loading setup (e.g in Quarkus testing). This change uses the current thread context class loader as fallback when Class.forName is not able to load a class. Fixes vaadin/quarkus#139 Part of #1655
Currently classes are loaded with Class.forName, that uses the classloader from the calling class. However, this might not work on all environments because of different class loading setup (e.g in Quarkus testing). This change uses the current thread context class loader as fallback when Class.forName is not able to load a class. Fixes vaadin/quarkus#139 Part of #1655
Currently classes are loaded with Class.forName, that uses the classloader from the calling class. However, this might not work on all environments because of different class loading setup (e.g in Quarkus testing). This change uses the current thread context class loader as fallback when Class.forName is not able to load a class. Fixes vaadin/quarkus#139 Part of #1655
One issue with running UI Unit Tests with Quarkus @ErrorProne in the provided example repository, the UI Unit tests are also starting the HTTP server. Did you manage in some way to prevent running the whole application and just focus on specific components? |
Adds a base class for UI Unit testing on Quarkus. Provides mocks for QuarkusVaadinServlet and QuarkusVaadinServletService integrated with Quarkus CDI. Fixes vaadin/quarkus#140 Part of #1655
This change allows to write UI Unit tests that profits of Quarkus security testing annotation that can be applied to test methods and test classes to control the security context that the test is run with for mock user. Fixes vaadin/quarkus#141 Part of #1655
Fixes #3169 Part of vaadin/quarkus#140 Part of vaadin/quarkus#141 Part of vaadin/testbench#1655
Adds a base class for UI Unit testing on Quarkus. Provides mocks for QuarkusVaadinServlet and QuarkusVaadinServletService integrated with Quarkus CDI. Fixes vaadin/quarkus#140 Part of #1655
This change allows to write UI Unit tests that profits of Quarkus security testing annotation that can be applied to test methods and test classes to control the security context that the test is run with for mock user. Fixes vaadin/quarkus#141 Part of #1655
* feat: add support for Quarkus security in UI Unit tests This change allows to write UI Unit tests that profits of Quarkus security testing annotation that can be applied to test methods and test classes to control the security context that the test is run with for mock user. Fixes vaadin/quarkus#141 Part of #1655 * Apply suggestions from code review Co-authored-by: Mikhail Shabarov <[email protected]> --------- Co-authored-by: Mikhail Shabarov <[email protected]>
* feat: add documentation for Quarkus UI Unit Testing Fixes #3169 Part of vaadin/quarkus#140 Part of vaadin/quarkus#141 Part of vaadin/testbench#1655 * add since tag * add simple test to example code * First full pass at editing. * Second full pass at editing. --------- Co-authored-by: Russell J.T. Dyer <[email protected]> Co-authored-by: Mikhail Shabarov <[email protected]>
What do I want
Working quarkus support for pro features like UiUnitTest
Explain your problem
Two things, based on who reads this
Testbench-Devs:
There are multiple problems we found with quarkus support so far:
@TestSecurity
(https://quarkus.io/guides/security-testing) feature is not working (similiar to springs @WithMockUser)All of those should be solved with the workarounds in [1] but an official out-of-the-box support should be the goal.
The vaadin project and team does such an amazing work and the framework is wonderful to use. The same should hold true for testing.
We will be happy to provide feedback or input to any implementations for this.
Project owner/Pro feature Support:
A little rant: Before switching to Vaadin we talked to a few folks and very explicitly stated that we do test a lot and use quarkus. We do deploy applications into factory lines. These apps have to work stable, no exceptions. Naturally we were very interested in the pro Testbench features and have been told that quarkus is supported. Our experience right now is: that is not the case at all.
We got it working eventually but only by diving into the vaadin code and with help from Marco Collovati in this issue in the quarkus extension here [1].
So far it looks like we solved all the issues in [1] but for a pro feature with official quarkus support and no mention about these problems at all (e.g. https://vaadin.com/docs/latest/integrations/quarkus) is a very frustrating experience. Additionally at least I see testing in 2023 not as an nice-to-have addition.
[1] vaadin/quarkus#121
The text was updated successfully, but these errors were encountered: