author | pconcannon |
Mon, 23 Sep 2019 16:53:16 +0100 | |
changeset 58289 | 3a79d4cccbcb |
parent 49765 | ee6f7a61f3a5 |
permissions | -rw-r--r-- |
49765 | 1 |
/* |
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
49765 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @build DummyWebSocketServer |
|
27 |
* @run testng/othervm |
|
28 |
* -Djdk.internal.httpclient.websocket.debug=true |
|
29 |
* AutomaticPong |
|
30 |
*/ |
|
31 |
import org.testng.annotations.DataProvider; |
|
32 |
import org.testng.annotations.Test; |
|
33 |
||
34 |
import java.io.IOException; |
|
35 |
import java.net.http.WebSocket; |
|
36 |
import java.nio.ByteBuffer; |
|
37 |
import java.nio.charset.StandardCharsets; |
|
38 |
import java.util.List; |
|
39 |
||
40 |
import static java.net.http.HttpClient.newHttpClient; |
|
41 |
import static org.testng.Assert.assertEquals; |
|
42 |
import static org.testng.Assert.assertFalse; |
|
43 |
import static org.testng.Assert.assertTrue; |
|
44 |
import static org.testng.Assert.fail; |
|
45 |
||
46 |
public class AutomaticPong { |
|
47 |
/* |
|
48 |
* The sendClose method has been invoked and a Ping comes from the server. |
|
49 |
* Naturally, the client cannot reply with a Pong (the output has been |
|
50 |
* closed). However, this MUST not be treated as an error. |
|
51 |
* At this stage the server either has received or pretty soon will receive |
|
52 |
* the Close message sent by the sendClose. Thus, the server will know the |
|
53 |
* client cannot send further messages and it's up to the server to decide |
|
54 |
* how to react on the corresponding Pong not being received. |
|
55 |
*/ |
|
56 |
@Test |
|
57 |
public void sendCloseThenAutomaticPong() throws IOException { |
|
58 |
int[] bytes = { |
|
59 |
0x89, 0x00, // ping |
|
60 |
0x89, 0x06, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x3f, // ping hello? |
|
61 |
0x88, 0x00, // close |
|
62 |
}; |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
63 |
try (var server = Support.serverWithCannedData(bytes)) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
64 |
server.open(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
65 |
MockListener listener = new MockListener() { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
66 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
67 |
protected void onOpen0(WebSocket webSocket) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
68 |
/* request nothing */ |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
69 |
} |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
70 |
}; |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
71 |
var webSocket = newHttpClient() |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
72 |
.newWebSocketBuilder() |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
73 |
.buildAsync(server.getURI(), listener) |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
74 |
.join(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
75 |
try { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
76 |
webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok").join(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
77 |
// now request all messages available |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
78 |
webSocket.request(Long.MAX_VALUE); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
79 |
List<MockListener.Invocation> actual = listener.invocations(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
80 |
ByteBuffer hello = ByteBuffer.wrap("hello?".getBytes(StandardCharsets.UTF_8)); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
81 |
ByteBuffer empty = ByteBuffer.allocate(0); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
82 |
List<MockListener.Invocation> expected = List.of( |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
83 |
MockListener.Invocation.onOpen(webSocket), |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
84 |
MockListener.Invocation.onPing(webSocket, empty), |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
85 |
MockListener.Invocation.onPing(webSocket, hello), |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
86 |
MockListener.Invocation.onClose(webSocket, 1005, "") |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
87 |
); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
88 |
assertEquals(actual, expected); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
89 |
} finally { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
90 |
webSocket.abort(); |
49765 | 91 |
} |
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
92 |
} |
49765 | 93 |
} |
94 |
||
95 |
/* |
|
96 |
* The server sends a number of contiguous Ping messages. The client replies |
|
97 |
* to these messages automatically. According to RFC 6455 a WebSocket client |
|
98 |
* is free to reply only to the most recent Pings. |
|
99 |
* |
|
100 |
* What is checked here is that: |
|
101 |
* |
|
102 |
* a) the order of Pong replies corresponds to the Pings received, |
|
103 |
* b) the last Pong corresponds to the last Ping |
|
104 |
* c) there are no unrelated Pongs |
|
105 |
*/ |
|
106 |
@Test(dataProvider = "nPings") |
|
107 |
public void automaticPongs(int nPings) throws Exception { |
|
108 |
// big enough to not bother with resize |
|
109 |
ByteBuffer buffer = ByteBuffer.allocate(65536); |
|
110 |
Frame.HeaderWriter w = new Frame.HeaderWriter(); |
|
111 |
for (int i = 0; i < nPings; i++) { |
|
112 |
w.fin(true) |
|
113 |
.opcode(Frame.Opcode.PING) |
|
114 |
.noMask() |
|
115 |
.payloadLen(4) // the length of the number of the Ping (int) |
|
116 |
.write(buffer); |
|
117 |
buffer.putInt(i); // the number of the Ping (int) |
|
118 |
} |
|
119 |
w.fin(true) |
|
120 |
.opcode(Frame.Opcode.CLOSE) |
|
121 |
.noMask() |
|
122 |
.payloadLen(2) |
|
123 |
.write(buffer); |
|
124 |
buffer.putChar((char) 1000); |
|
125 |
buffer.flip(); |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
126 |
try (var server = Support.serverWithCannedData(buffer.array())) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
127 |
server.open(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
128 |
MockListener listener = new MockListener(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
129 |
var webSocket = newHttpClient() |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
130 |
.newWebSocketBuilder() |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
131 |
.buildAsync(server.getURI(), listener) |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
132 |
.join(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
133 |
try { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
134 |
List<MockListener.Invocation> inv = listener.invocations(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
135 |
assertEquals(inv.size(), nPings + 2); // n * onPing + onOpen + onClose |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
136 |
|
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
137 |
ByteBuffer data = server.read(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
138 |
Frame.Reader reader = new Frame.Reader(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
139 |
|
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
140 |
Frame.Consumer consumer = new Frame.Consumer() { |
49765 | 141 |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
142 |
ByteBuffer number = ByteBuffer.allocate(4); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
143 |
Frame.Masker masker = new Frame.Masker(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
144 |
int i = -1; |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
145 |
boolean closed; |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
146 |
|
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
147 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
148 |
public void fin(boolean value) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
149 |
assertTrue(value); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
150 |
} |
49765 | 151 |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
152 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
153 |
public void rsv1(boolean value) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
154 |
assertFalse(value); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
155 |
} |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
156 |
|
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
157 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
158 |
public void rsv2(boolean value) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
159 |
assertFalse(value); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
160 |
} |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
161 |
|
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
162 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
163 |
public void rsv3(boolean value) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
164 |
assertFalse(value); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
165 |
} |
49765 | 166 |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
167 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
168 |
public void opcode(Frame.Opcode value) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
169 |
if (value == Frame.Opcode.CLOSE) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
170 |
closed = true; |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
171 |
return; |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
172 |
} |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
173 |
assertEquals(value, Frame.Opcode.PONG); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
174 |
} |
49765 | 175 |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
176 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
177 |
public void mask(boolean value) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
178 |
assertTrue(value); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
179 |
} |
49765 | 180 |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
181 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
182 |
public void payloadLen(long value) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
183 |
if (!closed) |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
184 |
assertEquals(value, 4); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
185 |
} |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
186 |
|
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
187 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
188 |
public void maskingKey(int value) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
189 |
masker.mask(value); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
190 |
} |
49765 | 191 |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
192 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
193 |
public void payloadData(ByteBuffer src) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
194 |
masker.transferMasking(src, number); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
195 |
if (closed) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
196 |
return; |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
197 |
} |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
198 |
number.flip(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
199 |
int n = number.getInt(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
200 |
System.out.printf("pong number=%s%n", n); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
201 |
number.clear(); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
202 |
// a Pong with the number less than the maximum of Pongs already |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
203 |
// received MUST never be received |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
204 |
if (i >= n) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
205 |
fail(String.format("i=%s, n=%s", i, n)); |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
206 |
} |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
207 |
i = n; |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
208 |
} |
49765 | 209 |
|
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
210 |
@Override |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
211 |
public void endFrame() { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
212 |
} |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
213 |
}; |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
214 |
while (data.hasRemaining()) { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
215 |
reader.readFrame(data, consumer); |
49765 | 216 |
} |
58289
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
217 |
} finally { |
3a79d4cccbcb
8217825: Verify @AfterTest is used correctly in WebSocket tests
pconcannon
parents:
49765
diff
changeset
|
218 |
webSocket.abort(); |
49765 | 219 |
} |
220 |
} |
|
221 |
} |
|
222 |
||
223 |
||
224 |
@DataProvider(name = "nPings") |
|
225 |
public Object[][] nPings() { |
|
226 |
return new Object[][]{{1}, {2}, {4}, {8}, {9}, {256}}; |
|
227 |
} |
|
228 |
} |