Package net.ex337.scriptus.model.api.functions

Examples of net.ex337.scriptus.model.api.functions.Get


    final ScriptProcess p = datastore.newProcess(TEST_USER, "wait2.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>();
    final ThreadLocal<Boolean> executedChildPostSleep = 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())) {
          //executing child

          if(Boolean.TRUE.equals(executedChild.get())) {
           
            executedChildPostSleep.set(Boolean.TRUE);
           
            ScriptProcess p2 = datastore.getProcess(pid);
           
            ScriptAction r2 = p2.call();

            assertTrue("in child termination", r2 instanceof Termination);
           
            p2.save();
           
            r2.visit(this, p2);

          } else {
           
            executedChild.set(Boolean.TRUE);
           
            childPid = pid;
           
            ScriptProcess p2 = datastore.getProcess(pid);
           
            ScriptAction r2 = p2.call();

            p2.save();
           
            assertTrue("in child sleep", r2 instanceof Sleep);
           

          }
         
          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", "waitedfooslept"+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
           
            r2.visit(this, p2);
           
            //assert parent is still waiting
            //wake child and execute
            execute(childPid);
View Full Code Here


    final ScriptProcess p = datastore.newProcess(TEST_USER, "kill.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> executedParentPostKill = 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())) {
          //executing child
         
          executedChild.set(Boolean.TRUE);
         
          childPid = pid;
         
          super.execute(pid);

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

          //executing parent
         
          if(Boolean.TRUE.equals(executedParentPostFork.get())) {
           
            //post-kill
           
            executedParentPostKill.set(Boolean.TRUE);

          } else {
           
            //post-fork, pre-kill, pid

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

            assertTrue("Killed correctly", r2 instanceof Kill);
           
            r2.visit(this, p2);

            boolean caughtNotFoundExcepton = false;
           
            try {
              datastore.getProcess(childPid);
View Full Code Here

  public void test_ask() throws IOException {

    ScriptProcess p = datastore.newProcess(TEST_USER, "ask.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Asked correctly", r instanceof Ask);
    assertTrue("Asked correctly foo", ((Ask)r).getWho().equals("foo"));
   
    p.save();

    r.visit(new ScriptusFacade(datastore, c, m, conf), p);
   
  }
View Full Code Here

  public void test_defaultAsk() throws IOException {

    ScriptProcess p = datastore.newProcess(TEST_USER, "defaultAsk.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Asked correctly", r instanceof Ask);
    assertNull("Asked correctly owner", ((Ask)r).getWho());
   
    p.save();

    r.visit(new ScriptusFacade(datastore, c, m, conf), p);
   
  }
View Full Code Here

  public void test_askTimeout() throws IOException {

    ScriptProcess p = datastore.newProcess(TEST_USER, "askTimeout.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Asked correctly", r instanceof Ask);
    assertTrue("Asked correctly owner", ((Ask)r).getWho().equals("foo"));
   
    p.save();

    r.visit(new ScriptusFacade(datastore, c, m, conf), p);
   
  }
View Full Code Here

  public void test_say() throws IOException {

    ScriptProcess p = datastore.newProcess(TEST_USER, "say.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Said correctly", r instanceof Say);
    assertTrue("Said correctly to user", ((Say)r).getWho().equals("foo"));
    assertTrue("Said correctly message", ((Say)r).getMsg().equals("message"));
   
    p.save();
   
    r.visit(new ScriptusFacade(datastore, c, m, conf), p);
  }
View Full Code Here

  public void test_defaultSay() throws IOException {

    ScriptProcess p = datastore.newProcess(TEST_USER, "defaultSay.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Said correctly", r instanceof Say);
    assertNull("Said to owner correctly", ((Say)r).getWho());

  }
View Full Code Here

  public void test_listen() throws IOException {

    ScriptProcess p = datastore.newProcess(TEST_USER, "listen.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Listened correctly", r instanceof Listen);
    assertTrue("Listened correctly to", ((Listen)r).getWho().equals("foo"));
   
    p.save();
   
    r.visit(new ScriptusFacade(datastore, c, m, conf), p);
  }
View Full Code Here

  public void test_defaultListen() throws IOException {

    ScriptProcess p = datastore.newProcess(TEST_USER, "defaultListen.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Listened correctly", r instanceof Listen);
    assertNull("Listened correctly to", ((Listen)r).getWho());
   
    p.save();
   
    r.visit(new ScriptusFacade(datastore, c, m, conf), p);
  }
View Full Code Here

  public void test_evalBroken() throws IOException {
   
    ScriptProcess p = datastore.newProcess(TEST_USER, "evalBroken.js", false, "", "owner", TransportType.Dummy);
   
    ScriptAction r = p.call();
   
    assertTrue("Broken", r instanceof ErrorTermination);
  }
View Full Code Here

TOP

Related Classes of net.ex337.scriptus.model.api.functions.Get

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.