|
2 | 2 |
|
3 | 3 | import static org.assertj.core.api.Assertions.assertThat; |
4 | 4 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; |
6 | 7 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
7 | 8 | import static org.junit.jupiter.api.Assertions.assertNull; |
@@ -144,6 +145,27 @@ void testClientOptionsCustomization() { |
144 | 145 | })).rootCause().isInstanceOf(UnknownHostException.class).hasMessageContaining("robert"); |
145 | 146 | } |
146 | 147 |
|
| 148 | + @Test |
| 149 | + void testBaseUriValidationFailure() { |
| 150 | + assertThrows(IllegalArgumentException.class, () -> connector.baseUri("localhost:8080")); |
| 151 | + assertThrows(IllegalArgumentException.class, () -> connector.baseUri("127.0.0.1:8080/")); |
| 152 | + assertThrows(IllegalArgumentException.class, () -> connector.baseUri("localhost:8080/hello")); |
| 153 | + assertThrows(IllegalArgumentException.class, () -> connector.baseUri("jdbc:localhost:8080/hello")); |
| 154 | + assertThrows(IllegalArgumentException.class, () -> connector.baseUri("jdbc://localhost:8080/hello")); |
| 155 | + assertDoesNotThrow(() -> connector.baseUri("http://localhost:8080/hello")); |
| 156 | + assertDoesNotThrow(() -> connector.baseUri("http://localhost:8080/")); |
| 157 | + assertDoesNotThrow(() -> connector.baseUri("http://localhost:8080")); |
| 158 | + assertDoesNotThrow(() -> connector.baseUri("ws://localhost:8080/hello")); |
| 159 | + assertDoesNotThrow(() -> connector.baseUri("ws://localhost:8080/")); |
| 160 | + assertDoesNotThrow(() -> connector.baseUri("ws://localhost:8080")); |
| 161 | + assertDoesNotThrow(() -> connector.baseUri("https://localhost:8080/hello")); |
| 162 | + assertDoesNotThrow(() -> connector.baseUri("https://localhost:8080/")); |
| 163 | + assertDoesNotThrow(() -> connector.baseUri("https://localhost:8080")); |
| 164 | + assertDoesNotThrow(() -> connector.baseUri("wss://localhost:8080/hello")); |
| 165 | + assertDoesNotThrow(() -> connector.baseUri("wss://localhost:8080/")); |
| 166 | + assertDoesNotThrow(() -> connector.baseUri("wss://localhost:8080")); |
| 167 | + } |
| 168 | + |
147 | 169 | private WebSocketClientConnection createConnection2(CountDownLatch conn2Latch, |
148 | 170 | BiConsumer<WebSocketConnectOptions, WebSocketClientOptions> customizer) { |
149 | 171 | return BasicWebSocketConnector |
|
0 commit comments