20
20
import static org .junit .Assert .assertEquals ;
21
21
import static org .mockito .Mockito .mock ;
22
22
23
- import com .google .gson .JsonObject ;
24
-
25
23
import org .junit .AfterClass ;
26
24
import org .junit .BeforeClass ;
27
25
import org .junit .Test ;
@@ -152,61 +150,60 @@ public void testBrowserLocations() throws MalformedURLException {
152
150
newSessionRequest = new MockedRequestHandler (getNewRequest (req_caps ));
153
151
newSessionRequest .process ();
154
152
155
- JsonObject json = (JsonObject ) newSessionRequest .getSession ().getRequestedCapabilities ().get (ChromeOptions .CAPABILITY );
156
- assertEquals (locationChrome27 , json .get ("binary" ). getAsString () );
153
+ Map < String , Object > json = (Map < String , Object > ) newSessionRequest .getSession ().getRequestedCapabilities ().get (ChromeOptions .CAPABILITY );
154
+ assertEquals (locationChrome27 , json .get ("binary" ));
157
155
158
156
req_caps = new HashMap <String , Object >();
159
157
req_caps .put (CapabilityType .BROWSER_NAME , BrowserType .CHROME );
160
158
req_caps .put (CapabilityType .VERSION , "29" );
161
159
newSessionRequest = new MockedRequestHandler (getNewRequest (req_caps ));
162
160
newSessionRequest .process ();
163
161
164
- json = (JsonObject ) newSessionRequest .getSession ().getRequestedCapabilities ().get (ChromeOptions .CAPABILITY );
165
- assertEquals (locationChrome29 , json .get ("binary" ). getAsString () );
162
+ json = (Map < String , Object > ) newSessionRequest .getSession ().getRequestedCapabilities ().get (ChromeOptions .CAPABILITY );
163
+ assertEquals (locationChrome29 , json .get ("binary" ));
166
164
167
165
req_caps = new HashMap <String , Object >();
168
166
req_caps .put (CapabilityType .BROWSER_NAME , BrowserType .CHROME );
169
167
req_caps .put (CapabilityType .VERSION , "29" );
170
- JsonObject options = new JsonObject ();
171
- options .addProperty ("test1" , "test2" );
168
+ Map < String , Object > options = new HashMap < String , Object > ();
169
+ options .put ("test1" , "test2" );
172
170
req_caps .put (ChromeOptions .CAPABILITY , options );
173
171
newSessionRequest = new MockedRequestHandler (getNewRequest (req_caps ));
174
172
newSessionRequest .process ();
175
173
176
- json = (JsonObject ) newSessionRequest .getSession ().getRequestedCapabilities ().get (ChromeOptions .CAPABILITY );
177
- assertEquals (locationChrome29 , json .get ("binary" ). getAsString () );
178
- assertEquals ("test2" , json .get ("test1" ). getAsString () );
174
+ json = (Map < String , Object > ) newSessionRequest .getSession ().getRequestedCapabilities ().get (ChromeOptions .CAPABILITY );
175
+ assertEquals (locationChrome29 , json .get ("binary" ));
176
+ assertEquals ("test2" , json .get ("test1" ));
179
177
180
178
req_caps = new HashMap <String , Object >();
181
179
req_caps .put (CapabilityType .BROWSER_NAME , BrowserType .CHROME );
182
180
req_caps .put (CapabilityType .VERSION , "30" );
183
- options = new JsonObject ();
184
- options .addProperty ("test11" , "test22" );
185
- options .addProperty ("binary" , "custom" );
181
+ options = new HashMap < String , Object > ();
182
+ options .put ("test11" , "test22" );
183
+ options .put ("binary" , "custom" );
186
184
req_caps .put (ChromeOptions .CAPABILITY , options );
187
185
newSessionRequest = new MockedRequestHandler (getNewRequest (req_caps ));
188
186
newSessionRequest .process ();
189
187
190
- json = (JsonObject ) newSessionRequest .getSession ().getRequestedCapabilities ().get (ChromeOptions .CAPABILITY );
191
- // Ignored due it fails
192
- //Assert.assertEquals("custom", json.get("binary").getAsString());
193
- assertEquals ("test22" , json .get ("test11" ).getAsString ());
188
+ json = (Map <String , Object >) newSessionRequest .getSession ().getRequestedCapabilities ().get (ChromeOptions .CAPABILITY );
189
+ assertEquals ("custom" , json .get ("binary" ));
190
+ assertEquals ("test22" , json .get ("test11" ));
194
191
}
195
192
196
193
@ AfterClass
197
194
public static void teardown () throws Exception {
198
195
remote .stopRemoteServer ();
199
196
hub .stop ();
200
197
}
201
-
198
+
202
199
private SeleniumBasedRequest getNewRequest (Map <String , Object > desiredCapability ) {
203
200
HttpServletRequest httpreq = mock (HttpServletRequest .class );
204
201
return new SeleniumBasedRequest (httpreq , registry , RequestType .START_SESSION , desiredCapability ) {
205
202
206
203
public String getNewSessionRequestedCapability (TestSession session ) {
207
204
return null ;
208
205
}
209
-
206
+
210
207
public ExternalSessionKey extractSession () {
211
208
return null ;
212
209
}
@@ -239,4 +236,4 @@ public void forwardNewSessionRequestAndUpdateRegistry(TestSession session)
239
236
throws NewSessionException {}
240
237
}
241
238
242
- }
239
+ }
0 commit comments