Reformat code following spring-javaformat upgrade
This commit is contained in:
@@ -212,7 +212,7 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
}
|
||||
initializers.addAll(application.getInitializers());
|
||||
for (Class<? extends ApplicationContextInitializer<?>> initializerClass : config
|
||||
.getContextInitializerClasses()) {
|
||||
.getContextInitializerClasses()) {
|
||||
initializers.add(BeanUtils.instantiateClass(initializerClass));
|
||||
}
|
||||
if (config.getParent() != null) {
|
||||
@@ -222,8 +222,11 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
}
|
||||
|
||||
private boolean isEmbeddedWebEnvironment(MergedContextConfiguration config) {
|
||||
return MergedAnnotations.from(config.getTestClass(), SearchStrategy.TYPE_HIERARCHY).get(SpringBootTest.class)
|
||||
.getValue("webEnvironment", WebEnvironment.class).orElse(WebEnvironment.NONE).isEmbedded();
|
||||
return MergedAnnotations.from(config.getTestClass(), SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(SpringBootTest.class)
|
||||
.getValue("webEnvironment", WebEnvironment.class)
|
||||
.orElse(WebEnvironment.NONE)
|
||||
.isEmbedded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -40,7 +40,9 @@ class SpringBootTestArgs implements ContextCustomizer {
|
||||
|
||||
SpringBootTestArgs(Class<?> testClass) {
|
||||
this.args = MergedAnnotations.from(testClass, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(SpringBootTest.class).getValue("args", String[].class).orElse(NO_ARGS);
|
||||
.get(SpringBootTest.class)
|
||||
.getValue("args", String[].class)
|
||||
.orElse(NO_ARGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -115,7 +115,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionListenerClasses() {
|
||||
Set<Class<? extends TestExecutionListener>> listeners = super.getDefaultTestExecutionListenerClasses();
|
||||
List<DefaultTestExecutionListenersPostProcessor> postProcessors = SpringFactoriesLoader
|
||||
.loadFactories(DefaultTestExecutionListenersPostProcessor.class, getClass().getClassLoader());
|
||||
.loadFactories(DefaultTestExecutionListenersPostProcessor.class, getClass().getClassLoader());
|
||||
for (DefaultTestExecutionListenersPostProcessor postProcessor : postProcessors) {
|
||||
listeners = postProcessor.postProcessDefaultTestExecutionListeners(listeners);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
TestPropertySourceUtils.convertInlinedPropertiesToMap(configuration.getPropertySourceProperties()));
|
||||
Binder binder = new Binder(source);
|
||||
return binder.bind("spring.main.web-application-type", Bindable.of(WebApplicationType.class))
|
||||
.orElseGet(this::deduceWebApplicationType);
|
||||
.orElseGet(this::deduceWebApplicationType);
|
||||
}
|
||||
|
||||
private WebApplicationType deduceWebApplicationType() {
|
||||
@@ -199,8 +199,9 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
*/
|
||||
protected String determineResourceBasePath(MergedContextConfiguration configuration) {
|
||||
return MergedAnnotations.from(configuration.getTestClass(), SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(WebAppConfiguration.class).getValue(MergedAnnotation.VALUE, String.class)
|
||||
.orElse("src/main/webapp");
|
||||
.get(WebAppConfiguration.class)
|
||||
.getValue(MergedAnnotation.VALUE, String.class)
|
||||
.orElse("src/main/webapp");
|
||||
}
|
||||
|
||||
private boolean isWebEnvironmentSupported(MergedContextConfiguration mergedConfig) {
|
||||
@@ -232,7 +233,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
return classes;
|
||||
}
|
||||
Class<?> found = new AnnotatedClassFinder(SpringBootConfiguration.class)
|
||||
.findFromClass(mergedConfig.getTestClass());
|
||||
.findFromClass(mergedConfig.getTestClass());
|
||||
Assert.state(found != null, "Unable to find a @SpringBootConfiguration, you need to use "
|
||||
+ "@ContextConfiguration or @SpringBootTest(classes=...) with your test");
|
||||
logger.info("Found @SpringBootConfiguration " + found.getName() + " for test " + mergedConfig.getTestClass());
|
||||
@@ -242,7 +243,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
private boolean containsNonTestComponent(Class<?>[] classes) {
|
||||
for (Class<?> candidate : classes) {
|
||||
if (!MergedAnnotations.from(candidate, SearchStrategy.INHERITED_ANNOTATIONS)
|
||||
.isPresent(TestConfiguration.class)) {
|
||||
.isPresent(TestConfiguration.class)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -328,8 +329,9 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
|
||||
protected void verifyConfiguration(Class<?> testClass) {
|
||||
SpringBootTest springBootTest = getAnnotation(testClass);
|
||||
if (springBootTest != null && isListeningOnPort(springBootTest.webEnvironment()) && MergedAnnotations
|
||||
.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS).isPresent(WebAppConfiguration.class)) {
|
||||
if (springBootTest != null && isListeningOnPort(springBootTest.webEnvironment())
|
||||
&& MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS)
|
||||
.isPresent(WebAppConfiguration.class)) {
|
||||
throw new IllegalStateException("@WebAppConfiguration should only be used "
|
||||
+ "with @SpringBootTest when @SpringBootTest is configured with a "
|
||||
+ "mock web environment. Please remove @WebAppConfiguration or reconfigure @SpringBootTest.");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -223,7 +223,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
throwAssertionError(contextFailedToStartWhenExpecting("to get beans names with type:%n <%s>", type));
|
||||
}
|
||||
return Assertions.assertThat(getApplicationContext().getBeanNamesForType(type))
|
||||
.as("Bean names of type <%s> from <%s>", type, getApplicationContext());
|
||||
.as("Bean names of type <%s> from <%s>", type, getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,8 +359,8 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
"%nExpecting:%n <%s>%nto contain a bean of name:%n <%s> (%s)%nbut found:%n <%s> of type <%s>",
|
||||
getApplicationContext(), name, type, bean, bean.getClass()));
|
||||
}
|
||||
return Assertions.assertThat((T) bean).as("Bean of name <%s> and type <%s> from <%s>", name, type,
|
||||
getApplicationContext());
|
||||
return Assertions.assertThat((T) bean)
|
||||
.as("Bean of name <%s> and type <%s> from <%s>", name, type, getApplicationContext());
|
||||
}
|
||||
|
||||
private Object findBean(String name) {
|
||||
@@ -411,7 +411,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
throwAssertionError(contextFailedToStartWhenExpecting("to get beans of type:%n <%s>", type));
|
||||
}
|
||||
return Assertions.assertThat(scope.getBeansOfType(getApplicationContext(), type))
|
||||
.as("Beans of type <%s> from <%s>", type, getApplicationContext());
|
||||
.as("Beans of type <%s> from <%s>", type, getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -96,9 +96,9 @@ class AssertProviderApplicationContextInvocationHandler implements InvocationHan
|
||||
+ this.startupFailure.getClass().getName() + "]";
|
||||
}
|
||||
ToStringCreator builder = new ToStringCreator(this.applicationContext)
|
||||
.append("id", this.applicationContext.getId())
|
||||
.append("applicationName", this.applicationContext.getApplicationName())
|
||||
.append("beanDefinitionCount", this.applicationContext.getBeanDefinitionCount());
|
||||
.append("id", this.applicationContext.getId())
|
||||
.append("applicationName", this.applicationContext.getApplicationName())
|
||||
.append("beanDefinitionCount", this.applicationContext.getBeanDefinitionCount());
|
||||
return "Started application " + builder;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -441,10 +441,10 @@ public abstract class AbstractApplicationContextRunner<SELF extends AbstractAppl
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
if (beanFactory instanceof AbstractAutowireCapableBeanFactory) {
|
||||
((AbstractAutowireCapableBeanFactory) beanFactory)
|
||||
.setAllowCircularReferences(this.runnerConfiguration.allowCircularReferences);
|
||||
.setAllowCircularReferences(this.runnerConfiguration.allowCircularReferences);
|
||||
if (beanFactory instanceof DefaultListableBeanFactory) {
|
||||
((DefaultListableBeanFactory) beanFactory)
|
||||
.setAllowBeanDefinitionOverriding(this.runnerConfiguration.allowBeanDefinitionOverriding);
|
||||
.setAllowBeanDefinitionOverriding(this.runnerConfiguration.allowBeanDefinitionOverriding);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2022 the original author or authors.
|
||||
* Copyright 2020-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.
|
||||
@@ -204,7 +204,7 @@ class HttpGraphQlTesterContextCustomizer implements ContextCustomizer {
|
||||
private boolean isSslEnabled(ApplicationContext context) {
|
||||
try {
|
||||
AbstractConfigurableWebServerFactory webServerFactory = context
|
||||
.getBean(AbstractConfigurableWebServerFactory.class);
|
||||
.getBean(AbstractConfigurableWebServerFactory.class);
|
||||
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -96,8 +96,10 @@ public class JacksonTester<T> extends AbstractJsonMarshalTester<T> {
|
||||
|
||||
@Override
|
||||
protected JsonContent<T> getJsonContent(String json) {
|
||||
Configuration configuration = Configuration.builder().jsonProvider(new JacksonJsonProvider(this.objectMapper))
|
||||
.mappingProvider(new JacksonMappingProvider(this.objectMapper)).build();
|
||||
Configuration configuration = Configuration.builder()
|
||||
.jsonProvider(new JacksonJsonProvider(this.objectMapper))
|
||||
.mappingProvider(new JacksonMappingProvider(this.objectMapper))
|
||||
.build();
|
||||
return new JsonContent<>(getResourceLoadClass(), getType(), json, configuration);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -67,10 +67,12 @@ class DefinitionsParser {
|
||||
|
||||
private void parseElement(AnnotatedElement element, Class<?> source) {
|
||||
MergedAnnotations annotations = MergedAnnotations.from(element, SearchStrategy.SUPERCLASS);
|
||||
annotations.stream(MockBean.class).map(MergedAnnotation::synthesize)
|
||||
.forEach((annotation) -> parseMockBeanAnnotation(annotation, element, source));
|
||||
annotations.stream(SpyBean.class).map(MergedAnnotation::synthesize)
|
||||
.forEach((annotation) -> parseSpyBeanAnnotation(annotation, element, source));
|
||||
annotations.stream(MockBean.class)
|
||||
.map(MergedAnnotation::synthesize)
|
||||
.forEach((annotation) -> parseMockBeanAnnotation(annotation, element, source));
|
||||
annotations.stream(SpyBean.class)
|
||||
.map(MergedAnnotation::synthesize)
|
||||
.forEach((annotation) -> parseSpyBeanAnnotation(annotation, element, source));
|
||||
}
|
||||
|
||||
private void parseMockBeanAnnotation(MockBean annotation, AnnotatedElement element, Class<?> source) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -129,9 +129,13 @@ class MockDefinition extends Definition {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("name", getName()).append("typeToMock", this.typeToMock)
|
||||
.append("extraInterfaces", this.extraInterfaces).append("answer", this.answer)
|
||||
.append("serializable", this.serializable).append("reset", getReset()).toString();
|
||||
return new ToStringCreator(this).append("name", getName())
|
||||
.append("typeToMock", this.typeToMock)
|
||||
.append("extraInterfaces", this.extraInterfaces)
|
||||
.append("answer", this.answer)
|
||||
.append("serializable", this.serializable)
|
||||
.append("reset", getReset())
|
||||
.toString();
|
||||
}
|
||||
|
||||
<T> T createMock() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -83,7 +83,7 @@ public class MockitoPostProcessor implements InstantiationAwareBeanPostProcessor
|
||||
private static final String BEAN_NAME = MockitoPostProcessor.class.getName();
|
||||
|
||||
private static final String CONFIGURATION_CLASS_ATTRIBUTE = Conventions
|
||||
.getQualifiedAttributeName(ConfigurationClassPostProcessor.class, "configurationClass");
|
||||
.getQualifiedAttributeName(ConfigurationClassPostProcessor.class, "configurationClass");
|
||||
|
||||
private static final BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -108,7 +108,7 @@ public class MockitoTestExecutionListener extends AbstractTestExecutionListener
|
||||
parser.parse(testContext.getTestClass());
|
||||
if (!parser.getDefinitions().isEmpty()) {
|
||||
MockitoPostProcessor postProcessor = testContext.getApplicationContext()
|
||||
.getBean(MockitoPostProcessor.class);
|
||||
.getBean(MockitoPostProcessor.class);
|
||||
for (Definition definition : parser.getDefinitions()) {
|
||||
Field field = parser.getField(definition);
|
||||
if (field != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -79,8 +79,10 @@ class SpyDefinition extends Definition {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("name", getName()).append("typeToSpy", this.typeToSpy)
|
||||
.append("reset", getReset()).toString();
|
||||
return new ToStringCreator(this).append("name", getName())
|
||||
.append("typeToSpy", this.typeToSpy)
|
||||
.append("reset", getReset())
|
||||
.toString();
|
||||
}
|
||||
|
||||
<T> T createSpy(Object instance) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -44,7 +44,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessor implements EnvironmentPos
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
MapPropertySource source = (MapPropertySource) environment.getPropertySources()
|
||||
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
if (source == null || isTestServerPortFixed(source, environment) || isTestManagementPortConfigured(source)) {
|
||||
return;
|
||||
}
|
||||
@@ -70,10 +70,14 @@ class SpringBootTestRandomPortEnvironmentPostProcessor implements EnvironmentPos
|
||||
}
|
||||
|
||||
private Integer getPropertyAsInteger(ConfigurableEnvironment environment, String property, Integer defaultValue) {
|
||||
return environment.getPropertySources().stream().filter(
|
||||
(source) -> !source.getName().equals(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME))
|
||||
.map((source) -> getPropertyAsInteger(source, property, environment)).filter(Objects::nonNull)
|
||||
.findFirst().orElse(defaultValue);
|
||||
return environment.getPropertySources()
|
||||
.stream()
|
||||
.filter((source) -> !source.getName()
|
||||
.equals(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME))
|
||||
.map((source) -> getPropertyAsInteger(source, property, environment))
|
||||
.filter(Objects::nonNull)
|
||||
.findFirst()
|
||||
.orElse(defaultValue);
|
||||
}
|
||||
|
||||
private Integer getPropertyAsInteger(PropertySource<?> source, String property,
|
||||
|
||||
@@ -135,7 +135,7 @@ public class TestRestTemplate {
|
||||
ClientHttpRequestFactory requestFactory = builder.buildRequestFactory();
|
||||
if (requestFactory instanceof HttpComponentsClientHttpRequestFactory) {
|
||||
builder = builder
|
||||
.requestFactory(() -> new CustomHttpComponentsClientHttpRequestFactory(httpClientOptions));
|
||||
.requestFactory(() -> new CustomHttpComponentsClientHttpRequestFactory(httpClientOptions));
|
||||
}
|
||||
}
|
||||
if (username != null || password != null) {
|
||||
@@ -952,12 +952,12 @@ public class TestRestTemplate {
|
||||
if (entity instanceof UriTemplateRequestEntity) {
|
||||
UriTemplateRequestEntity<?> templatedUriEntity = (UriTemplateRequestEntity<?>) entity;
|
||||
if (templatedUriEntity.getVars() != null) {
|
||||
return this.restTemplate.getUriTemplateHandler().expand(templatedUriEntity.getUriTemplate(),
|
||||
templatedUriEntity.getVars());
|
||||
return this.restTemplate.getUriTemplateHandler()
|
||||
.expand(templatedUriEntity.getUriTemplate(), templatedUriEntity.getVars());
|
||||
}
|
||||
else if (templatedUriEntity.getVarsMap() != null) {
|
||||
return this.restTemplate.getUriTemplateHandler().expand(templatedUriEntity.getUriTemplate(),
|
||||
templatedUriEntity.getVarsMap());
|
||||
return this.restTemplate.getUriTemplateHandler()
|
||||
.expand(templatedUriEntity.getUriTemplate(), templatedUriEntity.getVarsMap());
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"No variables specified for URI template: " + templatedUriEntity.getUriTemplate());
|
||||
@@ -1025,8 +1025,10 @@ public class TestRestTemplate {
|
||||
}
|
||||
|
||||
protected RequestConfig getRequestConfig() {
|
||||
Builder builder = RequestConfig.custom().setCookieSpec(this.cookieSpec).setAuthenticationEnabled(false)
|
||||
.setRedirectsEnabled(this.enableRedirects);
|
||||
Builder builder = RequestConfig.custom()
|
||||
.setCookieSpec(this.cookieSpec)
|
||||
.setAuthenticationEnabled(false)
|
||||
.setRedirectsEnabled(this.enableRedirects);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -53,7 +53,7 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer {
|
||||
public void customizeContext(ConfigurableApplicationContext context,
|
||||
MergedContextConfiguration mergedContextConfiguration) {
|
||||
SpringBootTest springBootTest = TestContextAnnotationUtils
|
||||
.findMergedAnnotation(mergedContextConfiguration.getTestClass(), SpringBootTest.class);
|
||||
.findMergedAnnotation(mergedContextConfiguration.getTestClass(), SpringBootTest.class);
|
||||
if (springBootTest.webEnvironment().isEmbedded()) {
|
||||
registerTestRestTemplate(context);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer {
|
||||
private boolean isSslEnabled(ApplicationContext context) {
|
||||
try {
|
||||
AbstractServletWebServerFactory webServerFactory = context
|
||||
.getBean(AbstractServletWebServerFactory.class);
|
||||
.getBean(AbstractServletWebServerFactory.class);
|
||||
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -208,7 +208,7 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
||||
private boolean isSslEnabled(ApplicationContext context) {
|
||||
try {
|
||||
AbstractReactiveWebServerFactory webServerFactory = context
|
||||
.getBean(AbstractReactiveWebServerFactory.class);
|
||||
.getBean(AbstractReactiveWebServerFactory.class);
|
||||
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
@@ -218,7 +218,8 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
||||
|
||||
private void customizeWebTestClientBuilder(WebTestClient.Builder clientBuilder, ApplicationContext context) {
|
||||
for (WebTestClientBuilderCustomizer customizer : context
|
||||
.getBeansOfType(WebTestClientBuilderCustomizer.class).values()) {
|
||||
.getBeansOfType(WebTestClientBuilderCustomizer.class)
|
||||
.values()) {
|
||||
customizer.customize(clientBuilder);
|
||||
}
|
||||
}
|
||||
@@ -226,9 +227,10 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
||||
private void customizeWebTestClientCodecs(WebTestClient.Builder clientBuilder, ApplicationContext context) {
|
||||
Collection<CodecCustomizer> codecCustomizers = context.getBeansOfType(CodecCustomizer.class).values();
|
||||
if (!CollectionUtils.isEmpty(codecCustomizers)) {
|
||||
clientBuilder.exchangeStrategies(ExchangeStrategies.builder().codecs(
|
||||
(codecs) -> codecCustomizers.forEach((codecCustomizer) -> codecCustomizer.customize(codecs)))
|
||||
.build());
|
||||
clientBuilder.exchangeStrategies(ExchangeStrategies.builder()
|
||||
.codecs((codecs) -> codecCustomizers
|
||||
.forEach((codecCustomizer) -> codecCustomizer.customize(codecs)))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -46,7 +46,7 @@ class WebTestClientContextCustomizerFactory implements ContextCustomizerFactory
|
||||
reactorClientPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
|
||||
jettyClientPresent = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
|
||||
httpComponentsClientPresent = ClassUtils
|
||||
.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader)
|
||||
.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader)
|
||||
&& ClassUtils.isPresent("org.apache.hc.core5.reactive.ReactiveDataConsumer", loader);
|
||||
webClientPresent = ClassUtils.isPresent("org.springframework.web.reactive.function.client.WebClient", loader);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user