Browse Source

Suppress warnings in tests

pull/30478/head
Sam Brannen 3 years ago
parent
commit
5e52259fb3
  1. 2
      spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java
  2. 3
      spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java
  3. 2
      spring-context/src/testFixtures/java/org/springframework/context/testfixture/context/annotation/QualifierConfiguration.java
  4. 8
      spring-context/src/testFixtures/java/org/springframework/context/testfixture/index/CandidateComponentsTestClassLoader.java
  5. 7
      spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java

2
spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java

@ -231,12 +231,14 @@ class CandidateComponentsIndexerTests { @@ -231,12 +231,14 @@ class CandidateComponentsIndexerTests {
assertThat(metadata.getItems()).hasSize(1);
}
@SuppressWarnings("removal")
private CandidateComponentsMetadata compile(Class<?>... types) {
CandidateComponentsIndexer processor = new CandidateComponentsIndexer();
this.compiler.getTask(types).call(processor);
return readGeneratedMetadata(this.compiler.getOutputLocation());
}
@SuppressWarnings("removal")
private CandidateComponentsMetadata compile(String... types) {
CandidateComponentsIndexer processor = new CandidateComponentsIndexer();
this.compiler.getTask(types).call(processor);

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

@ -61,6 +61,7 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests { @@ -61,6 +61,7 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
@Test
void zeroArgCtorResultsInDefaultTaskExecutorBeingUsed() {
@SuppressWarnings("deprecation")
ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor();
assertThatCode(() -> executor.execute(new NoOpRunnable())).doesNotThrowAnyException();
}
@ -73,6 +74,7 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests { @@ -73,6 +74,7 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
@Test
void earlySetConcurrentExecutorCallRespectsConfiguredTaskDecorator() {
@SuppressWarnings("deprecation")
ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor();
executor.setConcurrentExecutor(new DecoratedExecutor());
executor.setTaskDecorator(new RunnableDecorator());
@ -81,6 +83,7 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests { @@ -81,6 +83,7 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
@Test
void lateSetConcurrentExecutorCallRespectsConfiguredTaskDecorator() {
@SuppressWarnings("deprecation")
ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor();
executor.setTaskDecorator(new RunnableDecorator());
executor.setConcurrentExecutor(new DecoratedExecutor());

2
spring-context/src/testFixtures/java/org/springframework/context/testfixture/context/annotation/QualifierConfiguration.java

@ -24,6 +24,7 @@ import org.springframework.context.annotation.Configuration; @@ -24,6 +24,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
public class QualifierConfiguration {
@SuppressWarnings("unused")
private String bean;
@Autowired
@ -48,4 +49,5 @@ public class QualifierConfiguration { @@ -48,4 +49,5 @@ public class QualifierConfiguration {
}
}
}

8
spring-context/src/testFixtures/java/org/springframework/context/testfixture/index/CandidateComponentsTestClassLoader.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -22,7 +22,6 @@ import java.util.Collections; @@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.stream.Stream;
import org.springframework.context.index.CandidateComponentsIndexLoader;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
@ -40,7 +39,7 @@ public class CandidateComponentsTestClassLoader extends ClassLoader { @@ -40,7 +39,7 @@ public class CandidateComponentsTestClassLoader extends ClassLoader {
* if resources are present at the standard location.
* @param classLoader the classloader to use for all other operations
* @return a test {@link ClassLoader} that has no index
* @see CandidateComponentsIndexLoader#COMPONENTS_RESOURCE_LOCATION
* @see org.springframework.context.index.CandidateComponentsIndexLoader#COMPONENTS_RESOURCE_LOCATION
*/
public static ClassLoader disableIndex(ClassLoader classLoader) {
return new CandidateComponentsTestClassLoader(classLoader,
@ -87,8 +86,9 @@ public class CandidateComponentsTestClassLoader extends ClassLoader { @@ -87,8 +86,9 @@ public class CandidateComponentsTestClassLoader extends ClassLoader {
}
@Override
@SuppressWarnings({ "deprecation", "removal" })
public Enumeration<URL> getResources(String name) throws IOException {
if (CandidateComponentsIndexLoader.COMPONENTS_RESOURCE_LOCATION.equals(name)) {
if (org.springframework.context.index.CandidateComponentsIndexLoader.COMPONENTS_RESOURCE_LOCATION.equals(name)) {
if (this.resourceUrls != null) {
return this.resourceUrls;
}

7
spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java

@ -393,12 +393,11 @@ public class WebMvcConfigurationSupportExtensionTests { @@ -393,12 +393,11 @@ public class WebMvcConfigurationSupportExtensionTests {
}
@Override
@SuppressWarnings("deprecation")
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
configurer.setDefaultTimeout(2500).setTaskExecutor(new ConcurrentTaskExecutor())
.registerCallableInterceptors(new CallableProcessingInterceptor() {
})
.registerDeferredResultInterceptors(new DeferredResultProcessingInterceptor() {
});
.registerCallableInterceptors(new CallableProcessingInterceptor() {})
.registerDeferredResultInterceptors(new DeferredResultProcessingInterceptor() {});
}
@Override

Loading…
Cancel
Save