|
34 | 34 | import org.java_websocket.util.SocketUtil;
|
35 | 35 | import org.java_websocket.util.ThreadCheck;
|
36 | 36 | import org.junit.*;
|
| 37 | +import org.junit.runner.RunWith; |
| 38 | +import org.junit.runners.Parameterized; |
37 | 39 |
|
38 | 40 | import java.io.IOException;
|
39 | 41 | import java.net.InetSocketAddress;
|
40 | 42 | import java.net.URI;
|
| 43 | +import java.util.ArrayList; |
| 44 | +import java.util.Collection; |
| 45 | +import java.util.List; |
41 | 46 | import java.util.concurrent.CountDownLatch;
|
42 | 47 |
|
43 | 48 | import static org.hamcrest.core.Is.is;
|
44 | 49 | import static org.junit.Assume.assumeThat;
|
45 | 50 |
|
| 51 | +@RunWith(Parameterized.class) |
46 | 52 | public class Issue256Test {
|
47 | 53 |
|
| 54 | + private static final int NUMBER_OF_TESTS = 10; |
48 | 55 | private static WebSocketServer ws;
|
49 | 56 |
|
50 | 57 | private static int port;
|
51 | 58 | static CountDownLatch countServerDownLatch = new CountDownLatch( 1 );
|
52 | 59 | @Rule
|
53 | 60 | public ThreadCheck zombies = new ThreadCheck();
|
54 | 61 |
|
| 62 | + @Parameterized.Parameter |
| 63 | + public int count; |
| 64 | + |
55 | 65 | @BeforeClass
|
56 | 66 | public static void startServer() throws Exception {
|
57 | 67 | port = SocketUtil.getAvailablePort();
|
@@ -130,104 +140,21 @@ public static void successTests() throws InterruptedException, IOException {
|
130 | 140 | ws.stop();
|
131 | 141 | }
|
132 | 142 |
|
133 |
| - @Test(timeout = 5000) |
134 |
| - public void runReconnectBlockingScenario0() throws Exception { |
135 |
| - runTestScenarioReconnect( true ); |
136 |
| - } |
137 |
| - |
138 |
| - @Test(timeout = 5000) |
139 |
| - public void runReconnectBlockingScenario1() throws Exception { |
140 |
| - runTestScenarioReconnect( true ); |
141 |
| - } |
142 |
| - |
143 |
| - @Test(timeout = 5000) |
144 |
| - public void runReconnectBlockingScenario2() throws Exception { |
145 |
| - runTestScenarioReconnect( true ); |
146 |
| - } |
147 |
| - |
148 |
| - @Test(timeout = 5000) |
149 |
| - public void runReconnectBlockingScenario3() throws Exception { |
150 |
| - runTestScenarioReconnect( true ); |
151 |
| - } |
152 |
| - |
153 |
| - @Test(timeout = 5000) |
154 |
| - public void runReconnectBlockingScenario4() throws Exception { |
155 |
| - runTestScenarioReconnect( true ); |
| 143 | + @Parameterized.Parameters |
| 144 | + public static Collection<Integer[]> data() { |
| 145 | + List<Integer[]> ret = new ArrayList<Integer[]>(NUMBER_OF_TESTS); |
| 146 | + for (int i = 0; i < NUMBER_OF_TESTS; i++) ret.add(new Integer[]{i}); |
| 147 | + return ret; |
156 | 148 | }
|
157 | 149 |
|
158 | 150 | @Test(timeout = 5000)
|
159 |
| - public void runReconnectBlockingScenario5() throws Exception { |
160 |
| - runTestScenarioReconnect( true ); |
161 |
| - } |
162 |
| - |
163 |
| - @Test(timeout = 5000) |
164 |
| - public void runReconnectBlockingScenario6() throws Exception { |
165 |
| - runTestScenarioReconnect( true ); |
166 |
| - } |
167 |
| - |
168 |
| - @Test(timeout = 5000) |
169 |
| - public void runReconnectBlockingScenario7() throws Exception { |
170 |
| - runTestScenarioReconnect( true ); |
171 |
| - } |
172 |
| - |
173 |
| - @Test(timeout = 5000) |
174 |
| - public void runReconnectBlockingScenario8() throws Exception { |
175 |
| - runTestScenarioReconnect( true ); |
176 |
| - } |
177 |
| - |
178 |
| - @Test(timeout = 5000) |
179 |
| - public void runReconnectBlockingScenario9() throws Exception { |
180 |
| - runTestScenarioReconnect( true ); |
181 |
| - } |
182 |
| - |
183 |
| - @Test(timeout = 5000) |
184 |
| - public void runReconnectScenario0() throws Exception { |
185 |
| - runTestScenarioReconnect( false ); |
186 |
| - } |
187 |
| - |
188 |
| - @Test(timeout = 5000) |
189 |
| - public void runReconnectScenario1() throws Exception { |
190 |
| - runTestScenarioReconnect( false ); |
191 |
| - } |
192 |
| - |
193 |
| - @Test(timeout = 5000) |
194 |
| - public void runReconnectScenario2() throws Exception { |
195 |
| - runTestScenarioReconnect( false ); |
196 |
| - } |
197 |
| - |
198 |
| - @Test(timeout = 5000) |
199 |
| - public void runReconnectScenario3() throws Exception { |
200 |
| - runTestScenarioReconnect( false ); |
201 |
| - } |
202 |
| - |
203 |
| - @Test(timeout = 5000) |
204 |
| - public void runReconnectScenario4() throws Exception { |
| 151 | + public void runReconnectSocketClose() throws Exception { |
205 | 152 | runTestScenarioReconnect( false );
|
206 | 153 | }
|
207 | 154 |
|
208 | 155 | @Test(timeout = 5000)
|
209 |
| - public void runReconnectScenario5() throws Exception { |
210 |
| - runTestScenarioReconnect( false ); |
211 |
| - } |
212 |
| - |
213 |
| - @Test(timeout = 5000) |
214 |
| - public void runReconnectScenario6() throws Exception { |
215 |
| - runTestScenarioReconnect( false ); |
216 |
| - } |
217 |
| - |
218 |
| - @Test(timeout = 5000) |
219 |
| - public void runReconnectScenario7() throws Exception { |
220 |
| - runTestScenarioReconnect( false ); |
221 |
| - } |
222 |
| - |
223 |
| - @Test(timeout = 5000) |
224 |
| - public void runReconnectScenario8() throws Exception { |
225 |
| - runTestScenarioReconnect( false ); |
226 |
| - } |
227 |
| - |
228 |
| - @Test(timeout = 5000) |
229 |
| - public void runReconnectScenario9() throws Exception { |
230 |
| - runTestScenarioReconnect( false ); |
| 156 | + public void runReconnectCloseBlocking() throws Exception { |
| 157 | + runTestScenarioReconnect( true ); |
231 | 158 | }
|
232 | 159 |
|
233 | 160 | }
|
|
0 commit comments