Skip to content

Commit f4c0215

Browse files
committed
add unit test for additionalCommands
1 parent c4837a0 commit f4c0215

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

java/test/org/openqa/selenium/remote/RemoteWebDriverInitializationTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.openqa.selenium.remote.http.ClientConfig;
5252
import org.openqa.selenium.remote.http.Contents;
5353
import org.openqa.selenium.remote.http.HttpClient;
54+
import org.openqa.selenium.remote.http.HttpMethod;
5455
import org.openqa.selenium.remote.http.HttpResponse;
5556

5657
@Tag("UnitTests")
@@ -234,4 +235,22 @@ public void quit() {
234235
quitCalled = true;
235236
}
236237
}
238+
239+
@Test
240+
void additionalCommandsCanBeModified() throws MalformedURLException {
241+
HttpClient client = mock(HttpClient.class);
242+
HttpClient.Factory factory = mock(HttpClient.Factory.class);
243+
244+
when(factory.createClient(any(ClientConfig.class))).thenReturn(client);
245+
246+
URL url = new URL("http://localhost:4444/");
247+
HttpCommandExecutor executor =
248+
new HttpCommandExecutor(emptyMap(), ClientConfig.defaultConfig().baseUrl(url), factory);
249+
250+
String commandName = "customCommand";
251+
CommandInfo commandInfo = new CommandInfo("/session/:sessionId/custom", HttpMethod.GET);
252+
executor.addAdditionalCommand(commandName, commandInfo);
253+
254+
assertThat(executor.getAdditionalCommands()).containsEntry(commandName, commandInfo);
255+
}
237256
}

0 commit comments

Comments
 (0)