|
34 | 34 |
|
35 | 35 | import org.hamcrest.CoreMatchers;
|
36 | 36 | import org.junit.Test;
|
| 37 | +import org.openqa.grid.common.RegistrationRequest; |
37 | 38 | import org.openqa.grid.common.exception.GridConfigurationException;
|
38 | 39 | import org.openqa.selenium.Platform;
|
39 | 40 | import org.openqa.selenium.remote.DesiredCapabilities;
|
40 | 41 |
|
| 42 | +import java.io.IOException; |
| 43 | +import java.nio.file.Files; |
| 44 | +import java.nio.file.Path; |
41 | 45 | import java.util.Arrays;
|
42 | 46 |
|
43 | 47 | public class GridNodeConfigurationTest {
|
@@ -355,6 +359,27 @@ public void testFixupCapabilitiesAddsUUID() {
|
355 | 359 | .allMatch(cap -> cap.getCapability(GridNodeConfiguration.CONFIG_UUID_CAPABILITY) != null));
|
356 | 360 | }
|
357 | 361 |
|
| 362 | + @Test |
| 363 | + public void canLoadConfigFile() throws IOException { |
| 364 | + String json = "{\"capabilities\":[], \"hub\": \"http://dummyhost:1234\"}"; |
| 365 | + Path nodeConfig = Files.createTempFile("node", ".json"); |
| 366 | + Files.write(nodeConfig, json.getBytes()); |
| 367 | + GridNodeConfiguration gnc = parseCliOptions("-nodeConfig", nodeConfig.toString()); |
| 368 | + RegistrationRequest request = RegistrationRequest.build(gnc); |
| 369 | + assertEquals("dummyhost", request.getConfiguration().getHubHost()); |
| 370 | + } |
| 371 | + |
| 372 | + @Test |
| 373 | + public void hubOptionHasPrecedenceOverNodeConfig() throws IOException { |
| 374 | + String json = "{\"capabilities\":[], \"hub\": \"http://dummyhost:1234\"}"; |
| 375 | + Path nodeConfig = Files.createTempFile("node", ".json"); |
| 376 | + Files.write(nodeConfig, json.getBytes()); |
| 377 | + GridNodeConfiguration gnc = parseCliOptions( |
| 378 | + "-nodeConfig", nodeConfig.toString(), "-hub", "http://smarthost:1234"); |
| 379 | + RegistrationRequest request = RegistrationRequest.build(gnc); |
| 380 | + assertEquals("smarthost", request.getConfiguration().getHubHost()); |
| 381 | + } |
| 382 | + |
358 | 383 | private GridNodeConfiguration parseCliOptions(String... args) {
|
359 | 384 | GridNodeConfiguration config = new GridNodeConfiguration();
|
360 | 385 | JCommander.newBuilder().addObject(config).build().parse(args);
|
|
0 commit comments