Example usage for org.openqa.selenium.json JsonException getMessage

List of usage examples for org.openqa.selenium.json JsonException getMessage

Introduction

In this page you can find the example usage for org.openqa.selenium.json JsonException getMessage.

Prototype

@Override
    public String getMessage() 

Source Link

Usage

From source file:org.openqa.grid.web.servlet.NodeSessionsServlet.java

License:Apache License

private Map<String, Object> extractSessionInfo(RemoteProxy proxy) {
    try {//from  w w  w .  ja va2s . c o  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<>();
}

From source file:org.openqa.grid.web.servlet.TestSessionStatusServlet.java

License:Apache License

protected void process(HttpServletResponse response, Map<String, Object> requestJson) throws IOException {
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.setStatus(200);//  w  ww  . j av a  2 s.com
    try (Writer writer = response.getWriter(); JsonOutput out = json.newOutput(writer)) {
        out.write(getResponse(requestJson));
    } catch (JsonException e) {
        throw new GridException(e.getMessage());
    }
}