Skip to content

Commit 995aaa6

Browse files
committed
Polishing
1 parent 2c89ff9 commit 995aaa6

File tree

4 files changed

+41
-34
lines changed

4 files changed

+41
-34
lines changed

spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@
6161
* @author Sam Brannen
6262
* @since 20.02.2004
6363
*/
64-
public class QuartzSupportTests {
64+
class QuartzSupportTests {
6565

6666
@Test
67-
public void schedulerFactoryBeanWithApplicationContext() throws Exception {
67+
void schedulerFactoryBeanWithApplicationContext() throws Exception {
6868
TestBean tb = new TestBean("tb", 99);
6969
StaticApplicationContext ac = new StaticApplicationContext();
7070

@@ -101,7 +101,7 @@ protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String sc
101101

102102
@Test
103103
@EnabledForTestGroups(LONG_RUNNING)
104-
public void schedulerWithTaskExecutor() throws Exception {
104+
void schedulerWithTaskExecutor() throws Exception {
105105
CountingTaskExecutor taskExecutor = new CountingTaskExecutor();
106106
DummyJob.count = 0;
107107

@@ -134,15 +134,15 @@ public void schedulerWithTaskExecutor() throws Exception {
134134

135135
@Test
136136
@SuppressWarnings({ "unchecked", "rawtypes" })
137-
public void jobDetailWithRunnableInsteadOfJob() {
137+
void jobDetailWithRunnableInsteadOfJob() {
138138
JobDetailImpl jobDetail = new JobDetailImpl();
139139
assertThatIllegalArgumentException().isThrownBy(() ->
140140
jobDetail.setJobClass((Class) DummyRunnable.class));
141141
}
142142

143143
@Test
144144
@EnabledForTestGroups(LONG_RUNNING)
145-
public void schedulerWithQuartzJobBean() throws Exception {
145+
void schedulerWithQuartzJobBean() throws Exception {
146146
DummyJob.param = 0;
147147
DummyJob.count = 0;
148148

@@ -175,7 +175,7 @@ public void schedulerWithQuartzJobBean() throws Exception {
175175

176176
@Test
177177
@EnabledForTestGroups(LONG_RUNNING)
178-
public void schedulerWithSpringBeanJobFactory() throws Exception {
178+
void schedulerWithSpringBeanJobFactory() throws Exception {
179179
DummyJob.param = 0;
180180
DummyJob.count = 0;
181181

@@ -210,7 +210,7 @@ public void schedulerWithSpringBeanJobFactory() throws Exception {
210210

211211
@Test
212212
@EnabledForTestGroups(LONG_RUNNING)
213-
public void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws Exception {
213+
void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws Exception {
214214
DummyJob.param = 0;
215215
DummyJob.count = 0;
216216

@@ -246,7 +246,7 @@ public void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws
246246

247247
@Test
248248
@EnabledForTestGroups(LONG_RUNNING)
249-
public void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception {
249+
void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception {
250250
DummyJobBean.param = 0;
251251
DummyJobBean.count = 0;
252252

@@ -280,7 +280,7 @@ public void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception
280280

281281
@Test
282282
@EnabledForTestGroups(LONG_RUNNING)
283-
public void schedulerWithSpringBeanJobFactoryAndJobSchedulingData() throws Exception {
283+
void schedulerWithSpringBeanJobFactoryAndJobSchedulingData() throws Exception {
284284
DummyJob.param = 0;
285285
DummyJob.count = 0;
286286

@@ -298,7 +298,7 @@ public void schedulerWithSpringBeanJobFactoryAndJobSchedulingData() throws Excep
298298
}
299299

300300
@Test // SPR-772
301-
public void multipleSchedulers() throws Exception {
301+
void multipleSchedulers() throws Exception {
302302
try (ClassPathXmlApplicationContext ctx = context("multipleSchedulers.xml")) {
303303
Scheduler scheduler1 = (Scheduler) ctx.getBean("scheduler1");
304304
Scheduler scheduler2 = (Scheduler) ctx.getBean("scheduler2");
@@ -309,7 +309,7 @@ public void multipleSchedulers() throws Exception {
309309
}
310310

311311
@Test // SPR-16884
312-
public void multipleSchedulersWithQuartzProperties() throws Exception {
312+
void multipleSchedulersWithQuartzProperties() throws Exception {
313313
try (ClassPathXmlApplicationContext ctx = context("multipleSchedulersWithQuartzProperties.xml")) {
314314
Scheduler scheduler1 = (Scheduler) ctx.getBean("scheduler1");
315315
Scheduler scheduler2 = (Scheduler) ctx.getBean("scheduler2");
@@ -321,12 +321,13 @@ public void multipleSchedulersWithQuartzProperties() throws Exception {
321321

322322
@Test
323323
@EnabledForTestGroups(LONG_RUNNING)
324-
public void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
325-
Thread.sleep(3000);
324+
void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
326325
try (ClassPathXmlApplicationContext ctx = context("multipleAnonymousMethodInvokingJobDetailFB.xml")) {
327326
QuartzTestBean exportService = (QuartzTestBean) ctx.getBean("exportService");
328327
QuartzTestBean importService = (QuartzTestBean) ctx.getBean("importService");
329328

329+
Thread.sleep(400);
330+
330331
assertThat(exportService.getImportCount()).as("doImport called exportService").isEqualTo(0);
331332
assertThat(exportService.getExportCount()).as("doExport not called on exportService").isEqualTo(2);
332333
assertThat(importService.getImportCount()).as("doImport not called on importService").isEqualTo(2);
@@ -336,12 +337,13 @@ public void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
336337

337338
@Test
338339
@EnabledForTestGroups(LONG_RUNNING)
339-
public void schedulerAccessorBean() throws Exception {
340-
Thread.sleep(3000);
340+
void schedulerAccessorBean() throws Exception {
341341
try (ClassPathXmlApplicationContext ctx = context("schedulerAccessorBean.xml")) {
342342
QuartzTestBean exportService = (QuartzTestBean) ctx.getBean("exportService");
343343
QuartzTestBean importService = (QuartzTestBean) ctx.getBean("importService");
344344

345+
Thread.sleep(400);
346+
345347
assertThat(exportService.getImportCount()).as("doImport called exportService").isEqualTo(0);
346348
assertThat(exportService.getExportCount()).as("doExport not called on exportService").isEqualTo(2);
347349
assertThat(importService.getImportCount()).as("doImport not called on importService").isEqualTo(2);
@@ -351,7 +353,7 @@ public void schedulerAccessorBean() throws Exception {
351353

352354
@Test
353355
@SuppressWarnings("resource")
354-
public void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Exception {
356+
void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Exception {
355357
StaticApplicationContext context = new StaticApplicationContext();
356358
context.registerBeanDefinition("scheduler", new RootBeanDefinition(SchedulerFactoryBean.class));
357359
Scheduler bean = context.getBean("scheduler", Scheduler.class);
@@ -362,7 +364,7 @@ public void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Excepti
362364

363365
@Test
364366
@SuppressWarnings("resource")
365-
public void schedulerAutoStartupFalse() throws Exception {
367+
void schedulerAutoStartupFalse() throws Exception {
366368
StaticApplicationContext context = new StaticApplicationContext();
367369
BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(SchedulerFactoryBean.class)
368370
.addPropertyValue("autoStartup", false).getBeanDefinition();
@@ -374,7 +376,7 @@ public void schedulerAutoStartupFalse() throws Exception {
374376
}
375377

376378
@Test
377-
public void schedulerRepositoryExposure() throws Exception {
379+
void schedulerRepositoryExposure() throws Exception {
378380
try (ClassPathXmlApplicationContext ctx = context("schedulerRepositoryExposure.xml")) {
379381
assertThat(ctx.getBean("scheduler")).isSameAs(SchedulerRepository.getInstance().lookup("myScheduler"));
380382
}
@@ -385,7 +387,7 @@ public void schedulerRepositoryExposure() throws Exception {
385387
* TODO: Against Quartz 2.2, this test's job doesn't actually execute anymore...
386388
*/
387389
@Test
388-
public void schedulerWithHsqlDataSource() throws Exception {
390+
void schedulerWithHsqlDataSource() throws Exception {
389391
DummyJob.param = 0;
390392
DummyJob.count = 0;
391393

@@ -401,13 +403,14 @@ public void schedulerWithHsqlDataSource() throws Exception {
401403
}
402404

403405
@Test
404-
public void schedulerFactoryBeanWithCustomJobStore() throws Exception {
406+
@SuppressWarnings("resource")
407+
void schedulerFactoryBeanWithCustomJobStore() throws Exception {
405408
StaticApplicationContext context = new StaticApplicationContext();
406409

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();
409412

410-
final Properties properties = new Properties();
413+
Properties properties = new Properties();
411414
properties.setProperty("org.quartz.jobStore.class", JobStoreTX.class.getName());
412415
properties.setProperty("org.quartz.jobStore.dataSource", dbName);
413416

@@ -418,17 +421,17 @@ public void schedulerFactoryBeanWithCustomJobStore() throws Exception {
418421
.getBeanDefinition();
419422
context.registerBeanDefinition("scheduler", beanDefinition);
420423

421-
Scheduler bean = context.getBean("scheduler", Scheduler.class);
424+
Scheduler scheduler = context.getBean(Scheduler.class);
422425

423-
assertThat(bean.getMetaData().getJobStoreClass()).isEqualTo(JobStoreTX.class);
426+
assertThat(scheduler.getMetaData().getJobStoreClass()).isEqualTo(JobStoreTX.class);
424427
}
425428

426429
private ClassPathXmlApplicationContext context(String path) {
427430
return new ClassPathXmlApplicationContext(path, getClass());
428431
}
429432

430433

431-
public static class CountingTaskExecutor implements TaskExecutor {
434+
private static class CountingTaskExecutor implements TaskExecutor {
432435

433436
private int count;
434437

@@ -440,12 +443,14 @@ public void execute(Runnable task) {
440443
}
441444

442445

443-
public static class DummyJob implements Job {
446+
private static class DummyJob implements Job {
444447

445448
private static int param;
446449

447450
private static int count;
448451

452+
@SuppressWarnings("unused")
453+
// Must be public
449454
public void setParam(int value) {
450455
if (param > 0) {
451456
throw new IllegalStateException("Param already set");
@@ -460,12 +465,13 @@ public synchronized void execute(JobExecutionContext jobExecutionContext) throws
460465
}
461466

462467

463-
public static class DummyJobBean extends QuartzJobBean {
468+
private static class DummyJobBean extends QuartzJobBean {
464469

465470
private static int param;
466471

467472
private static int count;
468473

474+
@SuppressWarnings("unused")
469475
public void setParam(int value) {
470476
if (param > 0) {
471477
throw new IllegalStateException("Param already set");
@@ -480,7 +486,7 @@ protected synchronized void executeInternal(JobExecutionContext jobExecutionCont
480486
}
481487

482488

483-
public static class DummyRunnable implements Runnable {
489+
private static class DummyRunnable implements Runnable {
484490

485491
@Override
486492
public void run() {

spring-context-support/src/test/resources/org/springframework/scheduling/quartz/multipleAnonymousMethodInvokingJobDetailFB.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<property name="targetMethod" value="doExport"/>
2020
</bean>
2121
</property>
22-
<property name="repeatInterval" value="1000"/>
22+
<property name="repeatInterval" value="200"/>
2323
<property name="repeatCount" value="1"/>
2424
</bean>
2525

@@ -30,7 +30,7 @@
3030
<property name="targetMethod" value="doImport"/>
3131
</bean>
3232
</property>
33-
<property name="repeatInterval" value="1000"/>
33+
<property name="repeatInterval" value="200"/>
3434
<property name="repeatCount" value="1"/>
3535
</bean>
3636

spring-context-support/src/test/resources/org/springframework/scheduling/quartz/schedulerAccessorBean.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<property name="targetMethod" value="doExport"/>
2222
</bean>
2323
</property>
24-
<property name="repeatInterval" value="1000"/>
24+
<property name="repeatInterval" value="200"/>
2525
<property name="repeatCount" value="1"/>
2626
</bean>
2727

@@ -32,7 +32,7 @@
3232
<property name="targetMethod" value="doImport"/>
3333
</bean>
3434
</property>
35-
<property name="repeatInterval" value="1000"/>
35+
<property name="repeatInterval" value="200"/>
3636
<property name="repeatCount" value="1"/>
3737
</bean>
3838

spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -133,6 +133,7 @@ public void requestHeaderAndCookie() {
133133
}
134134

135135
@Test
136+
@SuppressWarnings("deprecation")
136137
public void contextFromThreadLocal() {
137138
WebClient client = this.builder
138139
.filter((request, next) ->

0 commit comments

Comments
 (0)