コード例 #1
0
  @Test
  public void textFile() throws Exception {
    ScriptEngine engine = TestUtils.getEngine();
    // String file = TestUtils.resourceToFile("/dream.txt");

    TestUtils.evalJSResource(engine, "/sparkcontexttests.js");
    Object ret = ((Invocable) engine).invokeFunction("textFile");

    assertEquals("failure - values are not equal", "[\"Rating(0,260,9.0)\"]", ret);
  };
コード例 #2
0
  @Test
  public void scFloatAccumulator() throws Exception {
    ScriptEngine engine = TestUtils.getEngine();
    // String file = TestUtils.resourceToFile("/dream.txt");

    TestUtils.evalJSResource(engine, "/sparkcontexttests.js");
    Object ret = ((Invocable) engine).invokeFunction("scFloatAccumulator");

    assertEquals("failure - values are not equal", 11.0, ret);
  };
コード例 #3
0
  @Test
  public void objectFile() throws Exception {
    ScriptEngine engine = TestUtils.getEngine();
    // String file = TestUtils.resourceToFile("/dream.txt");

    TestUtils.evalJSResource(engine, "/sparkcontexttests.js");
    Object ret = ((Invocable) engine).invokeFunction("objectFile");

    assertEquals(
        "failure - values are not equal", "[{\"user\":0,\"product\":260,\"rating\":9}]", ret);
  };