Skip to content

Commit

Permalink
Rename BaseServer to JettyServer
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Oct 15, 2019
1 parent e940e94 commit 879c4b0
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions java/server/src/org/openqa/selenium/grid/commands/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
import org.openqa.selenium.grid.distributor.local.LocalDistributor;
import org.openqa.selenium.grid.log.LoggingOptions;
import org.openqa.selenium.grid.router.Router;
import org.openqa.selenium.grid.server.BaseServer;
import org.openqa.selenium.grid.server.BaseServerFlags;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.EventBusConfig;
import org.openqa.selenium.grid.server.EventBusFlags;
import org.openqa.selenium.grid.server.HelpFlags;
import org.openqa.selenium.grid.server.JettyServer;
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
Expand Down Expand Up @@ -121,7 +121,7 @@ public Executable configure(String... args) {
handler.addHandler(distributor);
Router router = new Router(clientFactory, sessions, distributor);

Server<?> server = new BaseServer<>(serverOptions);
Server<?> server = new JettyServer(serverOptions);
server.setHandler(router);
server.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
import org.openqa.selenium.grid.node.config.NodeOptions;
import org.openqa.selenium.grid.node.local.LocalNode;
import org.openqa.selenium.grid.router.Router;
import org.openqa.selenium.grid.server.BaseServer;
import org.openqa.selenium.grid.server.BaseServerFlags;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.EventBusConfig;
import org.openqa.selenium.grid.server.EventBusFlags;
import org.openqa.selenium.grid.server.HelpFlags;
import org.openqa.selenium.grid.server.JettyServer;
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
Expand Down Expand Up @@ -158,7 +158,7 @@ public Executable configure(String... args) {
combinedHandler.addHandler(node);
distributor.add(node);

Server<?> server = new BaseServer<>(new BaseServerOptions(config));
Server<?> server = new JettyServer(new BaseServerOptions(config));
server.setHandler(router);
server.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
import org.openqa.selenium.grid.distributor.Distributor;
import org.openqa.selenium.grid.distributor.local.LocalDistributor;
import org.openqa.selenium.grid.log.LoggingOptions;
import org.openqa.selenium.grid.server.BaseServer;
import org.openqa.selenium.grid.server.BaseServerFlags;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.EventBusConfig;
import org.openqa.selenium.grid.server.EventBusFlags;
import org.openqa.selenium.grid.server.HelpFlags;
import org.openqa.selenium.grid.server.JettyServer;
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.config.SessionMapFlags;
Expand Down Expand Up @@ -116,7 +116,7 @@ public Executable configure(String... args) {

BaseServerOptions serverOptions = new BaseServerOptions(config);

Server<?> server = new BaseServer<>(serverOptions);
Server<?> server = new JettyServer(serverOptions);
server.setHandler(distributor);
server.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
import org.openqa.selenium.grid.log.LoggingOptions;
import org.openqa.selenium.grid.node.config.NodeOptions;
import org.openqa.selenium.grid.node.local.LocalNode;
import org.openqa.selenium.grid.server.BaseServer;
import org.openqa.selenium.grid.server.BaseServerFlags;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.EventBusConfig;
import org.openqa.selenium.grid.server.EventBusFlags;
import org.openqa.selenium.grid.server.HelpFlags;
import org.openqa.selenium.grid.server.JettyServer;
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.remote.http.HttpClient;

Expand Down Expand Up @@ -124,7 +124,7 @@ public Executable configure(String... args) {

LocalNode node = builder.build();

Server<?> server = new BaseServer<>(serverOptions);
Server<?> server = new JettyServer(serverOptions);
server.setHandler(node);
server.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
import org.openqa.selenium.grid.distributor.config.DistributorOptions;
import org.openqa.selenium.grid.log.LoggingOptions;
import org.openqa.selenium.grid.router.Router;
import org.openqa.selenium.grid.server.BaseServer;
import org.openqa.selenium.grid.server.BaseServerFlags;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.HelpFlags;
import org.openqa.selenium.grid.server.JettyServer;
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.config.SessionMapFlags;
Expand Down Expand Up @@ -111,7 +111,7 @@ public Executable configure(String... args) {

Router router = new Router(clientFactory, sessions, distributor);

Server<?> server = new BaseServer<>(serverOptions);
Server<?> server = new JettyServer(serverOptions);
server.setHandler(router);
server.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@

import static java.util.concurrent.TimeUnit.SECONDS;

public class BaseServer<T extends BaseServer> implements Server<T> {
public class JettyServer<T extends JettyServer> implements Server<T> {

private static final Logger LOG = Logger.getLogger(BaseServer.class.getName());
private static final Logger LOG = Logger.getLogger(JettyServer.class.getName());
private static final int MAX_SHUTDOWN_RETRIES = 8;

private final org.eclipse.jetty.server.Server server;
private final ServletContextHandler servletContextHandler;
private final URL url;
private HttpHandler handler;

public BaseServer(BaseServerOptions options) {
public JettyServer(BaseServerOptions options) {
int port = options.getPort() == 0 ? PortProber.findFreePort() : options.getPort();

String host = options.getHostname().orElseGet(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
import org.openqa.selenium.grid.config.Config;
import org.openqa.selenium.grid.config.EnvConfig;
import org.openqa.selenium.grid.log.LoggingOptions;
import org.openqa.selenium.grid.server.BaseServer;
import org.openqa.selenium.grid.server.BaseServerFlags;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.EventBusConfig;
import org.openqa.selenium.grid.server.EventBusFlags;
import org.openqa.selenium.grid.server.HelpFlags;
import org.openqa.selenium.grid.server.JettyServer;
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
Expand Down Expand Up @@ -101,7 +101,7 @@ public Executable configure(String... args) {

BaseServerOptions serverOptions = new BaseServerOptions(config);

Server<?> server = new BaseServer<>(serverOptions);
Server<?> server = new JettyServer(serverOptions);
server.setHandler(sessions);
server.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.beust.jcommander.JCommander;

import org.openqa.selenium.grid.config.AnnotatedConfig;
import org.openqa.selenium.grid.server.BaseServer;
import org.openqa.selenium.grid.server.JettyServer;
import org.openqa.selenium.grid.server.BaseServerFlags;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.HelpFlags;
Expand All @@ -49,7 +49,7 @@
* Provides a server that can launch and manage selenium sessions.
*/
@ManagedService(objectName = "org.seleniumhq.server:type=SeleniumServer")
public class SeleniumServer extends BaseServer {
public class SeleniumServer extends JettyServer {

private final static Logger LOG = Logger.getLogger(SeleniumServer.class.getName());

Expand Down Expand Up @@ -94,7 +94,7 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
}

@Override
public BaseServer start() {
public JettyServer start() {
long inactiveSessionTimeoutSeconds = Long.MAX_VALUE / 1000;

NewSessionPipeline pipeline = DefaultPipeline.createDefaultPipeline().create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import org.openqa.selenium.grid.distributor.remote.RemoteDistributor;
import org.openqa.selenium.grid.node.SessionFactory;
import org.openqa.selenium.grid.node.local.LocalNode;
import org.openqa.selenium.grid.server.BaseServer;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.JettyServer;
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
Expand Down Expand Up @@ -188,7 +188,7 @@ private static Object[] createRemotes() throws URISyntaxException {
LocalNode localNode = LocalNode.builder(bus, clientFactory, nodeUri)
.add(CAPS, createFactory(nodeUri))
.build();
Server<?> nodeServer = new BaseServer<>(
Server<?> nodeServer = new JettyServer<>(
new BaseServerOptions(
new MapConfig(ImmutableMap.of("server", ImmutableMap.of("port", port)))));
nodeServer.setHandler(localNode);
Expand All @@ -206,7 +206,7 @@ private static Object[] createRemotes() throws URISyntaxException {

private static Server<?> createServer() {
int port = PortProber.findFreePort();
return new BaseServer<>(new BaseServerOptions(
return new JettyServer(new BaseServerOptions(
new MapConfig(ImmutableMap.of("server", ImmutableMap.of("port", port)))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
import static org.openqa.selenium.remote.http.HttpMethod.GET;
import static org.openqa.selenium.remote.http.Route.get;

public class BaseServerTest {
public class JettyServerTest {

private BaseServerOptions emptyOptions = new BaseServerOptions(new MapConfig(ImmutableMap.of()));

@Test
public void baseServerStartsAndDoesNothing() throws IOException {
Server<?> server = new BaseServer<>(emptyOptions).setHandler(req -> new HttpResponse()).start();
Server<?> server = new JettyServer(emptyOptions).setHandler(req -> new HttpResponse()).start();

URL url = server.getUrl();
HttpClient client = HttpClient.Factory.createDefault().createClient(url);
Expand All @@ -64,7 +64,7 @@ public void baseServerStartsAndDoesNothing() throws IOException {

@Test
public void shouldAllowAHandlerToBeRegistered() throws IOException {
Server<?> server = new BaseServer<>(emptyOptions);
Server<?> server = new JettyServer(emptyOptions);
server.setHandler(get("/cheese").to(() -> req -> new HttpResponse().setContent(utf8String("cheddar"))));

server.start();
Expand All @@ -77,7 +77,7 @@ public void shouldAllowAHandlerToBeRegistered() throws IOException {

@Test
public void addHandlersOnceServerIsStartedIsAnError() {
Server<BaseServer> server = new BaseServer<>(emptyOptions);
Server<?> server = new JettyServer(emptyOptions);
server.setHandler(req -> new HttpResponse());
server.start();

Expand All @@ -87,7 +87,7 @@ public void addHandlersOnceServerIsStartedIsAnError() {

@Test
public void exceptionsThrownByHandlersAreConvertedToAProperPayload() throws IOException {
Server<BaseServer> server = new BaseServer<>(emptyOptions);
Server<?> server = new JettyServer(emptyOptions);
server.setHandler(req -> {
throw new UnableToSetCookieException("Yowza");
});
Expand Down

0 comments on commit 879c4b0

Please sign in to comment.