List of usage examples for org.openqa.selenium.json Json MAP_TYPE
Type MAP_TYPE
To view the source code for org.openqa.selenium.json Json MAP_TYPE.
Click Source Link
From source file:org.openqa.grid.e2e.misc.GridListActiveSessionsTest.java
License:Apache License
private Map<String, Object> getSessions(Hub hub) throws IOException { String url = String.format("http://%s:%d/grid/api/sessions", hub.getUrl().getHost(), hub.getUrl().getPort());/*from ww w .j av a2 s . c o m*/ URL grid = new URL(url); URLConnection connection = grid.openConnection(); try (InputStream in = connection.getInputStream(); JsonInput input = new Json().newInput(new BufferedReader(new InputStreamReader(in)))) { return input.read(Json.MAP_TYPE); } }
From source file:org.openqa.grid.web.servlet.HubStatusServletTest.java
License:Apache License
private Map<String, Object> invokeCommand(String method, Map<String, Object> params) throws IOException, ServletException { FakeHttpServletResponse fakeResponse = sendCommand(method, "/", params); Json json = new Json(); JsonInput jin = json.newInput(new StringReader(fakeResponse.getBody())); return jin.read(Json.MAP_TYPE); }
From source file:org.openqa.grid.web.servlet.NodeSessionsServlet.java
License:Apache License
private Map<String, Object> extractSessionInfo(RemoteProxy proxy) { try {/*w w w. j ava2s . co m*/ URL url = proxy.getRemoteHost(); HttpRequest req = new HttpRequest(HttpMethod.GET, "/wd/hub/sessions"); Integer nodeStatusCheckTimeout = proxy.getConfig().nodeStatusCheckTimeout; HttpResponse rsp = proxy.getHttpClient(url, nodeStatusCheckTimeout, nodeStatusCheckTimeout) .execute(req); try (InputStream in = new ByteArrayInputStream(rsp.getContent()); Reader reader = new InputStreamReader(in, rsp.getContentEncoding()); JsonInput jsonReader = json.newInput(reader)) { return jsonReader.read(Json.MAP_TYPE); } catch (JsonException e) { // Nothing to do --- poorly formed payload. } } catch (IOException e) { throw new GridException(e.getMessage()); } return new TreeMap<>(); }