Skip to content

Commit

Permalink
Adding tests for standalone launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Feb 9, 2018
1 parent 8ed2215 commit 5bc5690
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<Stoppable> 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<Stoppable> 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();
Expand Down

0 comments on commit 5bc5690

Please sign in to comment.