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

ArC: make it possible to activate the session context for a specific business method in a test #45146

Closed
mkouba opened this issue Dec 16, 2024 · 5 comments · Fixed by #45170
Closed
Assignees
Labels
area/testing kind/enhancement New feature or request
Milestone

Comments

@mkouba
Copy link
Contributor

mkouba commented Dec 16, 2024

Description

Currently, it's not possible to test a @SessionScoped component used in a WS Next app outside the real websocket communication. That is quite limiting.

Implementation ideas

We could provide an annotation similar to @jakarta.enterprise.context.control.ActivateRequestContext.

@mkouba mkouba added the kind/enhancement New feature or request label Dec 16, 2024
@quarkus-bot quarkus-bot bot added the area/arc Issue related to ARC (dependency injection) label Dec 16, 2024
Copy link

quarkus-bot bot commented Dec 16, 2024

/cc @Ladicek (arc), @manovotn (arc)

@mkouba mkouba added area/testing and removed area/arc Issue related to ARC (dependency injection) labels Dec 16, 2024
@mkouba mkouba self-assigned this Dec 16, 2024
@mkouba
Copy link
Contributor Author

mkouba commented Dec 16, 2024

Hm, I think that we should move the logic from WebSocketSessionContext into ArC because it does not contain anything WS Next-specific. It's actually almost identical to io.quarkus.arc.impl.RequestContext. So maybe we could also extract the logic in an abstract superclass.

@manovotn
Copy link
Contributor

Hm, I think that we should move the logic from WebSocketSessionContext into ArC because it does not contain anything WS Next-specific. It's actually almost identical to io.quarkus.arc.impl.RequestContext. So maybe we could also extract the logic in an abstract superclass.

Wouldn't that lead to a possible conflict with Undertow extension impl of @SessionScoped?

@mkouba
Copy link
Contributor Author

mkouba commented Dec 17, 2024

Hm, I think that we should move the logic from WebSocketSessionContext into ArC because it does not contain anything WS Next-specific. It's actually almost identical to io.quarkus.arc.impl.RequestContext. So maybe we could also extract the logic in an abstract superclass.

Wouldn't that lead to a possible conflict with Undertow extension impl of @SessionScoped?

It should not. First of all, it's perfectly fine to have multiple contexts registered for a scope. However, only one can be active at a given time. The plan is to only register the activating binding/interceptor for tests. And obviously, the interceptor should do nothing if the context is already active.

@manovotn
Copy link
Contributor

The plan is to only register the activating binding/interceptor for tests. And obviously, the interceptor should do nothing if the context is already active.

Got it; in that case, it should be perfectly fine 👍

mkouba added a commit to mkouba/quarkus that referenced this issue Dec 17, 2024
mkouba added a commit to mkouba/quarkus that referenced this issue Dec 17, 2024
mkouba added a commit to mkouba/quarkus that referenced this issue Dec 17, 2024
@mkouba mkouba closed this as completed in 09706b9 Dec 17, 2024
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/enhancement New feature or request
Projects
None yet
2 participants