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