mirror of
https://github.com/fabioformosa/quartz-manager.git
synced 2025-12-31 22:53:16 +09:00
#62 added a missing test for the MisfireTestJob
This commit is contained in:
@@ -2,10 +2,9 @@ package it.fabioformosa.quartzmanager.jobs.tests;
|
||||
|
||||
import it.fabioformosa.quartzmanager.api.jobs.AbstractQuartzManagerJob;
|
||||
import it.fabioformosa.quartzmanager.api.jobs.entities.LogRecord;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This job can be used to test the misfire policy. It pretends to be a long
|
||||
@@ -15,16 +14,21 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor
|
||||
public class MisfireTestJob extends AbstractQuartzManagerJob {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(MisfireTestJob.class);
|
||||
private long sleepPeriodInMs = 10 * 1000L;
|
||||
|
||||
public MisfireTestJob(long sleepPeriodInMs) {
|
||||
this.sleepPeriodInMs = sleepPeriodInMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogRecord doIt(JobExecutionContext jobExecutionContext) {
|
||||
try {
|
||||
log.info("{} is going to sleep...", Thread.currentThread().getName());
|
||||
|
||||
Thread.sleep(10 * 1000L);
|
||||
Thread.sleep(sleepPeriodInMs);
|
||||
|
||||
log.info("{} woke up!", Thread.currentThread().getName());
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@SpringBootTest(classes = QuartManagerDemoApplication.class)
|
||||
@WebAppConfiguration
|
||||
class QuartManagerApplicationTests {
|
||||
public class QuartManagerApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package it.fabioformosa.quartzmanager.jobs.tests;
|
||||
|
||||
import it.fabioformosa.quartzmanager.api.jobs.entities.LogRecord;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class MisfireTestJobTest {
|
||||
|
||||
@Test
|
||||
void givenAMisfireTestJob_whenIsExecuted_shoulReturnALogRecord() {
|
||||
MisfireTestJob misfireTestJob = new MisfireTestJob(10L);
|
||||
LogRecord logRecord = misfireTestJob.doIt(null);
|
||||
Assertions.assertThat(logRecord.getMessage()).isEqualTo("Hello!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user