fix tests
This commit is contained in:
@@ -11,6 +11,8 @@ import org.junit.runners.JUnit4;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
@@ -269,7 +271,7 @@ public class ServerConnectionTest extends Connection {
|
||||
|
||||
@Test(timeout = TIMEOUT)
|
||||
public void pollingHeaders() throws URISyntaxException, InterruptedException {
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
||||
|
||||
IO.Options opts = createOptions();
|
||||
opts.transports = new String[] {Polling.NAME};
|
||||
@@ -290,20 +292,21 @@ public class ServerConnectionTest extends Connection {
|
||||
public void call(Object... args) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> headers = (Map<String, String>)args[0];
|
||||
assertThat(headers.get("X-SocketIO"), is("hi"));
|
||||
socket.close();
|
||||
semaphore.release();
|
||||
String value = headers.get("X-SocketIO");
|
||||
values.offer(value != null ? value : "");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.open();
|
||||
semaphore.acquire();
|
||||
|
||||
assertThat((String)values.take(), is("hi"));
|
||||
socket.close();
|
||||
}
|
||||
|
||||
@Test(timeout = TIMEOUT)
|
||||
public void websocketHandshakeHeaders() throws URISyntaxException, InterruptedException {
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
|
||||
|
||||
IO.Options opts = createOptions();
|
||||
opts.transports = new String[] {WebSocket.NAME};
|
||||
@@ -324,14 +327,15 @@ public class ServerConnectionTest extends Connection {
|
||||
public void call(Object... args) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> headers = (Map<String, String>)args[0];
|
||||
assertThat(headers.get("X-SocketIO"), is("hi"));
|
||||
socket.close();
|
||||
semaphore.release();
|
||||
String value = headers.get("X-SocketIO");
|
||||
values.offer(value != null ? value : "");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.open();
|
||||
semaphore.acquire();
|
||||
|
||||
assertThat((String)values.take(), is("hi"));
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,14 +73,14 @@ function before(context, name, fn) {
|
||||
};
|
||||
}
|
||||
|
||||
before(io.eio, 'handleRequest', function(req, res) {
|
||||
before(io.engine, 'handleRequest', function(req, res) {
|
||||
// echo a header value
|
||||
var value = req.headers['x-socketio'];
|
||||
if (!value) return;
|
||||
res.setHeader('X-SocketIO', value);
|
||||
});
|
||||
|
||||
before(io.eio, 'handleUpgrade', function(req, socket, head) {
|
||||
before(io.engine, 'handleUpgrade', function(req, socket, head) {
|
||||
// echo a header value for websocket handshake
|
||||
var value = req.headers['x-socketio'];
|
||||
if (!value) return;
|
||||
|
||||
Reference in New Issue
Block a user