Merge branch '2.7.x'
This commit is contained in:
commit
11e604af41
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,33 +38,6 @@ public class InvocationContext {
|
|||
|
||||
private final List<OperationArgumentResolver> argumentResolvers;
|
||||
|
||||
/**
|
||||
* Creates a new context for an operation being invoked by the given
|
||||
* {@code securityContext} with the given available {@code arguments}.
|
||||
* @param securityContext the current security context. Never {@code null}
|
||||
* @param arguments the arguments available to the operation. Never {@code null}
|
||||
*/
|
||||
public InvocationContext(SecurityContext securityContext, Map<String, Object> arguments) {
|
||||
this(null, securityContext, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new context for an operation being invoked by the given
|
||||
* {@code securityContext} with the given available {@code arguments}.
|
||||
* @param apiVersion the API version or {@code null} to use the latest
|
||||
* @param securityContext the current security context. Never {@code null}
|
||||
* @param arguments the arguments available to the operation. Never {@code null}
|
||||
* @since 2.2.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link #InvocationContext(SecurityContext, Map, OperationArgumentResolver[])}
|
||||
*/
|
||||
@Deprecated
|
||||
public InvocationContext(org.springframework.boot.actuate.endpoint.http.ApiVersion apiVersion,
|
||||
SecurityContext securityContext, Map<String, Object> arguments) {
|
||||
this(securityContext, arguments, OperationArgumentResolver.of(ApiVersion.class,
|
||||
() -> (apiVersion != null) ? ApiVersion.valueOf(apiVersion.name()) : null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new context for an operation being invoked by the given
|
||||
* {@code securityContext} with the given available {@code arguments}.
|
||||
|
@ -87,32 +60,6 @@ public class InvocationContext {
|
|||
this.argumentResolvers.add(OperationArgumentResolver.of(ApiVersion.class, () -> ApiVersion.LATEST));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the API version in use.
|
||||
* @return the apiVersion the API version
|
||||
* @since 2.2.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link #resolveArgument(Class)} using
|
||||
* {@link org.springframework.boot.actuate.endpoint.ApiVersion}
|
||||
*/
|
||||
@Deprecated
|
||||
public org.springframework.boot.actuate.endpoint.http.ApiVersion getApiVersion() {
|
||||
ApiVersion version = resolveArgument(ApiVersion.class);
|
||||
return (version != null) ? org.springframework.boot.actuate.endpoint.http.ApiVersion.valueOf(version.name())
|
||||
: org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the security context to use for the invocation.
|
||||
* @return the security context
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link #resolveArgument(Class)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SecurityContext getSecurityContext() {
|
||||
return resolveArgument(SecurityContext.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the invocation arguments.
|
||||
* @return the arguments
|
||||
|
|
|
@ -1,44 +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.endpoint.http;
|
||||
|
||||
/**
|
||||
* Media types that can be consumed and produced by Actuator endpoints.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Madhura Bhave
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link org.springframework.boot.actuate.endpoint.ApiVersion#getProducedMimeType()}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ActuatorMediaType {
|
||||
|
||||
/**
|
||||
* Constant for the Actuator {@link ApiVersion#V2 v2} media type.
|
||||
*/
|
||||
public static final String V2_JSON = "application/vnd.spring-boot.actuator.v2+json";
|
||||
|
||||
/**
|
||||
* Constant for the Actuator {@link ApiVersion#V3 v3} media type.
|
||||
*/
|
||||
public static final String V3_JSON = "application/vnd.spring-boot.actuator.v3+json";
|
||||
|
||||
private ActuatorMediaType() {
|
||||
}
|
||||
|
||||
}
|
|
@ -1,97 +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.endpoint.http;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.ProducibleOperationArgumentResolver;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
/**
|
||||
* API versions supported for the actuator HTTP API. This enum may be injected into
|
||||
* actuator endpoints in order to return a response compatible with the requested version.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link org.springframework.boot.actuate.endpoint.ApiVersion}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum ApiVersion {
|
||||
|
||||
/**
|
||||
* Version 2 (supported by Spring Boot 2.0+).
|
||||
*/
|
||||
V2,
|
||||
|
||||
/**
|
||||
* Version 3 (supported by Spring Boot 2.2+).
|
||||
*/
|
||||
V3;
|
||||
|
||||
private static final String MEDIA_TYPE_PREFIX = "application/vnd.spring-boot.actuator.";
|
||||
|
||||
/**
|
||||
* The latest API version.
|
||||
*/
|
||||
public static final ApiVersion LATEST = ApiVersion.V3;
|
||||
|
||||
/**
|
||||
* Return the {@link ApiVersion} to use based on the HTTP request headers. The version
|
||||
* will be deduced based on the {@code Accept} header.
|
||||
* @param headers the HTTP headers
|
||||
* @return the API version to use
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of direct injection with
|
||||
* resolution via the {@link ProducibleOperationArgumentResolver}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ApiVersion fromHttpHeaders(Map<String, List<String>> headers) {
|
||||
ApiVersion version = null;
|
||||
List<String> accepts = headers.get("Accept");
|
||||
if (!CollectionUtils.isEmpty(accepts)) {
|
||||
for (String accept : accepts) {
|
||||
for (String type : MimeTypeUtils.tokenize(accept)) {
|
||||
version = mostRecent(version, forType(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
return (version != null) ? version : LATEST;
|
||||
}
|
||||
|
||||
private static ApiVersion forType(String type) {
|
||||
if (type.startsWith(MEDIA_TYPE_PREFIX)) {
|
||||
type = type.substring(MEDIA_TYPE_PREFIX.length());
|
||||
int suffixIndex = type.indexOf('+');
|
||||
type = (suffixIndex != -1) ? type.substring(0, suffixIndex) : type;
|
||||
try {
|
||||
return valueOf(type.toUpperCase());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ApiVersion mostRecent(ApiVersion existing, ApiVersion candidate) {
|
||||
int existingOrdinal = (existing != null) ? existing.ordinal() : -1;
|
||||
int candidateOrdinal = (candidate != null) ? candidate.ordinal() : -1;
|
||||
return (candidateOrdinal > existingOrdinal) ? candidate : existing;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Actuator endpoint HTTP concerns (not tied to any specific implementation).
|
||||
*/
|
||||
package org.springframework.boot.actuate.endpoint.http;
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -46,21 +46,6 @@ public class MetricsRepositoryMethodInvocationListener implements RepositoryMeth
|
|||
|
||||
private final AutoTimer autoTimer;
|
||||
|
||||
/**
|
||||
* Create a new {@code MetricsRepositoryMethodInvocationListener}.
|
||||
* @param registry the registry to which metrics are recorded
|
||||
* @param tagsProvider provider for metrics tags
|
||||
* @param metricName name of the metric to record
|
||||
* @param autoTimer the auto-timers to apply or {@code null} to disable auto-timing
|
||||
* @deprecated since 2.5.4 for removal in 2.7.0 in favor of
|
||||
* {@link #MetricsRepositoryMethodInvocationListener(Supplier, RepositoryTagsProvider, String, AutoTimer)}
|
||||
*/
|
||||
@Deprecated
|
||||
public MetricsRepositoryMethodInvocationListener(MeterRegistry registry, RepositoryTagsProvider tagsProvider,
|
||||
String metricName, AutoTimer autoTimer) {
|
||||
this(SingletonSupplier.of(registry), tagsProvider, metricName, autoTimer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code MetricsRepositoryMethodInvocationListener}.
|
||||
* @param registrySupplier a supplier for the registry to which metrics are recorded
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -166,20 +166,6 @@ public final class WebFluxTags {
|
|||
return EXCEPTION_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@code outcome} tag based on the response status of the given
|
||||
* {@code exchange}.
|
||||
* @param exchange the exchange
|
||||
* @return the outcome tag derived from the response status
|
||||
* @since 2.1.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link #outcome(ServerWebExchange, Throwable)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Tag outcome(ServerWebExchange exchange) {
|
||||
return outcome(exchange, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@code outcome} tag based on the response status of the given
|
||||
* {@code exchange} and the exception thrown during request processing.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,20 +36,6 @@ class InvocationContextTests {
|
|||
|
||||
private final Map<String, Object> arguments = Collections.singletonMap("test", "value");
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void createWhenApiVersionIsNullUsesLatestVersion() {
|
||||
InvocationContext context = new InvocationContext(null, this.securityContext, this.arguments);
|
||||
assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void whenCreatedWithoutApiVersionThenGetApiVersionReturnsLatestVersion() {
|
||||
InvocationContext context = new InvocationContext(this.securityContext, this.arguments);
|
||||
assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenCreatedWithoutApiVersionThenResolveApiVersionReturnsLatestVersion() {
|
||||
InvocationContext context = new InvocationContext(this.securityContext, this.arguments);
|
||||
|
@ -68,21 +54,6 @@ class InvocationContextTests {
|
|||
.withMessage("Arguments must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void getApiVersionReturnsApiVersion() {
|
||||
InvocationContext context = new InvocationContext(org.springframework.boot.actuate.endpoint.http.ApiVersion.V2,
|
||||
this.securityContext, this.arguments);
|
||||
assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.V2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void getSecurityContextReturnsSecurityContext() {
|
||||
InvocationContext context = new InvocationContext(this.securityContext, this.arguments);
|
||||
assertThat(context.getSecurityContext()).isEqualTo(this.securityContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveSecurityContextReturnsSecurityContext() {
|
||||
InvocationContext context = new InvocationContext(this.securityContext, this.arguments);
|
||||
|
|
|
@ -1,105 +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.endpoint.http;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link ApiVersion}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Deprecated
|
||||
class ApiVersionTests {
|
||||
|
||||
@Test
|
||||
void latestIsLatestVersion() {
|
||||
ApiVersion[] values = ApiVersion.values();
|
||||
assertThat(ApiVersion.LATEST).isEqualTo(values[values.length - 1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenEmptyReturnsLatest() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(Collections.emptyMap());
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasSingleV2HeaderReturnsV2() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON));
|
||||
assertThat(version).isEqualTo(ApiVersion.V2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasSingleV3HeaderReturnsV3() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader(ActuatorMediaType.V3_JSON));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasV2AndV3HeaderReturnsV3() {
|
||||
ApiVersion version = ApiVersion
|
||||
.fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON, ActuatorMediaType.V3_JSON));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasV2AndV3AsOneHeaderReturnsV3() {
|
||||
ApiVersion version = ApiVersion
|
||||
.fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON + "," + ActuatorMediaType.V3_JSON));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasSingleHeaderWithoutJsonReturnsHeader() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("application/vnd.spring-boot.actuator.v2"));
|
||||
assertThat(version).isEqualTo(ApiVersion.V2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasUnknownVersionReturnsLatest() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("application/vnd.spring-boot.actuator.v200"));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenAcceptsEverythingReturnsLatest() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("*/*"));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
private Map<String, List<String>> acceptHeader(String... types) {
|
||||
List<String> value = Arrays.asList(types);
|
||||
return value.isEmpty() ? Collections.emptyMap() : Collections.singletonMap("Accept", value);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.boot.autoconfigure.batch;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
import org.springframework.boot.sql.init.DatabaseInitializationMode;
|
||||
|
||||
/**
|
||||
|
@ -36,56 +35,6 @@ public class BatchProperties {
|
|||
|
||||
private final Jdbc jdbc = new Jdbc();
|
||||
|
||||
/**
|
||||
* Return the datasource schema.
|
||||
* @return the schema
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of {@link Jdbc#getSchema()}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.batch.jdbc.schema")
|
||||
public String getSchema() {
|
||||
return this.jdbc.getSchema();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setSchema(String schema) {
|
||||
this.jdbc.setSchema(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the table prefix.
|
||||
* @return the table prefix
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link Jdbc#getTablePrefix()}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.batch.jdbc.table-prefix")
|
||||
public String getTablePrefix() {
|
||||
return this.jdbc.getTablePrefix();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTablePrefix(String tablePrefix) {
|
||||
this.jdbc.setTablePrefix(tablePrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the schema should be initialized.
|
||||
* @return the initialization mode
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link Jdbc#getInitializeSchema()}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.batch.jdbc.initialize-schema")
|
||||
public DatabaseInitializationMode getInitializeSchema() {
|
||||
return this.jdbc.getInitializeSchema();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setInitializeSchema(DatabaseInitializationMode initializeSchema) {
|
||||
this.jdbc.setInitializeSchema(initializeSchema);
|
||||
}
|
||||
|
||||
public Job getJob() {
|
||||
return this.job;
|
||||
}
|
||||
|
|
|
@ -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.autoconfigure.data.jpa;
|
||||
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
|
||||
/**
|
||||
* {@link BeanFactoryPostProcessor} that can be used to dynamically declare that all
|
||||
* {@link EntityManagerFactory} beans should "depend on" one or more specific beans.
|
||||
*
|
||||
* @author Marcel Overdijk
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Andrii Hrytsiuk
|
||||
* @since 1.1.0
|
||||
* @see BeanDefinition#setDependsOn(String[])
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor}
|
||||
*/
|
||||
@Deprecated
|
||||
public class EntityManagerFactoryDependsOnPostProcessor
|
||||
extends org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor {
|
||||
|
||||
/**
|
||||
* Creates a new {@code EntityManagerFactoryDependsOnPostProcessor} that will set up
|
||||
* dependencies upon beans with the given names.
|
||||
* @param dependsOn names of the beans to depend upon
|
||||
*/
|
||||
public EntityManagerFactoryDependsOnPostProcessor(String... dependsOn) {
|
||||
super(dependsOn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code EntityManagerFactoryDependsOnPostProcessor} that will set up
|
||||
* dependencies upon beans with the given types.
|
||||
* @param dependsOn types of the beans to depend upon
|
||||
* @since 2.1.8
|
||||
*/
|
||||
public EntityManagerFactoryDependsOnPostProcessor(Class<?>... dependsOn) {
|
||||
super(dependsOn);
|
||||
}
|
||||
|
||||
}
|
|
@ -117,7 +117,6 @@ public class FlywayAutoConfiguration {
|
|||
ObjectProvider<JavaMigration> javaMigrations, ObjectProvider<Callback> callbacks) {
|
||||
FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader());
|
||||
configureDataSource(configuration, properties, flywayDataSource.getIfAvailable(), dataSource.getIfUnique());
|
||||
checkLocationExists(configuration.getDataSource(), properties, resourceLoader);
|
||||
configureProperties(configuration, properties);
|
||||
List<Callback> orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList());
|
||||
configureCallbacks(configuration, orderedCallbacks);
|
||||
|
@ -163,17 +162,6 @@ public class FlywayAutoConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void checkLocationExists(DataSource dataSource, FlywayProperties properties,
|
||||
ResourceLoader resourceLoader) {
|
||||
if (properties.isCheckLocation()) {
|
||||
List<String> locations = new LocationResolver(dataSource).resolveLocations(properties.getLocations());
|
||||
if (!hasAtLeastOneLocation(resourceLoader, locations)) {
|
||||
throw new FlywayMigrationScriptMissingException(locations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void configureProperties(FluentConfiguration configuration, FlywayProperties properties) {
|
||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
String[] locations = new LocationResolver(configuration.getDataSource())
|
||||
|
|
|
@ -1,45 +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.flyway;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Exception thrown when no Flyway migration script is available.
|
||||
*
|
||||
* @author Anand Shastri
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.2.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 as location checking is deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public class FlywayMigrationScriptMissingException extends RuntimeException {
|
||||
|
||||
private final List<String> locations;
|
||||
|
||||
FlywayMigrationScriptMissingException(List<String> locations) {
|
||||
super(locations.isEmpty() ? "Migration script locations not configured" : "Cannot find migration scripts in: "
|
||||
+ locations + " (please add migration scripts or check your Flyway configuration)");
|
||||
this.locations = new ArrayList<>(locations);
|
||||
}
|
||||
|
||||
public List<String> getLocations() {
|
||||
return this.locations;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +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.flyway;
|
||||
|
||||
import org.springframework.boot.diagnostics.AbstractFailureAnalyzer;
|
||||
import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||
|
||||
/**
|
||||
* A {@code FailureAnalyzer} that performs analysis of failures caused by a
|
||||
* {@link FlywayMigrationScriptMissingException}.
|
||||
*
|
||||
* @author Anand Shastri
|
||||
* @author Stephane Nicoll
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 as location checking is deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
class FlywayMigrationScriptMissingFailureAnalyzer
|
||||
extends AbstractFailureAnalyzer<FlywayMigrationScriptMissingException> {
|
||||
|
||||
@Override
|
||||
protected FailureAnalysis analyze(Throwable rootFailure, FlywayMigrationScriptMissingException cause) {
|
||||
StringBuilder description = new StringBuilder("Flyway failed to initialize: ");
|
||||
if (cause.getLocations().isEmpty()) {
|
||||
return new FailureAnalysis(description.append("no migration scripts location is configured").toString(),
|
||||
"Check your Flyway configuration", cause);
|
||||
}
|
||||
description.append(String.format("none of the following migration scripts locations could be found:%n%n"));
|
||||
cause.getLocations().forEach((location) -> description.append(String.format("\t- %s%n", location)));
|
||||
return new FailureAnalysis(description.toString(),
|
||||
"Review the locations above or check your Flyway configuration", cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -402,18 +402,6 @@ public class FlywayProperties {
|
|||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(
|
||||
reason = "Locations can no longer be checked accurately due to changes in Flyway's location support.")
|
||||
public boolean isCheckLocation() {
|
||||
return this.checkLocation;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setCheckLocation(boolean checkLocation) {
|
||||
this.checkLocation = checkLocation;
|
||||
}
|
||||
|
||||
public boolean isFailOnMissingLocations() {
|
||||
return this.failOnMissingLocations;
|
||||
}
|
||||
|
@ -598,17 +586,6 @@ public class FlywayProperties {
|
|||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if a new datasource is being created.
|
||||
* @return {@code true} if a new datasource is created
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of directly checking user and
|
||||
* url.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isCreateDataSource() {
|
||||
return this.url != null || this.user != null;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
|
|
@ -1,103 +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.hateoas;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.hateoas.mediatype.hal.HalConfiguration;
|
||||
import org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.AbstractHttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||
|
||||
/**
|
||||
* Configuration for {@link HttpMessageConverter HttpMessageConverters} when hypermedia is
|
||||
* enabled.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.3.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of a {@link HalConfiguration}
|
||||
* bean
|
||||
*/
|
||||
@Deprecated
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class HypermediaHttpMessageConverterConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.hateoas", name = "use-hal-as-default-json-media-type",
|
||||
matchIfMissing = true)
|
||||
public static HalMessageConverterSupportedMediaTypesCustomizer halMessageConverterSupportedMediaTypeCustomizer() {
|
||||
return new HalMessageConverterSupportedMediaTypesCustomizer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates any {@link TypeConstrainedMappingJackson2HttpMessageConverter}s to support
|
||||
* {@code application/json} in addition to {@code application/hal+json}. Cannot be a
|
||||
* {@link BeanPostProcessor} as processing must be performed after
|
||||
* {@code Jackson2ModuleRegisteringBeanPostProcessor} has registered the converter and
|
||||
* it is unordered.
|
||||
*/
|
||||
static class HalMessageConverterSupportedMediaTypesCustomizer implements BeanFactoryAware, InitializingBean {
|
||||
|
||||
private volatile BeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (this.beanFactory instanceof ListableBeanFactory) {
|
||||
configureHttpMessageConverters(((ListableBeanFactory) this.beanFactory)
|
||||
.getBeansOfType(RequestMappingHandlerAdapter.class).values());
|
||||
}
|
||||
}
|
||||
|
||||
private void configureHttpMessageConverters(Collection<RequestMappingHandlerAdapter> handlerAdapters) {
|
||||
for (RequestMappingHandlerAdapter handlerAdapter : handlerAdapters) {
|
||||
for (HttpMessageConverter<?> messageConverter : handlerAdapter.getMessageConverters()) {
|
||||
configureHttpMessageConverter(messageConverter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void configureHttpMessageConverter(HttpMessageConverter<?> converter) {
|
||||
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
|
||||
List<MediaType> supportedMediaTypes = new ArrayList<>(converter.getSupportedMediaTypes());
|
||||
if (!supportedMediaTypes.contains(MediaType.APPLICATION_JSON)) {
|
||||
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
||||
}
|
||||
((AbstractHttpMessageConverter<?>) converter).setSupportedMediaTypes(supportedMediaTypes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +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.jdbc;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* {@link ApplicationEvent} used internally to indicate that the schema of a new
|
||||
* {@link DataSource} has been created. This happens when {@literal schema-*.sql} files
|
||||
* are executed or when Hibernate initializes the database.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 with no replacement as the event is no
|
||||
* longer published
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@Deprecated
|
||||
public class DataSourceSchemaCreatedEvent extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* Create a new {@link DataSourceSchemaCreatedEvent}.
|
||||
* @param source the source {@link DataSource}.
|
||||
*/
|
||||
public DataSourceSchemaCreatedEvent(DataSource source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
}
|
|
@ -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.autoconfigure.jdbc;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.AbstractDependsOnBeanFactoryPostProcessor;
|
||||
import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
|
||||
/**
|
||||
* {@link BeanFactoryPostProcessor} that can be used to dynamically declare that all
|
||||
* {@link JdbcOperations} beans should "depend on" one or more specific beans.
|
||||
*
|
||||
* @author Marcel Overdijk
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Andrii Hrytsiuk
|
||||
* @since 2.0.4
|
||||
* @see BeanDefinition#setDependsOn(String[])
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link DependsOnDatabaseInitializationDetector}
|
||||
*/
|
||||
@Deprecated
|
||||
public class JdbcOperationsDependsOnPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor {
|
||||
|
||||
/**
|
||||
* Creates a new {@code JdbcOperationsDependsOnPostProcessor} that will set up
|
||||
* dependencies upon beans with the given names.
|
||||
* @param dependsOn names of the beans to depend upon
|
||||
*/
|
||||
public JdbcOperationsDependsOnPostProcessor(String... dependsOn) {
|
||||
super(JdbcOperations.class, dependsOn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code JdbcOperationsDependsOnPostProcessor} that will set up
|
||||
* dependencies upon beans with the given types.
|
||||
* @param dependsOn types of the beans to depend upon
|
||||
* @since 2.1.8
|
||||
*/
|
||||
public JdbcOperationsDependsOnPostProcessor(Class<?>... dependsOn) {
|
||||
super(JdbcOperations.class, dependsOn);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +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.jdbc;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.AbstractDependsOnBeanFactoryPostProcessor;
|
||||
import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* {@link BeanFactoryPostProcessor} that can be used to dynamically declare that all
|
||||
* {@link NamedParameterJdbcOperations} beans should "depend on" one or more specific
|
||||
* beans.
|
||||
*
|
||||
* @author Dan Zheng
|
||||
* @author Andrii Hrytsiuk
|
||||
* @since 2.1.4
|
||||
* @see BeanDefinition#setDependsOn(String[])
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link DependsOnDatabaseInitializationDetector}
|
||||
*/
|
||||
@Deprecated
|
||||
public class NamedParameterJdbcOperationsDependsOnPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor {
|
||||
|
||||
/**
|
||||
* Creates a new {@code NamedParameterJdbcOperationsDependsOnPostProcessor} that will
|
||||
* set up dependencies upon beans with the given names.
|
||||
* @param dependsOn names of the beans to depend upon
|
||||
*/
|
||||
public NamedParameterJdbcOperationsDependsOnPostProcessor(String... dependsOn) {
|
||||
super(NamedParameterJdbcOperations.class, dependsOn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code NamedParameterJdbcOperationsDependsOnPostProcessor} that will
|
||||
* set up dependencies upon beans with the given types.
|
||||
* @param dependsOn types of the beans to depend upon
|
||||
* @since 2.1.8
|
||||
*/
|
||||
public NamedParameterJdbcOperationsDependsOnPostProcessor(Class<?>... dependsOn) {
|
||||
super(NamedParameterJdbcOperations.class, dependsOn);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.jooq;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.AbstractDependsOnBeanFactoryPostProcessor;
|
||||
import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector;
|
||||
|
||||
/**
|
||||
* {@link BeanFactoryPostProcessor} that can be used to dynamically declare that all
|
||||
* {@link DSLContext} beans should "depend on" one or more specific beans.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
* @since 2.3.9
|
||||
* @see BeanDefinition#setDependsOn(String[])
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link DependsOnDatabaseInitializationDetector}
|
||||
*/
|
||||
@Deprecated
|
||||
public class DslContextDependsOnPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor {
|
||||
|
||||
/**
|
||||
* Creates a new {@code DslContextDependsOnPostProcessor} that will set up
|
||||
* dependencies upon beans with the given names.
|
||||
* @param dependsOn names of the beans to depend upon
|
||||
*/
|
||||
public DslContextDependsOnPostProcessor(String... dependsOn) {
|
||||
super(DSLContext.class, dependsOn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code DslContextDependsOnPostProcessor} that will set up
|
||||
* dependencies upon beans with the given types.
|
||||
* @param dependsOn types of the beans to depend upon
|
||||
*/
|
||||
public DslContextDependsOnPostProcessor(Class<?>... dependsOn) {
|
||||
super(DSLContext.class, dependsOn);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.boot.autoconfigure.mustache;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Mustache.Collector;
|
||||
import com.samskivert.mustache.Mustache.TemplateLoader;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -31,7 +30,6 @@ import org.springframework.context.ApplicationContext;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Mustache.
|
||||
|
@ -71,15 +69,8 @@ public class MustacheAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Mustache.Compiler mustacheCompiler(TemplateLoader mustacheTemplateLoader, Environment environment) {
|
||||
return Mustache.compiler().withLoader(mustacheTemplateLoader).withCollector(collector(environment));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private Collector collector(Environment environment) {
|
||||
MustacheEnvironmentCollector collector = new MustacheEnvironmentCollector();
|
||||
collector.setEnvironment(environment);
|
||||
return collector;
|
||||
public Mustache.Compiler mustacheCompiler(TemplateLoader mustacheTemplateLoader) {
|
||||
return Mustache.compiler().withLoader(mustacheTemplateLoader);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -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.mustache;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.samskivert.mustache.DefaultCollector;
|
||||
import com.samskivert.mustache.Mustache.Collector;
|
||||
import com.samskivert.mustache.Mustache.VariableFetcher;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Mustache {@link Collector} to expose properties from the Spring {@link Environment}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Madhura Bhave
|
||||
* @since 1.2.2
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of direct addition of values from
|
||||
* the Environment to the model
|
||||
*/
|
||||
@Deprecated
|
||||
public class MustacheEnvironmentCollector extends DefaultCollector implements EnvironmentAware {
|
||||
|
||||
private ConfigurableEnvironment environment;
|
||||
|
||||
private final VariableFetcher propertyFetcher = new PropertyVariableFetcher();
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = (ConfigurableEnvironment) environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableFetcher createFetcher(Object ctx, String name) {
|
||||
VariableFetcher fetcher = super.createFetcher(ctx, name);
|
||||
if (fetcher != null) {
|
||||
return fetcher;
|
||||
}
|
||||
if (this.environment.containsProperty(name)) {
|
||||
return this.propertyFetcher;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class PropertyVariableFetcher implements VariableFetcher {
|
||||
|
||||
private final Log log = LogFactory.getLog(PropertyVariableFetcher.class);
|
||||
|
||||
private final AtomicBoolean logDeprecationWarning = new AtomicBoolean();
|
||||
|
||||
@Override
|
||||
public Object get(Object ctx, String name) {
|
||||
String property = MustacheEnvironmentCollector.this.environment.getProperty(name);
|
||||
if (property != null && this.logDeprecationWarning.compareAndSet(false, true)) {
|
||||
this.log.warn("Mustache variable resolution relied upon deprecated support for falling back to the "
|
||||
+ "Spring Environment. Please add values from the Environment directly to the model instead.");
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,143 +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.r2dbc;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import io.r2dbc.spi.ConnectionFactories;
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
import io.r2dbc.spi.ConnectionFactoryOptions;
|
||||
import io.r2dbc.spi.ConnectionFactoryOptions.Builder;
|
||||
|
||||
/**
|
||||
* Builder for {@link ConnectionFactory}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Tadaya Tsuyukubo
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.3.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link org.springframework.boot.r2dbc.ConnectionFactoryBuilder}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ConnectionFactoryBuilder {
|
||||
|
||||
private final ConnectionFactoryOptions.Builder optionsBuilder;
|
||||
|
||||
private ConnectionFactoryBuilder(ConnectionFactoryOptions.Builder optionsBuilder) {
|
||||
this.optionsBuilder = optionsBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new {@link ConnectionFactoryBuilder} based on the specified
|
||||
* {@link R2dbcProperties}. If no url is specified, the
|
||||
* {@link EmbeddedDatabaseConnection} supplier is invoked to determine if an embedded
|
||||
* database can be configured instead.
|
||||
* @param properties the properties to use to initialize the builder
|
||||
* @param embeddedDatabaseConnection a supplier for an
|
||||
* {@link EmbeddedDatabaseConnection}
|
||||
* @return a new builder initialized with the settings defined in
|
||||
* {@link R2dbcProperties}
|
||||
*/
|
||||
public static ConnectionFactoryBuilder of(R2dbcProperties properties,
|
||||
Supplier<EmbeddedDatabaseConnection> embeddedDatabaseConnection) {
|
||||
return new ConnectionFactoryBuilder(
|
||||
new ConnectionFactoryOptionsInitializer().initialize(properties, adapt(embeddedDatabaseConnection)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure additional options.
|
||||
* @param options a {@link Consumer} to customize the options
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public ConnectionFactoryBuilder configure(Consumer<Builder> options) {
|
||||
options.accept(this.optionsBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the {@linkplain ConnectionFactoryOptions#USER username}.
|
||||
* @param username the connection factory username
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public ConnectionFactoryBuilder username(String username) {
|
||||
return configure((options) -> options.option(ConnectionFactoryOptions.USER, username));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the {@linkplain ConnectionFactoryOptions#PASSWORD password}.
|
||||
* @param password the connection factory password
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public ConnectionFactoryBuilder password(CharSequence password) {
|
||||
return configure((options) -> options.option(ConnectionFactoryOptions.PASSWORD, password));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the {@linkplain ConnectionFactoryOptions#HOST host name}.
|
||||
* @param host the connection factory hostname
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public ConnectionFactoryBuilder hostname(String host) {
|
||||
return configure((options) -> options.option(ConnectionFactoryOptions.HOST, host));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the {@linkplain ConnectionFactoryOptions#PORT port}.
|
||||
* @param port the connection factory port
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public ConnectionFactoryBuilder port(int port) {
|
||||
return configure((options) -> options.option(ConnectionFactoryOptions.PORT, port));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the {@linkplain ConnectionFactoryOptions#DATABASE database}.
|
||||
* @param database the connection factory database
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public ConnectionFactoryBuilder database(String database) {
|
||||
return configure((options) -> options.option(ConnectionFactoryOptions.DATABASE, database));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a {@link ConnectionFactory} based on the state of this builder.
|
||||
* @return a connection factory
|
||||
*/
|
||||
public ConnectionFactory build() {
|
||||
return ConnectionFactories.get(buildOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a {@link ConnectionFactoryOptions} based on the state of this builder.
|
||||
* @return the options
|
||||
*/
|
||||
public ConnectionFactoryOptions buildOptions() {
|
||||
return this.optionsBuilder.build();
|
||||
}
|
||||
|
||||
private static Supplier<org.springframework.boot.r2dbc.EmbeddedDatabaseConnection> adapt(
|
||||
Supplier<EmbeddedDatabaseConnection> embeddedDatabaseConnection) {
|
||||
return () -> {
|
||||
EmbeddedDatabaseConnection connection = embeddedDatabaseConnection.get();
|
||||
return (connection != null)
|
||||
? org.springframework.boot.r2dbc.EmbeddedDatabaseConnection.valueOf(connection.name()) : null;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -1,98 +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.r2dbc;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Connection details for embedded databases compatible with r2dbc.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.3.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link org.springframework.boot.r2dbc.EmbeddedDatabaseConnection}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum EmbeddedDatabaseConnection {
|
||||
|
||||
/**
|
||||
* No Connection.
|
||||
*/
|
||||
NONE(null, null, null),
|
||||
|
||||
/**
|
||||
* H2 Database Connection.
|
||||
*/
|
||||
H2("H2", "io.r2dbc.h2.H2ConnectionFactoryProvider",
|
||||
"r2dbc:h2:mem:///%s?options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
|
||||
|
||||
private final String type;
|
||||
|
||||
private final String driverClassName;
|
||||
|
||||
private final String url;
|
||||
|
||||
EmbeddedDatabaseConnection(String type, String driverClassName, String url) {
|
||||
this.type = type;
|
||||
this.driverClassName = driverClassName;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver class name.
|
||||
* @return the driver class name
|
||||
*/
|
||||
public String getDriverClassName() {
|
||||
return this.driverClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the embedded database type name for the connection.
|
||||
* @return the database type
|
||||
*/
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the R2DBC URL for the connection using the specified {@code databaseName}.
|
||||
* @param databaseName the name of the database
|
||||
* @return the connection URL
|
||||
*/
|
||||
public String getUrl(String databaseName) {
|
||||
Assert.hasText(databaseName, "DatabaseName must not be empty");
|
||||
return (this.url != null) ? String.format(this.url, databaseName) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the most suitable {@link EmbeddedDatabaseConnection} for the given class
|
||||
* loader.
|
||||
* @param classLoader the class loader used to check for classes
|
||||
* @return an {@link EmbeddedDatabaseConnection} or {@link #NONE}.
|
||||
*/
|
||||
public static EmbeddedDatabaseConnection get(ClassLoader classLoader) {
|
||||
for (EmbeddedDatabaseConnection candidate : EmbeddedDatabaseConnection.values()) {
|
||||
if (candidate != NONE && ClassUtils.isPresent(candidate.getDriverClassName(), classLoader)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
}
|
|
@ -328,12 +328,28 @@
|
|||
"name": "spring.artemis.broker-url",
|
||||
"defaultValue": "tcp://localhost:61616"
|
||||
},
|
||||
{
|
||||
"name": "spring.artemis.host",
|
||||
"type": "java.lang.String",
|
||||
"deprecation": {
|
||||
"replacement": "spring.artemis.broker-url",
|
||||
"level": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spring.artemis.pool.maximum-active-session-per-connection",
|
||||
"deprecation": {
|
||||
"replacement": "spring.artemis.pool.max-sessions-per-connection"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spring.artemis.port",
|
||||
"type": "java.lang.Integer",
|
||||
"deprecation": {
|
||||
"replacement": "spring.artemis.broker-url",
|
||||
"level": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spring.autoconfigure.exclude",
|
||||
"type": "java.util.List<java.lang.Class>",
|
||||
|
@ -341,7 +357,11 @@
|
|||
},
|
||||
{
|
||||
"name": "spring.batch.initialize-schema",
|
||||
"defaultValue": "embedded"
|
||||
"type" : "org.springframework.boot.sql.init.DatabaseInitializationMode",
|
||||
"deprecation" : {
|
||||
"replacement": "spring.batch.jdbc.initialize-schema",
|
||||
"level" : "error"
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "spring.batch.initializer.enabled",
|
||||
|
@ -362,6 +382,22 @@
|
|||
"description": "Execute all Spring Batch jobs in the context on startup.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name" : "spring.batch.schema",
|
||||
"type" : "java.lang.String",
|
||||
"deprecation" : {
|
||||
"replacement": "spring.batch.jdbc.schema",
|
||||
"level" : "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spring.batch.table-prefix",
|
||||
"type": "java.lang.String",
|
||||
"deprecation": {
|
||||
"replacement": "spring.batch.jdbc.table-prefix",
|
||||
"level": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spring.couchbase.bootstrap-hosts",
|
||||
"type": "java.util.List<java.lang.String>",
|
||||
|
@ -848,6 +884,14 @@
|
|||
"name": "spring.flyway.baseline-migration-prefix",
|
||||
"defaultValue": "B"
|
||||
},
|
||||
{
|
||||
"name": "spring.flyway.check-location",
|
||||
"type": "java.lang.Boolean",
|
||||
"deprecation": {
|
||||
"replacement": "spring.flyway.fail-on-missing-locations",
|
||||
"level": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spring.flyway.connect-retries-interval",
|
||||
"defaultValue": 120
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -57,13 +57,10 @@ import org.springframework.boot.jdbc.DataSourceBuilder;
|
|||
import org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer;
|
||||
import org.springframework.boot.sql.init.DatabaseInitializationMode;
|
||||
import org.springframework.boot.sql.init.DatabaseInitializationSettings;
|
||||
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.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.jdbc.BadSqlGrammarException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
@ -188,28 +185,15 @@ class BatchAutoConfigurationTests {
|
|||
this.contextRunner.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.jdbc.initialize-schema:never")
|
||||
.run(assertDatasourceIsNotInitialized());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void testDisableSchemaLoaderWithDeprecatedProperty() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.initialize-schema:never")
|
||||
.run(assertDatasourceIsNotInitialized());
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> assertDatasourceIsNotInitialized() {
|
||||
return (context) -> {
|
||||
assertThat(context).hasSingleBean(JobLauncher.class);
|
||||
assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema())
|
||||
.isEqualTo(DatabaseInitializationMode.NEVER);
|
||||
assertThat(context).doesNotHaveBean(BatchDataSourceScriptDatabaseInitializer.class);
|
||||
assertThatExceptionOfType(BadSqlGrammarException.class)
|
||||
.isThrownBy(() -> new JdbcTemplate(context.getBean(DataSource.class))
|
||||
.queryForList("select * from BATCH_JOB_EXECUTION"));
|
||||
};
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(JobLauncher.class);
|
||||
assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema())
|
||||
.isEqualTo(DatabaseInitializationMode.NEVER);
|
||||
assertThat(context).doesNotHaveBean(BatchDataSourceScriptDatabaseInitializer.class);
|
||||
assertThatExceptionOfType(BadSqlGrammarException.class)
|
||||
.isThrownBy(() -> new JdbcTemplate(context.getBean(DataSource.class))
|
||||
.queryForList("select * from BATCH_JOB_EXECUTION"));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -236,33 +220,17 @@ class BatchAutoConfigurationTests {
|
|||
.withPropertyValues("spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.jdbc.schema:classpath:batch/custom-schema-hsql.sql",
|
||||
"spring.batch.jdbc.tablePrefix:PREFIX_")
|
||||
.run(assertCustomTablePrefix());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void testRenamePrefixWithDeprecatedProperty() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class)
|
||||
.withPropertyValues("spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
|
||||
"spring.batch.tablePrefix:PREFIX_")
|
||||
.run(assertCustomTablePrefix());
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> assertCustomTablePrefix() {
|
||||
return (context) -> {
|
||||
assertThat(context).hasSingleBean(JobLauncher.class);
|
||||
assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema())
|
||||
.isEqualTo(DatabaseInitializationMode.EMBEDDED);
|
||||
assertThat(new JdbcTemplate(context.getBean(DataSource.class))
|
||||
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
|
||||
JobExplorer jobExplorer = context.getBean(JobExplorer.class);
|
||||
assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty();
|
||||
JobRepository jobRepository = context.getBean(JobRepository.class);
|
||||
assertThat(jobRepository.getLastJobExecution("test", new JobParameters())).isNull();
|
||||
};
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(JobLauncher.class);
|
||||
assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema())
|
||||
.isEqualTo(DatabaseInitializationMode.EMBEDDED);
|
||||
assertThat(new JdbcTemplate(context.getBean(DataSource.class))
|
||||
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
|
||||
JobExplorer jobExplorer = context.getBean(JobExplorer.class);
|
||||
assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty();
|
||||
JobRepository jobRepository = context.getBean(JobRepository.class);
|
||||
assertThat(jobRepository.getLastJobExecution("test", new JobParameters())).isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -363,18 +331,6 @@ class BatchAutoConfigurationTests {
|
|||
.doesNotHaveBean("batchDataSourceScriptDatabaseInitializer").hasBean("customInitializer"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
void whenTheUserDefinesTheirOwnBatchDataSourceInitializerThenTheAutoConfiguredInitializerBacksOff() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(TestConfiguration.class, CustomBatchDataSourceInitializerConfiguration.class)
|
||||
.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class,
|
||||
DataSourceTransactionManagerAutoConfiguration.class))
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(BatchDataSourceScriptDatabaseInitializer.class)
|
||||
.hasSingleBean(BatchDataSourceInitializer.class).hasBean("customInitializer"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenTheUserDefinesTheirOwnDatabaseInitializerThenTheAutoConfiguredBatchInitializerRemains() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class, CustomDatabaseInitializerConfiguration.class)
|
||||
|
@ -548,16 +504,4 @@ class BatchAutoConfigurationTests {
|
|||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class CustomBatchDataSourceInitializerConfiguration {
|
||||
|
||||
@Bean
|
||||
BatchDataSourceInitializer customInitializer(DataSource dataSource, ResourceLoader resourceLoader,
|
||||
BatchProperties properties) {
|
||||
return new BatchDataSourceInitializer(dataSource, resourceLoader, properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,9 +31,7 @@ import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfigurati
|
|||
import org.springframework.boot.autoconfigure.orm.jpa.test.City;
|
||||
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
|
||||
import org.springframework.boot.sql.init.DatabaseInitializationMode;
|
||||
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.boot.testsupport.classpath.ClassPathExclusions;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
@ -77,26 +75,13 @@ class BatchAutoConfigurationWithoutJpaTests {
|
|||
.withPropertyValues("spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.jdbc.schema:classpath:batch/custom-schema-hsql.sql",
|
||||
"spring.batch.jdbc.tablePrefix:PREFIX_")
|
||||
.run(assertCustomPrefix());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void jdbcWithCustomPrefixWithDeprecatedProperties() {
|
||||
this.contextRunner.withUserConfiguration(DefaultConfiguration.class, EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
|
||||
"spring.batch.tablePrefix:PREFIX_")
|
||||
.run(assertCustomPrefix());
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> assertCustomPrefix() {
|
||||
return (context) -> {
|
||||
assertThat(new JdbcTemplate(context.getBean(DataSource.class))
|
||||
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
|
||||
assertThat(context.getBean(JobExplorer.class).findRunningJobExecutions("test")).isEmpty();
|
||||
assertThat(context.getBean(JobRepository.class).getLastJobExecution("test", new JobParameters())).isNull();
|
||||
};
|
||||
.run((context) -> {
|
||||
assertThat(new JdbcTemplate(context.getBean(DataSource.class))
|
||||
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
|
||||
assertThat(context.getBean(JobExplorer.class).findRunningJobExecutions("test")).isEmpty();
|
||||
assertThat(context.getBean(JobRepository.class).getLastJobExecution("test", new JobParameters()))
|
||||
.isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@EnableBatchProcessing
|
||||
|
|
|
@ -291,53 +291,18 @@ class FlywayAutoConfigurationTests {
|
|||
@Test
|
||||
void changeLogDoesNotExist() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.locations:filesystem:no-such-dir").run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context).getFailure().isInstanceOf(BeanCreationException.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void checkLocationsAllMissing() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.locations:classpath:db/missing1,classpath:db/migration2")
|
||||
.withPropertyValues("spring.flyway.fail-on-missing-locations=true",
|
||||
"spring.flyway.locations:filesystem:no-such-dir")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context).getFailure().isInstanceOf(BeanCreationException.class);
|
||||
assertThat(context).getFailure().hasMessageContaining("Cannot find migration scripts in");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void checkLocationsAllExist() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration")
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void checkLocationsAllExistWithImplicitClasspathPrefix() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.locations:db/changelog,db/migration")
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void checkLocationsAllExistWithFilesystemPrefix() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.locations:filesystem:src/test/resources/db/migration")
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
void failOnMissingLocationsAllMissing() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.check-location=false",
|
||||
"spring.flyway.fail-on-missing-locations=true")
|
||||
.withPropertyValues("spring.flyway.fail-on-missing-locations=true")
|
||||
.withPropertyValues("spring.flyway.locations:classpath:db/missing1,classpath:db/migration2")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
|
@ -349,8 +314,7 @@ class FlywayAutoConfigurationTests {
|
|||
@Test
|
||||
void failOnMissingLocationsAllExist() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.check-location=false",
|
||||
"spring.flyway.fail-on-missing-locations=true")
|
||||
.withPropertyValues("spring.flyway.fail-on-missing-locations=true")
|
||||
.withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration")
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
@ -358,8 +322,7 @@ class FlywayAutoConfigurationTests {
|
|||
@Test
|
||||
void failOnMissingLocationsAllExistWithImplicitClasspathPrefix() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.check-location=false",
|
||||
"spring.flyway.fail-on-missing-locations=true")
|
||||
.withPropertyValues("spring.flyway.fail-on-missing-locations=true")
|
||||
.withPropertyValues("spring.flyway.locations:db/changelog,db/migration")
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
@ -367,8 +330,7 @@ class FlywayAutoConfigurationTests {
|
|||
@Test
|
||||
void failOnMissingLocationsAllExistWithFilesystemPrefix() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.check-location=false",
|
||||
"spring.flyway.fail-on-missing-locations=true")
|
||||
.withPropertyValues("spring.flyway.fail-on-missing-locations=true")
|
||||
.withPropertyValues("spring.flyway.locations:filesystem:src/test/resources/db/migration")
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
|
|
@ -1,59 +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.flyway;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link FlywayMigrationScriptMissingFailureAnalyzer}.
|
||||
*
|
||||
* @author Anand Shastri
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 as location checking is deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
class FlywayMigrationScriptMissingFailureAnalyzerTests {
|
||||
|
||||
@Test
|
||||
void analysisForMissingScriptLocation() {
|
||||
FailureAnalysis failureAnalysis = performAnalysis();
|
||||
assertThat(failureAnalysis.getDescription()).contains("no migration scripts location is configured");
|
||||
assertThat(failureAnalysis.getAction()).contains("Check your Flyway configuration");
|
||||
}
|
||||
|
||||
@Test
|
||||
void analysisForScriptLocationsNotFound() {
|
||||
FailureAnalysis failureAnalysis = performAnalysis("classpath:db/migration");
|
||||
assertThat(failureAnalysis.getDescription())
|
||||
.contains("none of the following migration scripts locations could be found")
|
||||
.contains("classpath:db/migration");
|
||||
assertThat(failureAnalysis.getAction())
|
||||
.contains("Review the locations above or check your Flyway configuration");
|
||||
}
|
||||
|
||||
private FailureAnalysis performAnalysis(String... locations) {
|
||||
FlywayMigrationScriptMissingException exception = new FlywayMigrationScriptMissingException(
|
||||
Arrays.asList(locations));
|
||||
return new FlywayMigrationScriptMissingFailureAnalyzer().analyze(exception);
|
||||
}
|
||||
|
||||
}
|
|
@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Dave Syer
|
||||
*/
|
||||
@DirtiesContext
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, properties = { "env.FOO=There", "foo=World" })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE)
|
||||
class MustacheStandaloneIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
@ -49,22 +49,6 @@ class MustacheStandaloneIntegrationTests {
|
|||
.isEqualTo("Hello: World");
|
||||
}
|
||||
|
||||
@Test
|
||||
void environmentCollectorCompoundKey() {
|
||||
assertThat(this.compiler.compile("Hello: {{env.foo}}").execute(new Object())).isEqualTo("Hello: There");
|
||||
}
|
||||
|
||||
@Test
|
||||
void environmentCollectorCompoundKeyStandard() {
|
||||
assertThat(this.compiler.standardsMode(true).compile("Hello: {{env.foo}}").execute(new Object()))
|
||||
.isEqualTo("Hello: There");
|
||||
}
|
||||
|
||||
@Test
|
||||
void environmentCollectorSimpleKey() {
|
||||
assertThat(this.compiler.compile("Hello: {{foo}}").execute(new Object())).isEqualTo("Hello: World");
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import({ MustacheAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||
static class Application {
|
||||
|
|
|
@ -1,214 +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.r2dbc;
|
||||
|
||||
import io.r2dbc.spi.ConnectionFactoryOptions;
|
||||
import io.r2dbc.spi.Option;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryOptionsInitializer.ConnectionFactoryBeanCreationException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConnectionFactoryBuilder}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Tadaya Tsuyukubo
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
class ConnectionFactoryBuilderTests {
|
||||
|
||||
@Test
|
||||
void propertiesWithoutUrlAndNoAvailableEmbeddedConnectionShouldFail() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
assertThatThrownBy(() -> ConnectionFactoryBuilder.of(properties, () -> EmbeddedDatabaseConnection.NONE))
|
||||
.isInstanceOf(ConnectionFactoryBeanCreationException.class)
|
||||
.hasMessage("Failed to determine a suitable R2DBC Connection URL");
|
||||
}
|
||||
|
||||
@Test
|
||||
void connectionFactoryBeanCreationProvidesConnectionAndProperties() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
try {
|
||||
ConnectionFactoryBuilder.of(properties, () -> EmbeddedDatabaseConnection.NONE);
|
||||
fail("Should have thrown a " + ConnectionFactoryBeanCreationException.class.getName());
|
||||
}
|
||||
catch (ConnectionFactoryBeanCreationException ex) {
|
||||
assertThat(ex.getEmbeddedDatabaseConnection())
|
||||
.isEqualTo(org.springframework.boot.r2dbc.EmbeddedDatabaseConnection.NONE);
|
||||
assertThat(ex.getProperties()).isSameAs(properties);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void regularConnectionIsConfiguredAutomaticallyWithUrl() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setUrl("r2dbc:simple://:pool:");
|
||||
ConnectionFactoryOptions options = ConnectionFactoryBuilder
|
||||
.of(properties, () -> EmbeddedDatabaseConnection.NONE).buildOptions();
|
||||
assertThat(options.hasOption(ConnectionFactoryOptions.USER)).isFalse();
|
||||
assertThat(options.hasOption(ConnectionFactoryOptions.PASSWORD)).isFalse();
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)).isEqualTo("simple");
|
||||
}
|
||||
|
||||
@Test
|
||||
void regularConnectionShouldInitializeUrlOptions() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setUrl("r2dbc:simple:proto://user:password@myhost:4711/mydatabase");
|
||||
ConnectionFactoryOptions options = buildOptions(properties);
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)).isEqualTo("simple");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.PROTOCOL)).isEqualTo("proto");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("user");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.PASSWORD)).isEqualTo("password");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.HOST)).isEqualTo("myhost");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.PORT)).isEqualTo(4711);
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("mydatabase");
|
||||
}
|
||||
|
||||
@Test
|
||||
void regularConnectionShouldUseUrlOptionsOverProperties() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setUrl("r2dbc:simple://user:password@myhost/mydatabase");
|
||||
properties.setUsername("another-user");
|
||||
properties.setPassword("another-password");
|
||||
properties.setName("another-database");
|
||||
ConnectionFactoryOptions options = buildOptions(properties);
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("user");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.PASSWORD)).isEqualTo("password");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("mydatabase");
|
||||
}
|
||||
|
||||
@Test
|
||||
void regularConnectionShouldUseDatabaseNameOverRandomName() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setUrl("r2dbc:simple://user:password@myhost/mydatabase");
|
||||
properties.setGenerateUniqueName(true);
|
||||
ConnectionFactoryOptions options = buildOptions(properties);
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("mydatabase");
|
||||
}
|
||||
|
||||
@Test
|
||||
void regularConnectionWithRandomNameShouldIgnoreNameFromProperties() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setUrl("r2dbc:h2://host");
|
||||
properties.setName("test-database");
|
||||
properties.setGenerateUniqueName(true);
|
||||
ConnectionFactoryOptions options = buildOptions(properties);
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isNotEqualTo("test-database")
|
||||
.isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void regularConnectionShouldSetCustomDriverProperties() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setUrl("r2dbc:simple://user:password@myhost");
|
||||
properties.getProperties().put("simpleOne", "one");
|
||||
properties.getProperties().put("simpleTwo", "two");
|
||||
ConnectionFactoryOptions options = buildOptions(properties);
|
||||
assertThat(options.getRequiredValue(Option.<String>valueOf("simpleOne"))).isEqualTo("one");
|
||||
assertThat(options.getRequiredValue(Option.<String>valueOf("simpleTwo"))).isEqualTo("two");
|
||||
}
|
||||
|
||||
@Test
|
||||
void regularConnectionShouldUseBuilderValuesOverProperties() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setUrl("r2dbc:simple://user:password@myhost:47111/mydatabase");
|
||||
properties.setUsername("user");
|
||||
properties.setPassword("password");
|
||||
ConnectionFactoryOptions options = ConnectionFactoryBuilder
|
||||
.of(properties, () -> EmbeddedDatabaseConnection.NONE).username("another-user")
|
||||
.password("another-password").hostname("another-host").port(1234).database("another-database")
|
||||
.buildOptions();
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("another-user");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.PASSWORD)).isEqualTo("another-password");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.HOST)).isEqualTo("another-host");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.PORT)).isEqualTo(1234);
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("another-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
void embeddedConnectionIsConfiguredAutomaticallyWithoutUrl() {
|
||||
ConnectionFactoryOptions options = ConnectionFactoryBuilder
|
||||
.of(new R2dbcProperties(), () -> EmbeddedDatabaseConnection.H2).buildOptions();
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("sa");
|
||||
assertThat(options.hasOption(ConnectionFactoryOptions.PASSWORD)).isFalse();
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)).isEqualTo("h2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void embeddedConnectionWithUsernameAndPassword() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setUsername("embedded");
|
||||
properties.setPassword("secret");
|
||||
ConnectionFactoryOptions options = ConnectionFactoryBuilder.of(properties, () -> EmbeddedDatabaseConnection.H2)
|
||||
.buildOptions();
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("embedded");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.PASSWORD)).isEqualTo("secret");
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)).isEqualTo("h2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void embeddedConnectionUseDefaultDatabaseName() {
|
||||
ConnectionFactoryOptions options = ConnectionFactoryBuilder
|
||||
.of(new R2dbcProperties(), () -> EmbeddedDatabaseConnection.H2).buildOptions();
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("testdb");
|
||||
}
|
||||
|
||||
@Test
|
||||
void embeddedConnectionUseNameIfSet() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setName("test-database");
|
||||
ConnectionFactoryOptions options = buildOptions(properties);
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("test-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
void embeddedConnectionCanGenerateUniqueDatabaseName() {
|
||||
R2dbcProperties firstProperties = new R2dbcProperties();
|
||||
firstProperties.setGenerateUniqueName(true);
|
||||
ConnectionFactoryOptions options11 = buildOptions(firstProperties);
|
||||
ConnectionFactoryOptions options12 = buildOptions(firstProperties);
|
||||
assertThat(options11.getRequiredValue(ConnectionFactoryOptions.DATABASE))
|
||||
.isEqualTo(options12.getRequiredValue(ConnectionFactoryOptions.DATABASE));
|
||||
R2dbcProperties secondProperties = new R2dbcProperties();
|
||||
firstProperties.setGenerateUniqueName(true);
|
||||
ConnectionFactoryOptions options21 = buildOptions(secondProperties);
|
||||
ConnectionFactoryOptions options22 = buildOptions(secondProperties);
|
||||
assertThat(options21.getRequiredValue(ConnectionFactoryOptions.DATABASE))
|
||||
.isEqualTo(options22.getRequiredValue(ConnectionFactoryOptions.DATABASE));
|
||||
assertThat(options11.getRequiredValue(ConnectionFactoryOptions.DATABASE))
|
||||
.isNotEqualTo(options21.getRequiredValue(ConnectionFactoryOptions.DATABASE));
|
||||
}
|
||||
|
||||
@Test
|
||||
void embeddedConnectionShouldIgnoreNameIfRandomNameIsRequired() {
|
||||
R2dbcProperties properties = new R2dbcProperties();
|
||||
properties.setGenerateUniqueName(true);
|
||||
properties.setName("test-database");
|
||||
ConnectionFactoryOptions options = buildOptions(properties);
|
||||
assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isNotEqualTo("test-database");
|
||||
}
|
||||
|
||||
private ConnectionFactoryOptions buildOptions(R2dbcProperties properties) {
|
||||
return ConnectionFactoryBuilder.of(properties, () -> EmbeddedDatabaseConnection.H2).buildOptions();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -129,17 +129,6 @@ public class BootBuildImage extends DefaultTask {
|
|||
return this.archiveFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the property for the archive file from which the image will be built.
|
||||
* @return the archive file property
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of {@link #getArchiveFile()}
|
||||
*/
|
||||
@Deprecated
|
||||
@Input
|
||||
public RegularFileProperty getJar() {
|
||||
return this.archiveFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target Java version of the project (e.g. as provided by the
|
||||
* {@code targetCompatibility} build property).
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -86,20 +86,6 @@ public final class ConnectionFactoryBuilder {
|
|||
return new ConnectionFactoryBuilder(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new {@link ConnectionFactoryBuilder} derived from the options of the
|
||||
* specified {@code connectionFactory}.
|
||||
* @param connectionFactory the connection factory whose options are to be used to
|
||||
* initialize the builder
|
||||
* @return a new builder initialized with the options from the connection factory
|
||||
* @deprecated since 2.5.1 for removal in 2.7.0 in favor of
|
||||
* {@link #derivedFrom(ConnectionFactory)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static ConnectionFactoryBuilder derivefrom(ConnectionFactory connectionFactory) {
|
||||
return derivedFrom(connectionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new {@link ConnectionFactoryBuilder} derived from the options of the
|
||||
* specified {@code connectionFactory}.
|
||||
|
|
Loading…
Reference in New Issue