Пример #1
0
  @Test
  public void testAutomationCtxSharing() throws Exception {
    org.junit.Assert.assertNotNull(scriptingService);

    InputStream stream = this.getClass().getResourceAsStream("/shareAutomationContext.js");
    org.junit.Assert.assertNotNull(stream);
    scriptingService.run(stream, session);
    assertEquals("OK" + System.lineSeparator(), outContent.toString());
  }
Пример #2
0
 @Ignore("for performance testing purpose")
 @Test
 public void testPerf() throws ScriptException, OperationException {
   long start = System.currentTimeMillis();
   for (int i = 0; i < 500; i++) {
     scriptingService.run(scriptingService.getJSWrapper(), session);
   }
   long end = System.currentTimeMillis();
   System.err.println("DEBUG: Logic A toke " + (end - start) + " " + "MilliSeconds");
 }
Пример #3
0
  @Test
  public void testIsolationScriptCtx() throws Exception {
    org.junit.Assert.assertNotNull(scriptingService);

    InputStream stream = this.getClass().getResourceAsStream("/scriptCtxIsolation.js");
    org.junit.Assert.assertNotNull(stream);
    scriptingService.run(stream, session);
    assertEquals("[object Object]" + System.lineSeparator(), outContent.toString());

    stream = this.getClass().getResourceAsStream("/scriptCtxIsolation.js");
    org.junit.Assert.assertNotNull(stream);
    scriptingService.run(stream, session);
    // Failing returning "[object Object]\n" + "toto\n"
    assertEquals(
        "[object Object]"
            + System.lineSeparator()
            + "[object "
            + "Object]"
            + System.lineSeparator(),
        outContent.toString());
  }
Пример #4
0
  @Ignore("for performance testing purpose")
  @Test
  public void checkScriptingEngineCostAndIsolation() throws Exception {

    InputStream stream = this.getClass().getResourceAsStream("/QuickScript.js");
    assertNotNull(stream);
    String js = IOUtils.toString(stream);

    // long t0 = System.currentTimeMillis();
    scriptingService.run(getScriptWithRandomContent(js), session);
    // long t1 = System.currentTimeMillis();
    // System.err.println("Initial Exec = " + (t1-t0));

    // t0 = System.currentTimeMillis();
    scriptingService.run(getScriptWithRandomContent(js), session);
    // t1 = System.currentTimeMillis();
    // System.err.println("Second Exec = " + (t1-t0));

    int nbIter = 50;

    // long t = t1 - t0;
    for (int i = 0; i < nbIter; i++) {
      // t0 = System.currentTimeMillis();
      scriptingService.run(getScriptWithRandomContent(js), session);
      // t1 = System.currentTimeMillis();
      // System.err.println("Exec = " + (t1-t0));
      // t += t1 - t0;
    }

    // System.err.println("AvgExec = " + (t/(nbIter + 1.0)));

    // now we check isolation

    stream = this.getClass().getResourceAsStream("/checkIsolation.js");
    assertNotNull(stream);
    String check = IOUtils.toString(stream);

    scriptingService.run(check, session);

    scriptingService.run(check, session);

    scriptingService.run("Document.Fetch=\"toto\";", session);

    scriptingService.run(check, session);
  }