1212
1313import io .vertx .core .Future ;
1414import io .vertx .core .buffer .Buffer ;
15- import io .vertx .core .http .HttpClient ;
16- import io .vertx .core .http .HttpClientResponse ;
17- import io .vertx .core .http .HttpMethod ;
18- import io .vertx .core .http .ServerWebSocket ;
19- import io .vertx .core .http .UpgradeRejectedException ;
20- import io .vertx .core .http .WebSocketConnectOptions ;
21- import io .vertx .core .http .WebsocketVersion ;
15+ import io .vertx .core .http .*;
2216import io .vertx .core .net .SocketAddress ;
2317import io .vertx .ext .unit .Async ;
2418import io .vertx .ext .unit .TestContext ;
4135@ RunWith (VertxUnitRunner .class )
4236public class WebSocketTest extends ProxyTestBase {
4337
44- private HttpClient client ;
38+ private WebSocketClient wsClient ;
4539
4640 @ Override
4741 public void tearDown (TestContext context ) {
4842 super .tearDown (context );
49- client = null ;
43+ wsClient = null ;
5044 }
5145
5246 public WebSocketTest () {
@@ -85,13 +79,13 @@ private void testWebSocket(TestContext ctx, WebsocketVersion version) {
8579 }));
8680 });
8781 startProxy (backend );
88- client = vertx .createHttpClient ();
82+ wsClient = vertx .createWebSocketClient ();
8983 WebSocketConnectOptions options = new WebSocketConnectOptions ()
9084 .setPort (8080 )
9185 .setHost ("localhost" )
9286 .setURI ("/ws" )
9387 .setVersion (version );
94- client . webSocket (options ).onComplete (ctx .asyncAssertSuccess (ws -> {
88+ wsClient . connect (options ).onComplete (ctx .asyncAssertSuccess (ws -> {
9589 ws .write (Buffer .buffer ("ping" ));
9690 ws .handler (buff -> {
9791 ws .close ();
@@ -106,12 +100,12 @@ public void testWebSocketReject(TestContext ctx) {
106100 req .response ().setStatusCode (400 ).end ();
107101 });
108102 startProxy (backend );
109- client = vertx .createHttpClient ();
103+ wsClient = vertx .createWebSocketClient ();
110104 WebSocketConnectOptions options = new WebSocketConnectOptions ()
111105 .setPort (8080 )
112106 .setHost ("localhost" )
113107 .setURI ("/ws" );
114- client . webSocket (options ).onComplete (ctx .asyncAssertFailure (err -> {
108+ wsClient . connect (options ).onComplete (ctx .asyncAssertFailure (err -> {
115109 ctx .assertTrue (err .getClass () == UpgradeRejectedException .class );
116110 async .complete ();
117111 }));
@@ -126,12 +120,12 @@ public void testInboundClose(TestContext ctx) {
126120 });
127121 });
128122 startProxy (backend );
129- client = vertx .createHttpClient ();
123+ wsClient = vertx .createWebSocketClient ();
130124 WebSocketConnectOptions options = new WebSocketConnectOptions ()
131125 .setPort (8080 )
132126 .setHost ("localhost" )
133127 .setURI ("/ws" );
134- client . webSocket (options ).onComplete (ctx .asyncAssertFailure (err -> {
128+ wsClient . connect (options ).onComplete (ctx .asyncAssertFailure (err -> {
135129 ctx .assertTrue (err .getClass () == UpgradeRejectedException .class );
136130 async .complete ();
137131 }));
0 commit comments