Examples of ScriptResult


Examples of com.baasbox.service.scripting.base.ScriptResult

            return notFound("Script does not exists");
        }
        JsonNode reqAsJson = serializeRequest(path, request());

        try {
            ScriptResult result =ScriptingService.invoke(ScriptCall.rest(serv, reqAsJson));
            return status(result.status(),result.content());
        } catch (ScriptEvalException e) {
            Logger.error("Error evaluating script",e);
            return internalServerError("script failure "+ ExceptionUtils.getFullStackTrace(e));
        }
//        catch (IllegalStateException e){
View Full Code Here

Examples of com.baasbox.service.scripting.base.ScriptResult

        if (result == null){
            return ScriptResult.NULL;
        } else if (result instanceof Boolean){
            return (Boolean) result ?ScriptResult.TRUE:ScriptResult.FALSE;
        } else if (result instanceof String){
            return new ScriptResult((String)result);
        } else if (result instanceof ScriptObjectMirror){
            JsonNode node = convertDeepJson(result);
            if (node != null){
                return new ScriptResult(node);
            } else {
                return ScriptResult.NULL;
            }
        } else if (result instanceof Number){
            return  new ScriptResult((Number)result);
        } else if (result instanceof Undefined){
            return ScriptResult.NULL;
        } else {

            Logger.warn("Mirror: %s, of type: %s",result,result.getClass());
View Full Code Here

Examples of com.baasbox.service.scripting.base.ScriptResult

            if (call.event == null) {
                return null;
            }

            Object result = emitEvent(moduleRef, call.event, call.eventData);
            ScriptResult scriptResult = mMapper.convertResult(result);
            call.validate(scriptResult);
            if (Logger.isTraceEnabled())Logger.trace("ScriptResult: %s",scriptResult.toString());
            return scriptResult;
        } catch (Throwable err){
            if (err instanceof NashornException){
                if(Logger.isTraceEnabled())Logger.trace("Error in script");
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

    protected TestsResult getTestsResult() {
        TestsResult result = new TestsResult();

        executeTimer();

        ScriptResult scriptResult = page.executeJavaScript("window.simulationContext.results");
        NativeArray array = (NativeArray) scriptResult.getJavaScriptResult();

        for (int i = 0; i < array.getLength(); i++) {
            NativeObject object = (NativeObject) array.get(i, array);
            String data = null;
            Object dataObject = object.get("data", object);

            if (!(dataObject instanceof Undefined)) {
                data = (String) dataObject;
            }

            Object startTimeObject = object.get("startTime", object);
            Double startTime =  startTimeObject instanceof Double ? (Double) startTimeObject : Double.NaN;
            Object endTimeObject = object.get("endTime", object);
            Double endTime =  endTimeObject instanceof Double ? (Double) endTimeObject : Double.NaN;
            Object aborted = object.get("aborted", object);
            boolean abortedBoolean = aborted instanceof Boolean && (Boolean) aborted;

            result.addData(new RequestData(data, startTime, endTime, abortedBoolean));
        }

        scriptResult = page.executeJavaScript("Timer.currentTime");
        result.setCurrentTime((Double) scriptResult.getJavaScriptResult());

        System.out.println();
        System.out.println("Logged Javascript statements:");
        System.out.println("*****************************");
        System.out.println(loggedJavaScript.toString());
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

    protected TestsResult getTestsResult() {
        TestsResult result = new TestsResult();

        executeTimer();

        ScriptResult scriptResult = page.executeJavaScript("window.simulationContext.results");
        NativeArray array = (NativeArray) scriptResult.getJavaScriptResult();

        for (int i = 0; i < array.getLength(); i++) {
            NativeObject object = (NativeObject) array.get(i, array);
            String data = null;
            Object dataObject = object.get("data", object);

            if (!(dataObject instanceof Undefined)) {
                data = (String) dataObject;
            }

            Double startTime = (Double) object.get("startTime", object);
            Double endTime = (Double) object.get("endTime", object);
            Object aborted = object.get("aborted", object);
            boolean abortedBoolean = aborted instanceof Boolean && (Boolean) aborted;

            result.addData(new RequestData(data, startTime, endTime, abortedBoolean));
        }

        scriptResult = page.executeJavaScript("Timer.currentTime");
        result.setCurrentTime((Double) scriptResult.getJavaScriptResult());

        return result;
    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

        HtmlPage p = createWebClient().goTo("self/testBehaviour");

        p.executeJavaScript("renderOnDemand(document.getElementsBySelector('.lazy')[0])");
        // all AJAX calls complete before the above method returns

        ScriptResult r = p.executeJavaScript("var r=document.getElementsBySelector('DIV.a'); r[0].innerHTML+r[1].innerHTML+r[2].innerHTML");
        assertEquals("AlphaBravoCharlie",r.getJavaScriptResult().toString());
    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

        "InvokeSpecial must not be called on the client side");
  }

  public void loadJsni(BrowserChannel channel, String jsniString) {
    logger.log(TreeLogger.SPAM, "LOAD_JSNI: " + jsniString);
    ScriptResult scriptResult = htmlPage.executeJavaScript(jsniString);
    logger.log(TreeLogger.INFO, "LOAD_JSNI: scriptResult=" + scriptResult);
  }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

        "InvokeSpecial must not be called on the client side");
  }

  public void loadJsni(BrowserChannel channel, String jsniString) {
    logger.log(TreeLogger.SPAM, "LOAD_JSNI: " + jsniString);
    ScriptResult scriptResult = htmlPage.executeJavaScript(jsniString);
    logger.log(TreeLogger.INFO, "LOAD_JSNI: scriptResult=" + scriptResult);
  }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

  @Override
  public void loadJsni(BrowserChannelClient channel, String jsniString) {
    if (logger.isLoggable(TreeLogger.SPAM)) {
      logger.log(TreeLogger.SPAM, "LOAD_JSNI: " + jsniString);
    }
    ScriptResult scriptResult = htmlPage.executeJavaScript(jsniString);
    if (logger.isLoggable(TreeLogger.INFO)) {
      logger.log(TreeLogger.INFO, "LOAD_JSNI: scriptResult=" + scriptResult);
    }
  }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

    String escapedCoffee = StringEscapeUtils.escapeEcmaScript(coffee);
    return cache.containsKey(escapedCoffee) ? cache.get(escapedCoffee) : compileAndCache(escapedCoffee);
  }

  private String compileAndCache(String input) {
    ScriptResult scriptResult = htmlPage.get().executeJavaScript(String.format("CoffeeScript.compile(\"%s\");", input));
    String result = (String) scriptResult.getJavaScriptResult();
    cache.put(input,result);
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.