Skip to content

Commit

Permalink
Bump the Jetty version from 7 to 9
Browse files Browse the repository at this point in the history
Also, handle repacking the jar ourselves. In order for eclipse
users to be able to build within the IDE, they need to repack
the jetty jar using `go repack-jetty`. IJ users need to do this
too.
  • Loading branch information
shs96c committed Sep 30, 2015
1 parent 219e898 commit 0697307
Show file tree
Hide file tree
Showing 77 changed files with 724 additions and 291 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ py/selenium/webdriver/firefox/webdriver_prefs.json
py/selenium/webdriver/firefox/x86/
py/docs/build/
selenium.egg-info/
third_party/java/jetty/jetty-repacked.jar
*.user
*.cache
obj/
Expand Down
6 changes: 2 additions & 4 deletions .idea/libraries/jetty.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/libraries/servlet_api.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions .idea/libraries/xml_apis.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,49 @@ task :test_webdriverjs => [
desc "Generate a single file with WebDriverJS' public API"
task :webdriverjs => [ "//javascript/webdriver:webdriver" ]

desc "Repack jetty"
task "repack-jetty" => "build/third_party/java/jetty/jetty-repacked.jar"

# Expose the repack task to CrazyFun.
task "//third_party/java/jetty:repacked" => "build/third_party/java/jetty/jetty-repacked.jar"

file "build/third_party/java/jetty/jetty-repacked.jar" => [
"third_party/java/jetty/jetty-continuation-9.2.13.v20150730.jar",
"third_party/java/jetty/jetty-http-9.2.13.v20150730.jar",
"third_party/java/jetty/jetty-io-9.2.13.v20150730.jar",
"third_party/java/jetty/jetty-jmx-9.2.13.v20150730.jar",
"third_party/java/jetty/jetty-security-9.2.13.v20150730.jar",
"third_party/java/jetty/jetty-server-9.2.13.v20150730.jar",
"third_party/java/jetty/jetty-servlet-9.2.13.v20150730.jar",
"third_party/java/jetty/jetty-servlets-9.2.13.v20150730.jar",
"third_party/java/jetty/jetty-util-9.2.13.v20150730.jar"
] do |t|
print "Repacking jetty\n"
root = File.join("build", "third_party", "java", "jetty")
jarjar = File.join("third_party", "java", "jarjar", "jarjar-1.4.jar")
rules = File.join("third_party", "java", "jetty", "jetty-repack-rules")
temp = File.join(root, "temp")

# First, process the files
mkdir_p root
mkdir_p temp

t.prerequisites.each do |pre|
filename = File.basename(pre, ".jar")
out = File.join(root, "#{filename}-repacked.jar")
`java -jar #{jarjar} process #{rules} #{pre} #{out}`
`cd #{temp} && jar xf #{File.join("..", File.basename(out))}`
end

# Now, merge them
`cd #{temp} && jar cvf #{File.join("..", "jetty-repacked.jar")} *`

# And copy the artifact to third_party so that eclipse users can be made happy
cp "build/third_party/java/jetty/jetty-repacked.jar", "third_party/java/jetty/jetty-repacked.jar"
end

task

task :release => [
:clean,
:build,
Expand Down
14 changes: 7 additions & 7 deletions java/client/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<classpathentry kind="lib" path="/third-party/java/jna/jna-4.1.0.jar" sourcepath="/third-party/java/jna/jna-4.1.0-src.jar"/>
<classpathentry kind="lib" path="/third-party/java/jna/jna-platform-4.1.0.jar" sourcepath="/third-party/java/jna/jna-platform-4.1.0-src.jar"/>
<classpathentry kind="lib" path="/third-party/java/commons-exec/commons-exec-1.3.jar" sourcepath="/third-party/java/commons-exec/commons-exec-1.3-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty/jetty-repacked-7.6.1.jar" sourcepath="/third-party/java/jetty/jetty-repacked-7.6.1-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty/jetty-repacked.jar"/>
<classpathentry kind="lib" path="/third-party/java/cglib/cglib-nodep-2.1_3.jar"/>
<classpathentry kind="lib" path="/third-party/java/servlet/servlet-api-2.5-6.1.9.jar" sourcepath="/third-party/java/servlet/servlet-api-2.5-6.1.9-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/servlet/javax.servlet-api-3.1.0.jar" sourcepath="/third-party/java/servlet/javax.servlet-api-3.1.0-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/phantomjs-driver/phantomjsdriver-1.2.1.jar" sourcepath="/third-party/java/phantomjs-driver/phantomjsdriver-1.2.1-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/httpcomponents/httpclient-4.5.jar" sourcepath="/third-party/java/httpcomponents/httpclient-4.5-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/httpcomponents/httpcore-4.4.1.jar" sourcepath="/third-party/java/httpcomponents/httpcore-4.4.1-sources.jar"/>
Expand All @@ -40,10 +40,10 @@
<classpathentry kind="lib" path="/third-party/java/slf4j/slf4j-api-1.6.6.jar"/>
<classpathentry kind="lib" path="/third-party/java/slf4j/slf4j-jdk14-1.6.6.jar"/>
<classpathentry kind="lib" path="/third-party/java/gson/gson-2.3.1.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty-websocket/websocket-api-9.2.12.v20150709.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty-websocket/websocket-client-9.2.12.v20150709.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty-websocket/websocket-common-9.2.12.v20150709.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty-websocket/jetty-io-9.2.12.v20150709.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty-websocket/jetty-util-9.2.12.v20150709.jar"/>
<classpathentry kind="lib" path="/third-party/java/websocket/websocket-api-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="/third-party/java/websocket/websocket-client-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="/third-party/java/websocket/websocket-common-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty/jetty-io-9.2.13.v20150730.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty/jetty-util-9.2.13.v20150730.jar"/>
<classpathentry kind="output" path="build/production"/>
</classpath>
2 changes: 1 addition & 1 deletion java/client/client.iml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<orderEntry type="library" name="sac" level="project" />
<orderEntry type="library" scope="TEST" name="dnsjava" level="project" />
<orderEntry type="library" scope="TEST" name="dnssec4j" level="project" />
<orderEntry type="library" scope="TEST" name="jetty" level="project" />
<orderEntry type="library" name="jetty" level="project" />
<orderEntry type="library" scope="TEST" name="little_proxy" level="project" />
<orderEntry type="library" scope="TEST" name="slf4j" level="project" />
<orderEntry type="library" name="mockito-core-1.9.5-srcs" level="project" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package com.thoughtworks.selenium.testing;

import org.seleniumhq.jetty7.http.HttpFields;

import java.io.IOException;
import java.util.Calendar;

Expand Down Expand Up @@ -48,8 +46,8 @@ private void setAlwaysCacheHeaders(HttpServletResponse resp) {
resp.setHeader("Cache-Control", "max-age=29723626");
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.YEAR, 1);
resp.setHeader("Expires", HttpFields.formatDate(calendar.getTimeInMillis()));
resp.setHeader("Last-Modified", HttpFields.__01Jan1970);
resp.setDateHeader("Expires", calendar.getTimeInMillis());
resp.setDateHeader("Last-Modified", 0);
resp.setHeader("Pragma", "");
resp.setHeader("ETag", "foo");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package com.thoughtworks.selenium.testing;

import java.io.File;

import org.openqa.selenium.environment.webserver.JettyAppServer;
import org.openqa.selenium.testing.InProject;
import org.seleniumhq.jetty7.servlet.ServletContextHandler;
import org.seleniumhq.jetty9.servlet.ServletContextHandler;

import java.io.File;

public class SeleniumAppServer extends JettyAppServer {

Expand Down
2 changes: 1 addition & 1 deletion java/client/test/org/openqa/selenium/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java_test(name = 'small-tests',
],
)

java_test(name = 'large-tests',
java_library(name = 'large-tests',
srcs = [
'StandardSeleniumTests.java',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,31 @@
import static org.openqa.selenium.net.PortProber.findFreePort;
import static org.openqa.selenium.testing.InProject.locate;

import com.google.common.collect.ImmutableList;

import org.openqa.selenium.net.NetworkUtils;
import org.openqa.selenium.testing.InProject;
import org.seleniumhq.jetty7.server.Server;
import org.seleniumhq.jetty7.server.handler.ContextHandlerCollection;
import org.seleniumhq.jetty7.server.nio.SelectChannelConnector;
import org.seleniumhq.jetty7.server.ssl.SslSocketConnector;
import org.seleniumhq.jetty7.servlet.DefaultServlet;
import org.seleniumhq.jetty7.servlet.ServletContextHandler;
import org.seleniumhq.jetty7.servlet.ServletHolder;
import org.seleniumhq.jetty7.servlets.MultiPartFilter;
import org.seleniumhq.jetty7.util.ssl.SslContextFactory;
import org.seleniumhq.jetty9.http.HttpVersion;
import org.seleniumhq.jetty9.server.Connector;
import org.seleniumhq.jetty9.server.HttpConfiguration;
import org.seleniumhq.jetty9.server.HttpConnectionFactory;
import org.seleniumhq.jetty9.server.SecureRequestCustomizer;
import org.seleniumhq.jetty9.server.Server;
import org.seleniumhq.jetty9.server.ServerConnector;
import org.seleniumhq.jetty9.server.SslConnectionFactory;
import org.seleniumhq.jetty9.server.handler.AllowSymLinkAliasChecker;
import org.seleniumhq.jetty9.server.handler.ContextHandler.ApproveAliases;
import org.seleniumhq.jetty9.server.handler.ContextHandlerCollection;
import org.seleniumhq.jetty9.servlet.DefaultServlet;
import org.seleniumhq.jetty9.servlet.ServletContextHandler;
import org.seleniumhq.jetty9.servlet.ServletHolder;
import org.seleniumhq.jetty9.servlets.MultiPartFilter;
import org.seleniumhq.jetty9.util.ssl.SslContextFactory;

import java.io.File;
import java.util.EnumSet;

import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.Servlet;

Expand Down Expand Up @@ -106,7 +117,7 @@ public JettyAppServer(String hostName) {
addServlet(defaultContext, "/basicAuth", BasicAuth.class);
addServlet(defaultContext, "/generated/*", GeneratedJsTestServlet.class);

addFilter(defaultContext, MultiPartFilter.class, "/upload", 0 /* DEFAULT dispatches */);
addFilter(defaultContext, MultiPartFilter.class, "/upload", DispatcherType.REQUEST);

listenOn(getHttpPort());
listenSecurelyOn(getHttpsPort());
Expand Down Expand Up @@ -167,26 +178,36 @@ protected String getMainContextPath(String relativeUrl) {

@Override
public void start() {
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
server.addConnector(connector);
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(securePort);

ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(port);
http.setIdleTimeout(500000);

File keyStore = getKeyStore();
if (!keyStore.exists()) {
File keystore = getKeyStore();
if (!keystore.exists()) {
throw new RuntimeException(
"Cannot find keystore for SSL cert: " + keyStore.getAbsolutePath());
"Cannot find keystore for SSL cert: " + keystore.getAbsolutePath());
}

SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(keyStore.getAbsolutePath());
sslContextFactory.setKeyStorePath(keystore.getAbsolutePath());
sslContextFactory.setKeyStorePassword("password");
sslContextFactory.setKeyManagerPassword("password");
sslContextFactory.setTrustStore(keyStore.getAbsolutePath());
sslContextFactory.setTrustStorePassword("password");

SslSocketConnector secureSocket = new SslSocketConnector(sslContextFactory);
secureSocket.setPort(securePort);
server.addConnector(secureSocket);
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());

ServerConnector https = new ServerConnector(
server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig));
https.setPort(securePort);
https.setIdleTimeout(500000);

server.setConnectors(new Connector[]{http, https});

try {
server.start();
Expand Down Expand Up @@ -219,7 +240,9 @@ public void stop() {
}

public void addServlet(
ServletContextHandler context, String url, Class<? extends Servlet> servletClass) {
ServletContextHandler context,
String url,
Class<? extends Servlet> servletClass) {
try {
context.addServlet(new ServletHolder(servletClass), url);
} catch (Exception e) {
Expand All @@ -228,8 +251,11 @@ public void addServlet(
}

public void addFilter(
ServletContextHandler context, Class<? extends Filter> filter, String path, int dispatches) {
context.addFilter(filter, path, dispatches);
ServletContextHandler context,
Class<? extends Filter> filter,
String path,
DispatcherType dispatches) {
context.addFilter(filter, path, EnumSet.of(dispatches));
}

protected ServletContextHandler addResourceHandler(String contextPath, File resourceBase) {
Expand All @@ -240,7 +266,7 @@ protected ServletContextHandler addResourceHandler(String contextPath, File reso

context.setContextPath(contextPath);
context.setResourceBase(resourceBase.getAbsolutePath());
context.setAliases(true);
context.setAliasChecks(ImmutableList.of(new ApproveAliases(), new AllowSymLinkAliasChecker()));
context.addServlet(new ServletHolder(new DefaultServlet()), "/*");

handlers.addHandler(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

package org.openqa.selenium.environment.webserver;

import org.seleniumhq.jetty7.util.log.Logger;

import org.seleniumhq.jetty9.util.log.Logger;

public class NullLogger implements Logger {
public void disableLogging() {
Expand All @@ -34,6 +35,10 @@ public void setDebugEnabled(boolean b) {
public void debug(String s, Object... o) {
}

@Override
public void debug(String s, long l) {
}

public void debug(String s, Throwable throwable) {
}

Expand Down
4 changes: 2 additions & 2 deletions java/server/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
<classpathentry kind="src" path="test"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/client"/>
<classpathentry kind="lib" path="/third-party/java/gson/gson-2.3.1.jar"/>
<classpathentry kind="lib" path="/third-party/java/servlet/servlet-api-2.5-6.1.9.jar" sourcepath="/third-party/java/servlet/servlet-api-2.5-6.1.9-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/servlet/javax.servlet-api-3.1.0.jar" sourcepath="/third-party/java/servlet/javax.servlet-api-3.1.0-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/httpcomponents/httpclient-4.5.jar" sourcepath="/third-party/java/httpcomponents/httpclient-4.5-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/httpcomponents/httpcore-4.4.1.jar" sourcepath="/third-party/java/httpcomponents/httpcore-4.4.1-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/hamcrest/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="/third-party/java/hamcrest/hamcrest-library-1.3.jar"/>
<classpathentry kind="lib" path="/third-party/java/junit/junit-4.12.jar" sourcepath="/third-party/java/junit/junit-4.12-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/bouncycastle/bcprov-jdk15on-1.48.jar" sourcepath="/third-party/java/bouncycastle/bcprov-jdk15on-1.48-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty/jetty-repacked-7.6.1.jar" sourcepath="/third-party/java/jetty/jetty-repacked-7.6.1-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty/jetty-repacked-5.jar" sourcepath="/third-party/java/jetty/jetty-repacked-5-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/commons-logging/commons-logging-1.1.3.jar"/>
<classpathentry kind="lib" path="/third-party/java/mx4j/mx4j-tools-3.0.1.jar"/>
Expand All @@ -23,5 +22,6 @@
<classpathentry kind="lib" path="/third-party/java/netty/netty-3.5.7.Final.jar"/>
<classpathentry kind="lib" path="/third-party/java/guava-libraries/guava-18.0.jar" sourcepath="/third-party/java/guava-libraries/guava-18.0-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/mockito/mockito-core-1.9.5.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty/jetty-repacked.jar"/>
<classpathentry kind="output" path="build/production"/>
</classpath>
Loading

0 comments on commit 0697307

Please sign in to comment.