diff --git a/java/server/test/org/openqa/grid/e2e/misc/GridViaCommandLineTest.java b/java/server/test/org/openqa/grid/e2e/misc/GridViaCommandLineTest.java index ca9ad91f291db..aa3c72ffedda0 100644 --- a/java/server/test/org/openqa/grid/e2e/misc/GridViaCommandLineTest.java +++ b/java/server/test/org/openqa/grid/e2e/misc/GridViaCommandLineTest.java @@ -18,6 +18,7 @@ package org.openqa.grid.e2e.misc; import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.startsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -34,6 +35,10 @@ import org.openqa.selenium.net.UrlChecker; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.remote.http.HttpClient; +import org.openqa.selenium.remote.http.HttpMethod; +import org.openqa.selenium.remote.http.HttpRequest; +import org.openqa.selenium.remote.server.SeleniumServer; import org.openqa.selenium.support.ui.FluentWait; import java.io.BufferedReader; @@ -110,6 +115,35 @@ public void canRedirectLogToFile() throws Exception { server.get().stop(); } + @Test + public void canLaunchStandalone() throws IOException { + Integer port = PortProber.findFreePort(); + ByteArrayOutputStream outSpy = new ByteArrayOutputStream(); + String[] args = {"-role", "standalone", "-port", port.toString()}; + Optional server = new GridLauncherV3(new PrintStream(outSpy), args).launch(); + assertTrue(server.isPresent()); + assertThat(server.get(), instanceOf(SeleniumServer.class)); + + String url = "http://localhost:" + port; + HttpClient client = HttpClient.Factory.createDefault().createClient(new URL(url)); + HttpRequest req = new HttpRequest(HttpMethod.GET, "/"); + String content = client.execute(req).getContentString(); + assertThat(content, containsString("Whoops! The URL specified routes to this help page.")); + + server.get().stop(); + } + + @Test + public void launchesStandaloneByDefault() { + Integer port = PortProber.findFreePort(); + ByteArrayOutputStream outSpy = new ByteArrayOutputStream(); + String[] args = {"-port", port.toString()}; + Optional server = new GridLauncherV3(new PrintStream(outSpy), args).launch(); + assertTrue(server.isPresent()); + assertThat(server.get(), instanceOf(SeleniumServer.class)); + server.get().stop(); + } + @Test public void canStartHtmlSuite() { ByteArrayOutputStream outSpy = new ByteArrayOutputStream();