Skip to content

Commit

Permalink
Adding tests for -hub and -nodeConfig option combination
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Feb 7, 2018
1 parent 4fff7fc commit 8eabd85
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@

import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.common.exception.GridConfigurationException;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;

public class GridNodeConfigurationTest {
Expand Down Expand Up @@ -355,6 +359,27 @@ public void testFixupCapabilitiesAddsUUID() {
.allMatch(cap -> cap.getCapability(GridNodeConfiguration.CONFIG_UUID_CAPABILITY) != null));
}

@Test
public void canLoadConfigFile() throws IOException {
String json = "{\"capabilities\":[], \"hub\": \"http://dummyhost:1234\"}";
Path nodeConfig = Files.createTempFile("node", ".json");
Files.write(nodeConfig, json.getBytes());
GridNodeConfiguration gnc = parseCliOptions("-nodeConfig", nodeConfig.toString());
RegistrationRequest request = RegistrationRequest.build(gnc);
assertEquals("dummyhost", request.getConfiguration().getHubHost());
}

@Test
public void hubOptionHasPrecedenceOverNodeConfig() throws IOException {
String json = "{\"capabilities\":[], \"hub\": \"http://dummyhost:1234\"}";
Path nodeConfig = Files.createTempFile("node", ".json");
Files.write(nodeConfig, json.getBytes());
GridNodeConfiguration gnc = parseCliOptions(
"-nodeConfig", nodeConfig.toString(), "-hub", "http://smarthost:1234");
RegistrationRequest request = RegistrationRequest.build(gnc);
assertEquals("smarthost", request.getConfiguration().getHubHost());
}

private GridNodeConfiguration parseCliOptions(String... args) {
GridNodeConfiguration config = new GridNodeConfiguration();
JCommander.newBuilder().addObject(config).build().parse(args);
Expand Down

0 comments on commit 8eabd85

Please sign in to comment.