File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
src/org/openqa/grid/internal/utils/configuration
test/org/openqa/grid/internal/utils/configuration Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ public class GridNodeConfiguration extends GridConfiguration {
68
68
@ Expose ( serialize = false )
69
69
String remoteHost ;
70
70
71
+ // used to read a Selenium 2.x nodeConfig.json file and throw a friendly exception
72
+ @ Expose ( serialize = false )
73
+ @ Deprecated
74
+ private Object configuration ;
75
+
71
76
/*
72
77
* config parameters which serialize and deserialize to/from json
73
78
*/
@@ -293,6 +298,14 @@ public static GridNodeConfiguration loadFromJSON(JsonObject json) {
293
298
GridNodeConfiguration config =
294
299
builder .excludeFieldsWithoutExposeAnnotation ().create ().fromJson (json , GridNodeConfiguration .class );
295
300
301
+ if (config .configuration != null ) {
302
+ // caught below
303
+ throw new GridConfigurationException ("Deprecated -nodeConfig file encountered. Please update"
304
+ + " the file to work with Selenium 3. See https://github.com"
305
+ + "/SeleniumHQ/selenium/wiki/Grid2#configuring-the-nodes-by-json"
306
+ + " for more details." );
307
+ }
308
+
296
309
return config ;
297
310
} catch (Throwable e ) {
298
311
throw new GridConfigurationException ("Error with the JSON of the config : " + e .getMessage (),
Original file line number Diff line number Diff line change 29
29
import com .beust .jcommander .JCommander ;
30
30
31
31
import org .junit .Test ;
32
+ import org .openqa .grid .common .exception .GridConfigurationException ;
32
33
import org .openqa .selenium .remote .DesiredCapabilities ;
33
34
34
35
import java .util .Arrays ;
@@ -63,6 +64,20 @@ public void testLoadFromJson() {
63
64
assertEquals (5L , gnc .capabilities .get (0 ).getCapability ("maxInstances" ));
64
65
}
65
66
67
+ @ Test (expected = GridConfigurationException .class )
68
+ public void testLoadFromOldJson () {
69
+ final String configJson = "{"
70
+ + "\" configuration\" :"
71
+ + " {"
72
+ + "\" host\" : \" dummyhost\" ,"
73
+ + "\" maxSession\" : 5,"
74
+ + "\" port\" : 1234"
75
+ + " }"
76
+ + "}" ;
77
+ JsonObject json = new JsonParser ().parse (configJson ).getAsJsonObject ();
78
+ GridNodeConfiguration gnc = GridNodeConfiguration .loadFromJSON (json );
79
+ }
80
+
66
81
@ Test
67
82
public void testDefaults () {
68
83
GridNodeConfiguration gnc = new GridNodeConfiguration ();
You can’t perform that action at this time.
0 commit comments