}
public void test_scheduleTask() throws IOException {
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;
for(ScheduledScriptAction t : actions){
if(t.equals(w)) {