Skip to content

Commit 01508b4

Browse files
committed
Adding some tests for GridLauncherV3
1 parent ebd0e41 commit 01508b4

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

java/server/src/org/openqa/grid/selenium/GridLauncherV3.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ private GridItemLauncher buildLauncher(String[] args) {
160160
}
161161

162162
if (toReturn.getConfiguration().version) {
163-
System.out.println(String.format("Selenium server version: %s, revision: %s",
164-
buildInfo.getReleaseLabel(),
165-
buildInfo.getBuildRevision()));
163+
out.println(String.format("Selenium server version: %s, revision: %s",
164+
buildInfo.getReleaseLabel(), buildInfo.getBuildRevision()));
166165
return null;
167166
}
168167

java/server/test/org/openqa/grid/e2e/misc/GridViaCommandLineTest.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.openqa.grid.e2e.misc;
1919

2020
import static org.hamcrest.CoreMatchers.containsString;
21+
import static org.hamcrest.CoreMatchers.startsWith;
2122
import static org.junit.Assert.assertEquals;
2223
import static org.junit.Assert.assertThat;
2324

@@ -54,7 +55,42 @@ public void unrecognizedRole() throws Exception {
5455
String[] args = {"-role", "hamlet"};
5556
new GridLauncherV3(new PrintStream(outSpy), args).launch();
5657
assertThat(outSpy.toString(),
57-
containsString("Error: the role 'hamlet' does not match a recognized server role"));
58+
startsWith("Error: the role 'hamlet' does not match a recognized server role"));
59+
}
60+
61+
@Test
62+
public void canPrintVersion() throws Exception {
63+
ByteArrayOutputStream outSpy = new ByteArrayOutputStream();
64+
String[] args = {"-version"};
65+
new GridLauncherV3(new PrintStream(outSpy), args).launch();
66+
assertThat(outSpy.toString(), startsWith("Selenium server version: "));
67+
}
68+
69+
@Test
70+
public void canPrintGeneralHelp() throws Exception {
71+
ByteArrayOutputStream outSpy = new ByteArrayOutputStream();
72+
String[] args = {"-help"};
73+
new GridLauncherV3(new PrintStream(outSpy), args).launch();
74+
assertThat(outSpy.toString(), startsWith("Usage: <main class> [options]"));
75+
assertThat(outSpy.toString(), containsString("-role"));
76+
}
77+
78+
@Test
79+
public void canPrintHubHelp() throws Exception {
80+
ByteArrayOutputStream outSpy = new ByteArrayOutputStream();
81+
String[] args = {"-role", "hub", "-help"};
82+
new GridLauncherV3(new PrintStream(outSpy), args).launch();
83+
assertThat(outSpy.toString(), startsWith("Usage: <main class> [options]"));
84+
assertThat(outSpy.toString(), containsString("-hubConfig"));
85+
}
86+
87+
@Test
88+
public void canPrintNodeHelp() throws Exception {
89+
ByteArrayOutputStream outSpy = new ByteArrayOutputStream();
90+
String[] args = {"-role", "node", "-help"};
91+
new GridLauncherV3(new PrintStream(outSpy), args).launch();
92+
assertThat(outSpy.toString(), startsWith("Usage: <main class> [options]"));
93+
assertThat(outSpy.toString(), containsString("-nodeConfig"));
5894
}
5995

6096
@Test

0 commit comments

Comments
 (0)