3031323334353637
@Before public void setUp() throws Exception { console = new RestConsole(new SimpleConsole(ConsoleConfig.consoleConfig()), randomServerPort()); console.start(); client = new ClientHttpHandler(); prefixUrl = "http://localhost:" + console.port(); }
5758596061626364656667
} } private ConsoleStatus status() { try { return ConsoleStatus.valueOf(parse(new ClientHttpHandler().handle(get("http://localhost:" + port.get() + "/status").build()).entity().toString()) .get("status", String.class)); } catch (Exception e) { return Idle; }
8687888990919293949596
public Response execute(String expression) { createProcess(); try { return reportProcessError(new ClientHttpHandler().handle(RequestBuilder.post("http://localhost:" + port.get() + "/" + "execute").form("expression", expression).build())); } catch (Exception e) { e.printStackTrace(); return response(INTERNAL_SERVER_ERROR); } }
979899100101102103104105106107
public Response readExpression(String line) { createProcess(); try { return reportProcessError(new ClientHttpHandler().handle(RequestBuilder.post("http://localhost:" + port.get() + "/" + "readExpression").form("line", line).build())); } catch (Exception e) { e.printStackTrace(); return response(INTERNAL_SERVER_ERROR); } }
108109110111112113114115116117118
public Response completions(String expression) { createProcess(); try { return reportProcessError(new ClientHttpHandler().handle(RequestBuilder.get("http://localhost:" + port.get() + "/" + "completions").query("expression", expression).build())); } catch (Exception e) { e.printStackTrace(); return response(INTERNAL_SERVER_ERROR); } }
26272829303132
private final ClientHttpHandler client; public JavaREPLClient(String hostname, Integer port) { this.hostname = hostname; this.port = port; this.client = new ClientHttpHandler(); }