refactor: minor cleanup
- replace explicit types by <> - remove unnecessary interface modifiers
This commit is contained in:
@@ -5,7 +5,7 @@ package io.socket.client;
|
|||||||
*/
|
*/
|
||||||
public interface Ack {
|
public interface Ack {
|
||||||
|
|
||||||
public void call(Object... args);
|
void call(Object... args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class IO {
|
|||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(IO.class.getName());
|
private static final Logger logger = Logger.getLogger(IO.class.getName());
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String, Manager> managers = new ConcurrentHashMap<String, Manager>();
|
private static final ConcurrentHashMap<String, Manager> managers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protocol version.
|
* Protocol version.
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ public class Manager extends Emitter {
|
|||||||
opts.callFactory = defaultCallFactory;
|
opts.callFactory = defaultCallFactory;
|
||||||
}
|
}
|
||||||
this.opts = opts;
|
this.opts = opts;
|
||||||
this.nsps = new ConcurrentHashMap<String, Socket>();
|
this.nsps = new ConcurrentHashMap<>();
|
||||||
this.subs = new LinkedList<On.Handle>();
|
this.subs = new LinkedList<>();
|
||||||
this.reconnection(opts.reconnection);
|
this.reconnection(opts.reconnection);
|
||||||
this.reconnectionAttempts(opts.reconnectionAttempts != 0 ? opts.reconnectionAttempts : Integer.MAX_VALUE);
|
this.reconnectionAttempts(opts.reconnectionAttempts != 0 ? opts.reconnectionAttempts : Integer.MAX_VALUE);
|
||||||
this.reconnectionDelay(opts.reconnectionDelay != 0 ? opts.reconnectionDelay : 1000);
|
this.reconnectionDelay(opts.reconnectionDelay != 0 ? opts.reconnectionDelay : 1000);
|
||||||
@@ -129,7 +129,7 @@ public class Manager extends Emitter {
|
|||||||
this.readyState = ReadyState.CLOSED;
|
this.readyState = ReadyState.CLOSED;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.encoding = false;
|
this.encoding = false;
|
||||||
this.packetBuffer = new ArrayList<Packet>();
|
this.packetBuffer = new ArrayList<>();
|
||||||
this.encoder = opts.encoder != null ? opts.encoder : new IOParser.Encoder();
|
this.encoder = opts.encoder != null ? opts.encoder : new IOParser.Encoder();
|
||||||
this.decoder = opts.decoder != null ? opts.decoder : new IOParser.Decoder();
|
this.decoder = opts.decoder != null ? opts.decoder : new IOParser.Decoder();
|
||||||
}
|
}
|
||||||
@@ -555,9 +555,9 @@ public class Manager extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static interface OpenCallback {
|
public interface OpenCallback {
|
||||||
|
|
||||||
public void call(Exception err);
|
void call(Exception err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ public class On {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface Handle {
|
public interface Handle {
|
||||||
|
|
||||||
public void destroy();
|
void destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ public class Socket extends Emitter {
|
|||||||
private String nsp;
|
private String nsp;
|
||||||
private Manager io;
|
private Manager io;
|
||||||
private Map<String, String> auth;
|
private Map<String, String> auth;
|
||||||
private Map<Integer, Ack> acks = new HashMap<Integer, Ack>();
|
private Map<Integer, Ack> acks = new HashMap<>();
|
||||||
private Queue<On.Handle> subs;
|
private Queue<On.Handle> subs;
|
||||||
private final Queue<List<Object>> receiveBuffer = new LinkedList<List<Object>>();
|
private final Queue<List<Object>> receiveBuffer = new LinkedList<>();
|
||||||
private final Queue<Packet<JSONArray>> sendBuffer = new LinkedList<Packet<JSONArray>>();
|
private final Queue<Packet<JSONArray>> sendBuffer = new LinkedList<>();
|
||||||
|
|
||||||
public Socket(Manager io, String nsp, Manager.Options opts) {
|
public Socket(Manager io, String nsp, Manager.Options opts) {
|
||||||
this.io = io;
|
this.io = io;
|
||||||
@@ -205,7 +205,7 @@ public class Socket extends Emitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet<JSONArray> packet = new Packet<JSONArray>(Parser.EVENT, jsonArgs);
|
Packet<JSONArray> packet = new Packet<>(Parser.EVENT, jsonArgs);
|
||||||
|
|
||||||
if (ack != null) {
|
if (ack != null) {
|
||||||
logger.fine(String.format("emitting packet with ack id %d", ids));
|
logger.fine(String.format("emitting packet with ack id %d", ids));
|
||||||
@@ -302,7 +302,7 @@ public class Socket extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onevent(Packet<JSONArray> packet) {
|
private void onevent(Packet<JSONArray> packet) {
|
||||||
List<Object> args = new ArrayList<Object>(Arrays.asList(toArray(packet.data)));
|
List<Object> args = new ArrayList<>(Arrays.asList(toArray(packet.data)));
|
||||||
if (logger.isLoggable(Level.FINE)) {
|
if (logger.isLoggable(Level.FINE)) {
|
||||||
logger.fine(String.format("emitting event %s", args));
|
logger.fine(String.format("emitting event %s", args));
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,7 @@ public class Socket extends Emitter {
|
|||||||
jsonArgs.put(arg);
|
jsonArgs.put(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet<JSONArray> packet = new Packet<JSONArray>(Parser.ACK, jsonArgs);
|
Packet<JSONArray> packet = new Packet<>(Parser.ACK, jsonArgs);
|
||||||
packet.id = id;
|
packet.id = id;
|
||||||
self.packet(packet);
|
self.packet(packet);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Binary {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static DeconstructedPacket deconstructPacket(Packet packet) {
|
public static DeconstructedPacket deconstructPacket(Packet packet) {
|
||||||
List<byte[]> buffers = new ArrayList<byte[]>();
|
List<byte[]> buffers = new ArrayList<>();
|
||||||
|
|
||||||
packet.data = _deconstructPacket(packet.data, buffers);
|
packet.data = _deconstructPacket(packet.data, buffers);
|
||||||
packet.attachments = buffers.size();
|
packet.attachments = buffers.size();
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ final public class IOParser implements Parser {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int length = str.length();
|
int length = str.length();
|
||||||
|
|
||||||
Packet<Object> p = new Packet<Object>(Character.getNumericValue(str.charAt(0)));
|
Packet<Object> p = new Packet<>(Character.getNumericValue(str.charAt(0)));
|
||||||
|
|
||||||
if (p.type < 0 || p.type > types.length - 1) {
|
if (p.type < 0 || p.type > types.length - 1) {
|
||||||
throw new DecodingException("unknown packet type " + p.type);
|
throw new DecodingException("unknown packet type " + p.type);
|
||||||
@@ -214,7 +214,7 @@ final public class IOParser implements Parser {
|
|||||||
|
|
||||||
BinaryReconstructor(Packet packet) {
|
BinaryReconstructor(Packet packet) {
|
||||||
this.reconPack = packet;
|
this.reconPack = packet;
|
||||||
this.buffers = new ArrayList<byte[]>();
|
this.buffers = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Packet takeBinaryData(byte[] binData) {
|
public Packet takeBinaryData(byte[] binData) {
|
||||||
@@ -230,7 +230,7 @@ final public class IOParser implements Parser {
|
|||||||
|
|
||||||
public void finishReconstruction () {
|
public void finishReconstruction () {
|
||||||
this.reconPack = null;
|
this.reconPack = null;
|
||||||
this.buffers = new ArrayList<byte[]>();
|
this.buffers = new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,44 +5,44 @@ public interface Parser {
|
|||||||
/**
|
/**
|
||||||
* Packet type `connect`.
|
* Packet type `connect`.
|
||||||
*/
|
*/
|
||||||
public static final int CONNECT = 0;
|
int CONNECT = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packet type `disconnect`.
|
* Packet type `disconnect`.
|
||||||
*/
|
*/
|
||||||
public static final int DISCONNECT = 1;
|
int DISCONNECT = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packet type `event`.
|
* Packet type `event`.
|
||||||
*/
|
*/
|
||||||
public static final int EVENT = 2;
|
int EVENT = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packet type `ack`.
|
* Packet type `ack`.
|
||||||
*/
|
*/
|
||||||
public static final int ACK = 3;
|
int ACK = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packet type `error`.
|
* Packet type `error`.
|
||||||
*/
|
*/
|
||||||
public static final int CONNECT_ERROR = 4;
|
int CONNECT_ERROR = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packet type `binary event`.
|
* Packet type `binary event`.
|
||||||
*/
|
*/
|
||||||
public static final int BINARY_EVENT = 5;
|
int BINARY_EVENT = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packet type `binary ack`.
|
* Packet type `binary ack`.
|
||||||
*/
|
*/
|
||||||
public static final int BINARY_ACK = 6;
|
int BINARY_ACK = 6;
|
||||||
|
|
||||||
public static int protocol = 5;
|
int protocol = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packet types.
|
* Packet types.
|
||||||
*/
|
*/
|
||||||
public static String[] types = new String[] {
|
String[] types = new String[] {
|
||||||
"CONNECT",
|
"CONNECT",
|
||||||
"DISCONNECT",
|
"DISCONNECT",
|
||||||
"EVENT",
|
"EVENT",
|
||||||
@@ -52,29 +52,29 @@ public interface Parser {
|
|||||||
"BINARY_ACK"
|
"BINARY_ACK"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static interface Encoder {
|
interface Encoder {
|
||||||
|
|
||||||
public void encode(Packet obj, Callback callback);
|
void encode(Packet obj, Callback callback);
|
||||||
|
|
||||||
public interface Callback {
|
interface Callback {
|
||||||
|
|
||||||
public void call(Object[] data);
|
void call(Object[] data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface Decoder {
|
interface Decoder {
|
||||||
|
|
||||||
public void add(String obj);
|
void add(String obj);
|
||||||
|
|
||||||
public void add(byte[] obj);
|
void add(byte[] obj);
|
||||||
|
|
||||||
public void destroy();
|
void destroy();
|
||||||
|
|
||||||
public void onDecoded(Callback callback);
|
void onDecoded(Callback callback);
|
||||||
|
|
||||||
public interface Callback {
|
interface Callback {
|
||||||
|
|
||||||
public void call(Packet packet);
|
void call(Packet packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public abstract class Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String[] createEnv() {
|
String[] createEnv() {
|
||||||
Map<String, String> env = new HashMap<String, String>(System.getenv());
|
Map<String, String> env = new HashMap<>(System.getenv());
|
||||||
env.put("DEBUG", "socket.io:*");
|
env.put("DEBUG", "socket.io:*");
|
||||||
env.put("PORT", String.valueOf(PORT));
|
env.put("PORT", String.valueOf(PORT));
|
||||||
String[] _env = new String[env.size()];
|
String[] _env = new String[env.size()];
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void connectToLocalhost() throws InterruptedException {
|
public void connectToLocalhost() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -71,7 +71,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void workWithAcks() throws InterruptedException {
|
public void workWithAcks() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -112,7 +112,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void receiveDateWithAck() throws InterruptedException {
|
public void receiveDateWithAck() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -137,7 +137,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void sendBinaryAck() throws InterruptedException {
|
public void sendBinaryAck() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final byte[] buf = "huehue".getBytes(Charset.forName("UTF-8"));
|
final byte[] buf = "huehue".getBytes(Charset.forName("UTF-8"));
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
@@ -169,7 +169,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void receiveBinaryDataWithAck() throws InterruptedException {
|
public void receiveBinaryDataWithAck() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final byte[] buf = "huehue".getBytes(Charset.forName("UTF-8"));
|
final byte[] buf = "huehue".getBytes(Charset.forName("UTF-8"));
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
@@ -192,7 +192,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void workWithFalse() throws InterruptedException {
|
public void workWithFalse() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -213,7 +213,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void receiveUTF8MultibyteCharacters() throws InterruptedException {
|
public void receiveUTF8MultibyteCharacters() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final String[] correct = new String[] {
|
final String[] correct = new String[] {
|
||||||
"てすと",
|
"てすと",
|
||||||
"Я Б Г Д Ж Й",
|
"Я Б Г Д Ж Й",
|
||||||
@@ -246,7 +246,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void connectToNamespaceAfterConnectionEstablished() throws InterruptedException {
|
public void connectToNamespaceAfterConnectionEstablished() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final Manager manager = new Manager(uri());
|
final Manager manager = new Manager(uri());
|
||||||
socket = manager.socket("/");
|
socket = manager.socket("/");
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -271,7 +271,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void connectToNamespaceAfterConnectionGetsClosed() throws InterruptedException {
|
public void connectToNamespaceAfterConnectionGetsClosed() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final Manager manager = new Manager(uri());
|
final Manager manager = new Manager(uri());
|
||||||
socket = manager.socket("/");
|
socket = manager.socket("/");
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -300,7 +300,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void reconnectByDefault() throws InterruptedException {
|
public void reconnectByDefault() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.io().on(Manager.EVENT_RECONNECT, new Emitter.Listener() {
|
socket.io().on(Manager.EVENT_RECONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -321,7 +321,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void reconnectManually() throws InterruptedException {
|
public void reconnectManually() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -347,7 +347,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void reconnectAutomaticallyAfterReconnectingManually() throws InterruptedException {
|
public void reconnectAutomaticallyAfterReconnectingManually() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -379,7 +379,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = 14000)
|
@Test(timeout = 14000)
|
||||||
public void attemptReconnectsAfterAFailedReconnect() throws InterruptedException {
|
public void attemptReconnectsAfterAFailedReconnect() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = createOptions();
|
IO.Options opts = createOptions();
|
||||||
opts.reconnection = true;
|
opts.reconnection = true;
|
||||||
opts.timeout = 0;
|
opts.timeout = 0;
|
||||||
@@ -416,7 +416,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void reconnectDelayShouldIncreaseEveryTime() throws InterruptedException {
|
public void reconnectDelayShouldIncreaseEveryTime() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = createOptions();
|
IO.Options opts = createOptions();
|
||||||
opts.reconnection = true;
|
opts.reconnection = true;
|
||||||
opts.timeout = 0;
|
opts.timeout = 0;
|
||||||
@@ -466,7 +466,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void notReconnectWhenForceClosed() throws URISyntaxException, InterruptedException {
|
public void notReconnectWhenForceClosed() throws URISyntaxException, InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = createOptions();
|
IO.Options opts = createOptions();
|
||||||
opts.timeout = 0;
|
opts.timeout = 0;
|
||||||
opts.reconnectionDelay = 10;
|
opts.reconnectionDelay = 10;
|
||||||
@@ -495,7 +495,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void stopReconnectingWhenForceClosed() throws URISyntaxException, InterruptedException {
|
public void stopReconnectingWhenForceClosed() throws URISyntaxException, InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = createOptions();
|
IO.Options opts = createOptions();
|
||||||
opts.timeout = 0;
|
opts.timeout = 0;
|
||||||
opts.reconnectionDelay = 10;
|
opts.reconnectionDelay = 10;
|
||||||
@@ -525,7 +525,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void reconnectAfterStoppingReconnection() throws InterruptedException {
|
public void reconnectAfterStoppingReconnection() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = createOptions();
|
IO.Options opts = createOptions();
|
||||||
opts.forceNew = true;
|
opts.forceNew = true;
|
||||||
opts.timeout = 0;
|
opts.timeout = 0;
|
||||||
@@ -551,7 +551,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void stopReconnectingOnASocketAndKeepToReconnectOnAnother() throws InterruptedException {
|
public void stopReconnectingOnASocketAndKeepToReconnectOnAnother() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final Manager manager = new Manager(uri());
|
final Manager manager = new Manager(uri());
|
||||||
final Socket socket1 = manager.socket("/");
|
final Socket socket1 = manager.socket("/");
|
||||||
final Socket socket2 = manager.socket("/asd");
|
final Socket socket2 = manager.socket("/asd");
|
||||||
@@ -597,7 +597,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void connectWhileDisconnectingAnotherSocket() throws InterruptedException {
|
public void connectWhileDisconnectingAnotherSocket() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
final Manager manager = new Manager(uri());
|
final Manager manager = new Manager(uri());
|
||||||
final Socket socket1 = manager.socket("/foo");
|
final Socket socket1 = manager.socket("/foo");
|
||||||
@@ -624,7 +624,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void tryToReconnectTwiceAndFailWithIncorrectAddress() throws InterruptedException {
|
public void tryToReconnectTwiceAndFailWithIncorrectAddress() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = new IO.Options();
|
IO.Options opts = new IO.Options();
|
||||||
opts.reconnection = true;
|
opts.reconnection = true;
|
||||||
opts.reconnectionAttempts = 2;
|
opts.reconnectionAttempts = 2;
|
||||||
@@ -656,7 +656,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void tryToReconnectTwiceAndFailWithImmediateTimeout() throws InterruptedException {
|
public void tryToReconnectTwiceAndFailWithImmediateTimeout() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = new IO.Options();
|
IO.Options opts = new IO.Options();
|
||||||
opts.reconnection = true;
|
opts.reconnection = true;
|
||||||
opts.timeout = 0;
|
opts.timeout = 0;
|
||||||
@@ -689,7 +689,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void notTryToReconnectWithIncorrectPortWhenReconnectionDisabled() throws InterruptedException {
|
public void notTryToReconnectWithIncorrectPortWhenReconnectionDisabled() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = new IO.Options();
|
IO.Options opts = new IO.Options();
|
||||||
opts.reconnection = false;
|
opts.reconnection = false;
|
||||||
final Manager manager = new Manager(URI.create("http://localhost:9823"), opts);
|
final Manager manager = new Manager(URI.create("http://localhost:9823"), opts);
|
||||||
@@ -723,7 +723,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void fireReconnectEventsOnSocket() throws InterruptedException {
|
public void fireReconnectEventsOnSocket() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
Manager.Options opts = new Manager.Options();
|
Manager.Options opts = new Manager.Options();
|
||||||
opts.reconnection = true;
|
opts.reconnection = true;
|
||||||
@@ -758,7 +758,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void fireReconnectingWithAttemptsNumberWhenReconnectingTwice() throws InterruptedException {
|
public void fireReconnectingWithAttemptsNumberWhenReconnectingTwice() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
Manager.Options opts = new Manager.Options();
|
Manager.Options opts = new Manager.Options();
|
||||||
opts.reconnection = true;
|
opts.reconnection = true;
|
||||||
@@ -793,7 +793,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void emitDateAsString() throws InterruptedException {
|
public void emitDateAsString() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -814,7 +814,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void emitDateInObject() throws InterruptedException, JSONException {
|
public void emitDateInObject() throws InterruptedException, JSONException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -844,7 +844,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void sendAndGetBinaryData() throws InterruptedException {
|
public void sendAndGetBinaryData() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final byte[] buf = "asdfasdf".getBytes(Charset.forName("UTF-8"));
|
final byte[] buf = "asdfasdf".getBytes(Charset.forName("UTF-8"));
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -866,7 +866,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void sendBinaryDataMixedWithJson() throws InterruptedException, JSONException {
|
public void sendBinaryDataMixedWithJson() throws InterruptedException, JSONException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final byte[] buf = "howdy".getBytes(Charset.forName("UTF-8"));
|
final byte[] buf = "howdy".getBytes(Charset.forName("UTF-8"));
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -899,7 +899,7 @@ public class ConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void sendEventsWithByteArraysInTheCorrectOrder() throws Exception {
|
public void sendEventsWithByteArraysInTheCorrectOrder() throws Exception {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
final byte[] buf = "abuff1".getBytes(Charset.forName("UTF-8"));
|
final byte[] buf = "abuff1".getBytes(Charset.forName("UTF-8"));
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class SSLConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void connect() throws Exception {
|
public void connect() throws Exception {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = createOptions();
|
IO.Options opts = createOptions();
|
||||||
opts.callFactory = sOkHttpClient;
|
opts.callFactory = sOkHttpClient;
|
||||||
opts.webSocketFactory = sOkHttpClient;
|
opts.webSocketFactory = sOkHttpClient;
|
||||||
@@ -113,7 +113,7 @@ public class SSLConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void defaultSSLContext() throws Exception {
|
public void defaultSSLContext() throws Exception {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
IO.setDefaultOkHttpWebSocketFactory(sOkHttpClient);
|
IO.setDefaultOkHttpWebSocketFactory(sOkHttpClient);
|
||||||
IO.setDefaultOkHttpCallFactory(sOkHttpClient);
|
IO.setDefaultOkHttpCallFactory(sOkHttpClient);
|
||||||
socket = client();
|
socket = client();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void openAndClose() throws InterruptedException {
|
public void openAndClose() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -51,7 +51,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void message() throws InterruptedException {
|
public void message() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -74,7 +74,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void event() throws Exception {
|
public void event() throws Exception {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
final JSONObject obj = new JSONObject();
|
final JSONObject obj = new JSONObject();
|
||||||
obj.put("foo", 1);
|
obj.put("foo", 1);
|
||||||
@@ -103,7 +103,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void ack() throws Exception {
|
public void ack() throws Exception {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
final JSONObject obj = new JSONObject();
|
final JSONObject obj = new JSONObject();
|
||||||
obj.put("foo", 1);
|
obj.put("foo", 1);
|
||||||
@@ -131,7 +131,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void ackWithoutArgs() throws InterruptedException {
|
public void ackWithoutArgs() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -153,7 +153,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void ackWithoutArgsFromClient() throws InterruptedException {
|
public void ackWithoutArgsFromClient() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -188,7 +188,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void closeEngineConnection() throws InterruptedException {
|
public void closeEngineConnection() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -209,7 +209,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void broadcast() throws InterruptedException {
|
public void broadcast() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -242,7 +242,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void room() throws InterruptedException {
|
public void room() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@@ -266,7 +266,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void pollingHeaders() throws InterruptedException {
|
public void pollingHeaders() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
IO.Options opts = createOptions();
|
IO.Options opts = createOptions();
|
||||||
opts.transports = new String[] {Polling.NAME};
|
opts.transports = new String[] {Polling.NAME};
|
||||||
@@ -301,7 +301,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void websocketHandshakeHeaders() throws InterruptedException {
|
public void websocketHandshakeHeaders() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
IO.Options opts = createOptions();
|
IO.Options opts = createOptions();
|
||||||
opts.transports = new String[] {WebSocket.NAME};
|
opts.transports = new String[] {WebSocket.NAME};
|
||||||
@@ -336,7 +336,7 @@ public class ServerConnectionTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void disconnectFromServer() throws InterruptedException {
|
public void disconnectFromServer() throws InterruptedException {
|
||||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
final BlockingQueue<Object> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void shouldHaveAnAccessibleSocketIdEqualToServerSideSocketId() throws InterruptedException {
|
public void shouldHaveAnAccessibleSocketIdEqualToServerSideSocketId() throws InterruptedException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -45,7 +45,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void shouldHaveAnAccessibleSocketIdEqualToServerSideSocketIdOnCustomNamespace() throws InterruptedException {
|
public void shouldHaveAnAccessibleSocketIdEqualToServerSideSocketIdOnCustomNamespace() throws InterruptedException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
socket = client("/foo");
|
socket = client("/foo");
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -64,7 +64,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void clearsSocketIdUponDisconnection() throws InterruptedException {
|
public void clearsSocketIdUponDisconnection() throws InterruptedException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -87,7 +87,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void doesNotFireConnectErrorIfWeForceDisconnectInOpeningState() throws InterruptedException {
|
public void doesNotFireConnectErrorIfWeForceDisconnectInOpeningState() throws InterruptedException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
IO.Options opts = new IO.Options();
|
IO.Options opts = new IO.Options();
|
||||||
opts.timeout = 100;
|
opts.timeout = 100;
|
||||||
socket = client(opts);
|
socket = client(opts);
|
||||||
@@ -114,7 +114,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void shouldChangeSocketIdUponReconnection() throws InterruptedException {
|
public void shouldChangeSocketIdUponReconnection() throws InterruptedException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
socket = client();
|
socket = client();
|
||||||
socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -155,7 +155,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void shouldAcceptAQueryStringOnDefaultNamespace() throws InterruptedException, JSONException {
|
public void shouldAcceptAQueryStringOnDefaultNamespace() throws InterruptedException, JSONException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client("/?c=d");
|
socket = client("/?c=d");
|
||||||
socket.emit("getHandshake", new Ack() {
|
socket.emit("getHandshake", new Ack() {
|
||||||
@@ -176,7 +176,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void shouldAcceptAQueryString() throws InterruptedException, JSONException {
|
public void shouldAcceptAQueryString() throws InterruptedException, JSONException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client("/abc?b=c&d=e");
|
socket = client("/abc?b=c&d=e");
|
||||||
socket.on("handshake", new Emitter.Listener() {
|
socket.on("handshake", new Emitter.Listener() {
|
||||||
@@ -199,7 +199,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void shouldAcceptAnAuthOption() throws InterruptedException, JSONException {
|
public void shouldAcceptAnAuthOption() throws InterruptedException, JSONException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
IO.Options opts = new IO.Options();
|
IO.Options opts = new IO.Options();
|
||||||
opts.auth = singletonMap("token", "abcd");
|
opts.auth = singletonMap("token", "abcd");
|
||||||
@@ -223,7 +223,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void shouldFireAnErrorEventOnMiddlewareFailure() throws InterruptedException, JSONException {
|
public void shouldFireAnErrorEventOnMiddlewareFailure() throws InterruptedException, JSONException {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client("/no");
|
socket = client("/no");
|
||||||
socket.on(Socket.EVENT_CONNECT_ERROR, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT_ERROR, new Emitter.Listener() {
|
||||||
@@ -245,7 +245,7 @@ public class SocketTest extends Connection {
|
|||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
public void shouldThrowOnReservedEvent() {
|
public void shouldThrowOnReservedEvent() {
|
||||||
final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
|
final BlockingQueue<Optional> values = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
socket = client("/no");
|
socket = client("/no");
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class ByteArrayTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encodeByteArray() {
|
public void encodeByteArray() {
|
||||||
Packet<byte[]> packet = new Packet<byte[]>(Parser.BINARY_EVENT);
|
Packet<byte[]> packet = new Packet<>(Parser.BINARY_EVENT);
|
||||||
packet.data = "abc".getBytes(Charset.forName("UTF-8"));
|
packet.data = "abc".getBytes(Charset.forName("UTF-8"));
|
||||||
packet.id = 23;
|
packet.id = 23;
|
||||||
packet.nsp = "/cool";
|
packet.nsp = "/cool";
|
||||||
@@ -29,7 +29,7 @@ public class ByteArrayTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encodeByteArray2() {
|
public void encodeByteArray2() {
|
||||||
Packet<byte[]> packet = new Packet<byte[]>(Parser.BINARY_EVENT);
|
Packet<byte[]> packet = new Packet<>(Parser.BINARY_EVENT);
|
||||||
packet.data = new byte[2];
|
packet.data = new byte[2];
|
||||||
packet.id = 0;
|
packet.id = 0;
|
||||||
packet.nsp = "/";
|
packet.nsp = "/";
|
||||||
@@ -42,7 +42,7 @@ public class ByteArrayTest {
|
|||||||
data.getJSONObject("b").put("why", new byte[3]);
|
data.getJSONObject("b").put("why", new byte[3]);
|
||||||
data.getJSONObject("c").getJSONObject("b").put("a", new byte[6]);
|
data.getJSONObject("c").getJSONObject("b").put("a", new byte[6]);
|
||||||
|
|
||||||
Packet<JSONObject> packet = new Packet<JSONObject>(Parser.BINARY_EVENT);
|
Packet<JSONObject> packet = new Packet<>(Parser.BINARY_EVENT);
|
||||||
packet.data = data;
|
packet.data = data;
|
||||||
packet.id = 999;
|
packet.id = 999;
|
||||||
packet.nsp = "/deep";
|
packet.nsp = "/deep";
|
||||||
@@ -54,7 +54,7 @@ public class ByteArrayTest {
|
|||||||
JSONObject data = new JSONObject("{a: \"b\", c: 4, e: {g: null}, h: null}");
|
JSONObject data = new JSONObject("{a: \"b\", c: 4, e: {g: null}, h: null}");
|
||||||
data.put("h", new byte[9]);
|
data.put("h", new byte[9]);
|
||||||
|
|
||||||
Packet<JSONObject> packet = new Packet<JSONObject>(Parser.BINARY_EVENT);
|
Packet<JSONObject> packet = new Packet<>(Parser.BINARY_EVENT);
|
||||||
packet.data = data;
|
packet.data = data;
|
||||||
packet.nsp = "/";
|
packet.nsp = "/";
|
||||||
packet.id = 600;
|
packet.id = 600;
|
||||||
@@ -66,7 +66,7 @@ public class ByteArrayTest {
|
|||||||
JSONArray data = new JSONArray("[a, null, {}]");
|
JSONArray data = new JSONArray("[a, null, {}]");
|
||||||
data.put(1, "xxx".getBytes(Charset.forName("UTF-8")));
|
data.put(1, "xxx".getBytes(Charset.forName("UTF-8")));
|
||||||
|
|
||||||
Packet<JSONArray> packet = new Packet<JSONArray>(Parser.BINARY_ACK);
|
Packet<JSONArray> packet = new Packet<>(Parser.BINARY_ACK);
|
||||||
packet.data = data;
|
packet.data = data;
|
||||||
packet.id = 127;
|
packet.id = 127;
|
||||||
packet.nsp = "/back";
|
packet.nsp = "/back";
|
||||||
@@ -79,7 +79,7 @@ public class ByteArrayTest {
|
|||||||
data.put(new byte[2]);
|
data.put(new byte[2]);
|
||||||
data.put(new byte[3]);
|
data.put(new byte[3]);
|
||||||
|
|
||||||
Packet<JSONArray> packet = new Packet<JSONArray>(Parser.BINARY_EVENT);
|
Packet<JSONArray> packet = new Packet<>(Parser.BINARY_EVENT);
|
||||||
packet.data = data;
|
packet.data = data;
|
||||||
packet.id = 0;
|
packet.id = 0;
|
||||||
packet.nsp = "/";
|
packet.nsp = "/";
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ public class ParserTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encodeEvent() throws JSONException {
|
public void encodeEvent() throws JSONException {
|
||||||
Packet<JSONArray> packet1 = new Packet<JSONArray>(Parser.EVENT);
|
Packet<JSONArray> packet1 = new Packet<>(Parser.EVENT);
|
||||||
packet1.data = new JSONArray("[\"a\", 1, {}]");
|
packet1.data = new JSONArray("[\"a\", 1, {}]");
|
||||||
packet1.nsp = "/";
|
packet1.nsp = "/";
|
||||||
Helpers.test(packet1);
|
Helpers.test(packet1);
|
||||||
|
|
||||||
Packet<JSONArray> packet2 = new Packet<JSONArray>(Parser.EVENT);
|
Packet<JSONArray> packet2 = new Packet<>(Parser.EVENT);
|
||||||
packet2.data = new JSONArray("[\"a\", 1, {}]");
|
packet2.data = new JSONArray("[\"a\", 1, {}]");
|
||||||
packet2.nsp = "/test";
|
packet2.nsp = "/test";
|
||||||
Helpers.test(packet2);
|
Helpers.test(packet2);
|
||||||
@@ -40,7 +40,7 @@ public class ParserTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encodeAck() throws JSONException {
|
public void encodeAck() throws JSONException {
|
||||||
Packet<JSONArray> packet = new Packet<JSONArray>(Parser.ACK);
|
Packet<JSONArray> packet = new Packet<>(Parser.ACK);
|
||||||
packet.data = new JSONArray("[\"a\", 1, {}]");
|
packet.data = new JSONArray("[\"a\", 1, {}]");
|
||||||
packet.id = 123;
|
packet.id = 123;
|
||||||
packet.nsp = "/";
|
packet.nsp = "/";
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ public class Optional<T> {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
return new Optional<T>(value);
|
return new Optional<>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Optional<T> ofNullable(T value) {
|
public static <T> Optional<T> ofNullable(T value) {
|
||||||
return new Optional<T>(value);
|
return new Optional<>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<Void> empty() {
|
public static Optional<Void> empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user