-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebSockets Next: honor the quarkus.http.root-path correctly
- i.e. do not use HttpRootPathBuildItem together with RouteBuildItem.builder()
- Loading branch information
Showing
3 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
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
52 changes: 52 additions & 0 deletions
52
...deployment/src/test/java/io/quarkus/websockets/next/test/rootpath/CustomRootPathTest.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,52 @@ | ||
package io.quarkus.websockets.next.test.rootpath; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.net.URI; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
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; | ||
|
||
public class CustomRootPathTest { | ||
|
||
@RegisterExtension | ||
public static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> { | ||
root.addClasses(Echo.class, WSClient.class); | ||
}).overrideConfigKey("quarkus.http.root-path", "/api"); | ||
|
||
@Inject | ||
Vertx vertx; | ||
|
||
@TestHTTPResource("echo") | ||
URI testUri; | ||
|
||
@Test | ||
void testEndpoint() { | ||
assertTrue(testUri.toString().contains("/api")); | ||
try (WSClient client = WSClient.create(vertx).connect(testUri)) { | ||
assertEquals("monty", client.sendAndAwaitReply("monty").toString()); | ||
} | ||
} | ||
|
||
@WebSocket(path = "/echo") | ||
public static class Echo { | ||
|
||
@OnTextMessage | ||
String process(String message) throws InterruptedException { | ||
return message; | ||
} | ||
|
||
} | ||
|
||
} |