File tree 3 files changed +27
-5
lines changed
quartz-manager-parent/quartz-manager-web-showcase/src
main/java/it/fabioformosa/quartzmanager/jobs/tests
test/java/it/fabioformosa
3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import it .fabioformosa .quartzmanager .api .jobs .AbstractQuartzManagerJob ;
4
4
import it .fabioformosa .quartzmanager .api .jobs .entities .LogRecord ;
5
+ import lombok .NoArgsConstructor ;
5
6
import lombok .extern .slf4j .Slf4j ;
6
7
import org .quartz .JobExecutionContext ;
7
- import org .slf4j .Logger ;
8
- import org .slf4j .LoggerFactory ;
9
8
10
9
/**
11
10
* This job can be used to test the misfire policy. It pretends to be a long
15
14
*
16
15
*/
17
16
@ Slf4j
17
+ @ NoArgsConstructor
18
18
public class MisfireTestJob extends AbstractQuartzManagerJob {
19
19
20
- private Logger log = LoggerFactory .getLogger (MisfireTestJob .class );
20
+ private long sleepPeriodInMs = 10 * 1000L ;
21
+
22
+ public MisfireTestJob (long sleepPeriodInMs ) {
23
+ this .sleepPeriodInMs = sleepPeriodInMs ;
24
+ }
21
25
22
26
@ Override
23
27
public LogRecord doIt (JobExecutionContext jobExecutionContext ) {
24
28
try {
25
29
log .info ("{} is going to sleep..." , Thread .currentThread ().getName ());
26
30
27
- Thread .sleep (10 * 1000L );
31
+ Thread .sleep (sleepPeriodInMs );
28
32
29
33
log .info ("{} woke up!" , Thread .currentThread ().getName ());
30
34
} catch (InterruptedException e ) {
Original file line number Diff line number Diff line change 6
6
7
7
@ SpringBootTest (classes = QuartManagerDemoApplication .class )
8
8
@ WebAppConfiguration
9
- class QuartManagerApplicationTests {
9
+ public class QuartManagerApplicationTests {
10
10
11
11
@ Test
12
12
void contextLoads () {
Original file line number Diff line number Diff line change
1
+ package it .fabioformosa .quartzmanager .jobs .tests ;
2
+
3
+ import it .fabioformosa .quartzmanager .api .jobs .entities .LogRecord ;
4
+ import org .assertj .core .api .Assertions ;
5
+ import org .junit .jupiter .api .Test ;
6
+
7
+ class MisfireTestJobTest {
8
+
9
+ @ Test
10
+ void givenAMisfireTestJob_whenIsExecuted_shoulReturnALogRecord () {
11
+ MisfireTestJob misfireTestJob = new MisfireTestJob (10L );
12
+ LogRecord logRecord = misfireTestJob .doIt (null );
13
+ Assertions .assertThat (logRecord .getMessage ()).isEqualTo ("Hello!" );
14
+ }
15
+
16
+ }
17
+
18
+
You can’t perform that action at this time.
0 commit comments