Suppress warnings in tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -187,6 +187,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void handleExceptionWithFuture() {
|
||||
ConfigurableApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
|
||||
@@ -200,6 +201,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void handleExceptionWithListenableFuture() {
|
||||
ConfigurableApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,6 +49,7 @@ import static org.junit.Assert.*;
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public class AsyncExecutionTests {
|
||||
|
||||
private static String originalThreadName;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,11 +38,11 @@ import org.springframework.aop.scope.ScopedProxyUtils;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
@@ -435,7 +435,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
public void propertyPlaceholderWithCron() {
|
||||
String businessHoursCronExpression = "0 0 9-17 * * MON-FRI";
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("schedules.businessHours", businessHoursCronExpression);
|
||||
placeholderDefinition.getPropertyValues().addPropertyValue("properties", properties);
|
||||
@@ -468,7 +468,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
public void propertyPlaceholderWithInactiveCron() {
|
||||
String businessHoursCronExpression = "-";
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("schedules.businessHours", businessHoursCronExpression);
|
||||
placeholderDefinition.getPropertyValues().addPropertyValue("properties", properties);
|
||||
@@ -494,7 +494,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
|
||||
private void propertyPlaceholderWithFixedDelay(boolean durationFormat) {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("fixedDelay", (durationFormat ? "PT5S" : "5000"));
|
||||
properties.setProperty("initialDelay", (durationFormat ? "PT1S" : "1000"));
|
||||
@@ -537,7 +537,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
|
||||
private void propertyPlaceholderWithFixedRate(boolean durationFormat) {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("fixedRate", (durationFormat ? "PT3S" : "3000"));
|
||||
properties.setProperty("initialDelay", (durationFormat ? "PT1S" : "1000"));
|
||||
@@ -603,7 +603,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
public void propertyPlaceholderForMetaAnnotation() {
|
||||
String businessHoursCronExpression = "0 0 9-17 * * MON-FRI";
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("schedules.businessHours", businessHoursCronExpression);
|
||||
placeholderDefinition.getPropertyValues().addPropertyValue("properties", properties);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
package org.springframework.scheduling.concurrent;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -36,17 +35,13 @@ public class ThreadPoolExecutorFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
public void defaultExecutor() throws Exception {
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorConfig.class);
|
||||
ExecutorService executor = context.getBean("executor", ExecutorService.class);
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ExecutorConfig.class);
|
||||
ExecutorService executor = context.getBean(ExecutorService.class);
|
||||
|
||||
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "foo";
|
||||
}
|
||||
});
|
||||
FutureTask<String> task = new FutureTask<>(() -> "foo");
|
||||
executor.execute(task);
|
||||
assertEquals("foo", task.get());
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,11 +18,11 @@ package org.springframework.scheduling.config;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -33,13 +33,13 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class AnnotationDrivenBeanDefinitionParserTests {
|
||||
|
||||
private ApplicationContext context;
|
||||
private ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class);
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.context = new ClassPathXmlApplicationContext(
|
||||
"annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class);
|
||||
@After
|
||||
public void closeApplicationContext() {
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
||||
public void asyncPostProcessorExecutorReference() {
|
||||
Object executor = context.getBean("testExecutor");
|
||||
Object postProcessor = context.getBean(TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME);
|
||||
assertSame(executor, ((Supplier) new DirectFieldAccessor(postProcessor).getPropertyValue("executor")).get());
|
||||
assertSame(executor, ((Supplier<?>) new DirectFieldAccessor(postProcessor).getPropertyValue("executor")).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,7 +71,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
||||
public void asyncPostProcessorExceptionHandlerReference() {
|
||||
Object exceptionHandler = context.getBean("testExceptionHandler");
|
||||
Object postProcessor = context.getBean(TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME);
|
||||
assertSame(exceptionHandler, ((Supplier) new DirectFieldAccessor(postProcessor).getPropertyValue("exceptionHandler")).get());
|
||||
assertSame(exceptionHandler, ((Supplier<?>) new DirectFieldAccessor(postProcessor).getPropertyValue("exceptionHandler")).get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
public class LazyScheduledTasksBeanDefinitionParserTests {
|
||||
|
||||
@Test(timeout = 5000)
|
||||
@SuppressWarnings("resource")
|
||||
public void checkTarget() {
|
||||
Task task =
|
||||
new GenericXmlApplicationContext(
|
||||
|
||||
Reference in New Issue
Block a user