Package net.ex337.scriptus.model

Examples of net.ex337.scriptus.model.TransportAccessToken


//      System.out.println(ss.exec(cx, globalScope));
     
//      System.out.println(cx.evaluateString(globalScope, "scriptus.foo();", "<test>", 1, null));
     
    } catch (Exception e) {
      throw new ScriptusRuntimeException(e);
    } finally {
      Context.exit();
    }
   
  }
View Full Code Here


   
    String c = "tweet:"+Math.abs(r.nextInt());
        String f = "from:"+Math.abs(r.nextInt());
        String u = "user:"+Math.abs(r.nextInt());
   
    MessageCorrelation m = new MessageCorrelation(UUID.randomUUID(), f, c, System.currentTimeMillis(), TransportType.Dummy, u);
   
    datastore.registerMessageCorrelation(m);

    Set<MessageCorrelation> cc = datastore.getMessageCorrelations(c, f, u, TransportType.Dummy);
   
    assertTrue("correct pid returned", cc.contains(m));
   
    datastore.unregisterMessageCorrelation(m);
   
    assertTrue("nothing left", ! datastore.getMessageCorrelations(c, f, u, TransportType.Dummy).contains(m));

    //listen({to:"user", messageId:"foo"})
        MessageCorrelation both      = new MessageCorrelation(UUID.randomUUID(), f,    c,    System.currentTimeMillis(), TransportType.Dummy, u);
        //listen({to:"user"})
        MessageCorrelation byuser    = new MessageCorrelation(UUID.randomUUID(), f,    null, System.currentTimeMillis(), TransportType.Dummy, u);
        //listen({messageId:"foo"})
        MessageCorrelation messageId = new MessageCorrelation(UUID.randomUUID(), null, c,    System.currentTimeMillis(), TransportType.Dummy, u);
        //listen()
        MessageCorrelation byNull    = new MessageCorrelation(UUID.randomUUID(), null, null, System.currentTimeMillis(), TransportType.Dummy, u);

        MessageCorrelation byNullOtheruser    = new MessageCorrelation(UUID.randomUUID(), null, null, System.currentTimeMillis(), TransportType.Dummy, u+r.nextInt());

        datastore.registerMessageCorrelation(both);
        datastore.registerMessageCorrelation(byuser);
        datastore.registerMessageCorrelation(messageId);
        datastore.registerMessageCorrelation(byNull);
View Full Code Here

     
        String tt = UUID.randomUUID().toString();
        String u1 = UUID.randomUUID().toString();
        String u2 = UUID.randomUUID().toString();
     
      MessageCorrelation d1 = new MessageCorrelation(
              UUID.randomUUID(),
              "from1", "mid1", System.currentTimeMillis(), TransportType.Dummy, u1);

      datastore.registerMessageCorrelation(d1);

        MessageCorrelation d2 = new MessageCorrelation(
                UUID.randomUUID(),
                "from2", "mid2", System.currentTimeMillis(), TransportType.Dummy, u2);

        datastore.registerMessageCorrelation(d2);
       
        MessageCorrelation d3 = new MessageCorrelation(
                UUID.randomUUID(),
                "from3", "mid3", System.currentTimeMillis(), TransportType.Dummy, u2);

        datastore.registerMessageCorrelation(d3);
       
View Full Code Here

     
      List<ProcessListItem> i = datastore.getProcessesForUser(uid);
     
      assertEquals("good size", 1, i.size());
     
      ProcessListItem l = i.get(0);
     
      assertEquals("good pid", p.getPid(), l.getPid());
      assertEquals("uid", uid, l.getUid());
  }
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

    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
           
            r2.visit(this, p2);

          }

        }
       
View Full Code Here

    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

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.