Package net.ex337.scriptus.model

Examples of net.ex337.scriptus.model.TransportAccessToken


  }

  public void test_getHttp() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "getHttp.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("slept correctly", r instanceof Get);

    p.save();

    Get g = (Get) r;
   
    g.visit(new ScriptusFacade(datastore, c, m, conf), p);
   
    p = datastore.getProcess(p.getPid());
   
    assertTrue("got content", p.getState() instanceof String);
   
    String content = (String) p.getState();
   
    assertTrue("content ok", content.contains("User-agent: *"));
   
  }
 
View Full Code Here


  }


  public void test_evalGet() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "evalget.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("slept correctly", r instanceof Get);

    p.save();

    Get g = (Get) r;
   
    g.visit(new ScriptusFacade(datastore, c, m, conf), p);
   
    p = datastore.getProcess(p.getPid());
   
    assertTrue("got content", p.getState() instanceof String);
   
    r = p.call();
   
    assertTrue("said correctly", r instanceof Say);
   
    assertTrue("contains fn def", ((Say)r).getMsg().contains("return new Date().clearTime();"));
  }
View Full Code Here

  }


  public void test_evalGetBug() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "evalgetBUG.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("slept correctly", r instanceof Get);

    p.save();

    Get g = (Get) r;
   
    g.visit(new ScriptusFacade(datastore, c, m, conf), p);
   
    p = datastore.getProcess(p.getPid());
   
    assertTrue("got content", p.getState() instanceof String);
   
    r = p.call();
   
    assertTrue("said correctly", r instanceof Say);
   
    assertTrue("contains fn def", ((Say)r).getMsg().contains("return new Date().clearTime();"));
  }
View Full Code Here

  }

 
  public void test_getHttps() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "getHttps.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("slept correctly", r instanceof Get);

    p.save();

    Get g = (Get) r;
   
    g.visit(new ScriptusFacade(datastore, c, m, conf), p);
   
    p = datastore.getProcess(p.getPid());
   
    assertTrue("got content", p.getState() instanceof String);
   
    String content = (String) p.getState();
   
    assertTrue("content ok", content.contains("User-agent: *"));

  }
 
View Full Code Here

  }

  public void test_sleepDate() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "sleepDate.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("slept correctly", r instanceof Sleep);

  }
View Full Code Here

  }

  public void test_sleepDateObject() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "sleepDateObject.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("slept correctly", r instanceof Sleep);

  }
View Full Code Here

  }

  public void test_sleepDuration() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "sleepDuration.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("slept correctly", r instanceof Sleep);

    Sleep s = (Sleep)r;
   
View Full Code Here

   
  }

  public void test_sleepBadDuration() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "sleepBadDuration.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("error", r instanceof ErrorTermination);

   
  }
View Full Code Here

   
  }

  public void test_sleepBadDate() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "sleepBadDate.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Forked correctly", r instanceof ErrorTermination);

  }
View Full Code Here

  /**
   * tests for when child process finished before wait() is called
   */
  public void test_wait() throws IOException {

    final ScriptProcess p = datastore.newProcess(TEST_USER, "wait.js", false, "", "owner", TransportType.Dummy);
   
    p.save();
   
    ScriptAction r = p.call();

    assertTrue("Forked correctly", r instanceof Fork);
   
    final ThreadLocal<Boolean> executedParentPostFork = new ThreadLocal<Boolean>();
    final ThreadLocal<Boolean> executedParentPostWait = new ThreadLocal<Boolean>();
    final ThreadLocal<Boolean> executedChild = new ThreadLocal<Boolean>();
   
    ScriptusFacade testFacade = new ScriptusFacade(datastore, c, m, conf) {
     
      private UUID childPid;

      @Override
      public void execute(UUID pid) {
       
        if( ! pid.equals(p.getPid())) {
         
          executedChild.set(Boolean.TRUE);
         
          childPid = pid;
         
          super.execute(pid);

          return;
        }
       
        if(pid.equals(p.getPid())) {

          if(Boolean.TRUE.equals(executedParentPostFork.get())) {
           
            executedParentPostWait.set(Boolean.TRUE);
           
            ScriptAction enfin = datastore.getProcess(pid).call();
           
            assertTrue("script finished", enfin instanceof Termination);
            assertEquals("script result OK", "waitedfoo"+childPid, ((Termination)enfin).getResult());
           
          } else {

            executedParentPostFork.set(Boolean.TRUE);
           
            ScriptProcess p2 = datastore.getProcess(pid);
           
            ScriptAction r2 = p2.call();
           
            p2.save();

            assertTrue("Waited correctly", r2 instanceof Wait);

            //pause thread until child has termination
           
View Full Code Here

TOP

Related Classes of net.ex337.scriptus.model.TransportAccessToken

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.