Skip to content

Commit 0248a49

Browse files
committed
Re-enable the passthrough tests
1 parent bdc4787 commit 0248a49

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

java/server/test/org/openqa/selenium/remote/server/PassthroughTest.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
import static java.net.HttpURLConnection.HTTP_OK;
2121
import static java.nio.charset.StandardCharsets.UTF_8;
22+
import static org.junit.Assert.assertEquals;
23+
import static org.junit.Assert.assertNull;
2224

2325
import com.google.common.io.ByteStreams;
2426

@@ -32,6 +34,7 @@
3234
import org.openqa.selenium.net.PortProber;
3335
import org.openqa.selenium.remote.http.HttpMethod;
3436
import org.openqa.selenium.remote.http.HttpRequest;
37+
import org.openqa.selenium.remote.http.HttpResponse;
3538

3639
import java.io.IOException;
3740
import java.io.InputStream;
@@ -57,31 +60,31 @@ public void stopServer() {
5760
}
5861

5962
@Test
60-
public void shouldForwardRequestsToEndPoint() {
61-
// SessionCodec handler = new Passthrough(server.url);
62-
// FakeHttpServletRequest req = new FakeHttpServletRequest("GET", new UrlInfo(server.url.toString(), "", "/ok"));
63-
// req.addHeader("X-Cheese", "Cake");
64-
// FakeHttpServletResponse resp = new FakeHttpServletResponse();
65-
// handler.handle(req, resp);
66-
//
67-
// // HTTP headers are case insensitive. This is how the HttpUrlConnection likes to encode things
68-
// assertEquals("Cake", server.lastRequest.getHeader("x-cheese"));
63+
public void shouldForwardRequestsToEndPoint() throws IOException {
64+
SessionCodec handler = new Passthrough(server.url);
65+
HttpRequest req = new HttpRequest(HttpMethod.GET, "/ok");
66+
req.addHeader("X-Cheese", "Cake");
67+
HttpResponse resp = new HttpResponse();
68+
handler.handle(req, resp);
69+
70+
// HTTP headers are case insensitive. This is how the HttpUrlConnection likes to encode things
71+
assertEquals("Cake", server.lastRequest.getHeader("x-cheese"));
6972
}
7073

7174
@Test
72-
public void shouldStripKeepAliveHeader() {
73-
// SessionCodec handler = new Passthrough(server.url);
74-
// FakeHttpServletRequest req = new FakeHttpServletRequest("GET", new UrlInfo(server.url.toString(), "", "/ok"));
75-
// req.addHeader("Keep-Alive", "timeout=600");
76-
// req.addHeader("Connection", "Keep-Alive, Upgrade");
77-
// FakeHttpServletResponse resp = new FakeHttpServletResponse();
78-
// handler.handle(req, resp);
79-
//
80-
// assertNull(server.lastRequest.getHeader("keep-alive"));
81-
// // Not, we must set the connection to `close` in order to have the JVM avoid attempting to keep
82-
// // the url connection open.
83-
// // http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html
84-
// assertEquals("close", server.lastRequest.getHeader("connection"));
75+
public void shouldStripKeepAliveHeader() throws IOException {
76+
SessionCodec handler = new Passthrough(server.url);
77+
HttpRequest req = new HttpRequest(HttpMethod.GET, "/ok");
78+
req.addHeader("Keep-Alive", "timeout=600");
79+
req.addHeader("Connection", "Keep-Alive, Upgrade");
80+
HttpResponse resp = new HttpResponse();
81+
handler.handle(req, resp);
82+
83+
assertNull(server.lastRequest.getHeader("keep-alive"));
84+
// Not, we must set the connection to `close` in order to have the JVM avoid attempting to keep
85+
// the url connection open.
86+
// http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html
87+
assertEquals("close", server.lastRequest.getHeader("connection"));
8588
}
8689

8790
private static class Server {

0 commit comments

Comments
 (0)