compitible with engine.io 0.8.2

This commit is contained in:
Naoyuki Kanezawa
2014-01-27 05:36:22 +09:00
parent 803ee3bb25
commit 84f97d8caf
5 changed files with 48 additions and 30 deletions

View File

@@ -10,6 +10,8 @@ import org.junit.runners.JUnit4;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -47,7 +49,7 @@ public class SocketTest {
*/
@Test
public void socketClosing() throws URISyntaxException, InterruptedException {
Socket socket = new Socket("ws://localhost:8080") {
Socket socket = new Socket("ws://0.0.0.0:8080") {
@Override
public void onopen() {}
@Override
@@ -59,6 +61,19 @@ public class SocketTest {
};
final boolean[] closed = {false};
socket.once(Socket.EVENT_ERROR, new Emitter.Listener() {
@Override
public void call(Object... args) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
assertThat(closed[0], is(false));
}
}, 20);
}
});
socket.on(Socket.EVENT_CLOSE, new Emitter.Listener() {
@Override
public void call(Object... args) {
@@ -66,8 +81,5 @@ public class SocketTest {
}
});
socket.open();
Thread.sleep(200);
assertThat(closed[0], is(false));
}
}

View File

@@ -23,6 +23,7 @@ public class TransportTest {
opt.query = new HashMap<String, String>() {{
put("sid", "test");
}};
opt.timestampRequests = false;
Polling polling = new Polling(opt);
assertThat(polling.uri(), is("http://localhost/engine.io?sid=test"));
}
@@ -37,6 +38,7 @@ public class TransportTest {
put("sid", "test");
}};
opt.port = 80;
opt.timestampRequests = false;
Polling polling = new Polling(opt);
assertThat(polling.uri(), is("http://localhost/engine.io?sid=test"));
}
@@ -51,6 +53,7 @@ public class TransportTest {
put("sid", "test");
}};
opt.port = 3000;
opt.timestampRequests = false;
Polling polling = new Polling(opt);
assertThat(polling.uri(), is("http://localhost:3000/engine.io?sid=test"));
}
@@ -65,6 +68,7 @@ public class TransportTest {
put("sid", "test");
}};
opt.port = 443;
opt.timestampRequests = false;
Polling polling = new Polling(opt);
assertThat(polling.uri(), is("https://localhost/engine.io?sid=test"));
}
@@ -89,6 +93,7 @@ public class TransportTest {
opt.query = new HashMap<String, String>() {{
put("transport", "websocket");
}};
opt.timestampRequests = false;
WS ws = new WS(opt);
assertThat(ws.uri(), is("ws://test/engine.io?transport=websocket"));
}
@@ -99,6 +104,7 @@ public class TransportTest {
opt.path ="/engine.io";
opt.hostname = "test";
opt.secure = true;
opt.timestampRequests = false;
WS ws = new WS(opt);
assertThat(ws.uri(), is("wss://test/engine.io"));
}

View File

@@ -3,6 +3,6 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"engine.io": "0.7.9"
"engine.io": "0.8.2"
}
}