51
51
52
52
public class NodeOptions {
53
53
54
+ private static final String NODE_SECTION = "node" ;
55
+
54
56
private static final Logger LOG = Logger .getLogger (NodeOptions .class .getName ());
55
57
private static final Json JSON = new Json ();
56
58
private static final String DEFAULT_IMPL = "org.openqa.selenium.grid.node.local.LocalNodeFactory" ;
@@ -62,7 +64,7 @@ public NodeOptions(Config config) {
62
64
}
63
65
64
66
public Optional <URI > getPublicGridUri () {
65
- return config .get ("node" , "grid-url" ).map (url -> {
67
+ return config .get (NODE_SECTION , "grid-url" ).map (url -> {
66
68
try {
67
69
return new URI (url );
68
70
} catch (URISyntaxException e ) {
@@ -72,7 +74,7 @@ public Optional<URI> getPublicGridUri() {
72
74
}
73
75
74
76
public Node getNode () {
75
- return config .getClass ("node" , "implementation" , Node .class , DEFAULT_IMPL );
77
+ return config .getClass (NODE_SECTION , "implementation" , Node .class , DEFAULT_IMPL );
76
78
}
77
79
78
80
public Map <Capabilities , Collection <SessionFactory >> getSessionFactories (
@@ -93,13 +95,13 @@ public Map<Capabilities, Collection<SessionFactory>> getSessionFactories(
93
95
94
96
public int getMaxSessions () {
95
97
return Math .min (
96
- config .getInt ("node" , "max-concurrent-sessions" )
98
+ config .getInt (NODE_SECTION , "max-concurrent-sessions" )
97
99
.orElse (Runtime .getRuntime ().availableProcessors ()),
98
100
Runtime .getRuntime ().availableProcessors ());
99
101
}
100
102
101
103
private void addDriverFactoriesFromConfig (ImmutableMultimap .Builder <Capabilities , SessionFactory > sessionFactories ) {
102
- config .getAll ("node" , "driver-factories" ).ifPresent (allConfigs -> {
104
+ config .getAll (NODE_SECTION , "driver-factories" ).ifPresent (allConfigs -> {
103
105
if (allConfigs .size () % 2 != 0 ) {
104
106
throw new ConfigException ("Expected each driver class to be mapped to a config" );
105
107
}
@@ -146,7 +148,7 @@ private SessionFactory createSessionFactory(String clazz, Capabilities stereotyp
146
148
private void addDetectedDrivers (
147
149
Map <WebDriverInfo , Collection <SessionFactory >> allDrivers ,
148
150
ImmutableMultimap .Builder <Capabilities , SessionFactory > sessionFactories ) {
149
- if (!config .getBool ("node" , "detect-drivers" ).orElse (false )) {
151
+ if (!config .getBool (NODE_SECTION , "detect-drivers" ).orElse (false )) {
150
152
return ;
151
153
}
152
154
@@ -158,7 +160,7 @@ private void addDetectedDrivers(
158
160
private void addSpecificDrivers (
159
161
Map <WebDriverInfo , Collection <SessionFactory >> allDrivers ,
160
162
ImmutableMultimap .Builder <Capabilities , SessionFactory > sessionFactories ) {
161
- List <String > drivers = config .getAll ("node" , "drivers" ).orElse (new ArrayList <>()).stream ()
163
+ List <String > drivers = config .getAll (NODE_SECTION , "drivers" ).orElse (new ArrayList <>()).stream ()
162
164
.map (String ::toLowerCase )
163
165
.collect (Collectors .toList ());
164
166
@@ -173,7 +175,7 @@ private Map<WebDriverInfo, Collection<SessionFactory>> discoverDrivers(
173
175
int maxSessions ,
174
176
Function <WebDriverInfo , Collection <SessionFactory >> factoryFactory ) {
175
177
176
- if (!config .getBool ("node" , "detect-drivers" ).orElse (false )) {
178
+ if (!config .getBool (NODE_SECTION , "detect-drivers" ).orElse (false )) {
177
179
return ImmutableMap .of ();
178
180
}
179
181
0 commit comments