mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Align with breaking changes in spring-test
See gh-31241
This commit is contained in:
parent
eca9343675
commit
ac59b5781f
@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.boot.test.autoconfigure;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
|
||||
import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportMessage;
|
||||
@ -64,12 +64,12 @@ public class SpringBootDependencyInjectionTestExecutionListener extends Dependen
|
||||
static class PostProcessor implements DefaultTestExecutionListenersPostProcessor {
|
||||
|
||||
@Override
|
||||
public Set<Class<? extends TestExecutionListener>> postProcessDefaultTestExecutionListeners(
|
||||
Set<Class<? extends TestExecutionListener>> listeners) {
|
||||
Set<Class<? extends TestExecutionListener>> updated = new LinkedHashSet<>(listeners.size());
|
||||
for (Class<? extends TestExecutionListener> listener : listeners) {
|
||||
updated.add(listener.equals(DependencyInjectionTestExecutionListener.class)
|
||||
? SpringBootDependencyInjectionTestExecutionListener.class : listener);
|
||||
public List<TestExecutionListener> postProcessDefaultTestExecutionListeners(
|
||||
List<TestExecutionListener> listeners) {
|
||||
List<TestExecutionListener> updated = new ArrayList<>();
|
||||
for (TestExecutionListener listener : listeners) {
|
||||
updated.add((listener instanceof DependencyInjectionTestExecutionListener)
|
||||
? new SpringBootDependencyInjectionTestExecutionListener() : listener);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 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,14 +16,15 @@
|
||||
|
||||
package org.springframework.boot.test.context;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.test.context.TestExecutionListener;
|
||||
|
||||
/**
|
||||
* Callback interface trigger from {@link SpringBootTestContextBootstrapper} that can be
|
||||
* used to post-process the list of default {@link TestExecutionListener} classes to be
|
||||
* used by a test. Can be used to add or remove existing listener classes.
|
||||
* used to post-process the list of default {@link TestExecutionListener
|
||||
* TestExecutionListeners} to be used by a test. Can be used to add or remove existing
|
||||
* listeners.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.4.1
|
||||
@ -33,11 +34,12 @@ import org.springframework.test.context.TestExecutionListener;
|
||||
public interface DefaultTestExecutionListenersPostProcessor {
|
||||
|
||||
/**
|
||||
* Post process the list of default {@link TestExecutionListener} classes to be used.
|
||||
* Post process the list of default {@link TestExecutionListener listeners} to be
|
||||
* used.
|
||||
* @param listeners the source listeners
|
||||
* @return the actual listeners that should be used
|
||||
* @since 3.0.0
|
||||
*/
|
||||
Set<Class<? extends TestExecutionListener>> postProcessDefaultTestExecutionListeners(
|
||||
Set<Class<? extends TestExecutionListener>> listeners);
|
||||
List<TestExecutionListener> postProcessDefaultTestExecutionListeners(List<TestExecutionListener> listeners);
|
||||
|
||||
}
|
||||
|
@ -110,8 +110,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionListenerClasses() {
|
||||
Set<Class<? extends TestExecutionListener>> listeners = super.getDefaultTestExecutionListenerClasses();
|
||||
protected List<TestExecutionListener> getDefaultTestExecutionListeners() {
|
||||
List<TestExecutionListener> listeners = new ArrayList<>(super.getDefaultTestExecutionListeners());
|
||||
List<DefaultTestExecutionListenersPostProcessor> postProcessors = SpringFactoriesLoader
|
||||
.loadFactories(DefaultTestExecutionListenersPostProcessor.class, getClass().getClassLoader());
|
||||
for (DefaultTestExecutionListenersPostProcessor postProcessor : postProcessors) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.test.context.bootstrap;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.test.context.DefaultTestExecutionListenersPostProcessor;
|
||||
import org.springframework.test.context.TestContext;
|
||||
@ -31,9 +31,8 @@ import org.springframework.test.context.support.AbstractTestExecutionListener;
|
||||
public class TestDefaultTestExecutionListenersPostProcessor implements DefaultTestExecutionListenersPostProcessor {
|
||||
|
||||
@Override
|
||||
public Set<Class<? extends TestExecutionListener>> postProcessDefaultTestExecutionListeners(
|
||||
Set<Class<? extends TestExecutionListener>> listeners) {
|
||||
listeners.add(ExampleTestExecutionListener.class);
|
||||
public List<TestExecutionListener> postProcessDefaultTestExecutionListeners(List<TestExecutionListener> listeners) {
|
||||
listeners.add(new ExampleTestExecutionListener());
|
||||
return listeners;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user