Skip to content

Commit e7bd305

Browse files
committed
Suppress warnings in tests
1 parent 4112ca7 commit e7bd305

File tree

6 files changed

+30
-31
lines changed

6 files changed

+30
-31
lines changed

spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -187,6 +187,7 @@ public void configuredThroughNamespace() {
187187
}
188188

189189
@Test
190+
@SuppressWarnings("resource")
190191
public void handleExceptionWithFuture() {
191192
ConfigurableApplicationContext context =
192193
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
@@ -200,6 +201,7 @@ public void handleExceptionWithFuture() {
200201
}
201202

202203
@Test
204+
@SuppressWarnings("resource")
203205
public void handleExceptionWithListenableFuture() {
204206
ConfigurableApplicationContext context =
205207
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);

spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -49,6 +49,7 @@
4949
* @author Juergen Hoeller
5050
* @author Chris Beams
5151
*/
52+
@SuppressWarnings("resource")
5253
public class AsyncExecutionTests {
5354

5455
private static String originalThreadName;

spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -38,11 +38,11 @@
3838
import org.springframework.beans.DirectFieldAccessor;
3939
import org.springframework.beans.factory.BeanCreationException;
4040
import org.springframework.beans.factory.config.BeanDefinition;
41-
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
4241
import org.springframework.beans.factory.support.RootBeanDefinition;
4342
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
4443
import org.springframework.context.annotation.Scope;
4544
import org.springframework.context.annotation.ScopedProxyMode;
45+
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
4646
import org.springframework.context.support.StaticApplicationContext;
4747
import org.springframework.core.annotation.AliasFor;
4848
import org.springframework.scheduling.Trigger;
@@ -435,7 +435,7 @@ public void metaAnnotationWithCronExpression() {
435435
public void propertyPlaceholderWithCron() {
436436
String businessHoursCronExpression = "0 0 9-17 * * MON-FRI";
437437
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
438-
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
438+
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
439439
Properties properties = new Properties();
440440
properties.setProperty("schedules.businessHours", businessHoursCronExpression);
441441
placeholderDefinition.getPropertyValues().addPropertyValue("properties", properties);
@@ -468,7 +468,7 @@ public void propertyPlaceholderWithCron() {
468468
public void propertyPlaceholderWithInactiveCron() {
469469
String businessHoursCronExpression = "-";
470470
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
471-
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
471+
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
472472
Properties properties = new Properties();
473473
properties.setProperty("schedules.businessHours", businessHoursCronExpression);
474474
placeholderDefinition.getPropertyValues().addPropertyValue("properties", properties);
@@ -494,7 +494,7 @@ public void propertyPlaceholderWithFixedDelayInDuration() {
494494

495495
private void propertyPlaceholderWithFixedDelay(boolean durationFormat) {
496496
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
497-
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
497+
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
498498
Properties properties = new Properties();
499499
properties.setProperty("fixedDelay", (durationFormat ? "PT5S" : "5000"));
500500
properties.setProperty("initialDelay", (durationFormat ? "PT1S" : "1000"));
@@ -537,7 +537,7 @@ public void propertyPlaceholderWithFixedRateInDuration() {
537537

538538
private void propertyPlaceholderWithFixedRate(boolean durationFormat) {
539539
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
540-
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
540+
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
541541
Properties properties = new Properties();
542542
properties.setProperty("fixedRate", (durationFormat ? "PT3S" : "3000"));
543543
properties.setProperty("initialDelay", (durationFormat ? "PT1S" : "1000"));
@@ -603,7 +603,7 @@ public void expressionWithCron() {
603603
public void propertyPlaceholderForMetaAnnotation() {
604604
String businessHoursCronExpression = "0 0 9-17 * * MON-FRI";
605605
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
606-
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
606+
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
607607
Properties properties = new Properties();
608608
properties.setProperty("schedules.businessHours", businessHoursCronExpression);
609609
placeholderDefinition.getPropertyValues().addPropertyValue("properties", properties);

spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -16,13 +16,12 @@
1616

1717
package org.springframework.scheduling.concurrent;
1818

19-
import java.util.concurrent.Callable;
2019
import java.util.concurrent.ExecutorService;
2120
import java.util.concurrent.FutureTask;
2221

2322
import org.junit.Test;
2423

25-
import org.springframework.context.ApplicationContext;
24+
import org.springframework.context.ConfigurableApplicationContext;
2625
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
2726
import org.springframework.context.annotation.Bean;
2827
import org.springframework.context.annotation.Configuration;
@@ -36,17 +35,13 @@ public class ThreadPoolExecutorFactoryBeanTests {
3635

3736
@Test
3837
public void defaultExecutor() throws Exception {
39-
ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorConfig.class);
40-
ExecutorService executor = context.getBean("executor", ExecutorService.class);
38+
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ExecutorConfig.class);
39+
ExecutorService executor = context.getBean(ExecutorService.class);
4140

42-
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
43-
@Override
44-
public String call() throws Exception {
45-
return "foo";
46-
}
47-
});
41+
FutureTask<String> task = new FutureTask<>(() -> "foo");
4842
executor.execute(task);
4943
assertEquals("foo", task.get());
44+
context.close();
5045
}
5146

5247

spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -18,11 +18,11 @@
1818

1919
import java.util.function.Supplier;
2020

21-
import org.junit.Before;
21+
import org.junit.After;
2222
import org.junit.Test;
2323

2424
import org.springframework.beans.DirectFieldAccessor;
25-
import org.springframework.context.ApplicationContext;
25+
import org.springframework.context.ConfigurableApplicationContext;
2626
import org.springframework.context.support.ClassPathXmlApplicationContext;
2727

2828
import static org.junit.Assert.*;
@@ -33,13 +33,13 @@
3333
*/
3434
public class AnnotationDrivenBeanDefinitionParserTests {
3535

36-
private ApplicationContext context;
36+
private ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
37+
"annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class);
3738

3839

39-
@Before
40-
public void setup() {
41-
this.context = new ClassPathXmlApplicationContext(
42-
"annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class);
40+
@After
41+
public void closeApplicationContext() {
42+
context.close();
4343
}
4444

4545

@@ -57,7 +57,7 @@ public void scheduledPostProcessorRegistered() {
5757
public void asyncPostProcessorExecutorReference() {
5858
Object executor = context.getBean("testExecutor");
5959
Object postProcessor = context.getBean(TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME);
60-
assertSame(executor, ((Supplier) new DirectFieldAccessor(postProcessor).getPropertyValue("executor")).get());
60+
assertSame(executor, ((Supplier<?>) new DirectFieldAccessor(postProcessor).getPropertyValue("executor")).get());
6161
}
6262

6363
@Test
@@ -71,7 +71,7 @@ public void scheduledPostProcessorSchedulerReference() {
7171
public void asyncPostProcessorExceptionHandlerReference() {
7272
Object exceptionHandler = context.getBean("testExceptionHandler");
7373
Object postProcessor = context.getBean(TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME);
74-
assertSame(exceptionHandler, ((Supplier) new DirectFieldAccessor(postProcessor).getPropertyValue("exceptionHandler")).get());
74+
assertSame(exceptionHandler, ((Supplier<?>) new DirectFieldAccessor(postProcessor).getPropertyValue("exceptionHandler")).get());
7575
}
7676

7777
}

spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -31,6 +31,7 @@
3131
public class LazyScheduledTasksBeanDefinitionParserTests {
3232

3333
@Test(timeout = 5000)
34+
@SuppressWarnings("resource")
3435
public void checkTarget() {
3536
Task task =
3637
new GenericXmlApplicationContext(

0 commit comments

Comments
 (0)