...17package org.openqa.selenium.grid.router;18import org.openqa.selenium.Capabilities;19import org.openqa.selenium.grid.commands.EventBusCommand;20import org.openqa.selenium.grid.commands.Hub;21import org.openqa.selenium.grid.commands.Standalone;22import org.openqa.selenium.grid.config.CompoundConfig;23import org.openqa.selenium.grid.config.Config;24import org.openqa.selenium.grid.config.MapConfig;25import org.openqa.selenium.grid.config.MemoizedConfig;26import org.openqa.selenium.grid.config.TomlConfig;27import org.openqa.selenium.grid.distributor.httpd.DistributorServer;28import org.openqa.selenium.grid.node.httpd.NodeServer;29import org.openqa.selenium.grid.router.httpd.RouterServer;30import org.openqa.selenium.grid.server.Server;31import org.openqa.selenium.grid.sessionmap.httpd.SessionMapServer;32import org.openqa.selenium.grid.sessionqueue.httpd.NewSessionQueueServer;33import org.openqa.selenium.grid.web.Values;34import org.openqa.selenium.json.Json;35import org.openqa.selenium.json.JsonOutput;36import org.openqa.selenium.net.PortProber;37import org.openqa.selenium.remote.http.HttpClient;38import org.openqa.selenium.remote.http.HttpRequest;39import org.openqa.selenium.remote.http.HttpResponse;40import org.openqa.selenium.support.ui.FluentWait;41import org.openqa.selenium.testing.Safely;42import org.openqa.selenium.testing.TearDownFixture;43import java.io.IOException;44import java.io.StringReader;45import java.io.UncheckedIOException;46import java.net.ConnectException;47import java.time.Duration;48import java.util.Arrays;49import java.util.List;50import java.util.Map;51import static org.openqa.selenium.json.Json.MAP_TYPE;52import static org.openqa.selenium.remote.http.HttpMethod.GET;53public enum DeploymentTypes {54 STANDALONE {55 @Override56 public Deployment start(Capabilities capabilities, Config additionalConfig) {57 StringBuilder rawCaps = new StringBuilder();58 try (JsonOutput out = new Json().newOutput(rawCaps)) {59 out.setPrettyPrint(false).write(capabilities);60 }61 String[] rawConfig = new String[]{62 "[network]",63 "relax-checks = true",64 "",65 "[server]",66 "registration-secret = \"provolone\"",67 "",68 "[sessionqueue]",69 "session-request-timeout = 100",70 "session-retry-interval = 1"71 };72 Config config = new MemoizedConfig(73 new CompoundConfig(74 additionalConfig,75 new TomlConfig(new StringReader(String.join("\n", rawConfig)))));76 Server<?> server = new Standalone().asServer(new CompoundConfig(setRandomPort(), config)).start();77 waitUntilReady(server, Duration.ofSeconds(5));78 return new Deployment(server, server::stop);79 }80 },81 HUB_AND_NODE {82 @Override83 public Deployment start(Capabilities capabilities, Config additionalConfig) {84 StringBuilder rawCaps = new StringBuilder();85 try (JsonOutput out = new Json().newOutput(rawCaps)) {86 out.setPrettyPrint(false).write(capabilities);87 }88 int publish = PortProber.findFreePort();89 int subscribe = PortProber.findFreePort();90 String[] rawConfig = new String[] {...