Search in sources :

Example 1 with HelloWorldTask

use of org.openmrs.scheduler.tasks.HelloWorldTask in project openmrs-core by openmrs.

the class DaemonTest method executeScheduledTask_shouldNotBeCalledFromOtherMethodsOtherThanTimerSchedulerTask.

/**
 * @see Daemon#executeScheduledTask(Task)
 */
@Test
public void executeScheduledTask_shouldNotBeCalledFromOtherMethodsOtherThanTimerSchedulerTask() throws Throwable {
    try {
        Daemon.executeScheduledTask(new HelloWorldTask());
        Assert.fail("Should not be here, an exception should have been thrown in the line above");
    } catch (APIException e) {
        Assert.assertTrue(e.getMessage().startsWith(Context.getMessageSourceService().getMessage("Scheduler.timer.task.only", new Object[] { this.getClass().getName() }, null)));
    }
}
Also used : HelloWorldTask(org.openmrs.scheduler.tasks.HelloWorldTask) APIException(org.openmrs.api.APIException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Test (org.junit.Test)1 APIException (org.openmrs.api.APIException)1 HelloWorldTask (org.openmrs.scheduler.tasks.HelloWorldTask)1 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)1