-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46233 from mkouba/ws-next-max-frame-config
WebSockets Next: make it possible to configure max frame size
- Loading branch information
Showing
6 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...ployment/src/test/java/io/quarkus/websockets/next/test/maxframesize/MaxFrameSizeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.quarkus.websockets.next.test.maxframesize; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.net.URI; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.netty.handler.codec.http.websocketx.CorruptedWebSocketFrameException; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.quarkus.websockets.next.OnError; | ||
import io.quarkus.websockets.next.OnTextMessage; | ||
import io.quarkus.websockets.next.WebSocket; | ||
import io.quarkus.websockets.next.test.utils.WSClient; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.core.http.WebSocketFrame; | ||
|
||
public class MaxFrameSizeTest { | ||
|
||
@RegisterExtension | ||
public static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> { | ||
root.addClasses(Echo.class, WSClient.class); | ||
}) | ||
.overrideConfigKey("quarkus.websockets-next.server.max-frame-size", "10"); | ||
|
||
@Inject | ||
Vertx vertx; | ||
|
||
@TestHTTPResource("/echo") | ||
URI echoUri; | ||
|
||
@Test | ||
void testMaxFrameSize() throws InterruptedException, ExecutionException, TimeoutException { | ||
WSClient client = WSClient.create(vertx).connect(echoUri); | ||
client.socket().writeFrame(WebSocketFrame.textFrame("foo".repeat(10), false)); | ||
assertTrue(Echo.CORRUPTED_LATCH.await(5, TimeUnit.SECONDS)); | ||
} | ||
|
||
@WebSocket(path = "/echo") | ||
public static class Echo { | ||
|
||
static final CountDownLatch CORRUPTED_LATCH = new CountDownLatch(1); | ||
|
||
@OnTextMessage | ||
String process(String message) { | ||
return message; | ||
} | ||
|
||
@OnError | ||
void onError(CorruptedWebSocketFrameException e) { | ||
// Note that connection is automatically closed when CorruptedWebSocketFrameException is thrown | ||
CORRUPTED_LATCH.countDown(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters