public SparkRInterpreter(Properties property) {
    super(property);
  }
@Test
  void testSparkRInterpreter() throws InterpreterException, InterruptedException {
    InterpreterResult result = sparkRInterpreter.interpret("1+1", getInterpreterContext());
    assertEquals(InterpreterResult.Code.SUCCESS, result.code());
    assertTrue(result.message().get(0).getData().contains("2"));

    result = sparkRInterpreter.interpret("sparkR.version()", getInterpreterContext());
    assertEquals(InterpreterResult.Code.SUCCESS, result.code());

    result = sparkRInterpreter.interpret("df <- as.DataFrame(faithful)\nhead(df)", getInterpreterContext());
    assertEquals(InterpreterResult.Code.SUCCESS, result.code());
    assertTrue(result.message().get(0).getData().contains("eruptions waiting"), result.toString());
    // spark job url is sent
    verify(mockRemoteIntpEventClient, atLeastOnce()).onParaInfosReceived(any(Map.class));

    // cancel
    InterpreterContext context = getInterpreterContext();
    InterpreterContext finalContext = context;
    Thread thread = new Thread() {
      @Override
      public void run() {
        try {
          InterpreterResult result = sparkRInterpreter.interpret("ldf <- dapplyCollect(\n" +
                  "         df,\n" +
                  "         function(x) {\n" +
                  "           Sys.sleep(3)\n" +
                  "           x <- cbind(x, \"waiting_secs\" = x$waiting * 60)\n" +
                  "         })\n" +
                  "head(ldf, 3)", finalContext);
          assertTrue(result.message().get(0).getData().contains("cancelled"));
        } catch (InterpreterException e) {
          fail("Should not throw InterpreterException");
        }
      }
    };
    thread.setName("Cancel-Thread");
    thread.start();
    Thread.sleep(1000);
    sparkRInterpreter.cancel(context);

    // plotting
    context = getInterpreterContext();
    context.getLocalProperties().put("imageWidth", "100");
    result = sparkRInterpreter.interpret("hist(mtcars$mpg)", context);
    assertEquals(InterpreterResult.Code.SUCCESS, result.code());
    assertEquals(1, result.message().size());
    assertEquals(InterpreterResult.Type.HTML, result.message().get(0).getType());
    assertTrue(result.message().get(0).getData().contains("<img src="));
    assertTrue(result.message().get(0).getData().contains("width=\"100\""));

    result = sparkRInterpreter.interpret("library(ggplot2)\n" +
        "ggplot(diamonds, aes(x=carat, y=price, color=cut)) + geom_point()", getInterpreterContext());
    assertEquals(InterpreterResult.Code.SUCCESS, result.code());
    assertEquals(1, result.message().size());
    assertEquals(InterpreterResult.Type.HTML, result.message().get(0).getType());
    assertTrue(result.message().get(0).getData().contains("<img src="));

    // sparkr backend would be timeout after 10 seconds
    Thread.sleep(15 * 1000);
    result = sparkRInterpreter.interpret("1+1", getInterpreterContext());
    assertEquals(InterpreterResult.Code.ERROR, result.code());
    assertTrue(result.message().get(0).getData().contains("sparkR backend is dead"));
  }