Package net.sf.sahi.response

Examples of net.sf.sahi.response.SimpleHttpResponse


    String filePath = request.getParameter("v");
    list.add(filePath);
    session.setObject(key, list);
        session.mockResponder().add(request.getParameter("action").replaceAll("[.]", "[.]") + ".*", "FileUpload_appendFiles");
        if (new File(Configuration.getAbsoluteUserPath(filePath)).exists()) {
          return new SimpleHttpResponse("true");
        } else {
          return new SimpleHttpResponse("File not found: " + filePath + "; Base directory is userdata directory: " + Configuration.getUserDataDir());
        }
    }
View Full Code Here


    public HttpResponse isReady(final HttpRequest request){
//    ScriptRunner scriptRunner = request.session().getScriptRunner();
//    boolean isReady = scriptRunner != null && scriptRunner.isRunning();
//    return new SimpleHttpResponse("" + isReady);   
    return new SimpleHttpResponse("" + request.session().isReadyForDriver());   
    }   
View Full Code Here

      String key = request.getParameter("key");
//      System.out.println("key="+key);
    Session session = request.session();
    String val = session.getVariable(key);
//      System.out.println("val="+val);
    return new SimpleHttpResponse(val != null ? val : "");
    }
View Full Code Here

   
    public HttpResponse doneStep(final HttpRequest request){
    Session session = request.session();
    ScriptRunner scriptRunner = session.getScriptRunner();
    if (scriptRunner == null){
      return new SimpleHttpResponse("error:Playback session not started. Verify that proxy is set on the browser.");
    }
    boolean done = scriptRunner.doneStep(""|| scriptRunner.isStopped();
    if (done){
      Status status = scriptRunner.getStatus();
      String browserException = scriptRunner.getBrowserException();
      if (browserException == null) browserException = "";
      if (status == Status.ERROR){
        return new SimpleHttpResponse("error:" +  browserException);
      } else if (status == Status.FAILURE) {
        return new SimpleHttpResponse("failure:" + browserException);       
      }
    }
    return new SimpleHttpResponse(""+done);
    }
View Full Code Here

   
    public SimpleHttpResponse getLastIdentifiedElement(final HttpRequest request) {
      Session session = request.session();
    String val = session.getVariable("__sahi__lastIdentifiedElement");
    session.setVariable("__sahi__lastIdentifiedElement", null);
    return new SimpleHttpResponse(val == null ? "" : val);
  }
View Full Code Here

    session.setIsRecording(false);
    session.setIsPlaying(true);     
    }
   
    public SimpleHttpResponse isRecording(final HttpRequest request) {
      return new SimpleHttpResponse("" + request.session().isRecording());
    }
View Full Code Here

    }

    public HttpResponse select(final HttpRequest request) {
        init(request);
        String s = select(driverName, jdbcurl, username, password, sql);
        return new SimpleHttpResponse(s);
    }
View Full Code Here

        String fileName = request.getParameter("file");
        if (Utils.isBlankOrNull(fileName)){
          fileName = Utils.concatPaths(Configuration.getScriptRoots()[0], "/tmp/" + session.id() + ".sah");
        }
    session.setVariable("CONTROLLER_recordFile", fileName);
    return new SimpleHttpResponse(fileName);
    }
View Full Code Here

public class LocalRequestProcessor {
    public HttpResponse getLocalResponse(String uri, HttpRequest requestFromBrowser) throws Exception {
        HttpResponse httpResponse = new NoCacheHttpResponse("");
        if (uri.indexOf("/dyn/pro/") != -1) {
//          httpResponse = handleDyn(uri, requestFromBrowser, httpResponse, true);
          httpResponse = new SimpleHttpResponse("This feature is available only in Sahi Pro");
        } else if (uri.indexOf("/dyn/") != -1) {
            httpResponse = handleDyn(uri, requestFromBrowser, httpResponse, false);
        } else if (uri.indexOf("/scripts/") != -1) {
            String fileName = URLParser.scriptFileNamefromURI(
                    requestFromBrowser.uri(), "/scripts/");
View Full Code Here

                    } else {
                        processAsProxy(requestFromBrowser);
                    }
                }
            } else {
                sendResponseToBrowser(new SimpleHttpResponse(""));
            }
            if (isKeepAlive() && !client.isClosed()) {
                new Thread(new ProxyProcessor(client)).start();
            }
        } catch (SSLHandshakeException ssle) {
View Full Code Here

TOP

Related Classes of net.sf.sahi.response.SimpleHttpResponse

Copyright © 2018 www.massapicom. 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.