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

Verify web socket signatures, scopes, and endpoint annotation issues #2

Conversation

cescoffier
Copy link

@mkouba there are test failures (that's expected). I will add more tests soon.

void testConnectionNotAccessibleOutsideOfWsMethods() {
assertThat(CDI.current().getBeanContainer().isScope(SessionScoped.class)).isFalse();
assertThat(CDI.current().getBeanContainer().isScope(RequestScoped.class)).isTrue();
assertThat(connection).isNull();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be null - a client proxy is injected. If you try to call a method you should get ContextNotActiveException.


@OnMessage
public String onMessage(String message) {
assertThat(CDI.current().getBeanContainer().isScope(SessionScoped.class)).isTrue();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not test what you expect ;-). It merely tests if the class represents a scope annotation. Which it does. In order to test active context, you can try something like Arc.container().getActiveContext(SessionScoped.class) != null.

@mkouba
Copy link
Owner

mkouba commented Feb 21, 2024

I've cherry-picked the commit, fixed the assertions (DeploymentException -> WebSocketServerException). There were actually no validation failures ;-). Thanks!

@mkouba mkouba closed this Feb 21, 2024
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

Successfully merging this pull request may close these issues.

2 participants