@@ -0,0 +1,3250 @@
+package org.mifos.framework.components.batchjobs;%0A%0Aimport java.sql.Timestamp;%0Aimport java.util.Date;%0A%0Aimport junit.framework.Assert;%0A%0Aimport org.hibernate.Query;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mifos.framework.MifosIntegrationTestCase;%0Aimport org.mifos.framework.components.batchjobs.business.Task;%0Aimport org.mifos.framework.components.batchjobs.helpers.SavingsIntCalcTask;%0Aimport org.mifos.framework.components.batchjobs.helpers.SavingsIntPostingTask;%0Aimport org.mifos.framework.components.batchjobs.helpers.TaskStatus;%0Aimport org.mifos.framework.components.batchjobs.persistence.TaskPersistence;%0Aimport org.mifos.framework.exceptions.PersistenceException;%0Aimport org.mifos.framework.hibernate.helper.StaticHibernateUtil;%0Aimport org.mifos.framework.util.helpers.TestObjectFactory;%0A%0Apublic class TaskHelperIntegrationTest extends MifosIntegrationTestCase %7B%0A%0A    public TaskHelperIntegrationTest() throws Exception %7B%0A        super();%0A    %7D%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A    %7D%0A%0A    @After%0A    public void tearDown() throws Exception %7B%0A        Query query = StaticHibernateUtil.getSessionTL().createQuery(%22from %22 + Task.class.getName());%0A        for (Object task : query.list()) %7B%0A            TestObjectFactory.removeObject((Task) task);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testIncompleteTaskHandling() throws PersistenceException %7B%0A        MifosScheduler mifosScheduler = new MifosScheduler();%0A%0A        Task task1 = new Task();%0A        task1.setDescription(SchedulerConstants.FINISHED_SUCCESSFULLY);%0A        task1.setStartTime(new Timestamp(System.currentTimeMillis() - 86500000)); // over a day ago%0A        task1.setEndTime(new Timestamp(System.currentTimeMillis() - 86500000));%0A        task1.setStatus(TaskStatus.COMPLETE.getValue());%0A        task1.setTask(SavingsIntPostingTask.class.getSimpleName());%0A        TaskPersistence p = new TaskPersistence();%0A        p.saveAndCommitTask(task1);%0A%0A        Task task2 = new Task();%0A        task2.setDescription(SchedulerConstants.FINISHED_SUCCESSFULLY);%0A        task2.setStartTime(new Timestamp(System.currentTimeMillis() - 175000000)); // over two days ago%0A        task2.setEndTime(new Timestamp(System.currentTimeMillis() - 175000000));%0A        task2.setStatus(TaskStatus.COMPLETE.getValue());%0A        task2.setTask(SavingsIntCalcTask.class.getSimpleName());%0A        p = new TaskPersistence();%0A        p.saveAndCommitTask(task2);%0A%0A        StaticHibernateUtil.closeSession();%0A%0A        SavingsIntPostingTask savingsIntPostingTask = new SavingsIntPostingTask();%0A        savingsIntPostingTask.name = SavingsIntPostingTask.class.getSimpleName();%0A        mifosScheduler.schedule(savingsIntPostingTask, new Date(System.currentTimeMillis() + 3600000), 86400000);%0A%0A        SavingsIntCalcTask savingsIntCalcTask = new SavingsIntCalcTask();%0A        savingsIntCalcTask.name = SavingsIntCalcTask.class.getSimpleName();%0A        mifosScheduler.schedule(savingsIntCalcTask, new Date(System.currentTimeMillis() + 3600000), 86400000);%0A%0A        mifosScheduler.runAllTasks();%0A%0A        Query query = StaticHibernateUtil.getSessionTL().createQuery(%22from %22 + Task.class.getName());%0A        Assert.assertEquals(5, query.list().size());%0A    %7D%0A%0A%7D%0A

Test showing malfunction in executeTask() in TaskHelper.class