Package net.ex337.scriptus.model.scheduler

Examples of net.ex337.scriptus.model.scheduler.Wake


   
    ScriptAction r = p.call();
   
    assertTrue("Correct result", r instanceof NormalTermination);
   
    NormalTermination n = (NormalTermination) r;

    r.visit(new ScriptusFacade(datastore, c, m, conf), p); //sould say

    assertEquals("Correct result", "result", n.getResult());
   
  }
View Full Code Here


    ScriptusDatastore datastore = (ScriptusDatastore) appContext.getBean("datastore");
   
    Calendar then = Calendar.getInstance();
    then.add(Calendar.HOUR, 3);
   
    Wake w = new Wake(UUID.randomUUID(), 1234, then.getTimeInMillis());
   
    datastore.saveScheduledTask(w);
   
    List<ScheduledScriptAction> actions = datastore.getScheduledTasks(Calendar.getInstance());
   
    assertFalse("doesnt contain task in future", actions.contains(w));
   
    actions = datastore.getScheduledTasks(then);
   
    assertTrue("contains task in future",  actions.contains(w));
   
    boolean found = false;
   
    Wake neww = null;
   
    for(ScheduledScriptAction t : actions){
      if(t.equals(w)) {
        neww = (Wake) t;
        found = true;
        break;
      }
    }
   
    assertTrue("retrieved task", found);
   
    then.add(Calendar.HOUR, 1);
   
    actions = datastore.getScheduledTasks(then);
   
    assertTrue("list not empty",  ! actions.isEmpty());
   
    found = false;
   
    for(ScheduledScriptAction t : actions){
      if(t.equals(w)) {
        found = true;
        break;
      }
    }
   
    datastore.deleteScheduledTask(neww.getPid(), neww.getNonce());

    actions = datastore.getScheduledTasks(then);
   
    found = false;
   
View Full Code Here

  @Override
  public void visit(final ScriptusFacade scriptus, final ScriptProcess process) {
   
        scriptus.updateProcessState(process.getPid(), this);
       
      scriptus.scheduleTask(new Wake(process.getPid(), nonce, until.getTimeInMillis()));
   
   
  }
View Full Code Here

  @Override
  public void visit(final ScriptusFacade scriptus, final ScriptProcess process) {

    scriptus.updateProcessState(process.getPid(), this);

    scriptus.scheduleTask(new Wake(process.getPid(), nonce, timeout.getTimeInMillis()));

    String messageId = scriptus.send(process.getUserId(), process.getTransport(), getWho(), getMsg());
   
        scriptus.registerMessageCorrelation(new MessageCorrelation(process.getPid(), getWho(), messageId, System.currentTimeMillis(), process.getTransport(), process.getUserId()));
   
View Full Code Here

    @Override
    @Transactional(readOnly = false)
    public void saveScheduledTask(ScheduledScriptAction task) {
        if (task instanceof Wake) {
            Wake w = (Wake) task;

            ScheduledScriptActionDAO d = new ScheduledScriptActionDAO();
            d.action = "wake";
            d.nonce = w.getNonce();
            d.pid = w.getPid().toString();
            d.when = task.getWhen();

            em.persist(d);

        } else {
View Full Code Here

    private ScheduledScriptAction toScheduledAction(ScheduledScriptActionDAO dao) {
        ScheduledScriptAction r = null;

        if (dao.action.equalsIgnoreCase("wake")) {
            Wake w = new Wake(UUID.fromString(dao.pid), dao.nonce, dao.when);
            r = w;
        } else {
            throw new ScriptusRuntimeException("unkown type of action " + dao.action);
        }
View Full Code Here

  @Override
  public void visit(final ScriptusFacade scriptus, final ScriptProcess process) {

    scriptus.updateProcessState(process.getPid(), this);

    scriptus.scheduleTask(new Wake(process.getPid(), nonce, timeout.getTimeInMillis()));
   
    //who and messageId can both be null
        scriptus.registerMessageCorrelation(new MessageCorrelation(process.getPid(), getWho(), getMessageId(), System.currentTimeMillis(), process.getTransport(), process.getUserId()));

   
View Full Code Here

    }
 
   
  public void test_dummyTransport() throws IOException {
     
      DummyTransport dummy = (DummyTransport) appContext.getBean("dummyTransport");
     
        assertEquals("straight text replacement", "ACK", dummy.getResponse("SYN"));
        assertEquals("regexp replacement", "CAT", dummy.getResponse("DIG"));
        assertEquals("variable replacement", "I have 1024 dogs", dummy.getResponse("I have 1024 cats"));
     
  }
View Full Code Here

        assertEquals("1 correlation", 1, ccc.size());

        assertEquals("correct pid registered", ccc.iterator().next().getPid(), ccc.iterator().next().getPid());
        assertEquals("correct user registered", "ianso", ccc.iterator().next().getFrom());

        Tweet t = new Tweet(123, "reply", "ianso", Long.parseLong(StringUtils.remove(tweetId.get(), "tweet:")));

        clientMock.getMentions().add(t);
       
        //should find & process the reply
        twitter.checkMessages();
View Full Code Here

        assertEquals("1 correlation", 1, ccc.size());

        assertEquals("correct pid registered", ccc.iterator().next().getPid(), ccc.iterator().next().getPid());
        assertEquals("correct user registered", null, ccc.iterator().next().getFrom());

        Tweet t = new Tweet(123, "reply", "ianso");

        clientMock.getMentions().add(t);
       
        //should find & process the reply
        twitter.checkMessages();
View Full Code Here

TOP

Related Classes of net.ex337.scriptus.model.scheduler.Wake

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.