Remove deprecated code flagged for removal
Closes gh-27303
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -42,9 +42,7 @@ import org.springframework.context.annotation.Import;
|
||||
@ConditionalOnEnabledHealthIndicator("cassandra")
|
||||
@AutoConfigureAfter({ CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class,
|
||||
CassandraReactiveHealthContributorAutoConfiguration.class })
|
||||
@Import({ CassandraDriverConfiguration.class,
|
||||
CassandraHealthContributorConfigurations.CassandraOperationsConfiguration.class })
|
||||
@SuppressWarnings("deprecation")
|
||||
@Import(CassandraDriverConfiguration.class)
|
||||
public class CassandraHealthContributorAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -27,12 +27,9 @@ import org.springframework.boot.actuate.cassandra.CassandraDriverReactiveHealthI
|
||||
import org.springframework.boot.actuate.health.HealthContributor;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthContributor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
|
||||
/**
|
||||
* Health contributor options for Cassandra.
|
||||
@@ -54,21 +51,6 @@ class CassandraHealthContributorConfigurations {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(CassandraOperations.class)
|
||||
@ConditionalOnBean(CassandraOperations.class)
|
||||
@Deprecated
|
||||
static class CassandraOperationsConfiguration extends
|
||||
CompositeHealthContributorConfiguration<org.springframework.boot.actuate.cassandra.CassandraHealthIndicator, CassandraOperations> {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = { "cassandraHealthIndicator", "cassandraHealthContributor" })
|
||||
HealthContributor cassandraHealthContributor(Map<String, CassandraOperations> cassandraOperations) {
|
||||
return createContributor(cassandraOperations);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBean(CqlSession.class)
|
||||
static class CassandraReactiveDriverConfiguration extends
|
||||
@@ -82,20 +64,4 @@ class CassandraHealthContributorConfigurations {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(ReactiveCassandraOperations.class)
|
||||
@ConditionalOnBean(ReactiveCassandraOperations.class)
|
||||
@Deprecated
|
||||
static class CassandraReactiveOperationsConfiguration extends
|
||||
CompositeReactiveHealthContributorConfiguration<org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator, ReactiveCassandraOperations> {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = { "cassandraHealthIndicator", "cassandraHealthContributor" })
|
||||
ReactiveHealthContributor cassandraHealthContributor(
|
||||
Map<String, ReactiveCassandraOperations> reactiveCassandraOperations) {
|
||||
return createContributor(reactiveCassandraOperations);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -41,9 +41,7 @@ import org.springframework.context.annotation.Import;
|
||||
@ConditionalOnClass({ CqlSession.class, Flux.class })
|
||||
@ConditionalOnEnabledHealthIndicator("cassandra")
|
||||
@AutoConfigureAfter(CassandraReactiveDataAutoConfiguration.class)
|
||||
@Import({ CassandraReactiveDriverConfiguration.class,
|
||||
CassandraHealthContributorConfigurations.CassandraReactiveOperationsConfiguration.class })
|
||||
@SuppressWarnings("deprecation")
|
||||
@Import(CassandraReactiveDriverConfiguration.class)
|
||||
public class CassandraReactiveHealthContributorAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -20,10 +20,8 @@ import java.net.InetAddress;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
import org.springframework.boot.web.server.Ssl;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -56,8 +54,6 @@ public class ManagementServerProperties {
|
||||
*/
|
||||
private String basePath = "";
|
||||
|
||||
private final Servlet servlet = new Servlet();
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private Ssl ssl;
|
||||
|
||||
@@ -105,10 +101,6 @@ public class ManagementServerProperties {
|
||||
this.ssl = ssl;
|
||||
}
|
||||
|
||||
public Servlet getServlet() {
|
||||
return this.servlet;
|
||||
}
|
||||
|
||||
private String cleanBasePath(String basePath) {
|
||||
String candidate = StringUtils.trimWhitespace(basePath);
|
||||
if (StringUtils.hasText(candidate)) {
|
||||
@@ -122,49 +114,4 @@ public class ManagementServerProperties {
|
||||
return candidate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Servlet properties.
|
||||
*/
|
||||
public static class Servlet {
|
||||
|
||||
/**
|
||||
* Management endpoint context-path (for instance, `/management`). Requires a
|
||||
* custom management.server.port.
|
||||
*/
|
||||
private String contextPath = "";
|
||||
|
||||
/**
|
||||
* Return the context path with no trailing slash (i.e. the '/' root context is
|
||||
* represented as the empty string).
|
||||
* @return the context path (no trailing slash)
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link ManagementServerProperties#getBasePath()}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "management.server.base-path")
|
||||
public String getContextPath() {
|
||||
return this.contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the context path.
|
||||
* @param contextPath the context path
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link ManagementServerProperties#setBasePath(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setContextPath(String contextPath) {
|
||||
Assert.notNull(contextPath, "ContextPath must not be null");
|
||||
this.contextPath = cleanContextPath(contextPath);
|
||||
}
|
||||
|
||||
private String cleanContextPath(String contextPath) {
|
||||
if (StringUtils.hasText(contextPath) && contextPath.endsWith("/")) {
|
||||
return contextPath.substring(0, contextPath.length() - 1);
|
||||
}
|
||||
return contextPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -126,10 +126,9 @@ class ServletManagementChildContextConfiguration {
|
||||
webServerFactory.setContextPath(getContextPath(managementServerProperties));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private String getContextPath(ManagementServerProperties managementServerProperties) {
|
||||
String basePath = managementServerProperties.getBasePath();
|
||||
return StringUtils.hasText(basePath) ? basePath : managementServerProperties.getServlet().getContextPath();
|
||||
return StringUtils.hasText(basePath) ? basePath : "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -35,7 +35,6 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class CassandraHealthContributorAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
@@ -45,39 +44,20 @@ class CassandraHealthContributorAutoConfigurationTests {
|
||||
@Test
|
||||
void runWithoutCqlSessionOrCassandraOperationsShouldNotCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionOnlyShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCassandraOperationsOnlyShouldCreateRegularIndicator() {
|
||||
this.contextRunner.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionAndCassandraOperationsShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionAndSpringDataAbsentShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withClassLoader(new FilteredClassLoader("org.springframework.data"))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,7 +66,6 @@ class CassandraHealthContributorAutoConfigurationTests {
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -37,7 +37,6 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Artsiom Yudovin
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class CassandraReactiveHealthContributorAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
@@ -47,28 +46,13 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
|
||||
@Test
|
||||
void runWithoutCqlSessionOrReactiveCassandraOperationsShouldNotCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionOnlyShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class).doesNotHaveBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithReactiveCassandraOperationsOnlyShouldCreateReactiveIndicator() {
|
||||
this.contextRunner.withBean(ReactiveCassandraOperations.class, () -> mock(ReactiveCassandraOperations.class))
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class)).run((context) -> assertThat(context)
|
||||
.hasBean("cassandraHealthContributor").hasSingleBean(CassandraDriverReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,9 +62,6 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(org.springframework.boot.actuate.cassandra.CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@@ -89,8 +70,7 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withClassLoader(new FilteredClassLoader("org.springframework.data"))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class).doesNotHaveBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class));
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,8 +78,7 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(ReactiveCassandraOperations.class, () -> mock(ReactiveCassandraOperations.class))
|
||||
.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor").doesNotHaveBean(
|
||||
org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class ConfigurationPropertiesReportEndpointDocumentationTests extends MockMvcEnd
|
||||
|
||||
@Test
|
||||
void configPropsFilterByPrefix() throws Exception {
|
||||
this.mockMvc.perform(get("/actuator/configprops/spring.resources")).andExpect(status().isOk())
|
||||
this.mockMvc.perform(get("/actuator/configprops/spring.jackson")).andExpect(status().isOk())
|
||||
.andDo(MockMvcRestDocumentation.document("configprops/prefixed",
|
||||
preprocessResponse(limit("contexts", getApplicationContext().getId(), "beans")),
|
||||
responseFields(fieldWithPath("contexts").description("Application contexts keyed by id."),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -41,21 +41,6 @@ class ManagementServerPropertiesTests {
|
||||
assertThat(properties.getPort()).isEqualTo(123);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void defaultContextPathIsEmptyString() {
|
||||
ManagementServerProperties properties = new ManagementServerProperties();
|
||||
assertThat(properties.getServlet().getContextPath()).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void definedContextPath() {
|
||||
ManagementServerProperties properties = new ManagementServerProperties();
|
||||
properties.getServlet().setContextPath("/foo");
|
||||
assertThat(properties.getServlet().getContextPath()).isEqualTo("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultBasePathIsEmptyString() {
|
||||
ManagementServerProperties properties = new ManagementServerProperties();
|
||||
@@ -69,14 +54,6 @@ class ManagementServerPropertiesTests {
|
||||
assertThat(properties.getBasePath()).isEqualTo("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void trailingSlashOfContextPathIsRemoved() {
|
||||
ManagementServerProperties properties = new ManagementServerProperties();
|
||||
properties.getServlet().setContextPath("/foo/");
|
||||
assertThat(properties.getServlet().getContextPath()).isEqualTo("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void trailingSlashOfBasePathIsRemoved() {
|
||||
ManagementServerProperties properties = new ManagementServerProperties();
|
||||
@@ -84,14 +61,6 @@ class ManagementServerPropertiesTests {
|
||||
assertThat(properties.getBasePath()).isEqualTo("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void slashOfContextPathIsDefaultValue() {
|
||||
ManagementServerProperties properties = new ManagementServerProperties();
|
||||
properties.getServlet().setContextPath("/");
|
||||
assertThat(properties.getServlet().getContextPath()).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
void slashOfBasePathIsDefaultValue() {
|
||||
ManagementServerProperties properties = new ManagementServerProperties();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -135,26 +135,6 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests {
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenManagementServletContextPathIsConfiguredThenEndpointsAreBeneathThatPath() {
|
||||
this.runner.withPropertyValues("management.server.servlet.context-path:/manage")
|
||||
.run(withWebTestClient((client) -> {
|
||||
String body = client.get().uri("manage/actuator/success").accept(MediaType.APPLICATION_JSON)
|
||||
.exchangeToMono((response) -> response.bodyToMono(String.class)).block();
|
||||
assertThat(body).isEqualTo("Success");
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenManagementBasePathAndServletContextPathAreConfiguredThenEndpointsAreBeneathBasePath() {
|
||||
this.runner.withPropertyValues("management.server.servlet.context-path:/admin",
|
||||
"management.server.base-path:/manage").run(withWebTestClient((client) -> {
|
||||
String body = client.get().uri("manage/actuator/success").accept(MediaType.APPLICATION_JSON)
|
||||
.exchangeToMono((response) -> response.bodyToMono(String.class)).block();
|
||||
assertThat(body).isEqualTo("Success");
|
||||
}));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableWebApplicationContext> withWebTestClient(Consumer<WebClient> webClient) {
|
||||
return (context) -> {
|
||||
String port = context.getEnvironment().getProperty("local.management.port");
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.cassandra;
|
||||
|
||||
import com.datastax.oss.driver.api.core.ConsistencyLevel;
|
||||
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
|
||||
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Simple implementation of a {@link HealthIndicator} returning status information for
|
||||
* Cassandra data stores.
|
||||
*
|
||||
* @author Julien Dubois
|
||||
* @author Alexandre Dutra
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link CassandraDriverHealthIndicator}
|
||||
*/
|
||||
@Deprecated
|
||||
public class CassandraHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
private static final SimpleStatement SELECT = SimpleStatement
|
||||
.newInstance("SELECT release_version FROM system.local").setConsistencyLevel(ConsistencyLevel.LOCAL_ONE);
|
||||
|
||||
private CassandraOperations cassandraOperations;
|
||||
|
||||
public CassandraHealthIndicator() {
|
||||
super("Cassandra health check failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link CassandraHealthIndicator} instance.
|
||||
* @param cassandraOperations the Cassandra operations
|
||||
*/
|
||||
public CassandraHealthIndicator(CassandraOperations cassandraOperations) {
|
||||
super("Cassandra health check failed");
|
||||
Assert.notNull(cassandraOperations, "CassandraOperations must not be null");
|
||||
this.cassandraOperations = cassandraOperations;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
String version = this.cassandraOperations.getCqlOperations().queryForObject(SELECT, String.class);
|
||||
builder.up().withDetail("version", version);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.cassandra;
|
||||
|
||||
import com.datastax.oss.driver.api.core.ConsistencyLevel;
|
||||
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.actuate.health.AbstractReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link ReactiveHealthIndicator} for Cassandra.
|
||||
*
|
||||
* @author Artsiom Yudovin
|
||||
* @since 2.1.0
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link CassandraDriverHealthIndicator}
|
||||
*/
|
||||
@Deprecated
|
||||
public class CassandraReactiveHealthIndicator extends AbstractReactiveHealthIndicator {
|
||||
|
||||
private static final SimpleStatement SELECT = SimpleStatement
|
||||
.newInstance("SELECT release_version FROM system.local").setConsistencyLevel(ConsistencyLevel.LOCAL_ONE);
|
||||
|
||||
private final ReactiveCassandraOperations reactiveCassandraOperations;
|
||||
|
||||
/**
|
||||
* Create a new {@link CassandraHealthIndicator} instance.
|
||||
* @param reactiveCassandraOperations the Cassandra operations
|
||||
*/
|
||||
public CassandraReactiveHealthIndicator(ReactiveCassandraOperations reactiveCassandraOperations) {
|
||||
super("Cassandra health check failed");
|
||||
Assert.notNull(reactiveCassandraOperations, "ReactiveCassandraOperations must not be null");
|
||||
this.reactiveCassandraOperations = reactiveCassandraOperations;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mono<Health> doHealthCheck(Health.Builder builder) {
|
||||
return this.reactiveCassandraOperations.getReactiveCqlOperations().queryForObject(SELECT, String.class)
|
||||
.map((version) -> builder.up().withDetail("version", version).build()).single();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.cassandra;
|
||||
|
||||
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.data.cassandra.CassandraInternalException;
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.data.cassandra.core.cql.CqlOperations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link CassandraHealthIndicator}.
|
||||
*
|
||||
* @author Oleksii Bondar
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
class CassandraHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
void createWhenCassandraOperationsIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new CassandraHealthIndicator(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWithCassandraUp() {
|
||||
CassandraOperations cassandraOperations = mock(CassandraOperations.class);
|
||||
CqlOperations cqlOperations = mock(CqlOperations.class);
|
||||
CassandraHealthIndicator healthIndicator = new CassandraHealthIndicator(cassandraOperations);
|
||||
given(cassandraOperations.getCqlOperations()).willReturn(cqlOperations);
|
||||
given(cqlOperations.queryForObject(any(SimpleStatement.class), eq(String.class))).willReturn("1.0.0");
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails().get("version")).isEqualTo("1.0.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWithCassandraDown() {
|
||||
CassandraOperations cassandraOperations = mock(CassandraOperations.class);
|
||||
given(cassandraOperations.getCqlOperations()).willThrow(new CassandraInternalException("Connection failed"));
|
||||
CassandraHealthIndicator healthIndicator = new CassandraHealthIndicator(cassandraOperations);
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat(health.getDetails().get("error"))
|
||||
.isEqualTo(CassandraInternalException.class.getName() + ": Connection failed");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.cassandra;
|
||||
|
||||
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.data.cassandra.CassandraInternalException;
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
import org.springframework.data.cassandra.core.cql.ReactiveCqlOperations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link CassandraReactiveHealthIndicator}.
|
||||
*
|
||||
* @author Artsiom Yudovin
|
||||
*/
|
||||
@Deprecated
|
||||
class CassandraReactiveHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
void testCassandraIsUp() {
|
||||
ReactiveCqlOperations reactiveCqlOperations = mock(ReactiveCqlOperations.class);
|
||||
given(reactiveCqlOperations.queryForObject(any(SimpleStatement.class), eq(String.class)))
|
||||
.willReturn(Mono.just("6.0.0"));
|
||||
ReactiveCassandraOperations reactiveCassandraOperations = mock(ReactiveCassandraOperations.class);
|
||||
given(reactiveCassandraOperations.getReactiveCqlOperations()).willReturn(reactiveCqlOperations);
|
||||
|
||||
CassandraReactiveHealthIndicator cassandraReactiveHealthIndicator = new CassandraReactiveHealthIndicator(
|
||||
reactiveCassandraOperations);
|
||||
Mono<Health> health = cassandraReactiveHealthIndicator.health();
|
||||
StepVerifier.create(health).consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(h.getDetails()).containsOnlyKeys("version");
|
||||
assertThat(h.getDetails().get("version")).isEqualTo("6.0.0");
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCassandraIsDown() {
|
||||
ReactiveCassandraOperations reactiveCassandraOperations = mock(ReactiveCassandraOperations.class);
|
||||
given(reactiveCassandraOperations.getReactiveCqlOperations())
|
||||
.willThrow(new CassandraInternalException("Connection failed"));
|
||||
|
||||
CassandraReactiveHealthIndicator cassandraReactiveHealthIndicator = new CassandraReactiveHealthIndicator(
|
||||
reactiveCassandraOperations);
|
||||
Mono<Health> health = cassandraReactiveHealthIndicator.health();
|
||||
StepVerifier.create(health).consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat(h.getDetails()).containsOnlyKeys("error");
|
||||
assertThat(h.getDetails().get("error"))
|
||||
.isEqualTo(CassandraInternalException.class.getName() + ": Connection failed");
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.batch;
|
||||
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
|
||||
/**
|
||||
* {@link ApplicationRunner} to {@link JobLauncher launch} Spring Batch jobs. Runs all
|
||||
* jobs in the surrounding context by default. Can also be used to launch a specific job
|
||||
* by providing a jobName.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Jean-Pierre Bergamin
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 1.0.0
|
||||
* @deprecated since 2.3.0 for removal in 2.6.0 in favor of
|
||||
* {@link JobLauncherApplicationRunner}
|
||||
*/
|
||||
@Deprecated
|
||||
public class JobLauncherCommandLineRunner extends JobLauncherApplicationRunner {
|
||||
|
||||
/**
|
||||
* Create a new {@link JobLauncherCommandLineRunner}.
|
||||
* @param jobLauncher to launch jobs
|
||||
* @param jobExplorer to check the job repository for previous executions
|
||||
* @param jobRepository to check if a job instance exists with the given parameters
|
||||
* when running a job
|
||||
*/
|
||||
public JobLauncherCommandLineRunner(JobLauncher jobLauncher, JobExplorer jobExplorer, JobRepository jobRepository) {
|
||||
super(jobLauncher, jobExplorer, jobRepository);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.hazelcast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.hazelcast.client.HazelcastClient;
|
||||
import com.hazelcast.client.config.ClientConfig;
|
||||
import com.hazelcast.client.config.XmlClientConfigBuilder;
|
||||
import com.hazelcast.client.config.YamlClientConfigBuilder;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Factory that can be used to create a client {@link HazelcastInstance}.
|
||||
*
|
||||
* @author Vedran Pavic
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.4.3 for removal in 2.6 in favor of using the Hazelcast API directly
|
||||
*/
|
||||
@Deprecated
|
||||
public class HazelcastClientFactory {
|
||||
|
||||
private final ClientConfig clientConfig;
|
||||
|
||||
/**
|
||||
* Create a {@link HazelcastClientFactory} for the specified configuration location.
|
||||
* @param clientConfigLocation the location of the configuration file
|
||||
* @throws IOException if the configuration location could not be read
|
||||
*/
|
||||
public HazelcastClientFactory(Resource clientConfigLocation) throws IOException {
|
||||
this.clientConfig = getClientConfig(clientConfigLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link HazelcastClientFactory} for the specified configuration.
|
||||
* @param clientConfig the configuration
|
||||
*/
|
||||
public HazelcastClientFactory(ClientConfig clientConfig) {
|
||||
Assert.notNull(clientConfig, "ClientConfig must not be null");
|
||||
this.clientConfig = clientConfig;
|
||||
}
|
||||
|
||||
private ClientConfig getClientConfig(Resource clientConfigLocation) throws IOException {
|
||||
URL configUrl = clientConfigLocation.getURL();
|
||||
String configFileName = configUrl.getPath();
|
||||
if (configFileName.endsWith(".yaml")) {
|
||||
return new YamlClientConfigBuilder(configUrl).build();
|
||||
}
|
||||
return new XmlClientConfigBuilder(configUrl).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link HazelcastInstance}.
|
||||
* @return the {@link HazelcastInstance}
|
||||
*/
|
||||
public HazelcastInstance getHazelcastInstance() {
|
||||
if (StringUtils.hasText(this.clientConfig.getInstanceName())) {
|
||||
return HazelcastClient.getOrCreateHazelcastClient(this.clientConfig);
|
||||
}
|
||||
return HazelcastClient.newHazelcastClient(this.clientConfig);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.hazelcast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.hazelcast.config.Config;
|
||||
import com.hazelcast.config.XmlConfigBuilder;
|
||||
import com.hazelcast.config.YamlConfigBuilder;
|
||||
import com.hazelcast.core.Hazelcast;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Factory that can be used to create a {@link HazelcastInstance}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Phillip Webb
|
||||
* @since 1.3.0
|
||||
* @deprecated since 2.4.3 for removal in 2.6 in favor of using the Hazelcast API directly
|
||||
*/
|
||||
@Deprecated
|
||||
public class HazelcastInstanceFactory {
|
||||
|
||||
private final Config config;
|
||||
|
||||
/**
|
||||
* Create a {@link HazelcastInstanceFactory} for the specified configuration location.
|
||||
* @param configLocation the location of the configuration file
|
||||
* @throws IOException if the configuration location could not be read
|
||||
*/
|
||||
public HazelcastInstanceFactory(Resource configLocation) throws IOException {
|
||||
Assert.notNull(configLocation, "ConfigLocation must not be null");
|
||||
this.config = getConfig(configLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link HazelcastInstanceFactory} for the specified configuration.
|
||||
* @param config the configuration
|
||||
*/
|
||||
public HazelcastInstanceFactory(Config config) {
|
||||
Assert.notNull(config, "Config must not be null");
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
private Config getConfig(Resource configLocation) throws IOException {
|
||||
URL configUrl = configLocation.getURL();
|
||||
Config config = createConfig(configUrl);
|
||||
if (ResourceUtils.isFileURL(configUrl)) {
|
||||
config.setConfigurationFile(configLocation.getFile());
|
||||
}
|
||||
else {
|
||||
config.setConfigurationUrl(configUrl);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
private static Config createConfig(URL configUrl) throws IOException {
|
||||
String configFileName = configUrl.getPath();
|
||||
if (configFileName.endsWith(".yaml")) {
|
||||
return new YamlConfigBuilder(configUrl).build();
|
||||
}
|
||||
return new XmlConfigBuilder(configUrl).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link HazelcastInstance}.
|
||||
* @return the {@link HazelcastInstance}
|
||||
*/
|
||||
public HazelcastInstance getHazelcastInstance() {
|
||||
if (StringUtils.hasText(this.config.getInstanceName())) {
|
||||
return Hazelcast.getOrCreateHazelcastInstance(this.config);
|
||||
}
|
||||
return Hazelcast.newHazelcastInstance(this.config);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import com.mongodb.ConnectionString;
|
||||
import org.bson.UuidRepresentation;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Configuration properties for Mongo.
|
||||
@@ -195,23 +194,6 @@ public class MongoProperties {
|
||||
return this.gridfs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the GridFS database name.
|
||||
* @return the GridFS database name
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link Gridfs#getDatabase()}
|
||||
*/
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.data.mongodb.gridfs.database")
|
||||
@Deprecated
|
||||
public String getGridFsDatabase() {
|
||||
return this.gridfs.getDatabase();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setGridFsDatabase(String gridFsDatabase) {
|
||||
this.gridfs.setDatabase(gridFsDatabase);
|
||||
}
|
||||
|
||||
public String getMongoClientDatabase() {
|
||||
if (this.database != null) {
|
||||
return this.database;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -20,12 +20,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.autoconfigure.web.WebProperties.Resources.Chain;
|
||||
import org.springframework.boot.context.properties.bind.BindResult;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -45,10 +42,9 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
|
||||
String prefix = determineResourcePropertiesPrefix(environment);
|
||||
boolean fixed = getEnabledProperty(environment, prefix, "strategy.fixed.", false);
|
||||
boolean content = getEnabledProperty(environment, prefix, "strategy.content.", false);
|
||||
Boolean chain = getEnabledProperty(environment, prefix, "", null);
|
||||
boolean fixed = getEnabledProperty(environment, "strategy.fixed.", false);
|
||||
boolean content = getEnabledProperty(environment, "strategy.content.", false);
|
||||
Boolean chain = getEnabledProperty(environment, "", null);
|
||||
Boolean match = Chain.getEnabled(fixed, content, chain);
|
||||
ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnEnabledResourceChain.class);
|
||||
if (match == null) {
|
||||
@@ -63,19 +59,8 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
|
||||
return ConditionOutcome.noMatch(message.because("disabled"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private String determineResourcePropertiesPrefix(Environment environment) {
|
||||
BindResult<org.springframework.boot.autoconfigure.web.ResourceProperties> result = Binder.get(environment)
|
||||
.bind("spring.resources", org.springframework.boot.autoconfigure.web.ResourceProperties.class);
|
||||
if (result.isBound() && result.get().hasBeenCustomized()) {
|
||||
return "spring.resources.chain.";
|
||||
}
|
||||
return "spring.web.resources.chain.";
|
||||
}
|
||||
|
||||
private Boolean getEnabledProperty(ConfigurableEnvironment environment, String prefix, String key,
|
||||
Boolean defaultValue) {
|
||||
String name = prefix + key + "enabled";
|
||||
private Boolean getEnabledProperty(ConfigurableEnvironment environment, String key, Boolean defaultValue) {
|
||||
String name = "spring.web.resources.chain." + key + "enabled";
|
||||
return environment.getProperty(name, Boolean.class, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,282 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.web;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Properties used to configure resource handling.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Brian Clozel
|
||||
* @author Dave Syer
|
||||
* @author Venil Noronha
|
||||
* @author Kristine Jetzke
|
||||
* @since 1.1.0
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link WebProperties.Resources}
|
||||
*/
|
||||
@Deprecated
|
||||
@ConfigurationProperties(prefix = "spring.resources", ignoreUnknownFields = false)
|
||||
public class ResourceProperties extends Resources {
|
||||
|
||||
private final Chain chain = new Chain();
|
||||
|
||||
private final Cache cache = new Cache();
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.static-locations")
|
||||
public String[] getStaticLocations() {
|
||||
return super.getStaticLocations();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.add-mappings")
|
||||
public boolean isAddMappings() {
|
||||
return super.isAddMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chain getChain() {
|
||||
return this.chain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cache getCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static class Chain extends Resources.Chain {
|
||||
|
||||
private final org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy strategy = new org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy();
|
||||
|
||||
/**
|
||||
* Whether to enable HTML5 application cache manifest rewriting.
|
||||
*/
|
||||
private boolean htmlApplicationCache = false;
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.enabled")
|
||||
public Boolean getEnabled() {
|
||||
return super.getEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.cache")
|
||||
public boolean isCache() {
|
||||
return super.isCache();
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(reason = "The appcache manifest feature is being removed from browsers.")
|
||||
public boolean isHtmlApplicationCache() {
|
||||
return this.htmlApplicationCache;
|
||||
}
|
||||
|
||||
public void setHtmlApplicationCache(boolean htmlApplicationCache) {
|
||||
this.htmlApplicationCache = htmlApplicationCache;
|
||||
this.customized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.compressed")
|
||||
public boolean isCompressed() {
|
||||
return super.isCompressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy getStrategy() {
|
||||
return this.strategy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Strategies for extracting and embedding a resource version in its URL path.
|
||||
*/
|
||||
@Deprecated
|
||||
public static class Strategy extends Resources.Chain.Strategy {
|
||||
|
||||
private final org.springframework.boot.autoconfigure.web.ResourceProperties.Fixed fixed = new org.springframework.boot.autoconfigure.web.ResourceProperties.Fixed();
|
||||
|
||||
private final org.springframework.boot.autoconfigure.web.ResourceProperties.Content content = new org.springframework.boot.autoconfigure.web.ResourceProperties.Content();
|
||||
|
||||
@Override
|
||||
public org.springframework.boot.autoconfigure.web.ResourceProperties.Fixed getFixed() {
|
||||
return this.fixed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.springframework.boot.autoconfigure.web.ResourceProperties.Content getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Version Strategy based on content hashing.
|
||||
*/
|
||||
@Deprecated
|
||||
public static class Content extends Resources.Chain.Strategy.Content {
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.content.enabled")
|
||||
public boolean isEnabled() {
|
||||
return super.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.content.paths")
|
||||
public String[] getPaths() {
|
||||
return super.getPaths();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Version Strategy based on a fixed version string.
|
||||
*/
|
||||
@Deprecated
|
||||
public static class Fixed extends Resources.Chain.Strategy.Fixed {
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.fixed.enabled")
|
||||
public boolean isEnabled() {
|
||||
return super.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.fixed.paths")
|
||||
public String[] getPaths() {
|
||||
return super.getPaths();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.fixed.version")
|
||||
public String getVersion() {
|
||||
return super.getVersion();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache configuration.
|
||||
*/
|
||||
@Deprecated
|
||||
public static class Cache extends Resources.Cache {
|
||||
|
||||
private final Cachecontrol cachecontrol = new Cachecontrol();
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.period")
|
||||
public Duration getPeriod() {
|
||||
return super.getPeriod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cachecontrol getCachecontrol() {
|
||||
return this.cachecontrol;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.use-last-modified")
|
||||
public boolean isUseLastModified() {
|
||||
return super.isUseLastModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache Control HTTP header configuration.
|
||||
*/
|
||||
@Deprecated
|
||||
public static class Cachecontrol extends Resources.Cache.Cachecontrol {
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.max-age")
|
||||
public Duration getMaxAge() {
|
||||
return super.getMaxAge();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.no-cache")
|
||||
public Boolean getNoCache() {
|
||||
return super.getNoCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.no-store")
|
||||
public Boolean getNoStore() {
|
||||
return super.getNoStore();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.must-revalidate")
|
||||
public Boolean getMustRevalidate() {
|
||||
return super.getMustRevalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.no-transform")
|
||||
public Boolean getNoTransform() {
|
||||
return super.getNoTransform();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.cache-public")
|
||||
public Boolean getCachePublic() {
|
||||
return super.getCachePublic();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.cache-private")
|
||||
public Boolean getCachePrivate() {
|
||||
return super.getCachePrivate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.proxy-revalidate")
|
||||
public Boolean getProxyRevalidate() {
|
||||
return super.getProxyRevalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(
|
||||
replacement = "spring.web.resources.cache.cachecontrol.stale-while-revalidate")
|
||||
public Duration getStaleWhileRevalidate() {
|
||||
return super.getStaleWhileRevalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.stale-if-error")
|
||||
public Duration getStaleIfError() {
|
||||
return super.getStaleIfError();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.s-max-age")
|
||||
public Duration getSMaxAge() {
|
||||
return super.getSMaxAge();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -52,11 +52,6 @@ class ResourceChainResourceHandlerRegistrationCustomizer implements ResourceHand
|
||||
if (strategy.getFixed().isEnabled() || strategy.getContent().isEnabled()) {
|
||||
chain.addResolver(getVersionResourceResolver(strategy));
|
||||
}
|
||||
if ((properties instanceof org.springframework.boot.autoconfigure.web.ResourceProperties.Chain)
|
||||
&& ((org.springframework.boot.autoconfigure.web.ResourceProperties.Chain) properties)
|
||||
.isHtmlApplicationCache()) {
|
||||
chain.addTransformer(new org.springframework.web.reactive.resource.AppCacheManifestTransformer());
|
||||
}
|
||||
}
|
||||
|
||||
private ResourceResolver getVersionResourceResolver(Resources.Chain.Strategy properties) {
|
||||
|
||||
@@ -115,11 +115,8 @@ public class WebFluxAutoConfiguration {
|
||||
@Bean
|
||||
@SuppressWarnings("deprecation")
|
||||
public RouterFunctionMapping welcomePageRouterFunctionMapping(ApplicationContext applicationContext,
|
||||
WebFluxProperties webFluxProperties,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
WebProperties webProperties) {
|
||||
String[] staticLocations = resourceProperties.hasBeenCustomized() ? resourceProperties.getStaticLocations()
|
||||
: webProperties.getResources().getStaticLocations();
|
||||
WebFluxProperties webFluxProperties, WebProperties webProperties) {
|
||||
String[] staticLocations = webProperties.getResources().getStaticLocations();
|
||||
WelcomePageRouterFunctionFactory factory = new WelcomePageRouterFunctionFactory(
|
||||
new TemplateAvailabilityProviders(applicationContext), applicationContext, staticLocations,
|
||||
webFluxProperties.getStaticPathPattern());
|
||||
@@ -136,8 +133,7 @@ public class WebFluxAutoConfiguration {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties({ org.springframework.boot.autoconfigure.web.ResourceProperties.class,
|
||||
WebProperties.class, WebFluxProperties.class })
|
||||
@EnableConfigurationProperties({ WebProperties.class, WebFluxProperties.class })
|
||||
@Import({ EnableWebFluxConfiguration.class })
|
||||
@Order(0)
|
||||
public static class WebFluxConfig implements WebFluxConfigurer {
|
||||
@@ -158,14 +154,12 @@ public class WebFluxAutoConfiguration {
|
||||
|
||||
private final ObjectProvider<ViewResolver> viewResolvers;
|
||||
|
||||
public WebFluxConfig(org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
WebProperties webProperties, WebFluxProperties webFluxProperties, ListableBeanFactory beanFactory,
|
||||
ObjectProvider<HandlerMethodArgumentResolver> resolvers,
|
||||
public WebFluxConfig(WebProperties webProperties, WebFluxProperties webFluxProperties,
|
||||
ListableBeanFactory beanFactory, ObjectProvider<HandlerMethodArgumentResolver> resolvers,
|
||||
ObjectProvider<CodecCustomizer> codecCustomizers,
|
||||
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizer,
|
||||
ObjectProvider<ViewResolver> viewResolvers) {
|
||||
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
|
||||
: webProperties.getResources();
|
||||
this.resourceProperties = webProperties.getResources();
|
||||
this.webFluxProperties = webFluxProperties;
|
||||
this.beanFactory = beanFactory;
|
||||
this.argumentResolvers = resolvers;
|
||||
@@ -331,13 +325,9 @@ public class WebFluxAutoConfiguration {
|
||||
static class ResourceChainCustomizerConfiguration {
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("deprecation")
|
||||
ResourceChainResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer(
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
WebProperties webProperties) {
|
||||
Resources resources = resourceProperties.hasBeenCustomized() ? resourceProperties
|
||||
: webProperties.getResources();
|
||||
return new ResourceChainResourceHandlerRegistrationCustomizer(resources);
|
||||
return new ResourceChainResourceHandlerRegistrationCustomizer(webProperties.getResources());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,21 +92,6 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept
|
||||
|
||||
private List<ViewResolver> viewResolvers = Collections.emptyList();
|
||||
|
||||
/**
|
||||
* Create a new {@code AbstractErrorWebExceptionHandler}.
|
||||
* @param errorAttributes the error attributes
|
||||
* @param resourceProperties the resource properties
|
||||
* @param applicationContext the application context
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #AbstractErrorWebExceptionHandler(ErrorAttributes, Resources, ApplicationContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
public AbstractErrorWebExceptionHandler(ErrorAttributes errorAttributes,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
ApplicationContext applicationContext) {
|
||||
this(errorAttributes, (Resources) resourceProperties, applicationContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code AbstractErrorWebExceptionHandler}.
|
||||
* @param errorAttributes the error attributes
|
||||
|
||||
@@ -91,22 +91,6 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
|
||||
|
||||
private final ErrorProperties errorProperties;
|
||||
|
||||
/**
|
||||
* Create a new {@code DefaultErrorWebExceptionHandler} instance.
|
||||
* @param errorAttributes the error attributes
|
||||
* @param resourceProperties the resources configuration properties
|
||||
* @param errorProperties the error configuration properties
|
||||
* @param applicationContext the current application context
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #DefaultErrorWebExceptionHandler(ErrorAttributes, Resources, ErrorProperties, ApplicationContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
public DefaultErrorWebExceptionHandler(ErrorAttributes errorAttributes,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
ErrorProperties errorProperties, ApplicationContext applicationContext) {
|
||||
this(errorAttributes, (Resources) resourceProperties, errorProperties, applicationContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code DefaultErrorWebExceptionHandler} instance.
|
||||
* @param errorAttributes the error attributes
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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,8 +53,7 @@ import org.springframework.web.reactive.result.view.ViewResolver;
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
|
||||
@ConditionalOnClass(WebFluxConfigurer.class)
|
||||
@AutoConfigureBefore(WebFluxAutoConfiguration.class)
|
||||
@EnableConfigurationProperties({ ServerProperties.class,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties.class, WebProperties.class })
|
||||
@EnableConfigurationProperties({ ServerProperties.class, WebProperties.class })
|
||||
public class ErrorWebFluxAutoConfiguration {
|
||||
|
||||
private final ServerProperties serverProperties;
|
||||
@@ -67,12 +66,10 @@ public class ErrorWebFluxAutoConfiguration {
|
||||
@ConditionalOnMissingBean(value = ErrorWebExceptionHandler.class, search = SearchStrategy.CURRENT)
|
||||
@Order(-1)
|
||||
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
WebProperties webProperties, ObjectProvider<ViewResolver> viewResolvers,
|
||||
ServerCodecConfigurer serverCodecConfigurer, ApplicationContext applicationContext) {
|
||||
DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes,
|
||||
resourceProperties.hasBeenCustomized() ? resourceProperties : webProperties.getResources(),
|
||||
this.serverProperties.getError(), applicationContext);
|
||||
webProperties.getResources(), this.serverProperties.getError(), applicationContext);
|
||||
exceptionHandler.setViewResolvers(viewResolvers.orderedStream().collect(Collectors.toList()));
|
||||
exceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters());
|
||||
exceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders());
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.web.servlet;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -180,8 +179,7 @@ public class WebMvcAutoConfiguration {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import(EnableWebMvcConfiguration.class)
|
||||
@EnableConfigurationProperties({ WebMvcProperties.class,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties.class, WebProperties.class })
|
||||
@EnableConfigurationProperties({ WebMvcProperties.class, WebProperties.class })
|
||||
@Order(0)
|
||||
public static class WebMvcAutoConfigurationAdapter implements WebMvcConfigurer, ServletContextAware {
|
||||
|
||||
@@ -203,15 +201,12 @@ public class WebMvcAutoConfiguration {
|
||||
|
||||
private ServletContext servletContext;
|
||||
|
||||
public WebMvcAutoConfigurationAdapter(
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
WebProperties webProperties, WebMvcProperties mvcProperties, ListableBeanFactory beanFactory,
|
||||
ObjectProvider<HttpMessageConverters> messageConvertersProvider,
|
||||
public WebMvcAutoConfigurationAdapter(WebProperties webProperties, WebMvcProperties mvcProperties,
|
||||
ListableBeanFactory beanFactory, ObjectProvider<HttpMessageConverters> messageConvertersProvider,
|
||||
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizerProvider,
|
||||
ObjectProvider<DispatcherServletPath> dispatcherServletPath,
|
||||
ObjectProvider<ServletRegistrationBean<?>> servletRegistrations) {
|
||||
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
|
||||
: webProperties.getResources();
|
||||
this.resourceProperties = webProperties.getResources();
|
||||
this.mvcProperties = mvcProperties;
|
||||
this.beanFactory = beanFactory;
|
||||
this.messageConvertersProvider = messageConvertersProvider;
|
||||
@@ -399,15 +394,11 @@ public class WebMvcAutoConfiguration {
|
||||
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public EnableWebMvcConfiguration(
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
WebMvcProperties mvcProperties, WebProperties webProperties,
|
||||
public EnableWebMvcConfiguration(WebMvcProperties mvcProperties, WebProperties webProperties,
|
||||
ObjectProvider<WebMvcRegistrations> mvcRegistrationsProvider,
|
||||
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizerProvider,
|
||||
ListableBeanFactory beanFactory) {
|
||||
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
|
||||
: webProperties.getResources();
|
||||
this.resourceProperties = webProperties.getResources();
|
||||
this.mvcProperties = mvcProperties;
|
||||
this.webProperties = webProperties;
|
||||
this.mvcRegistrations = mvcRegistrationsProvider.getIfUnique();
|
||||
@@ -464,18 +455,12 @@ public class WebMvcAutoConfiguration {
|
||||
@Override
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME)
|
||||
@SuppressWarnings("deprecation")
|
||||
public LocaleResolver localeResolver() {
|
||||
if (this.webProperties.getLocaleResolver() == WebProperties.LocaleResolver.FIXED) {
|
||||
return new FixedLocaleResolver(this.webProperties.getLocale());
|
||||
}
|
||||
if (this.mvcProperties.getLocaleResolver() == WebMvcProperties.LocaleResolver.FIXED) {
|
||||
return new FixedLocaleResolver(this.mvcProperties.getLocale());
|
||||
}
|
||||
AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();
|
||||
Locale locale = (this.webProperties.getLocale() != null) ? this.webProperties.getLocale()
|
||||
: this.mvcProperties.getLocale();
|
||||
localeResolver.setDefaultLocale(locale);
|
||||
localeResolver.setDefaultLocale(this.webProperties.getLocale());
|
||||
return localeResolver;
|
||||
}
|
||||
|
||||
@@ -616,12 +601,9 @@ public class WebMvcAutoConfiguration {
|
||||
static class ResourceChainCustomizerConfiguration {
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("deprecation")
|
||||
ResourceChainResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer(
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
WebProperties webProperties) {
|
||||
return new ResourceChainResourceHandlerRegistrationCustomizer(
|
||||
resourceProperties.hasBeenCustomized() ? resourceProperties : webProperties.getResources());
|
||||
return new ResourceChainResourceHandlerRegistrationCustomizer(webProperties.getResources());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -646,7 +628,6 @@ public class WebMvcAutoConfiguration {
|
||||
configureResourceChain(properties, registration.resourceChain(properties.isCache()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void configureResourceChain(Resources.Chain properties, ResourceChainRegistration chain) {
|
||||
Strategy strategy = properties.getStrategy();
|
||||
if (properties.isCompressed()) {
|
||||
@@ -655,11 +636,6 @@ public class WebMvcAutoConfiguration {
|
||||
if (strategy.getFixed().isEnabled() || strategy.getContent().isEnabled()) {
|
||||
chain.addResolver(getVersionResourceResolver(strategy));
|
||||
}
|
||||
if (properties instanceof org.springframework.boot.autoconfigure.web.ResourceProperties.Chain
|
||||
&& ((org.springframework.boot.autoconfigure.web.ResourceProperties.Chain) properties)
|
||||
.isHtmlApplicationCache()) {
|
||||
chain.addTransformer(new org.springframework.web.servlet.resource.AppCacheManifestTransformer());
|
||||
}
|
||||
}
|
||||
|
||||
private ResourceResolver getVersionResourceResolver(Strategy properties) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.web.servlet;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -46,17 +45,6 @@ public class WebMvcProperties {
|
||||
*/
|
||||
private DefaultMessageCodesResolver.Format messageCodesResolverFormat;
|
||||
|
||||
/**
|
||||
* Locale to use. By default, this locale is overridden by the "Accept-Language"
|
||||
* header.
|
||||
*/
|
||||
private Locale locale;
|
||||
|
||||
/**
|
||||
* Define how the locale should be resolved.
|
||||
*/
|
||||
private LocaleResolver localeResolver = LocaleResolver.ACCEPT_HEADER;
|
||||
|
||||
private final Format format = new Format();
|
||||
|
||||
/**
|
||||
@@ -121,26 +109,6 @@ public class WebMvcProperties {
|
||||
this.messageCodesResolverFormat = messageCodesResolverFormat;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.locale")
|
||||
public Locale getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.web.locale-resolver")
|
||||
public LocaleResolver getLocaleResolver() {
|
||||
return this.localeResolver;
|
||||
}
|
||||
|
||||
public void setLocaleResolver(LocaleResolver localeResolver) {
|
||||
this.localeResolver = localeResolver;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.mvc.format.date")
|
||||
public String getDateFormat() {
|
||||
@@ -547,25 +515,4 @@ public class WebMvcProperties {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale resolution options.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link org.springframework.boot.autoconfigure.web.WebProperties.LocaleResolver}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum LocaleResolver {
|
||||
|
||||
/**
|
||||
* Always use the configured locale.
|
||||
*/
|
||||
FIXED,
|
||||
|
||||
/**
|
||||
* Use the "Accept-Language" header or the configured locale if the header is not
|
||||
* set.
|
||||
*/
|
||||
ACCEPT_HEADER
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,19 +74,6 @@ public class DefaultErrorViewResolver implements ErrorViewResolver, Ordered {
|
||||
|
||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
/**
|
||||
* Create a new {@link DefaultErrorViewResolver} instance.
|
||||
* @param applicationContext the source application context
|
||||
* @param resourceProperties resource properties
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #DefaultErrorViewResolver(ApplicationContext, Resources)}
|
||||
*/
|
||||
@Deprecated
|
||||
public DefaultErrorViewResolver(ApplicationContext applicationContext,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties) {
|
||||
this(applicationContext, (Resources) resourceProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link DefaultErrorViewResolver} instance.
|
||||
* @param applicationContext the source application context
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -124,20 +124,16 @@ public class ErrorMvcAutoConfiguration {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties({ org.springframework.boot.autoconfigure.web.ResourceProperties.class,
|
||||
WebProperties.class, WebMvcProperties.class })
|
||||
@EnableConfigurationProperties({ WebProperties.class, WebMvcProperties.class })
|
||||
static class DefaultErrorViewResolverConfiguration {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final Resources resources;
|
||||
|
||||
DefaultErrorViewResolverConfiguration(ApplicationContext applicationContext,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
||||
WebProperties webProperties) {
|
||||
DefaultErrorViewResolverConfiguration(ApplicationContext applicationContext, WebProperties webProperties) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.resources = webProperties.getResources().hasBeenCustomized() ? webProperties.getResources()
|
||||
: resourceProperties;
|
||||
this.resources = webProperties.getResources();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1585,10 +1585,6 @@
|
||||
"description": "Whether to enable Spring's HiddenHttpMethodFilter.",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "spring.mvc.locale-resolver",
|
||||
"defaultValue": "accept-header"
|
||||
},
|
||||
{
|
||||
"name": "spring.mvc.pathmatch.matching-strategy",
|
||||
"defaultValue": "ant-path-matcher"
|
||||
@@ -1682,7 +1678,7 @@
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether to enable resolution of already gzipped resources. Checks for a resource name variant with the \"*.gz\" extension.",
|
||||
"deprecation": {
|
||||
"replacement": "spring.resources.chain.compressed",
|
||||
"replacement": "spring.web.resources.chain.compressed",
|
||||
"level": "error"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -79,17 +79,6 @@ class MongoDataAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void whenGridFsDatabaseIsConfiguredWithDeprecatedPropertyThenGridFsTemplateIsAutoConfiguredAndUsesIt() {
|
||||
this.contextRunner.withPropertyValues("spring.data.mongodb.gridFsDatabase:grid").run((context) -> {
|
||||
assertThat(context).hasSingleBean(GridFsTemplate.class);
|
||||
GridFsTemplate template = context.getBean(GridFsTemplate.class);
|
||||
MongoDatabaseFactory factory = (MongoDatabaseFactory) ReflectionTestUtils.getField(template, "dbFactory");
|
||||
assertThat(factory.getMongoDatabase().getName()).isEqualTo("grid");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenGridFsBucketIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt() {
|
||||
this.contextRunner.withPropertyValues("spring.data.mongodb.gridfs.bucket:test-bucket").run((context) -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -58,13 +58,6 @@ class MongoReactiveDataAutoConfigurationTests {
|
||||
.run((context) -> assertThat(grisFsTemplateDatabaseName(context)).isEqualTo("grid"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void whenGridFsDatabaseIsConfiguredWithDeprecatedPropertyThenGridFsTemplateUsesIt() {
|
||||
this.contextRunner.withPropertyValues("spring.data.mongodb.gridFsDatabase:grid")
|
||||
.run((context) -> assertThat(grisFsTemplateDatabaseName(context)).isEqualTo("grid"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenGridFsBucketIsConfiguredThenGridFsTemplateUsesIt() {
|
||||
this.contextRunner.withPropertyValues("spring.data.mongodb.gridfs.bucket:test-bucket").run((context) -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -155,7 +155,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
|
||||
|
||||
@Test
|
||||
void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() {
|
||||
load("spring.resources.chain.enabled:true");
|
||||
load("spring.web.resources.chain.enabled:true");
|
||||
FilterRegistrationBean<?> registration = this.context.getBean(FilterRegistrationBean.class);
|
||||
assertThat(registration.getFilter()).isInstanceOf(ResourceUrlEncodingFilter.class);
|
||||
assertThat(registration).hasFieldOrPropertyWithValue("dispatcherTypes",
|
||||
@@ -166,7 +166,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
void registerResourceHandlingFilterWithOtherRegistrationBean() {
|
||||
// gh-14897
|
||||
load(FilterRegistrationOtherConfiguration.class, "spring.resources.chain.enabled:true");
|
||||
load(FilterRegistrationOtherConfiguration.class, "spring.web.resources.chain.enabled:true");
|
||||
Map<String, FilterRegistrationBean> beans = this.context.getBeansOfType(FilterRegistrationBean.class);
|
||||
assertThat(beans).hasSize(2);
|
||||
FilterRegistrationBean registration = beans.values().stream()
|
||||
@@ -179,7 +179,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
void registerResourceHandlingFilterWithResourceRegistrationBean() {
|
||||
// gh-14926
|
||||
load(FilterRegistrationResourceConfiguration.class, "spring.resources.chain.enabled:true");
|
||||
load(FilterRegistrationResourceConfiguration.class, "spring.web.resources.chain.enabled:true");
|
||||
Map<String, FilterRegistrationBean> beans = this.context.getBeansOfType(FilterRegistrationBean.class);
|
||||
assertThat(beans).hasSize(1);
|
||||
FilterRegistrationBean registration = beans.values().stream()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -260,7 +260,7 @@ class ThymeleafServletAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() {
|
||||
this.contextRunner.withPropertyValues("spring.resources.chain.enabled:true").run((context) -> {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.chain.enabled:true").run((context) -> {
|
||||
FilterRegistrationBean<?> registration = context.getBean(FilterRegistrationBean.class);
|
||||
assertThat(registration.getFilter()).isInstanceOf(ResourceUrlEncodingFilter.class);
|
||||
assertThat(registration).hasFieldOrPropertyWithValue("dispatcherTypes",
|
||||
@@ -273,7 +273,7 @@ class ThymeleafServletAutoConfigurationTests {
|
||||
void registerResourceHandlingFilterWithOtherRegistrationBean() {
|
||||
// gh-14897
|
||||
this.contextRunner.withUserConfiguration(FilterRegistrationOtherConfiguration.class)
|
||||
.withPropertyValues("spring.resources.chain.enabled:true").run((context) -> {
|
||||
.withPropertyValues("spring.web.resources.chain.enabled:true").run((context) -> {
|
||||
Map<String, FilterRegistrationBean> beans = context.getBeansOfType(FilterRegistrationBean.class);
|
||||
assertThat(beans).hasSize(2);
|
||||
FilterRegistrationBean registration = beans.values().stream()
|
||||
@@ -288,7 +288,7 @@ class ThymeleafServletAutoConfigurationTests {
|
||||
void registerResourceHandlingFilterWithResourceRegistrationBean() {
|
||||
// gh-14926
|
||||
this.contextRunner.withUserConfiguration(FilterRegistrationResourceConfiguration.class)
|
||||
.withPropertyValues("spring.resources.chain.enabled:true").run((context) -> {
|
||||
.withPropertyValues("spring.web.resources.chain.enabled:true").run((context) -> {
|
||||
Map<String, FilterRegistrationBean> beans = context.getBeansOfType(FilterRegistrationBean.class);
|
||||
assertThat(beans).hasSize(1);
|
||||
FilterRegistrationBean registration = beans.values().stream()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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,8 +18,6 @@ package org.springframework.boot.autoconfigure.web;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -48,31 +46,27 @@ class ConditionalOnEnabledResourceChainTests {
|
||||
assertThat(this.context.containsBean("foo")).isFalse();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void disabledExplicitly(String prefix) {
|
||||
load(prefix + "chain.enabled:false");
|
||||
@Test
|
||||
void disabledExplicitly() {
|
||||
load("spring.web.resources.chain.enabled:false");
|
||||
assertThat(this.context.containsBean("foo")).isFalse();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void enabledViaMainEnabledFlag(String prefix) {
|
||||
load(prefix + "chain.enabled:true");
|
||||
@Test
|
||||
void enabledViaMainEnabledFlag() {
|
||||
load("spring.web.resources.chain.enabled:true");
|
||||
assertThat(this.context.containsBean("foo")).isTrue();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void enabledViaFixedStrategyFlag(String prefix) {
|
||||
load(prefix + "chain.strategy.fixed.enabled:true");
|
||||
@Test
|
||||
void enabledViaFixedStrategyFlag() {
|
||||
load("spring.web.resources.chain.strategy.fixed.enabled:true");
|
||||
assertThat(this.context.containsBean("foo")).isTrue();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void enabledViaContentStrategyFlag(String prefix) {
|
||||
load(prefix + "chain.strategy.content.enabled:true");
|
||||
@Test
|
||||
void enabledViaContentStrategyFlag() {
|
||||
load("spring.web.resources.chain.strategy.content.enabled:true");
|
||||
assertThat(this.context.containsBean("foo")).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.web;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.test.context.runner.ContextConsumer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Binding tests for {@link ResourceProperties}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
class ResourcePropertiesBindingTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TestConfiguration.class);
|
||||
|
||||
@Test
|
||||
void staticLocationsExpandArray() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.resources.static-locations[0]=classpath:/one/",
|
||||
"spring.resources.static-locations[1]=classpath:/two",
|
||||
"spring.resources.static-locations[2]=classpath:/three/",
|
||||
"spring.resources.static-locations[3]=classpath:/four",
|
||||
"spring.resources.static-locations[4]=classpath:/five/",
|
||||
"spring.resources.static-locations[5]=classpath:/six")
|
||||
.run(assertResourceProperties((properties) -> assertThat(properties.getStaticLocations()).contains(
|
||||
"classpath:/one/", "classpath:/two/", "classpath:/three/", "classpath:/four/",
|
||||
"classpath:/five/", "classpath:/six/")));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> assertResourceProperties(
|
||||
Consumer<ResourceProperties> consumer) {
|
||||
return (context) -> {
|
||||
assertThat(context).hasSingleBean(ResourceProperties.class);
|
||||
consumer.accept(context.getBean(ResourceProperties.class));
|
||||
};
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(ResourceProperties.class)
|
||||
static class TestConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.web;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.CacheControl;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ResourceProperties}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Kristine Jetzke
|
||||
*/
|
||||
@Deprecated
|
||||
class ResourcePropertiesTests {
|
||||
|
||||
private final ResourceProperties properties = new ResourceProperties();
|
||||
|
||||
@Test
|
||||
void resourceChainNoCustomization() {
|
||||
assertThat(this.properties.getChain().getEnabled()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void resourceChainStrategyEnabled() {
|
||||
this.properties.getChain().getStrategy().getFixed().setEnabled(true);
|
||||
assertThat(this.properties.getChain().getEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void resourceChainEnabled() {
|
||||
this.properties.getChain().setEnabled(true);
|
||||
assertThat(this.properties.getChain().getEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void resourceChainDisabled() {
|
||||
this.properties.getChain().setEnabled(false);
|
||||
assertThat(this.properties.getChain().getEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultStaticLocationsAllEndWithTrailingSlash() {
|
||||
assertThat(this.properties.getStaticLocations()).allMatch((location) -> location.endsWith("/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customStaticLocationsAreNormalizedToEndWithTrailingSlash() {
|
||||
this.properties.setStaticLocations(new String[] { "/foo", "/bar", "/baz/" });
|
||||
String[] actual = this.properties.getStaticLocations();
|
||||
assertThat(actual).containsExactly("/foo/", "/bar/", "/baz/");
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyCacheControl() {
|
||||
CacheControl cacheControl = this.properties.getCache().getCachecontrol().toHttpCacheControl();
|
||||
assertThat(cacheControl).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void cacheControlAllPropertiesSet() {
|
||||
ResourceProperties.Cache.Cachecontrol properties = this.properties.getCache().getCachecontrol();
|
||||
properties.setMaxAge(Duration.ofSeconds(4));
|
||||
properties.setCachePrivate(true);
|
||||
properties.setCachePublic(true);
|
||||
properties.setMustRevalidate(true);
|
||||
properties.setNoTransform(true);
|
||||
properties.setProxyRevalidate(true);
|
||||
properties.setSMaxAge(Duration.ofSeconds(5));
|
||||
properties.setStaleIfError(Duration.ofSeconds(6));
|
||||
properties.setStaleWhileRevalidate(Duration.ofSeconds(7));
|
||||
CacheControl cacheControl = properties.toHttpCacheControl();
|
||||
assertThat(cacheControl.getHeaderValue())
|
||||
.isEqualTo("max-age=4, must-revalidate, no-transform, public, private, proxy-revalidate,"
|
||||
+ " s-maxage=5, stale-if-error=6, stale-while-revalidate=7");
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidCacheControlCombination() {
|
||||
ResourceProperties.Cache.Cachecontrol properties = this.properties.getCache().getCachecontrol();
|
||||
properties.setMaxAge(Duration.ofSeconds(4));
|
||||
properties.setNoStore(true);
|
||||
CacheControl cacheControl = properties.toHttpCacheControl();
|
||||
assertThat(cacheControl.getHeaderValue()).isEqualTo("no-store");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -32,7 +32,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Stephane Nicoll
|
||||
* @author Kristine Jetzke
|
||||
*/
|
||||
@Deprecated
|
||||
class WebPropertiesResourcesTests {
|
||||
|
||||
private final Resources properties = new WebProperties().getResources();
|
||||
|
||||
@@ -34,8 +34,6 @@ import javax.validation.ValidatorFactory;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
|
||||
@@ -182,18 +180,16 @@ class WebFluxAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void shouldNotMapResourcesWhenDisabled(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + ".add-mappings:false")
|
||||
@Test
|
||||
void shouldNotMapResourcesWhenDisabled() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.add-mappings:false")
|
||||
.run((context) -> assertThat(context.getBean("resourceHandlerMapping"))
|
||||
.isNotInstanceOf(SimpleUrlHandlerMapping.class));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void resourceHandlerChainEnabled(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "chain.enabled:true").run((context) -> {
|
||||
@Test
|
||||
void resourceHandlerChainEnabled() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.chain.enabled:true").run((context) -> {
|
||||
SimpleUrlHandlerMapping hm = context.getBean("resourceHandlerMapping", SimpleUrlHandlerMapping.class);
|
||||
assertThat(hm.getUrlMap().get("/**")).isInstanceOf(ResourceWebHandler.class);
|
||||
ResourceWebHandler staticHandler = (ResourceWebHandler) hm.getUrlMap().get("/**");
|
||||
@@ -418,11 +414,10 @@ class WebFluxAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void cachePeriod(String prefix) {
|
||||
@Test
|
||||
void cachePeriod() {
|
||||
Assertions.setExtractBareNamePropertyMethods(false);
|
||||
this.contextRunner.withPropertyValues(prefix + "cache.period:5").run((context) -> {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.cache.period:5").run((context) -> {
|
||||
Map<PathPattern, Object> handlerMap = getHandlerMap(context);
|
||||
assertThat(handlerMap).hasSize(2);
|
||||
for (Object handler : handlerMap.values()) {
|
||||
@@ -435,12 +430,11 @@ class WebFluxAutoConfigurationTests {
|
||||
Assertions.setExtractBareNamePropertyMethods(true);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void cacheControl(String prefix) {
|
||||
@Test
|
||||
void cacheControl() {
|
||||
Assertions.setExtractBareNamePropertyMethods(false);
|
||||
this.contextRunner.withPropertyValues(prefix + "cache.cachecontrol.max-age:5",
|
||||
prefix + "cache.cachecontrol.proxy-revalidate:true").run((context) -> {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.cache.cachecontrol.max-age:5",
|
||||
"spring.web.resources.cache.cachecontrol.proxy-revalidate:true").run((context) -> {
|
||||
Map<PathPattern, Object> handlerMap = getHandlerMap(context);
|
||||
assertThat(handlerMap).hasSize(2);
|
||||
for (Object handler : handlerMap.values()) {
|
||||
@@ -476,14 +470,14 @@ class WebFluxAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void welcomePageHandlerMapping(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "static-locations=classpath:/welcome-page/").run((context) -> {
|
||||
assertThat(context).getBeans(RouterFunctionMapping.class).hasSize(2);
|
||||
assertThat(context.getBean("welcomePageRouterFunctionMapping", HandlerMapping.class)).isNotNull()
|
||||
.extracting("order").isEqualTo(1);
|
||||
});
|
||||
@Test
|
||||
void welcomePageHandlerMapping() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.static-locations=classpath:/welcome-page/")
|
||||
.run((context) -> {
|
||||
assertThat(context).getBeans(RouterFunctionMapping.class).hasSize(2);
|
||||
assertThat(context.getBean("welcomePageRouterFunctionMapping", HandlerMapping.class)).isNotNull()
|
||||
.extracting("order").isEqualTo(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,8 +38,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.ValidatorFactory;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
@@ -216,17 +214,15 @@ class WebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void resourceHandlerMappingDisabled(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "add-mappings:false")
|
||||
@Test
|
||||
void resourceHandlerMappingDisabled() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.add-mappings:false")
|
||||
.run((context) -> assertThat(getResourceMappingLocations(context)).hasSize(0));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void resourceHandlerChainEnabled(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "chain.enabled:true").run((context) -> {
|
||||
@Test
|
||||
void resourceHandlerChainEnabled() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.chain.enabled:true").run((context) -> {
|
||||
assertThat(getResourceResolvers(context, "/webjars/**")).hasSize(2);
|
||||
assertThat(getResourceTransformers(context, "/webjars/**")).hasSize(1);
|
||||
assertThat(getResourceResolvers(context, "/**")).extractingResultOf("getClass")
|
||||
@@ -236,13 +232,11 @@ class WebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void resourceHandlerFixedStrategyEnabled(String prefix) {
|
||||
this.contextRunner
|
||||
.withPropertyValues(prefix + "chain.strategy.fixed.enabled:true",
|
||||
prefix + "chain.strategy.fixed.version:test", prefix + "chain.strategy.fixed.paths:/**/*.js")
|
||||
.run((context) -> {
|
||||
@Test
|
||||
void resourceHandlerFixedStrategyEnabled() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.chain.strategy.fixed.enabled:true",
|
||||
"spring.web.resources.chain.strategy.fixed.version:test",
|
||||
"spring.web.resources.chain.strategy.fixed.paths:/**/*.js").run((context) -> {
|
||||
assertThat(getResourceResolvers(context, "/webjars/**")).hasSize(3);
|
||||
assertThat(getResourceTransformers(context, "/webjars/**")).hasSize(2);
|
||||
assertThat(getResourceResolvers(context, "/**")).extractingResultOf("getClass").containsOnly(
|
||||
@@ -255,11 +249,10 @@ class WebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void resourceHandlerContentStrategyEnabled(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "chain.strategy.content.enabled:true",
|
||||
prefix + "chain.strategy.content.paths:/**,/*.png").run((context) -> {
|
||||
@Test
|
||||
void resourceHandlerContentStrategyEnabled() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.chain.strategy.content.enabled:true",
|
||||
"spring.web.resources.chain.strategy.content.paths:/**,/*.png").run((context) -> {
|
||||
assertThat(getResourceResolvers(context, "/webjars/**")).hasSize(3);
|
||||
assertThat(getResourceTransformers(context, "/webjars/**")).hasSize(2);
|
||||
assertThat(getResourceResolvers(context, "/**")).extractingResultOf("getClass").containsOnly(
|
||||
@@ -272,25 +265,22 @@ class WebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
@SuppressWarnings("deprecation")
|
||||
void resourceHandlerChainCustomized(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "chain.enabled:true", prefix + "chain.cache:false",
|
||||
prefix + "chain.strategy.content.enabled:true", prefix + "chain.strategy.content.paths:/**,/*.png",
|
||||
prefix + "chain.strategy.fixed.enabled:true", prefix + "chain.strategy.fixed.version:test",
|
||||
prefix + "chain.strategy.fixed.paths:/**/*.js", prefix + "chain.html-application-cache:true",
|
||||
prefix + "chain.compressed:true").run((context) -> {
|
||||
@Test
|
||||
void resourceHandlerChainCustomized() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.chain.enabled:true",
|
||||
"spring.web.resources.chain.cache:false", "spring.web.resources.chain.strategy.content.enabled:true",
|
||||
"spring.web.resources.chain.strategy.content.paths:/**,/*.png",
|
||||
"spring.web.resources.chain.strategy.fixed.enabled:true",
|
||||
"spring.web.resources.chain.strategy.fixed.version:test",
|
||||
"spring.web.resources.chain.strategy.fixed.paths:/**/*.js",
|
||||
"spring.web.resources.chain.html-application-cache:true", "spring.web.resources.chain.compressed:true")
|
||||
.run((context) -> {
|
||||
assertThat(getResourceResolvers(context, "/webjars/**")).hasSize(3);
|
||||
assertThat(getResourceTransformers(context, "/webjars/**"))
|
||||
.hasSize(prefix.equals("spring.resources.") ? 2 : 1);
|
||||
assertThat(getResourceTransformers(context, "/webjars/**")).hasSize(1);
|
||||
assertThat(getResourceResolvers(context, "/**")).extractingResultOf("getClass").containsOnly(
|
||||
EncodedResourceResolver.class, VersionResourceResolver.class, PathResourceResolver.class);
|
||||
assertThat(getResourceTransformers(context, "/**")).extractingResultOf("getClass")
|
||||
.containsOnly(prefix.equals("spring.resources.")
|
||||
? new Class<?>[] { CssLinkResourceTransformer.class,
|
||||
org.springframework.web.servlet.resource.AppCacheManifestTransformer.class }
|
||||
: new Class<?>[] { CssLinkResourceTransformer.class });
|
||||
.containsOnly(CssLinkResourceTransformer.class);
|
||||
VersionResourceResolver resolver = (VersionResourceResolver) getResourceResolvers(context, "/**")
|
||||
.get(1);
|
||||
Map<String, VersionStrategy> strategyMap = resolver.getStrategyMap();
|
||||
@@ -308,11 +298,10 @@ class WebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "mvc", "web" })
|
||||
void overrideLocale(String mvcOrWeb) {
|
||||
this.contextRunner.withPropertyValues("spring." + mvcOrWeb + ".locale:en_UK",
|
||||
"spring." + mvcOrWeb + ".locale-resolver=fixed").run((loader) -> {
|
||||
@Test
|
||||
void overrideLocale() {
|
||||
this.contextRunner.withPropertyValues("spring.web.locale:en_UK", "spring.web.locale-resolver=fixed")
|
||||
.run((loader) -> {
|
||||
// mock request and set user preferred locale
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addPreferredLocale(StringUtils.parseLocaleString("nl_NL"));
|
||||
@@ -326,10 +315,9 @@ class WebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "mvc", "web" })
|
||||
void useAcceptHeaderLocale(String mvcOrWeb) {
|
||||
this.contextRunner.withPropertyValues("spring." + mvcOrWeb + ".locale:en_UK").run((loader) -> {
|
||||
@Test
|
||||
void useAcceptHeaderLocale() {
|
||||
this.contextRunner.withPropertyValues("spring.web.locale:en_UK").run((loader) -> {
|
||||
// mock request and set user preferred locale
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addPreferredLocale(StringUtils.parseLocaleString("nl_NL"));
|
||||
@@ -342,10 +330,9 @@ class WebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "mvc", "web" })
|
||||
void useDefaultLocaleIfAcceptHeaderNoSet(String mvcOrWeb) {
|
||||
this.contextRunner.withPropertyValues("spring." + mvcOrWeb + ".locale:en_UK").run((context) -> {
|
||||
@Test
|
||||
void useDefaultLocaleIfAcceptHeaderNoSet() {
|
||||
this.contextRunner.withPropertyValues("spring.web.locale:en_UK").run((context) -> {
|
||||
// mock request and set user preferred locale
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
LocaleResolver localeResolver = context.getBean(LocaleResolver.class);
|
||||
@@ -680,20 +667,19 @@ class WebMvcAutoConfigurationTests {
|
||||
};
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void welcomePageHandlerMappingIsAutoConfigured(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "static-locations:classpath:/welcome-page/").run((context) -> {
|
||||
assertThat(context).hasSingleBean(WelcomePageHandlerMapping.class);
|
||||
WelcomePageHandlerMapping bean = context.getBean(WelcomePageHandlerMapping.class);
|
||||
assertThat(bean.getRootHandler()).isNotNull();
|
||||
});
|
||||
@Test
|
||||
void welcomePageHandlerMappingIsAutoConfigured() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.static-locations:classpath:/welcome-page/")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(WelcomePageHandlerMapping.class);
|
||||
WelcomePageHandlerMapping bean = context.getBean(WelcomePageHandlerMapping.class);
|
||||
assertThat(bean.getRootHandler()).isNotNull();
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void welcomePageHandlerIncludesCorsConfiguration(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "static-locations:classpath:/welcome-page/")
|
||||
@Test
|
||||
void welcomePageHandlerIncludesCorsConfiguration() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.static-locations:classpath:/welcome-page/")
|
||||
.withUserConfiguration(CorsConfigurer.class).run((context) -> {
|
||||
WelcomePageHandlerMapping bean = context.getBean(WelcomePageHandlerMapping.class);
|
||||
UrlBasedCorsConfigurationSource source = (UrlBasedCorsConfigurationSource) bean
|
||||
@@ -816,10 +802,9 @@ class WebMvcAutoConfigurationTests {
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void cachePeriod(String prefix) {
|
||||
this.contextRunner.withPropertyValues(prefix + "cache.period:5").run((context) -> {
|
||||
@Test
|
||||
void cachePeriod() {
|
||||
this.contextRunner.withPropertyValues("spring.web.resources.cache.period:5").run((context) -> {
|
||||
assertResourceHttpRequestHandler((context), (handler) -> {
|
||||
assertThat(handler.getCacheSeconds()).isEqualTo(5);
|
||||
assertThat(handler.getCacheControl()).isNull();
|
||||
@@ -827,12 +812,11 @@ class WebMvcAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "spring.resources.", "spring.web.resources." })
|
||||
void cacheControl(String prefix) {
|
||||
@Test
|
||||
void cacheControl() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(prefix + "cache.cachecontrol.max-age:5",
|
||||
prefix + "cache.cachecontrol.proxy-revalidate:true")
|
||||
.withPropertyValues("spring.web.resources.cache.cachecontrol.max-age:5",
|
||||
"spring.web.resources.cache.cachecontrol.proxy-revalidate:true")
|
||||
.run((context) -> assertResourceHttpRequestHandler(context, (handler) -> {
|
||||
assertThat(handler.getCacheSeconds()).isEqualTo(-1);
|
||||
assertThat(handler.getCacheControl()).usingRecursiveComparison()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||
properties = { "spring.resources.chain.strategy.content.enabled=true",
|
||||
properties = { "spring.web.resources.chain.strategy.content.enabled=true",
|
||||
"spring.thymeleaf.prefix=classpath:/templates/thymeleaf/" })
|
||||
class WelcomePageIntegrationTests {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -23,8 +23,6 @@ import java.util.Map;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.context.properties.bind.BindResult;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.devtools.logger.DevToolsLogFactory;
|
||||
import org.springframework.boot.devtools.restart.Restarter;
|
||||
import org.springframework.boot.devtools.system.DevToolsEnablementDeducer;
|
||||
@@ -87,9 +85,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
|
||||
if (canAddProperties(environment)) {
|
||||
logger.info(LogMessage.format("Devtools property defaults active! Set '%s' to 'false' to disable",
|
||||
ENABLED));
|
||||
Map<String, Object> properties = new HashMap<>(PROPERTIES);
|
||||
properties.putAll(getResourceProperties(environment));
|
||||
environment.getPropertySources().addLast(new MapPropertySource("devtools", properties));
|
||||
environment.getPropertySources().addLast(new MapPropertySource("devtools", PROPERTIES));
|
||||
}
|
||||
if (isWebApplication(environment) && !environment.containsProperty(WEB_LOGGING)) {
|
||||
logger.info(LogMessage.format(
|
||||
@@ -99,27 +95,6 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> getResourceProperties(Environment environment) {
|
||||
Map<String, String> resourceProperties = new HashMap<>();
|
||||
String prefix = determineResourcePropertiesPrefix(environment);
|
||||
resourceProperties.put(prefix + "cache.period", "0");
|
||||
resourceProperties.put(prefix + "chain.cache", "false");
|
||||
return resourceProperties;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private String determineResourcePropertiesPrefix(Environment environment) {
|
||||
if (ClassUtils.isPresent("org.springframework.boot.autoconfigure.web.ResourceProperties",
|
||||
getClass().getClassLoader())) {
|
||||
BindResult<org.springframework.boot.autoconfigure.web.ResourceProperties> result = Binder.get(environment)
|
||||
.bind("spring.resources", org.springframework.boot.autoconfigure.web.ResourceProperties.class);
|
||||
if (result.isBound() && result.get().hasBeenCustomized()) {
|
||||
return "spring.resources.";
|
||||
}
|
||||
}
|
||||
return "spring.web.resources.";
|
||||
}
|
||||
|
||||
private boolean isLocalApplication(ConfigurableEnvironment environment) {
|
||||
return environment.getPropertySources().get("remoteUrl") == null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -118,16 +118,6 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
assertThat(properties.getCache().getPeriod()).isZero();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
void deprecatedResourceCachePeriodIsZeroWhenDeprecatedResourcePropertiesAreInUse() throws Exception {
|
||||
this.context = getContext(() -> initializeAndRun(WebResourcesConfig.class,
|
||||
Collections.singletonMap("spring.resources.add-mappings", false)));
|
||||
Resources properties = this.context
|
||||
.getBean(org.springframework.boot.autoconfigure.web.ResourceProperties.class);
|
||||
assertThat(properties.getCache().getPeriod()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void liveReloadServer() throws Exception {
|
||||
this.context = getContext(() -> initializeAndRun(Config.class));
|
||||
@@ -293,10 +283,9 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import({ ServletWebServerFactoryAutoConfiguration.class, LocalDevToolsAutoConfiguration.class, WebProperties.class,
|
||||
org.springframework.boot.autoconfigure.web.ResourceProperties.class })
|
||||
@Import({ ServletWebServerFactoryAutoConfiguration.class, LocalDevToolsAutoConfiguration.class,
|
||||
WebProperties.class })
|
||||
static class WebResourcesConfig {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.test.context;
|
||||
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
* {@link ApplicationContextInitializer} that can be used with the
|
||||
* {@link ContextConfiguration#initializers()} to trigger loading of
|
||||
* {@literal application.properties}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.4.0
|
||||
* @see org.springframework.boot.context.config.ConfigFileApplicationListener
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link ConfigDataApplicationContextInitializer}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ConfigFileApplicationContextInitializer
|
||||
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
new org.springframework.boot.context.config.ConfigFileApplicationListener() {
|
||||
public void apply() {
|
||||
addPropertySources(applicationContext.getEnvironment(), applicationContext);
|
||||
addPostProcessors(applicationContext);
|
||||
}
|
||||
}.apply();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -304,21 +304,13 @@ public final class TestPropertyValues {
|
||||
/**
|
||||
* A single name value pair.
|
||||
*/
|
||||
public static class Pair {
|
||||
public static final class Pair {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
* Create a new {@link Pair} instance.
|
||||
* @param name the name
|
||||
* @param value the value
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #of(String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Pair(String name, String value) {
|
||||
private Pair(String name, String value) {
|
||||
Assert.hasLength(name, "Name must not be empty");
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.test.context;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConfigFileApplicationContextInitializer}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Deprecated
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@DirtiesContext
|
||||
@ContextConfiguration(classes = ConfigFileApplicationContextInitializerTests.Config.class,
|
||||
initializers = ConfigFileApplicationContextInitializer.class)
|
||||
class ConfigFileApplicationContextInitializerTests {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Test
|
||||
void initializerPopulatesEnvironment() {
|
||||
assertThat(this.environment.getProperty("foo")).isEqualTo("bucket");
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -41,30 +41,6 @@ public abstract class AbstractBuildLog implements BuildLog {
|
||||
log();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Consumer<TotalProgressEvent> pullingBuilder(BuildRequest request, ImageReference imageReference) {
|
||||
return pullingImage(imageReference, ImageType.BUILDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void pulledBuilder(BuildRequest request, Image image) {
|
||||
pulledImage(image, ImageType.BUILDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Consumer<TotalProgressEvent> pullingRunImage(BuildRequest request, ImageReference imageReference) {
|
||||
return pullingImage(imageReference, ImageType.RUNNER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void pulledRunImage(BuildRequest request, Image image) {
|
||||
pulledImage(image, ImageType.RUNNER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<TotalProgressEvent> pullingImage(ImageReference imageReference, ImageType imageType) {
|
||||
return getProgressConsumer(String.format(" > Pulling %s '%s'", imageType.getDescription(), imageReference));
|
||||
|
||||
@@ -42,48 +42,6 @@ public interface BuildLog {
|
||||
*/
|
||||
void start(BuildRequest request);
|
||||
|
||||
/**
|
||||
* Log that the builder image is being pulled.
|
||||
* @param request the build request
|
||||
* @param imageReference the builder image reference
|
||||
* @return a consumer for progress update events
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #pullingImage(ImageReference, ImageType)}
|
||||
*/
|
||||
@Deprecated
|
||||
Consumer<TotalProgressEvent> pullingBuilder(BuildRequest request, ImageReference imageReference);
|
||||
|
||||
/**
|
||||
* Log that the builder image has been pulled.
|
||||
* @param request the build request
|
||||
* @param image the builder image that was pulled
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #pulledImage(Image, ImageType)}
|
||||
*/
|
||||
@Deprecated
|
||||
void pulledBuilder(BuildRequest request, Image image);
|
||||
|
||||
/**
|
||||
* Log that a run image is being pulled.
|
||||
* @param request the build request
|
||||
* @param imageReference the run image reference
|
||||
* @return a consumer for progress update events
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #pullingImage(ImageReference, ImageType)}
|
||||
*/
|
||||
@Deprecated
|
||||
Consumer<TotalProgressEvent> pullingRunImage(BuildRequest request, ImageReference imageReference);
|
||||
|
||||
/**
|
||||
* Log that a run image has been pulled.
|
||||
* @param request the build request
|
||||
* @param image the run image that was pulled
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #pulledImage(Image, ImageType)}
|
||||
*/
|
||||
@Deprecated
|
||||
void pulledRunImage(BuildRequest request, Image image);
|
||||
|
||||
/**
|
||||
* Log that an image is being pulled.
|
||||
* @param imageReference the image reference
|
||||
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClassName 'com.example.ExampleApplication'
|
||||
mainClass = 'com.example.ExampleApplication'
|
||||
}
|
||||
|
||||
// tag::env-runtime[]
|
||||
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClassName 'com.example.ExampleApplication'
|
||||
mainClass = 'com.example.ExampleApplication'
|
||||
}
|
||||
|
||||
// tag::publish[]
|
||||
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
tasks.getByName<BootJar>("bootJar") {
|
||||
mainClassName = "com.example.ExampleApplication"
|
||||
mainClass.set("com.example.ExampleApplication")
|
||||
}
|
||||
|
||||
// tag::publish[]
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.io.File;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.model.ReplacedBy;
|
||||
import org.gradle.api.plugins.BasePlugin;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
@@ -65,28 +64,6 @@ public class SpringBootExtension {
|
||||
return this.mainClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fully-qualified main class name of the application.
|
||||
* @return the fully-qualified name of the application's main class
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of {@link #getMainClass()}.
|
||||
*/
|
||||
@Deprecated
|
||||
@ReplacedBy("mainClass")
|
||||
public String getMainClassName() {
|
||||
return this.mainClass.getOrNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fully-qualified main class name of the application.
|
||||
* @param mainClassName the fully-qualified name of the application's main class
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of {@link #getMainClass} and
|
||||
* {@link Property#set(Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMainClassName(String mainClassName) {
|
||||
this.mainClass.set(mainClassName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link BuildInfo} task named {@code bootBuildInfo} and configures the
|
||||
* Java plugin's {@code classes} task to depend upon it.
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.file.FileTreeElement;
|
||||
import org.gradle.api.model.ReplacedBy;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.specs.Spec;
|
||||
import org.gradle.api.tasks.Classpath;
|
||||
@@ -44,24 +43,6 @@ public interface BootArchive extends Task {
|
||||
@Input
|
||||
Property<String> getMainClass();
|
||||
|
||||
/**
|
||||
* Returns the fully-qualified main class name of the application.
|
||||
* @return the fully-qualified name of the application's main class
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of {@link #getMainClass()}.
|
||||
*/
|
||||
@Deprecated
|
||||
@ReplacedBy("mainClass")
|
||||
String getMainClassName();
|
||||
|
||||
/**
|
||||
* Sets the fully-qualified main class name of the application.
|
||||
* @param mainClassName the fully-qualified name of the application's main class
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of {@link #getMainClass} and
|
||||
* {@link Property#set(Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
void setMainClassName(String mainClassName);
|
||||
|
||||
/**
|
||||
* Adds Ant-style patterns that identify files that must be unpacked from the archive
|
||||
* when it is launched.
|
||||
|
||||
@@ -133,18 +133,6 @@ public class BootJar extends Jar implements BootArchive {
|
||||
return this.mainClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMainClassName() {
|
||||
return this.mainClass.getOrNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setMainClassName(String mainClassName) {
|
||||
this.mainClass.set(mainClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requiresUnpack(String... patterns) {
|
||||
this.support.requiresUnpack(patterns);
|
||||
@@ -180,15 +168,6 @@ public class BootJar extends Jar implements BootArchive {
|
||||
return this.layered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the jar to be layered using the default layering.
|
||||
* @since 2.3.0
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 as layering as now enabled by default.
|
||||
*/
|
||||
@Deprecated
|
||||
public void layered() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the jar's layering using the given {@code action}.
|
||||
* @param action the action to apply
|
||||
|
||||
@@ -115,18 +115,6 @@ public class BootWar extends War implements BootArchive {
|
||||
return this.mainClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMainClassName() {
|
||||
return this.mainClass.getOrNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setMainClassName(String mainClassName) {
|
||||
this.mainClass.set(mainClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requiresUnpack(String... patterns) {
|
||||
this.support.requiresUnpack(patterns);
|
||||
|
||||
@@ -4,6 +4,6 @@ plugins {
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClassName = 'com.example.Application'
|
||||
mainClass = 'com.example.Application'
|
||||
launchScript()
|
||||
}
|
||||
|
||||
@@ -85,17 +85,6 @@ public abstract class AbstractJarWriter implements LoaderClassesWriter {
|
||||
writeEntry(entry, manifest::write);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write all entries from the specified jar file.
|
||||
* @param jarFile the source jar file
|
||||
* @throws IOException if the entries cannot be written
|
||||
* @deprecated since 2.4.8 for removal in 2.6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public void writeEntries(JarFile jarFile) throws IOException {
|
||||
writeEntries(jarFile, EntryTransformer.NONE, UnpackHandler.NEVER, (entry) -> null);
|
||||
}
|
||||
|
||||
final void writeEntries(JarFile jarFile, EntryTransformer entryTransformer, UnpackHandler unpackHandler,
|
||||
Function<JarEntry, Library> libraryLookup) throws IOException {
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
|
||||
@@ -54,70 +54,6 @@ public class Library {
|
||||
this(null, file, scope, null, false, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Library}.
|
||||
* @param file the source file
|
||||
* @param scope the scope of the library
|
||||
* @param unpackRequired if the library needs to be unpacked before it can be used
|
||||
* @deprecated since 2.4.8 for removal in 2.6.0 in favor of
|
||||
* {@link #Library(String, File, LibraryScope, LibraryCoordinates, boolean, boolean, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Library(File file, LibraryScope scope, boolean unpackRequired) {
|
||||
this(null, file, scope, unpackRequired);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Library}.
|
||||
* @param name the name of the library as it should be written or {@code null} to use
|
||||
* the file name
|
||||
* @param file the source file
|
||||
* @param scope the scope of the library
|
||||
* @param unpackRequired if the library needs to be unpacked before it can be used
|
||||
* @deprecated since 2.4.8 for removal in 2.6.0 in favor of
|
||||
* {@link #Library(String, File, LibraryScope, LibraryCoordinates, boolean, boolean, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Library(String name, File file, LibraryScope scope, boolean unpackRequired) {
|
||||
this(name, file, scope, null, unpackRequired);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Library}.
|
||||
* @param name the name of the library as it should be written or {@code null} to use
|
||||
* the file name
|
||||
* @param file the source file
|
||||
* @param scope the scope of the library
|
||||
* @param coordinates the library coordinates or {@code null}
|
||||
* @param unpackRequired if the library needs to be unpacked before it can be used
|
||||
* @deprecated since 2.4.8 for removal in 2.6.0 in favor of
|
||||
* {@link #Library(String, File, LibraryScope, LibraryCoordinates, boolean, boolean, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Library(String name, File file, LibraryScope scope, LibraryCoordinates coordinates, boolean unpackRequired) {
|
||||
this(name, file, scope, coordinates, unpackRequired, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Library}.
|
||||
* @param name the name of the library as it should be written or {@code null} to use
|
||||
* the file name
|
||||
* @param file the source file
|
||||
* @param scope the scope of the library
|
||||
* @param coordinates the library coordinates or {@code null}
|
||||
* @param unpackRequired if the library needs to be unpacked before it can be used
|
||||
* @param local if the library is local (part of the same build) to the application
|
||||
* that is being packaged
|
||||
* @since 2.4.0
|
||||
* @deprecated since 2.4.8 for removal in 2.6.0 in favor of
|
||||
* {@link #Library(String, File, LibraryScope, LibraryCoordinates, boolean, boolean, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Library(String name, File file, LibraryScope scope, LibraryCoordinates coordinates, boolean unpackRequired,
|
||||
boolean local) {
|
||||
this(name, file, scope, coordinates, unpackRequired, local, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Library}.
|
||||
* @param name the name of the library as it should be written or {@code null} to use
|
||||
|
||||
@@ -68,19 +68,6 @@ public class ArtifactsLibraries implements Libraries {
|
||||
|
||||
private final Log log;
|
||||
|
||||
/**
|
||||
* Creates a new {@code ArtifactsLibraries} from the given {@code artifacts}.
|
||||
* @param artifacts the artifacts to represent as libraries
|
||||
* @param unpacks artifacts that should be unpacked on launch
|
||||
* @param log the log
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #ArtifactsLibraries(Set, Collection, Collection, Log)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ArtifactsLibraries(Set<Artifact> artifacts, Collection<Dependency> unpacks, Log log) {
|
||||
this(artifacts, Collections.emptyList(), unpacks, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code ArtifactsLibraries} from the given {@code artifacts}.
|
||||
* @param artifacts the artifacts to represent as libraries
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot;
|
||||
|
||||
/**
|
||||
* Callback interface that can be used to initialize a {@link BootstrapRegistry} before it
|
||||
* is used.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.4.0
|
||||
* @see SpringApplication#addBootstrapper(Bootstrapper)
|
||||
* @see BootstrapRegistry
|
||||
* @deprecated since 2.4.5 for removal in 2.6 in favor of
|
||||
* {@link BootstrapRegistryInitializer}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Bootstrapper {
|
||||
|
||||
/**
|
||||
* Initialize the given {@link BootstrapRegistry} with any required registrations.
|
||||
* @param registry the registry to initialize
|
||||
* @since 2.4.4
|
||||
*/
|
||||
default void initialize(BootstrapRegistry registry) {
|
||||
intitialize(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the given {@link BootstrapRegistry} with any required registrations.
|
||||
* @param registry the registry to initialize
|
||||
* @deprecated since 2.4.4 for removal in 2.6 in favor of
|
||||
* {@link Bootstrapper#initialize(BootstrapRegistry)}
|
||||
*/
|
||||
@Deprecated
|
||||
void intitialize(BootstrapRegistry registry);
|
||||
|
||||
}
|
||||
@@ -156,36 +156,6 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class SpringApplication {
|
||||
|
||||
/**
|
||||
* The class name of application context that will be used by default for non-web
|
||||
* environments.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of using a
|
||||
* {@link ApplicationContextFactory}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String DEFAULT_CONTEXT_CLASS = "org.springframework.context."
|
||||
+ "annotation.AnnotationConfigApplicationContext";
|
||||
|
||||
/**
|
||||
* The class name of application context that will be used by default for web
|
||||
* environments.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of using an
|
||||
* {@link ApplicationContextFactory}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String DEFAULT_SERVLET_WEB_CONTEXT_CLASS = "org.springframework.boot."
|
||||
+ "web.servlet.context.AnnotationConfigServletWebServerApplicationContext";
|
||||
|
||||
/**
|
||||
* The class name of application context that will be used by default for reactive web
|
||||
* environments.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of using an
|
||||
* {@link ApplicationContextFactory}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String DEFAULT_REACTIVE_WEB_CONTEXT_CLASS = "org.springframework."
|
||||
+ "boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext";
|
||||
|
||||
/**
|
||||
* Default banner location.
|
||||
*/
|
||||
@@ -282,22 +252,13 @@ public class SpringApplication {
|
||||
Assert.notNull(primarySources, "PrimarySources must not be null");
|
||||
this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));
|
||||
this.webApplicationType = WebApplicationType.deduceFromClasspath();
|
||||
this.bootstrapRegistryInitializers = getBootstrapRegistryInitializersFromSpringFactories();
|
||||
this.bootstrapRegistryInitializers = new ArrayList<>(
|
||||
getSpringFactoriesInstances(BootstrapRegistryInitializer.class));
|
||||
setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));
|
||||
setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));
|
||||
this.mainApplicationClass = deduceMainApplicationClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private List<BootstrapRegistryInitializer> getBootstrapRegistryInitializersFromSpringFactories() {
|
||||
ArrayList<BootstrapRegistryInitializer> initializers = new ArrayList<>();
|
||||
getSpringFactoriesInstances(Bootstrapper.class).stream()
|
||||
.map((bootstrapper) -> ((BootstrapRegistryInitializer) bootstrapper::initialize))
|
||||
.forEach(initializers::add);
|
||||
initializers.addAll(getSpringFactoriesInstances(BootstrapRegistryInitializer.class));
|
||||
return initializers;
|
||||
}
|
||||
|
||||
private Class<?> deduceMainApplicationClass() {
|
||||
try {
|
||||
StackTraceElement[] stackTrace = new RuntimeException().getStackTrace();
|
||||
@@ -546,7 +507,6 @@ public class SpringApplication {
|
||||
* @param environment this application's environment
|
||||
* @param args arguments passed to the {@code run} method
|
||||
* @see #configureEnvironment(ConfigurableEnvironment, String[])
|
||||
* @see org.springframework.boot.context.config.ConfigFileApplicationListener
|
||||
*/
|
||||
protected void configureProfiles(ConfigurableEnvironment environment, String[] args) {
|
||||
}
|
||||
@@ -589,7 +549,6 @@ public class SpringApplication {
|
||||
* method will respect any explicitly set application context class or factory before
|
||||
* falling back to a suitable default.
|
||||
* @return the application context (not yet refreshed)
|
||||
* @see #setApplicationContextClass(Class)
|
||||
* @see #setApplicationContextFactory(ApplicationContextFactory)
|
||||
*/
|
||||
protected ConfigurableApplicationContext createApplicationContext() {
|
||||
@@ -1035,20 +994,6 @@ public class SpringApplication {
|
||||
this.addConversionService = addConversionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link Bootstrapper} that can be used to initialize the
|
||||
* {@link BootstrapRegistry}.
|
||||
* @param bootstrapper the bootstraper
|
||||
* @since 2.4.0
|
||||
* @deprecated since 2.4.5 for removal in 2.6 in favor of
|
||||
* {@link #addBootstrapRegistryInitializer(BootstrapRegistryInitializer)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void addBootstrapper(Bootstrapper bootstrapper) {
|
||||
Assert.notNull(bootstrapper, "Bootstrapper must not be null");
|
||||
this.bootstrapRegistryInitializers.add(bootstrapper::initialize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link BootstrapRegistryInitializer} instances that can be used to initialize
|
||||
* the {@link BootstrapRegistry}.
|
||||
@@ -1208,21 +1153,6 @@ public class SpringApplication {
|
||||
this.environmentPrefix = environmentPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of Spring {@link ApplicationContext} that will be created. If not
|
||||
* specified defaults to {@link #DEFAULT_SERVLET_WEB_CONTEXT_CLASS} for web based
|
||||
* applications or {@link AnnotationConfigApplicationContext} for non web based
|
||||
* applications.
|
||||
* @param applicationContextClass the context class to set
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #setApplicationContextFactory(ApplicationContextFactory)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setApplicationContextClass(Class<? extends ConfigurableApplicationContext> applicationContextClass) {
|
||||
this.webApplicationType = WebApplicationType.deduceFromApplicationContext(applicationContextClass);
|
||||
this.applicationContextFactory = ApplicationContextFactory.ofContextClass(applicationContextClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the factory that will be called to create the application context. If not set,
|
||||
* defaults to a factory that will create
|
||||
|
||||
@@ -41,17 +41,6 @@ public interface SpringApplicationRunListener {
|
||||
* @param bootstrapContext the bootstrap context
|
||||
*/
|
||||
default void starting(ConfigurableBootstrapContext bootstrapContext) {
|
||||
starting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called immediately when the run method has first started. Can be used for very
|
||||
* early initialization.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #starting(ConfigurableBootstrapContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
default void starting() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,18 +51,6 @@ public interface SpringApplicationRunListener {
|
||||
*/
|
||||
default void environmentPrepared(ConfigurableBootstrapContext bootstrapContext,
|
||||
ConfigurableEnvironment environment) {
|
||||
environmentPrepared(environment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once the environment has been prepared, but before the
|
||||
* {@link ApplicationContext} has been created.
|
||||
* @param environment the environment
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #environmentPrepared(ConfigurableBootstrapContext, ConfigurableEnvironment)}
|
||||
*/
|
||||
@Deprecated
|
||||
default void environmentPrepared(ConfigurableEnvironment environment) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -291,19 +291,6 @@ public class SpringApplicationBuilder {
|
||||
return runAndExtractParent(args).child(sources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly set the context class to be used.
|
||||
* @param cls the context class to use
|
||||
* @return the current builder
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #contextFactory(ApplicationContextFactory)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SpringApplicationBuilder contextClass(Class<? extends ConfigurableApplicationContext> cls) {
|
||||
this.application.setApplicationContextClass(cls);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly set the factory used to create the application context.
|
||||
* @param factory the factory to use
|
||||
@@ -418,21 +405,6 @@ public class SpringApplicationBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link org.springframework.boot.Bootstrapper} that can be used to initialize
|
||||
* the {@link BootstrapRegistry}.
|
||||
* @param bootstrapper the bootstraper
|
||||
* @return the current builder
|
||||
* @since 2.4.0
|
||||
* @deprecated since 2.4.5 for removal in 2.6 in favor of
|
||||
* {@link #addBootstrapRegistryInitializer(BootstrapRegistryInitializer)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SpringApplicationBuilder addBootstrapper(org.springframework.boot.Bootstrapper bootstrapper) {
|
||||
this.application.addBootstrapper(bootstrapper);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link BootstrapRegistryInitializer} instances that can be used to initialize
|
||||
* the {@link BootstrapRegistry}.
|
||||
|
||||
@@ -26,12 +26,9 @@ import org.apache.commons.logging.Log;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
|
||||
import org.springframework.boot.context.event.ApplicationPreparedEvent;
|
||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
import org.springframework.boot.json.JsonParser;
|
||||
import org.springframework.boot.json.JsonParserFactory;
|
||||
import org.springframework.boot.logging.DeferredLog;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.env.CommandLinePropertySource;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
@@ -91,8 +88,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public class CloudFoundryVcapEnvironmentPostProcessor
|
||||
implements EnvironmentPostProcessor, Ordered, ApplicationListener<ApplicationPreparedEvent> {
|
||||
public class CloudFoundryVcapEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
|
||||
|
||||
private static final String VCAP_APPLICATION = "VCAP_APPLICATION";
|
||||
|
||||
@@ -100,29 +96,15 @@ public class CloudFoundryVcapEnvironmentPostProcessor
|
||||
|
||||
private final Log logger;
|
||||
|
||||
private final boolean switchableLogger;
|
||||
|
||||
// Before ConfigFileApplicationListener so values there can use these ones
|
||||
private int order = ConfigDataEnvironmentPostProcessor.ORDER - 1;
|
||||
|
||||
/**
|
||||
* Create a new {@link CloudFoundryVcapEnvironmentPostProcessor} instance.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #CloudFoundryVcapEnvironmentPostProcessor(Log)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CloudFoundryVcapEnvironmentPostProcessor() {
|
||||
this.logger = new DeferredLog();
|
||||
this.switchableLogger = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link CloudFoundryVcapEnvironmentPostProcessor} instance.
|
||||
* @param logger the logger to use
|
||||
*/
|
||||
public CloudFoundryVcapEnvironmentPostProcessor(Log logger) {
|
||||
this.logger = logger;
|
||||
this.switchableLogger = false;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
@@ -152,19 +134,6 @@ public class CloudFoundryVcapEnvironmentPostProcessor
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener used to switch logging.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of only using
|
||||
* {@link EnvironmentPostProcessor} callbacks
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationPreparedEvent event) {
|
||||
if (this.switchableLogger) {
|
||||
((DeferredLog) this.logger).switchTo(CloudFoundryVcapEnvironmentPostProcessor.class);
|
||||
}
|
||||
}
|
||||
|
||||
private void addWithPrefix(Properties properties, Properties other, String prefix) {
|
||||
for (String key : other.stringPropertyNames()) {
|
||||
String prefixed = prefix + key;
|
||||
|
||||
@@ -129,7 +129,6 @@ public class ConfigDataEnvironmentPostProcessor implements EnvironmentPostProces
|
||||
getLegacyListener().addPropertySources(environment, resourceLoader);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
LegacyConfigFileApplicationListener getLegacyListener() {
|
||||
return new LegacyConfigFileApplicationListener(this.logFactory.getLog(ConfigFileApplicationListener.class));
|
||||
}
|
||||
@@ -201,7 +200,6 @@ public class ConfigDataEnvironmentPostProcessor implements EnvironmentPostProces
|
||||
postProcessor.postProcessEnvironment(environment, resourceLoader, additionalProfiles);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static class LegacyConfigFileApplicationListener extends ConfigFileApplicationListener {
|
||||
|
||||
LegacyConfigFileApplicationListener(Log logger) {
|
||||
|
||||
@@ -112,12 +112,8 @@ import org.springframework.util.StringUtils;
|
||||
* @author Eddú Meléndez
|
||||
* @author Madhura Bhave
|
||||
* @author Scott Frederick
|
||||
* @since 1.0.0
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link ConfigDataEnvironmentPostProcessor}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ConfigFileApplicationListener implements EnvironmentPostProcessor, SmartApplicationListener, Ordered {
|
||||
class ConfigFileApplicationListener implements EnvironmentPostProcessor, SmartApplicationListener, Ordered {
|
||||
|
||||
// Note the order is from least to most specific (last one wins)
|
||||
private static final String DEFAULT_SEARCH_LOCATIONS = "classpath:/,classpath:/config/,file:./,file:./config/*/,file:./config/";
|
||||
@@ -142,32 +138,32 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
|
||||
/**
|
||||
* The "active profiles" property name.
|
||||
*/
|
||||
public static final String ACTIVE_PROFILES_PROPERTY = "spring.profiles.active";
|
||||
static final String ACTIVE_PROFILES_PROPERTY = "spring.profiles.active";
|
||||
|
||||
/**
|
||||
* The "includes profiles" property name.
|
||||
*/
|
||||
public static final String INCLUDE_PROFILES_PROPERTY = "spring.profiles.include";
|
||||
static final String INCLUDE_PROFILES_PROPERTY = "spring.profiles.include";
|
||||
|
||||
/**
|
||||
* The "config name" property name.
|
||||
*/
|
||||
public static final String CONFIG_NAME_PROPERTY = "spring.config.name";
|
||||
static final String CONFIG_NAME_PROPERTY = "spring.config.name";
|
||||
|
||||
/**
|
||||
* The "config location" property name.
|
||||
*/
|
||||
public static final String CONFIG_LOCATION_PROPERTY = "spring.config.location";
|
||||
static final String CONFIG_LOCATION_PROPERTY = "spring.config.location";
|
||||
|
||||
/**
|
||||
* The "config additional location" property name.
|
||||
*/
|
||||
public static final String CONFIG_ADDITIONAL_LOCATION_PROPERTY = "spring.config.additional-location";
|
||||
static final String CONFIG_ADDITIONAL_LOCATION_PROPERTY = "spring.config.additional-location";
|
||||
|
||||
/**
|
||||
* The default order for the processor.
|
||||
*/
|
||||
public static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 10;
|
||||
static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 10;
|
||||
|
||||
private final Log logger;
|
||||
|
||||
@@ -181,7 +177,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
|
||||
|
||||
private int order = DEFAULT_ORDER;
|
||||
|
||||
public ConfigFileApplicationListener() {
|
||||
ConfigFileApplicationListener() {
|
||||
this(new DeferredLog());
|
||||
}
|
||||
|
||||
@@ -225,7 +221,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
|
||||
context.addBeanFactoryPostProcessor(new PropertySourceOrderingPostProcessor(context));
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@@ -243,7 +239,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
|
||||
* (like a map merge).
|
||||
* @param locations the search locations
|
||||
*/
|
||||
public void setSearchLocations(String locations) {
|
||||
void setSearchLocations(String locations) {
|
||||
Assert.hasLength(locations, "Locations must not be empty");
|
||||
this.searchLocations = locations;
|
||||
}
|
||||
@@ -253,7 +249,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
|
||||
* comma-separated list.
|
||||
* @param names the names to load
|
||||
*/
|
||||
public void setSearchNames(String names) {
|
||||
void setSearchNames(String names) {
|
||||
Assert.hasLength(names, "Names must not be empty");
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
@@ -28,10 +28,7 @@ import org.springframework.core.env.PropertySource;
|
||||
* {@link ConfigFileApplicationListener} to filter out properties for specific operations.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 along with
|
||||
* {@link ConfigFileApplicationListener}
|
||||
*/
|
||||
@Deprecated
|
||||
class FilteredPropertySource extends PropertySource<PropertySource<?>> {
|
||||
|
||||
private final Set<String> filteredProperties;
|
||||
|
||||
@@ -35,20 +35,6 @@ public class ApplicationEnvironmentPreparedEvent extends SpringApplicationEvent
|
||||
|
||||
private final ConfigurableEnvironment environment;
|
||||
|
||||
/**
|
||||
* Create a new {@link ApplicationEnvironmentPreparedEvent} instance.
|
||||
* @param application the current application
|
||||
* @param args the arguments the application is running with
|
||||
* @param environment the environment that was just created
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #ApplicationEnvironmentPreparedEvent(ConfigurableBootstrapContext, SpringApplication, String[], ConfigurableEnvironment)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ApplicationEnvironmentPreparedEvent(SpringApplication application, String[] args,
|
||||
ConfigurableEnvironment environment) {
|
||||
this(null, application, args, environment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link ApplicationEnvironmentPreparedEvent} instance.
|
||||
* @param bootstrapContext the bootstrap context
|
||||
|
||||
@@ -38,18 +38,6 @@ public class ApplicationStartingEvent extends SpringApplicationEvent {
|
||||
|
||||
private final ConfigurableBootstrapContext bootstrapContext;
|
||||
|
||||
/**
|
||||
* Create a new {@link ApplicationStartingEvent} instance.
|
||||
* @param application the current application
|
||||
* @param args the arguments the application is running with
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #ApplicationStartingEvent(ConfigurableBootstrapContext, SpringApplication, String[])}
|
||||
*/
|
||||
@Deprecated
|
||||
public ApplicationStartingEvent(SpringApplication application, String[] args) {
|
||||
this(null, application, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link ApplicationStartingEvent} instance.
|
||||
* @param bootstrapContext the bootstrap context
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.context.logging;
|
||||
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
|
||||
import org.springframework.boot.context.event.ApplicationFailedEvent;
|
||||
import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.event.GenericApplicationListener;
|
||||
import org.springframework.context.event.SmartApplicationListener;
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
/**
|
||||
* A {@link SmartApplicationListener} that reacts to
|
||||
* {@link ApplicationEnvironmentPreparedEvent environment prepared events} and to
|
||||
* {@link ApplicationFailedEvent failed events} by logging the classpath of the thread
|
||||
* context class loader (TCCL) at {@code DEBUG} level.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 with no direct replacement.
|
||||
* {@link FailureAnalysis} is now the preferred approach for diagnosing and reporting
|
||||
* startup failures.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ClasspathLoggingApplicationListener implements GenericApplicationListener {
|
||||
|
||||
private static final int ORDER = LoggingApplicationListener.DEFAULT_ORDER + 1;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ClasspathLoggingApplicationListener.class);
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (event instanceof ApplicationEnvironmentPreparedEvent) {
|
||||
logger.debug("Application started with classpath: " + getClasspath());
|
||||
}
|
||||
else if (event instanceof ApplicationFailedEvent) {
|
||||
logger.debug("Application failed to start with classpath: " + getClasspath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return ORDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsEventType(ResolvableType resolvableType) {
|
||||
Class<?> type = resolvableType.getRawClass();
|
||||
if (type == null) {
|
||||
return false;
|
||||
}
|
||||
return ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(type)
|
||||
|| ApplicationFailedEvent.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
private String getClasspath() {
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
if (classLoader instanceof URLClassLoader) {
|
||||
return Arrays.toString(((URLClassLoader) classLoader).getURLs());
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,15 +61,6 @@ public enum EmbeddedDatabaseConnection {
|
||||
DERBY(EmbeddedDatabaseType.DERBY, DatabaseDriver.DERBY.getDriverClassName(), "jdbc:derby:memory:%s;create=true",
|
||||
(url) -> true),
|
||||
|
||||
/**
|
||||
* HSQL Database Connection.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link EmbeddedDatabaseConnection#HSQLDB}.
|
||||
*/
|
||||
@Deprecated
|
||||
HSQL(EmbeddedDatabaseType.HSQL, DatabaseDriver.HSQLDB.getDriverClassName(), "org.hsqldb.jdbcDriver",
|
||||
"jdbc:hsqldb:mem:%s", (url) -> url.contains(":hsqldb:mem:")),
|
||||
|
||||
/**
|
||||
* HSQL Database Connection.
|
||||
* @since 2.4.0
|
||||
@@ -136,19 +127,6 @@ public enum EmbeddedDatabaseConnection {
|
||||
&& (driverClass.equals(this.driverClass) || driverClass.equals(this.alternativeDriverClass)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to determine if a given driver class name represents an embedded
|
||||
* database type.
|
||||
* @param driverClass the driver class
|
||||
* @return true if the driver class is one of the embedded types
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #isEmbedded(String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isEmbedded(String driverClass) {
|
||||
return isEmbedded(driverClass, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to determine if a given driver class name and url represent an
|
||||
* embedded database type.
|
||||
@@ -219,7 +197,7 @@ public enum EmbeddedDatabaseConnection {
|
||||
productName = productName.toUpperCase(Locale.ENGLISH);
|
||||
EmbeddedDatabaseConnection[] candidates = EmbeddedDatabaseConnection.values();
|
||||
for (EmbeddedDatabaseConnection candidate : candidates) {
|
||||
if (candidate != NONE && productName.contains(candidate.name())) {
|
||||
if (candidate != NONE && productName.contains(candidate.getType().name())) {
|
||||
String url = metaData.getURL();
|
||||
return (url == null || candidate.isEmbeddedUrl(url));
|
||||
}
|
||||
|
||||
@@ -80,47 +80,6 @@ public class LoggingSystemProperties {
|
||||
*/
|
||||
public static final String FILE_LOG_CHARSET = "FILE_LOG_CHARSET";
|
||||
|
||||
/**
|
||||
* The name of the System property that contains the rolled-over log file name
|
||||
* pattern.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#ROLLINGPOLICY_FILE_NAME_PATTERN}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String ROLLING_FILE_NAME_PATTERN = "ROLLING_FILE_NAME_PATTERN";
|
||||
|
||||
/**
|
||||
* The name of the System property that contains the clean history on start flag.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#ROLLINGPOLICY_CLEAN_HISTORY_ON_START}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String FILE_CLEAN_HISTORY_ON_START = "LOG_FILE_CLEAN_HISTORY_ON_START";
|
||||
|
||||
/**
|
||||
* The name of the System property that contains the file log max size.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#ROLLINGPOLICY_MAX_FILE_SIZE}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String FILE_MAX_SIZE = "LOG_FILE_MAX_SIZE";
|
||||
|
||||
/**
|
||||
* The name of the System property that contains the file total size cap.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#ROLLINGPOLICY_TOTAL_SIZE_CAP}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String FILE_TOTAL_SIZE_CAP = "LOG_FILE_TOTAL_SIZE_CAP";
|
||||
|
||||
/**
|
||||
* The name of the System property that contains the file log max history.
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#ROLLINGPOLICY_MAX_HISTORY}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String FILE_MAX_HISTORY = "LOG_FILE_MAX_HISTORY";
|
||||
|
||||
/**
|
||||
* The name of the System property that contains the log level pattern.
|
||||
*/
|
||||
@@ -184,20 +143,11 @@ public class LoggingSystemProperties {
|
||||
setSystemProperty(resolver, FILE_LOG_PATTERN, "logging.pattern.file");
|
||||
setSystemProperty(resolver, FILE_LOG_CHARSET, "logging.charset.file", getDefaultCharset().name());
|
||||
setSystemProperty(resolver, LOG_LEVEL_PATTERN, "logging.pattern.level");
|
||||
applyDeprecated(resolver);
|
||||
if (logFile != null) {
|
||||
logFile.applyToSystemProperties();
|
||||
}
|
||||
}
|
||||
|
||||
private void applyDeprecated(PropertyResolver resolver) {
|
||||
setSystemProperty(resolver, FILE_CLEAN_HISTORY_ON_START, "logging.file.clean-history-on-start");
|
||||
setSystemProperty(resolver, FILE_MAX_HISTORY, "logging.file.max-history");
|
||||
setSystemProperty(resolver, FILE_MAX_SIZE, "logging.file.max-size");
|
||||
setSystemProperty(resolver, FILE_TOTAL_SIZE_CAP, "logging.file.total-size-cap");
|
||||
setSystemProperty(resolver, ROLLING_FILE_NAME_PATTERN, "logging.pattern.rolling-file-name");
|
||||
}
|
||||
|
||||
private PropertyResolver getPropertyResolver() {
|
||||
if (this.environment instanceof ConfigurableEnvironment) {
|
||||
PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
|
||||
|
||||
@@ -246,31 +246,6 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
|
||||
this.resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if filters should be initialized eagerly.
|
||||
* @return {@code true} if filters are initialized eagerly, otherwise {@code false}.
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #isEagerFilterInit()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isEagerInitFilters() {
|
||||
return this.eagerFilterInit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether filters should be initialized eagerly.
|
||||
* @param eagerInitFilters {@code true} if filters are initialized eagerly, otherwise
|
||||
* {@code false}.
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
|
||||
* {@link #isEagerFilterInit()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEagerInitFilters(boolean eagerInitFilters) {
|
||||
this.eagerFilterInit = eagerInitFilters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if filters should be eagerly initialized.
|
||||
* @return {@code true} if filters are eagerly initialized, otherwise {@code false}.
|
||||
|
||||
@@ -66,10 +66,8 @@ import org.springframework.boot.testsupport.system.CapturedOutput;
|
||||
import org.springframework.boot.testsupport.system.OutputCaptureExtension;
|
||||
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext;
|
||||
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
|
||||
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
|
||||
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
|
||||
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
@@ -332,15 +330,6 @@ class SpringApplicationTests {
|
||||
assertThat(this.context.getId()).startsWith("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void specificApplicationContextClass() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
application.setApplicationContextClass(StaticApplicationContext.class);
|
||||
this.context = application.run();
|
||||
assertThat(this.context).isInstanceOf(StaticApplicationContext.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void specificApplicationContextFactory() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
@@ -350,30 +339,6 @@ class SpringApplicationTests {
|
||||
assertThat(this.context).isInstanceOf(StaticApplicationContext.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void specificWebApplicationContextClassDetectWebApplicationType() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
application.setApplicationContextClass(AnnotationConfigServletWebApplicationContext.class);
|
||||
assertThat(application.getWebApplicationType()).isEqualTo(WebApplicationType.SERVLET);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void specificReactiveApplicationContextClassDetectReactiveApplicationType() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
application.setApplicationContextClass(AnnotationConfigReactiveWebApplicationContext.class);
|
||||
assertThat(application.getWebApplicationType()).isEqualTo(WebApplicationType.REACTIVE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void nonWebNorReactiveApplicationContextClassDetectNoneApplicationType() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
application.setApplicationContextClass(StaticApplicationContext.class);
|
||||
assertThat(application.getWebApplicationType()).isEqualTo(WebApplicationType.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void specificApplicationContextInitializer() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
@@ -1244,31 +1209,6 @@ class SpringApplicationTests {
|
||||
assertThat(applicationContext.getBean("test")).isEqualTo("boot");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void whenABootstrapperImplementsOnlyTheOldMethodThenItIsCalled() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
application.setWebApplicationType(WebApplicationType.NONE);
|
||||
OnlyOldMethodTestBootstrapper bootstrapper = new OnlyOldMethodTestBootstrapper();
|
||||
application.addBootstrapper(bootstrapper);
|
||||
try (ConfigurableApplicationContext applicationContext = application.run()) {
|
||||
assertThat(bootstrapper.intitialized).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void whenABootstrapperImplementsTheOldMethodAndTheNewMethodThenOnlyTheNewMethodIsCalled() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
application.setWebApplicationType(WebApplicationType.NONE);
|
||||
BothMethodsTestBootstrapper bootstrapper = new BothMethodsTestBootstrapper();
|
||||
application.addBootstrapper(bootstrapper);
|
||||
try (ConfigurableApplicationContext applicationContext = application.run()) {
|
||||
assertThat(bootstrapper.intitialized).isFalse();
|
||||
assertThat(bootstrapper.initialized).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void settingEnvironmentPrefixViaPropertiesThrowsException() {
|
||||
assertThatIllegalStateException()
|
||||
@@ -1758,35 +1698,4 @@ class SpringApplicationTests {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static class OnlyOldMethodTestBootstrapper implements Bootstrapper {
|
||||
|
||||
private boolean intitialized;
|
||||
|
||||
@Override
|
||||
public void intitialize(BootstrapRegistry registry) {
|
||||
this.intitialized = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static class BothMethodsTestBootstrapper implements Bootstrapper {
|
||||
|
||||
private boolean intitialized;
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
@Override
|
||||
public void intitialize(BootstrapRegistry registry) {
|
||||
this.intitialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(BootstrapRegistry registry) {
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,15 +113,6 @@ class SpringApplicationBuilderTests {
|
||||
assertThat(environment.getProperty("four")).isEqualTo("a:b");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void specificApplicationContextClass() {
|
||||
SpringApplicationBuilder application = new SpringApplicationBuilder().sources(ExampleConfig.class)
|
||||
.contextClass(StaticApplicationContext.class);
|
||||
this.context = application.run();
|
||||
assertThat(this.context).isInstanceOf(StaticApplicationContext.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void specificApplicationContextFactory() {
|
||||
SpringApplicationBuilder application = new SpringApplicationBuilder().sources(ExampleConfig.class)
|
||||
@@ -287,16 +278,6 @@ class SpringApplicationBuilderTests {
|
||||
this.context.getBean(ChildConfig.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void addBootstrapper() {
|
||||
SpringApplicationBuilder application = new SpringApplicationBuilder(ExampleConfig.class)
|
||||
.web(WebApplicationType.NONE).addBootstrapper((context) -> context.addCloseListener(
|
||||
(event) -> event.getApplicationContext().getBeanFactory().registerSingleton("test", "spring")));
|
||||
this.context = application.run();
|
||||
assertThat(this.context.getBean("test")).isEqualTo("spring");
|
||||
}
|
||||
|
||||
@Test
|
||||
void addBootstrapRegistryInitializer() {
|
||||
SpringApplicationBuilder application = new SpringApplicationBuilder(ExampleConfig.class)
|
||||
|
||||
@@ -71,7 +71,6 @@ class ConfigDataEnvironmentPostProcessorTests {
|
||||
private ArgumentCaptor<ResourceLoader> resourceLoaderCaptor;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void defaultOrderMatchesDeprecatedListener() {
|
||||
assertThat(ConfigDataEnvironmentPostProcessor.ORDER).isEqualTo(ConfigFileApplicationListener.DEFAULT_ORDER);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Scott Frederick
|
||||
* @author Nguyen Bao Sach
|
||||
*/
|
||||
@Deprecated
|
||||
@ExtendWith({ OutputCaptureExtension.class, UseLegacyProcessing.class })
|
||||
class ConfigFileApplicationListenerTests {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -35,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Deprecated
|
||||
class FilteredPropertySourceTests {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -473,13 +473,6 @@ class LoggingApplicationListenerTests {
|
||||
assertThat(System.getProperty(LoggingSystemProperties.LOG_LEVEL_PATTERN)).isEqualTo("level");
|
||||
assertThat(System.getProperty(LoggingSystemProperties.LOG_PATH)).isEqualTo("path");
|
||||
assertThat(System.getProperty(LoggingSystemProperties.PID_KEY)).isNotNull();
|
||||
assertDeprecated();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void assertDeprecated() {
|
||||
assertThat(System.getProperty(LoggingSystemProperties.ROLLING_FILE_NAME_PATTERN))
|
||||
.isEqualTo("my.log.%d{yyyyMMdd}.%i.gz");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -587,9 +587,9 @@ class ConfigurationPropertyNameTests {
|
||||
|
||||
@Test
|
||||
void compareDifferentLengthsShouldSortNames() {
|
||||
ConfigurationPropertyName name = ConfigurationPropertyName.of("spring.resources.chain.strategy.content");
|
||||
ConfigurationPropertyName name = ConfigurationPropertyName.of("spring.web.resources.chain.strategy.content");
|
||||
ConfigurationPropertyName other = ConfigurationPropertyName
|
||||
.of("spring.resources.chain.strategy.content.enabled");
|
||||
.of("spring.web.resources.chain.strategy.content.enabled");
|
||||
assertThat(name.compareTo(other)).isLessThan(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -55,26 +55,6 @@ class EmbeddedDatabaseConnectionTests {
|
||||
.isEqualTo("jdbc:derby:memory:myderbydb;create=true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void hsqlCustomDatabaseName() {
|
||||
assertThat(EmbeddedDatabaseConnection.HSQL.getUrl("myhsql")).isEqualTo("jdbc:hsqldb:mem:myhsql");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void getUrlWithNullDatabaseName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQL.getUrl(null))
|
||||
.withMessageContaining("DatabaseName must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void getUrlWithEmptyDatabaseName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQL.getUrl(" "))
|
||||
.withMessageContaining("DatabaseName must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hsqldbCustomDatabaseName() {
|
||||
assertThat(EmbeddedDatabaseConnection.HSQLDB.getUrl("myhsqldb")).isEqualTo("jdbc:hsqldb:mem:myhsqldb");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -110,16 +110,6 @@ class LoggingSystemPropertiesTests {
|
||||
assertThat(System.getProperty(LoggingSystemProperties.FILE_LOG_PATTERN)).matches("[0-9]+");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void rollingFileNameIsSet() {
|
||||
new LoggingSystemProperties(
|
||||
new MockEnvironment().withProperty("logging.pattern.rolling-file-name", "rolling file pattern"))
|
||||
.apply(null);
|
||||
assertThat(System.getProperty(LoggingSystemProperties.ROLLING_FILE_NAME_PATTERN))
|
||||
.isEqualTo("rolling file pattern");
|
||||
}
|
||||
|
||||
private Environment environment(String key, Object value) {
|
||||
StandardEnvironment environment = new StandardEnvironment();
|
||||
environment.getPropertySources().addLast(new MapPropertySource("test", Collections.singletonMap(key, value)));
|
||||
|
||||
Reference in New Issue
Block a user