Skip to content

Commit b5fae19

Browse files
committed
fix batch 1
1 parent e5e8813 commit b5fae19

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

src/main/java/io/vertx/httpproxy/interceptors/impl/WebSocketInterceptorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import io.vertx.httpproxy.ProxyResponse;
77

88
public class WebSocketInterceptorImpl implements ProxyInterceptor {
9-
ProxyInterceptor interceptor;
9+
private final ProxyInterceptor interceptor;
1010

1111
public WebSocketInterceptorImpl(ProxyInterceptor interceptor) {
1212
this.interceptor = interceptor;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package io.vertx.tests;
2+
3+
import io.vertx.core.buffer.Buffer;
4+
import io.vertx.core.net.SocketAddress;
5+
import io.vertx.ext.unit.Async;
6+
import io.vertx.ext.unit.TestContext;
7+
import io.vertx.ext.unit.junit.VertxUnitRunner;
8+
import io.vertx.httpproxy.ProxyOptions;
9+
import io.vertx.httpproxy.cache.CacheOptions;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
13+
@RunWith(VertxUnitRunner.class)
14+
public class WebSocketCacheTest extends ProxyTestBase {
15+
16+
public WebSocketCacheTest() {
17+
super(new ProxyOptions().setCacheOptions(new CacheOptions()));
18+
}
19+
20+
@Test
21+
public void testWsWithCache(TestContext ctx) {
22+
Async latch = ctx.async();
23+
SocketAddress backend = startHttpBackend(ctx, 8081, req -> {
24+
req.toWebSocket().onSuccess(ws -> {
25+
ws.handler(ws::write);
26+
});
27+
});
28+
startProxy(backend);
29+
vertx.createWebSocketClient().connect(8080, "localhost", "/").onComplete(ctx.asyncAssertSuccess(ws1 -> {
30+
ws1.handler(buffer -> {
31+
ctx.assertEquals(buffer.toString(), "v1");
32+
ws1.close().onComplete(ctx.asyncAssertSuccess(v -> {
33+
vertx.createWebSocketClient().connect(8080, "localhost", "/").onComplete(ctx.asyncAssertSuccess(ws2 -> {
34+
ws2.handler(buffer2 -> {
35+
ctx.assertEquals(buffer2.toString(), "v2");
36+
ws2.close().onComplete(ctx.asyncAssertSuccess(v2 -> {
37+
latch.complete();
38+
}));
39+
});
40+
ws2.write(Buffer.buffer("v2"));
41+
}));
42+
}));
43+
});
44+
ws1.write(Buffer.buffer("v1"));
45+
}));
46+
}
47+
}

0 commit comments

Comments
 (0)