test: cleanup URISyntaxException exceptions

Note: we cannot update the `IO.socket(uri: string)` method without
doing a breaking change.
This commit is contained in:
Damien Arrachequesne
2021-04-26 10:48:41 +02:00
parent 67fd5f34a3
commit a4053e8645
5 changed files with 71 additions and 76 deletions

View File

@@ -29,7 +29,7 @@ public class ConnectionTest extends Connection {
private Socket socket;
@Test(timeout = TIMEOUT)
public void connectToLocalhost() throws URISyntaxException, InterruptedException {
public void connectToLocalhost() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@@ -50,7 +50,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void startTwoConnectionsWithSamePath() throws URISyntaxException, InterruptedException {
public void startTwoConnectionsWithSamePath() throws InterruptedException {
Socket s1 = client("/");
Socket s2 = client("/");
@@ -60,7 +60,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void startTwoConnectionsWithSamePathAndDifferentQuerystrings() throws URISyntaxException, InterruptedException {
public void startTwoConnectionsWithSamePathAndDifferentQuerystrings() throws InterruptedException {
Socket s1 = client("/?woot");
Socket s2 = client("/");
@@ -70,7 +70,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void workWithAcks() throws URISyntaxException, InterruptedException {
public void workWithAcks() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@@ -111,7 +111,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void receiveDateWithAck() throws URISyntaxException, InterruptedException {
public void receiveDateWithAck() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
@@ -136,7 +136,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void sendBinaryAck() throws URISyntaxException, InterruptedException {
public void sendBinaryAck() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final byte[] buf = "huehue".getBytes(Charset.forName("UTF-8"));
@@ -168,7 +168,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void receiveBinaryDataWithAck() throws URISyntaxException, InterruptedException {
public void receiveBinaryDataWithAck() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final byte[] buf = "huehue".getBytes(Charset.forName("UTF-8"));
@@ -191,7 +191,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void workWithFalse() throws URISyntaxException, InterruptedException {
public void workWithFalse() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@@ -212,7 +212,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void receiveUTF8MultibyteCharacters() throws URISyntaxException, InterruptedException {
public void receiveUTF8MultibyteCharacters() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final String[] correct = new String[] {
"てすと",
@@ -245,9 +245,9 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void connectToNamespaceAfterConnectionEstablished() throws URISyntaxException, InterruptedException {
public void connectToNamespaceAfterConnectionEstablished() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final Manager manager = new Manager(new URI(uri()));
final Manager manager = new Manager(uri());
socket = manager.socket("/");
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
@@ -270,9 +270,9 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void connectToNamespaceAfterConnectionGetsClosed() throws URISyntaxException, InterruptedException {
public void connectToNamespaceAfterConnectionGetsClosed() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final Manager manager = new Manager(new URI(uri()));
final Manager manager = new Manager(uri());
socket = manager.socket("/");
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
@@ -299,7 +299,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void reconnectByDefault() throws URISyntaxException, InterruptedException {
public void reconnectByDefault() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.io().on(Manager.EVENT_RECONNECT, new Emitter.Listener() {
@@ -320,7 +320,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void reconnectManually() throws URISyntaxException, InterruptedException {
public void reconnectManually() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() {
@@ -346,7 +346,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void reconnectAutomaticallyAfterReconnectingManually() throws URISyntaxException, InterruptedException {
public void reconnectAutomaticallyAfterReconnectingManually() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() {
@@ -378,14 +378,14 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = 14000)
public void attemptReconnectsAfterAFailedReconnect() throws URISyntaxException, InterruptedException {
public void attemptReconnectsAfterAFailedReconnect() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.Options opts = createOptions();
opts.reconnection = true;
opts.timeout = 0;
opts.reconnectionAttempts = 2;
opts.reconnectionDelay = 10;
final Manager manager = new Manager(new URI(uri()), opts);
final Manager manager = new Manager(uri(), opts);
socket = manager.socket("/timeout");
manager.once(Manager.EVENT_RECONNECT_FAILED, new Emitter.Listener() {
@Override
@@ -415,7 +415,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void reconnectDelayShouldIncreaseEveryTime() throws URISyntaxException, InterruptedException {
public void reconnectDelayShouldIncreaseEveryTime() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.Options opts = createOptions();
opts.reconnection = true;
@@ -423,7 +423,7 @@ public class ConnectionTest extends Connection {
opts.reconnectionAttempts = 3;
opts.reconnectionDelay = 100;
opts.randomizationFactor = 0.2;
final Manager manager = new Manager(new URI(uri()), opts);
final Manager manager = new Manager(uri(), opts);
socket = manager.socket("/timeout");
final int[] reconnects = new int[] {0};
@@ -524,7 +524,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void reconnectAfterStoppingReconnection() throws URISyntaxException, InterruptedException {
public void reconnectAfterStoppingReconnection() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.Options opts = createOptions();
opts.forceNew = true;
@@ -550,9 +550,9 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void stopReconnectingOnASocketAndKeepToReconnectOnAnother() throws URISyntaxException, InterruptedException {
public void stopReconnectingOnASocketAndKeepToReconnectOnAnother() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final Manager manager = new Manager(new URI(uri()));
final Manager manager = new Manager(uri());
final Socket socket1 = manager.socket("/");
final Socket socket2 = manager.socket("/asd");
@@ -596,10 +596,10 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void connectWhileDisconnectingAnotherSocket() throws URISyntaxException, InterruptedException {
public void connectWhileDisconnectingAnotherSocket() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final Manager manager = new Manager(new URI(uri()));
final Manager manager = new Manager(uri());
final Socket socket1 = manager.socket("/foo");
socket1.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
@@ -623,13 +623,13 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void tryToReconnectTwiceAndFailWithIncorrectAddress() throws URISyntaxException, InterruptedException {
public void tryToReconnectTwiceAndFailWithIncorrectAddress() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.Options opts = new IO.Options();
opts.reconnection = true;
opts.reconnectionAttempts = 2;
opts.reconnectionDelay = 10;
final Manager manager = new Manager(new URI("http://localhost:3940"), opts);
final Manager manager = new Manager(URI.create("http://localhost:3940"), opts);
socket = manager.socket("/asd");
final int[] reconnects = new int[] {0};
Emitter.Listener cb = new Emitter.Listener() {
@@ -655,14 +655,14 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void tryToReconnectTwiceAndFailWithImmediateTimeout() throws URISyntaxException, InterruptedException {
public void tryToReconnectTwiceAndFailWithImmediateTimeout() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.Options opts = new IO.Options();
opts.reconnection = true;
opts.timeout = 0;
opts.reconnectionAttempts = 2;
opts.reconnectionDelay = 10;
final Manager manager = new Manager(new URI(uri()), opts);
final Manager manager = new Manager(uri(), opts);
final int[] reconnects = new int[] {0};
Emitter.Listener reconnectCb = new Emitter.Listener() {
@@ -688,11 +688,11 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void notTryToReconnectWithIncorrectPortWhenReconnectionDisabled() throws URISyntaxException, InterruptedException {
public void notTryToReconnectWithIncorrectPortWhenReconnectionDisabled() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.Options opts = new IO.Options();
opts.reconnection = false;
final Manager manager = new Manager(new URI("http://localhost:9823"), opts);
final Manager manager = new Manager(URI.create("http://localhost:9823"), opts);
Emitter.Listener cb = new Emitter.Listener() {
@Override
public void call(Object... objects) {
@@ -722,7 +722,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void fireReconnectEventsOnSocket() throws URISyntaxException, InterruptedException {
public void fireReconnectEventsOnSocket() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
Manager.Options opts = new Manager.Options();
@@ -730,7 +730,7 @@ public class ConnectionTest extends Connection {
opts.timeout = 0;
opts.reconnectionAttempts = 2;
opts.reconnectionDelay = 10;
final Manager manager = new Manager(new URI(uri()), opts);
final Manager manager = new Manager(uri(), opts);
socket = manager.socket("/timeout_socket");
final int[] reconnects = new int[] {0};
@@ -757,7 +757,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void fireReconnectingWithAttemptsNumberWhenReconnectingTwice() throws URISyntaxException, InterruptedException {
public void fireReconnectingWithAttemptsNumberWhenReconnectingTwice() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
Manager.Options opts = new Manager.Options();
@@ -765,7 +765,7 @@ public class ConnectionTest extends Connection {
opts.timeout = 0;
opts.reconnectionAttempts = 2;
opts.reconnectionDelay = 10;
final Manager manager = new Manager(new URI(uri()), opts);
final Manager manager = new Manager(uri(), opts);
socket = manager.socket("/timeout_socket");
final int[] reconnects = new int[] {0};
@@ -792,7 +792,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void emitDateAsString() throws URISyntaxException, InterruptedException {
public void emitDateAsString() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@@ -813,7 +813,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void emitDateInObject() throws URISyntaxException, InterruptedException, JSONException {
public void emitDateInObject() throws InterruptedException, JSONException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@@ -843,7 +843,7 @@ public class ConnectionTest extends Connection {
@Test(timeout = TIMEOUT)
public void sendAndGetBinaryData() throws URISyntaxException, InterruptedException {
public void sendAndGetBinaryData() throws InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final byte[] buf = "asdfasdf".getBytes(Charset.forName("UTF-8"));
socket = client();
@@ -865,7 +865,7 @@ public class ConnectionTest extends Connection {
}
@Test(timeout = TIMEOUT)
public void sendBinaryDataMixedWithJson() throws URISyntaxException, InterruptedException, JSONException {
public void sendBinaryDataMixedWithJson() throws InterruptedException, JSONException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final byte[] buf = "howdy".getBytes(Charset.forName("UTF-8"));
socket = client();