61
61
* @author Sam Brannen
62
62
* @since 20.02.2004
63
63
*/
64
- public class QuartzSupportTests {
64
+ class QuartzSupportTests {
65
65
66
66
@ Test
67
- public void schedulerFactoryBeanWithApplicationContext () throws Exception {
67
+ void schedulerFactoryBeanWithApplicationContext () throws Exception {
68
68
TestBean tb = new TestBean ("tb" , 99 );
69
69
StaticApplicationContext ac = new StaticApplicationContext ();
70
70
@@ -101,7 +101,7 @@ protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String sc
101
101
102
102
@ Test
103
103
@ EnabledForTestGroups (LONG_RUNNING )
104
- public void schedulerWithTaskExecutor () throws Exception {
104
+ void schedulerWithTaskExecutor () throws Exception {
105
105
CountingTaskExecutor taskExecutor = new CountingTaskExecutor ();
106
106
DummyJob .count = 0 ;
107
107
@@ -134,15 +134,15 @@ public void schedulerWithTaskExecutor() throws Exception {
134
134
135
135
@ Test
136
136
@ SuppressWarnings ({ "unchecked" , "rawtypes" })
137
- public void jobDetailWithRunnableInsteadOfJob () {
137
+ void jobDetailWithRunnableInsteadOfJob () {
138
138
JobDetailImpl jobDetail = new JobDetailImpl ();
139
139
assertThatIllegalArgumentException ().isThrownBy (() ->
140
140
jobDetail .setJobClass ((Class ) DummyRunnable .class ));
141
141
}
142
142
143
143
@ Test
144
144
@ EnabledForTestGroups (LONG_RUNNING )
145
- public void schedulerWithQuartzJobBean () throws Exception {
145
+ void schedulerWithQuartzJobBean () throws Exception {
146
146
DummyJob .param = 0 ;
147
147
DummyJob .count = 0 ;
148
148
@@ -175,7 +175,7 @@ public void schedulerWithQuartzJobBean() throws Exception {
175
175
176
176
@ Test
177
177
@ EnabledForTestGroups (LONG_RUNNING )
178
- public void schedulerWithSpringBeanJobFactory () throws Exception {
178
+ void schedulerWithSpringBeanJobFactory () throws Exception {
179
179
DummyJob .param = 0 ;
180
180
DummyJob .count = 0 ;
181
181
@@ -210,7 +210,7 @@ public void schedulerWithSpringBeanJobFactory() throws Exception {
210
210
211
211
@ Test
212
212
@ EnabledForTestGroups (LONG_RUNNING )
213
- public void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored () throws Exception {
213
+ void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored () throws Exception {
214
214
DummyJob .param = 0 ;
215
215
DummyJob .count = 0 ;
216
216
@@ -246,7 +246,7 @@ public void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws
246
246
247
247
@ Test
248
248
@ EnabledForTestGroups (LONG_RUNNING )
249
- public void schedulerWithSpringBeanJobFactoryAndQuartzJobBean () throws Exception {
249
+ void schedulerWithSpringBeanJobFactoryAndQuartzJobBean () throws Exception {
250
250
DummyJobBean .param = 0 ;
251
251
DummyJobBean .count = 0 ;
252
252
@@ -280,7 +280,7 @@ public void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception
280
280
281
281
@ Test
282
282
@ EnabledForTestGroups (LONG_RUNNING )
283
- public void schedulerWithSpringBeanJobFactoryAndJobSchedulingData () throws Exception {
283
+ void schedulerWithSpringBeanJobFactoryAndJobSchedulingData () throws Exception {
284
284
DummyJob .param = 0 ;
285
285
DummyJob .count = 0 ;
286
286
@@ -298,7 +298,7 @@ public void schedulerWithSpringBeanJobFactoryAndJobSchedulingData() throws Excep
298
298
}
299
299
300
300
@ Test // SPR-772
301
- public void multipleSchedulers () throws Exception {
301
+ void multipleSchedulers () throws Exception {
302
302
try (ClassPathXmlApplicationContext ctx = context ("multipleSchedulers.xml" )) {
303
303
Scheduler scheduler1 = (Scheduler ) ctx .getBean ("scheduler1" );
304
304
Scheduler scheduler2 = (Scheduler ) ctx .getBean ("scheduler2" );
@@ -309,7 +309,7 @@ public void multipleSchedulers() throws Exception {
309
309
}
310
310
311
311
@ Test // SPR-16884
312
- public void multipleSchedulersWithQuartzProperties () throws Exception {
312
+ void multipleSchedulersWithQuartzProperties () throws Exception {
313
313
try (ClassPathXmlApplicationContext ctx = context ("multipleSchedulersWithQuartzProperties.xml" )) {
314
314
Scheduler scheduler1 = (Scheduler ) ctx .getBean ("scheduler1" );
315
315
Scheduler scheduler2 = (Scheduler ) ctx .getBean ("scheduler2" );
@@ -321,12 +321,13 @@ public void multipleSchedulersWithQuartzProperties() throws Exception {
321
321
322
322
@ Test
323
323
@ EnabledForTestGroups (LONG_RUNNING )
324
- public void twoAnonymousMethodInvokingJobDetailFactoryBeans () throws Exception {
325
- Thread .sleep (3000 );
324
+ void twoAnonymousMethodInvokingJobDetailFactoryBeans () throws Exception {
326
325
try (ClassPathXmlApplicationContext ctx = context ("multipleAnonymousMethodInvokingJobDetailFB.xml" )) {
327
326
QuartzTestBean exportService = (QuartzTestBean ) ctx .getBean ("exportService" );
328
327
QuartzTestBean importService = (QuartzTestBean ) ctx .getBean ("importService" );
329
328
329
+ Thread .sleep (400 );
330
+
330
331
assertThat (exportService .getImportCount ()).as ("doImport called exportService" ).isEqualTo (0 );
331
332
assertThat (exportService .getExportCount ()).as ("doExport not called on exportService" ).isEqualTo (2 );
332
333
assertThat (importService .getImportCount ()).as ("doImport not called on importService" ).isEqualTo (2 );
@@ -336,12 +337,13 @@ public void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
336
337
337
338
@ Test
338
339
@ EnabledForTestGroups (LONG_RUNNING )
339
- public void schedulerAccessorBean () throws Exception {
340
- Thread .sleep (3000 );
340
+ void schedulerAccessorBean () throws Exception {
341
341
try (ClassPathXmlApplicationContext ctx = context ("schedulerAccessorBean.xml" )) {
342
342
QuartzTestBean exportService = (QuartzTestBean ) ctx .getBean ("exportService" );
343
343
QuartzTestBean importService = (QuartzTestBean ) ctx .getBean ("importService" );
344
344
345
+ Thread .sleep (400 );
346
+
345
347
assertThat (exportService .getImportCount ()).as ("doImport called exportService" ).isEqualTo (0 );
346
348
assertThat (exportService .getExportCount ()).as ("doExport not called on exportService" ).isEqualTo (2 );
347
349
assertThat (importService .getImportCount ()).as ("doImport not called on importService" ).isEqualTo (2 );
@@ -351,7 +353,7 @@ public void schedulerAccessorBean() throws Exception {
351
353
352
354
@ Test
353
355
@ SuppressWarnings ("resource" )
354
- public void schedulerAutoStartsOnContextRefreshedEventByDefault () throws Exception {
356
+ void schedulerAutoStartsOnContextRefreshedEventByDefault () throws Exception {
355
357
StaticApplicationContext context = new StaticApplicationContext ();
356
358
context .registerBeanDefinition ("scheduler" , new RootBeanDefinition (SchedulerFactoryBean .class ));
357
359
Scheduler bean = context .getBean ("scheduler" , Scheduler .class );
@@ -362,7 +364,7 @@ public void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Excepti
362
364
363
365
@ Test
364
366
@ SuppressWarnings ("resource" )
365
- public void schedulerAutoStartupFalse () throws Exception {
367
+ void schedulerAutoStartupFalse () throws Exception {
366
368
StaticApplicationContext context = new StaticApplicationContext ();
367
369
BeanDefinition beanDefinition = BeanDefinitionBuilder .genericBeanDefinition (SchedulerFactoryBean .class )
368
370
.addPropertyValue ("autoStartup" , false ).getBeanDefinition ();
@@ -374,7 +376,7 @@ public void schedulerAutoStartupFalse() throws Exception {
374
376
}
375
377
376
378
@ Test
377
- public void schedulerRepositoryExposure () throws Exception {
379
+ void schedulerRepositoryExposure () throws Exception {
378
380
try (ClassPathXmlApplicationContext ctx = context ("schedulerRepositoryExposure.xml" )) {
379
381
assertThat (ctx .getBean ("scheduler" )).isSameAs (SchedulerRepository .getInstance ().lookup ("myScheduler" ));
380
382
}
@@ -385,7 +387,7 @@ public void schedulerRepositoryExposure() throws Exception {
385
387
* TODO: Against Quartz 2.2, this test's job doesn't actually execute anymore...
386
388
*/
387
389
@ Test
388
- public void schedulerWithHsqlDataSource () throws Exception {
390
+ void schedulerWithHsqlDataSource () throws Exception {
389
391
DummyJob .param = 0 ;
390
392
DummyJob .count = 0 ;
391
393
@@ -401,13 +403,14 @@ public void schedulerWithHsqlDataSource() throws Exception {
401
403
}
402
404
403
405
@ Test
404
- public void schedulerFactoryBeanWithCustomJobStore () throws Exception {
406
+ @ SuppressWarnings ("resource" )
407
+ void schedulerFactoryBeanWithCustomJobStore () throws Exception {
405
408
StaticApplicationContext context = new StaticApplicationContext ();
406
409
407
- final String dbName = "mydb" ;
408
- final EmbeddedDatabase database = new EmbeddedDatabaseBuilder ().setName (dbName ).build ();
410
+ String dbName = "mydb" ;
411
+ EmbeddedDatabase database = new EmbeddedDatabaseBuilder ().setName (dbName ).build ();
409
412
410
- final Properties properties = new Properties ();
413
+ Properties properties = new Properties ();
411
414
properties .setProperty ("org.quartz.jobStore.class" , JobStoreTX .class .getName ());
412
415
properties .setProperty ("org.quartz.jobStore.dataSource" , dbName );
413
416
@@ -418,17 +421,17 @@ public void schedulerFactoryBeanWithCustomJobStore() throws Exception {
418
421
.getBeanDefinition ();
419
422
context .registerBeanDefinition ("scheduler" , beanDefinition );
420
423
421
- Scheduler bean = context .getBean ("scheduler" , Scheduler .class );
424
+ Scheduler scheduler = context .getBean (Scheduler .class );
422
425
423
- assertThat (bean .getMetaData ().getJobStoreClass ()).isEqualTo (JobStoreTX .class );
426
+ assertThat (scheduler .getMetaData ().getJobStoreClass ()).isEqualTo (JobStoreTX .class );
424
427
}
425
428
426
429
private ClassPathXmlApplicationContext context (String path ) {
427
430
return new ClassPathXmlApplicationContext (path , getClass ());
428
431
}
429
432
430
433
431
- public static class CountingTaskExecutor implements TaskExecutor {
434
+ private static class CountingTaskExecutor implements TaskExecutor {
432
435
433
436
private int count ;
434
437
@@ -440,12 +443,14 @@ public void execute(Runnable task) {
440
443
}
441
444
442
445
443
- public static class DummyJob implements Job {
446
+ private static class DummyJob implements Job {
444
447
445
448
private static int param ;
446
449
447
450
private static int count ;
448
451
452
+ @ SuppressWarnings ("unused" )
453
+ // Must be public
449
454
public void setParam (int value ) {
450
455
if (param > 0 ) {
451
456
throw new IllegalStateException ("Param already set" );
@@ -460,12 +465,13 @@ public synchronized void execute(JobExecutionContext jobExecutionContext) throws
460
465
}
461
466
462
467
463
- public static class DummyJobBean extends QuartzJobBean {
468
+ private static class DummyJobBean extends QuartzJobBean {
464
469
465
470
private static int param ;
466
471
467
472
private static int count ;
468
473
474
+ @ SuppressWarnings ("unused" )
469
475
public void setParam (int value ) {
470
476
if (param > 0 ) {
471
477
throw new IllegalStateException ("Param already set" );
@@ -480,7 +486,7 @@ protected synchronized void executeInternal(JobExecutionContext jobExecutionCont
480
486
}
481
487
482
488
483
- public static class DummyRunnable implements Runnable {
489
+ private static class DummyRunnable implements Runnable {
484
490
485
491
@ Override
486
492
public void run () {
0 commit comments