mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
This commit is contained in:
parent
62d9d0fd29
commit
b234501af3
@ -51,8 +51,7 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
|
||||
*/
|
||||
public CloudFoundryWebEndpointDiscoverer(ApplicationContext applicationContext,
|
||||
ParameterValueMapper parameterValueMapper,
|
||||
EndpointMediaTypes endpointMediaTypes,
|
||||
PathMapper endpointPathMapper,
|
||||
EndpointMediaTypes endpointMediaTypes, PathMapper endpointPathMapper,
|
||||
Collection<OperationInvokerAdvisor> invokerAdvisors,
|
||||
Collection<EndpointFilter<ExposableWebEndpoint>> filters) {
|
||||
super(applicationContext, parameterValueMapper, endpointMediaTypes,
|
||||
|
@ -21,8 +21,8 @@ import java.util.Map;
|
||||
import org.springframework.boot.actuate.endpoint.web.PathMapper;
|
||||
|
||||
/**
|
||||
* A {@link PathMapper} implementation that uses a simple {@link Map} to
|
||||
* determine the endpoint path.
|
||||
* A {@link PathMapper} implementation that uses a simple {@link Map} to determine the
|
||||
* endpoint path.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
@ -65,8 +65,8 @@ class CacheMetricsRegistrarConfiguration {
|
||||
|
||||
@Bean
|
||||
public CacheMetricsRegistrar cacheMetricsRegistrar() {
|
||||
return new CacheMetricsRegistrar(this.registry,
|
||||
this.properties.getMetricName(), this.binderProviders);
|
||||
return new CacheMetricsRegistrar(this.registry, this.properties.getMetricName(),
|
||||
this.binderProviders);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
@ -68,8 +68,8 @@ public class CloudFoundryWebEndpointDiscovererTests {
|
||||
this.load((id) -> null, (id) -> id, configuration, consumer);
|
||||
}
|
||||
|
||||
private void load(Function<String, Long> timeToLive,
|
||||
PathMapper endpointPathMapper, Class<?> configuration,
|
||||
private void load(Function<String, Long> timeToLive, PathMapper endpointPathMapper,
|
||||
Class<?> configuration,
|
||||
Consumer<CloudFoundryWebEndpointDiscoverer> consumer) {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
configuration);
|
||||
|
@ -54,8 +54,8 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(
|
||||
this.tokenValidator, this.securityService, "my-app-id");
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(this.tokenValidator,
|
||||
this.securityService, "my-app-id");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -90,8 +90,8 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void preHandleWhenApplicationIdIsNullShouldReturnError() {
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(
|
||||
this.tokenValidator, this.securityService, null);
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(this.tokenValidator,
|
||||
this.securityService, null);
|
||||
MockServerWebExchange request = MockServerWebExchange
|
||||
.from(MockServerHttpRequest.get("/a")
|
||||
.header(HttpHeaders.AUTHORIZATION, "bearer " + mockAccessToken())
|
||||
@ -105,8 +105,8 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void preHandleWhenCloudFoundrySecurityServiceIsNullShouldReturnError() {
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(
|
||||
this.tokenValidator, null, "my-app-id");
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(this.tokenValidator, null,
|
||||
"my-app-id");
|
||||
MockServerWebExchange request = MockServerWebExchange.from(MockServerHttpRequest
|
||||
.get("/a").header(HttpHeaders.AUTHORIZATION, mockAccessToken()).build());
|
||||
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
|
||||
|
@ -58,8 +58,7 @@ public class CacheMetricsConfigurationTests {
|
||||
@Test
|
||||
public void autoConfiguredCacheManagerWithCustomMetricName() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"management.metrics.cache.metric-name=custom.name",
|
||||
.withPropertyValues("management.metrics.cache.metric-name=custom.name",
|
||||
"spring.cache.type=caffeine", "spring.cache.cache-names=cache1")
|
||||
.run((context) -> {
|
||||
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
||||
|
@ -38,9 +38,9 @@ public final class MissingParametersException extends InvalidEndpointRequestExce
|
||||
super("Failed to invoke operation because the following required "
|
||||
+ "parameters were missing: "
|
||||
+ StringUtils.collectionToCommaDelimitedString(missingParameters),
|
||||
"Missing parameters: " + missingParameters.stream()
|
||||
.map(OperationParameter::getName)
|
||||
.collect(Collectors.joining(",")));
|
||||
"Missing parameters: "
|
||||
+ missingParameters.stream().map(OperationParameter::getName)
|
||||
.collect(Collectors.joining(",")));
|
||||
this.missingParameters = missingParameters;
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
/**
|
||||
* Identifies a type as being an endpoint that is only exposed over Spring MVC or
|
||||
* Spring WebFlux. Mapped methods must be annotated with {@link GetMapping @GetMapping},
|
||||
* Identifies a type as being an endpoint that is only exposed over Spring MVC or Spring
|
||||
* WebFlux. Mapped methods must be annotated with {@link GetMapping @GetMapping},
|
||||
* {@link PostMapping @PostMapping}, {@link DeleteMapping @DeleteMapping}, etc annotations
|
||||
* rather than {@link ReadOperation @ReadOperation},
|
||||
* {@link WriteOperation @WriteOperation}, {@link DeleteOperation @DeleteOperation}.
|
||||
|
@ -31,7 +31,8 @@ import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link EndpointDiscoverer} for {@link ExposableControllerEndpoint controller endpoints}.
|
||||
* {@link EndpointDiscoverer} for {@link ExposableControllerEndpoint controller
|
||||
* endpoints}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
|
@ -288,8 +288,8 @@ public abstract class AbstractWebFluxEndpointHandlerMapping
|
||||
private Mono<ResponseEntity<Object>> handleResult(Publisher<?> result,
|
||||
HttpMethod httpMethod) {
|
||||
return Mono.from(result).map(this::toResponseEntity)
|
||||
.onErrorMap(InvalidEndpointRequestException.class, (ex) ->
|
||||
new ResponseStatusException(HttpStatus.BAD_REQUEST,
|
||||
.onErrorMap(InvalidEndpointRequestException.class,
|
||||
(ex) -> new ResponseStatusException(HttpStatus.BAD_REQUEST,
|
||||
ex.getReason()))
|
||||
.defaultIfEmpty(new ResponseEntity<>(httpMethod == HttpMethod.GET
|
||||
? HttpStatus.NOT_FOUND : HttpStatus.NO_CONTENT));
|
||||
|
@ -72,8 +72,7 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
|
||||
private Map<Object, ExposableControllerEndpoint> getHandlers(
|
||||
Collection<ExposableControllerEndpoint> endpoints) {
|
||||
Map<Object, ExposableControllerEndpoint> handlers = new LinkedHashMap<>();
|
||||
endpoints
|
||||
.forEach((endpoint) -> handlers.put(endpoint.getController(), endpoint));
|
||||
endpoints.forEach((endpoint) -> handlers.put(endpoint.getController(), endpoint));
|
||||
return Collections.unmodifiableMap(handlers);
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,7 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
|
||||
private Map<Object, ExposableControllerEndpoint> getHandlers(
|
||||
Collection<ExposableControllerEndpoint> endpoints) {
|
||||
Map<Object, ExposableControllerEndpoint> handlers = new LinkedHashMap<>();
|
||||
endpoints
|
||||
.forEach((endpoint) -> handlers.put(endpoint.getController(), endpoint));
|
||||
endpoints.forEach((endpoint) -> handlers.put(endpoint.getController(), endpoint));
|
||||
return Collections.unmodifiableMap(handlers);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@ -75,12 +75,12 @@ public class RouterFunctionMetrics {
|
||||
Iterable<Tag> tags) {
|
||||
return (request, next) -> {
|
||||
final long start = System.nanoTime();
|
||||
return next.handle(request).doOnSuccess(response -> {
|
||||
return next.handle(request).doOnSuccess((response) -> {
|
||||
Iterable<Tag> allTags = Tags.concat(tags,
|
||||
this.defaultTags.apply(request, response));
|
||||
this.registry.timer(name, allTags).record(System.nanoTime() - start,
|
||||
TimeUnit.NANOSECONDS);
|
||||
}).doOnError(error -> {
|
||||
}).doOnError((error) -> {
|
||||
// FIXME how do we get the response under an error condition?
|
||||
Iterable<Tag> allTags = Tags.concat(tags,
|
||||
this.defaultTags.apply(request, null));
|
||||
|
@ -99,7 +99,7 @@ public class BeansEndpointTests {
|
||||
parentRunner.run((parent) -> {
|
||||
new ApplicationContextRunner()
|
||||
.withUserConfiguration(EndpointConfiguration.class).withParent(parent)
|
||||
.run(child -> {
|
||||
.run((child) -> {
|
||||
ApplicationBeans result = child.getBean(BeansEndpoint.class).beans();
|
||||
assertThat(result.getContexts().get(parent.getId()).getBeans())
|
||||
.containsKey("bean");
|
||||
|
@ -42,7 +42,7 @@ public class ConfigurationPropertiesReportEndpointParentTests {
|
||||
.run((parent) -> {
|
||||
new ApplicationContextRunner()
|
||||
.withUserConfiguration(ClassConfigurationProperties.class)
|
||||
.withParent(parent).run(child -> {
|
||||
.withParent(parent).run((child) -> {
|
||||
ConfigurationPropertiesReportEndpoint endpoint = child
|
||||
.getBean(ConfigurationPropertiesReportEndpoint.class);
|
||||
ApplicationConfigurationProperties applicationProperties = endpoint
|
||||
@ -65,7 +65,7 @@ public class ConfigurationPropertiesReportEndpointParentTests {
|
||||
new ApplicationContextRunner()
|
||||
.withUserConfiguration(
|
||||
BeanMethodConfigurationProperties.class)
|
||||
.withParent(parent).run(child -> {
|
||||
.withParent(parent).run((child) -> {
|
||||
ConfigurationPropertiesReportEndpoint endpoint = child
|
||||
.getBean(ConfigurationPropertiesReportEndpoint.class);
|
||||
ApplicationConfigurationProperties applicationProperties = endpoint
|
||||
|
@ -159,9 +159,8 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
||||
@Test
|
||||
public void readOperationWithMappingFailureProducesBadRequestResponse() {
|
||||
load(QueryEndpointConfiguration.class, (client) -> {
|
||||
WebTestClient.BodyContentSpec body = client.get()
|
||||
.uri("/query?two=two").exchange().expectStatus().isBadRequest()
|
||||
.expectBody();
|
||||
WebTestClient.BodyContentSpec body = client.get().uri("/query?two=two")
|
||||
.exchange().expectStatus().isBadRequest().expectBody();
|
||||
validateErrorBody(body, HttpStatus.BAD_REQUEST, "/endpoints/query",
|
||||
"Missing parameters: one");
|
||||
});
|
||||
@ -282,9 +281,8 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
||||
@Test
|
||||
public void readOperationWithMissingRequiredParametersReturnsBadRequestResponse() {
|
||||
load(RequiredParameterEndpointConfiguration.class, (client) -> {
|
||||
WebTestClient.BodyContentSpec body = client.get()
|
||||
.uri("/requiredparameters").exchange().expectStatus().isBadRequest()
|
||||
.expectBody();
|
||||
WebTestClient.BodyContentSpec body = client.get().uri("/requiredparameters")
|
||||
.exchange().expectStatus().isBadRequest().expectBody();
|
||||
validateErrorBody(body, HttpStatus.BAD_REQUEST,
|
||||
"/endpoints/requiredparameters", "Missing parameters: foo");
|
||||
});
|
||||
@ -334,9 +332,8 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
||||
|
||||
protected void validateErrorBody(WebTestClient.BodyContentSpec body,
|
||||
HttpStatus status, String path, String message) {
|
||||
body.jsonPath("status").isEqualTo(status.value())
|
||||
.jsonPath("error").isEqualTo(status.getReasonPhrase())
|
||||
.jsonPath("path").isEqualTo(path)
|
||||
body.jsonPath("status").isEqualTo(status.value()).jsonPath("error")
|
||||
.isEqualTo(status.getReasonPhrase()).jsonPath("path").isEqualTo(path)
|
||||
.jsonPath("message").isEqualTo(message);
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ class BaseConfiguration {
|
||||
ParameterValueMapper parameterMapper = new ConversionServiceParameterValueMapper(
|
||||
DefaultConversionService.getSharedInstance());
|
||||
return new WebEndpointDiscoverer(applicationContext, parameterMapper,
|
||||
endpointMediaTypes(), PathMapper.useEndpointId(),
|
||||
Collections.emptyList(), Collections.emptyList());
|
||||
endpointMediaTypes(), PathMapper.useEndpointId(), Collections.emptyList(),
|
||||
Collections.emptyList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -298,9 +298,9 @@ public class WebEndpointDiscovererTests {
|
||||
Map<WebOperationRequestPredicate, Long> matchCounts = new HashMap<>();
|
||||
for (WebOperationRequestPredicate predicate : predicates) {
|
||||
matchCounts.put(predicate, Stream.of(matchers)
|
||||
.filter(matcher -> matcher.matches(predicate)).count());
|
||||
.filter((matcher) -> matcher.matches(predicate)).count());
|
||||
}
|
||||
return matchCounts.values().stream().noneMatch(count -> count != 1);
|
||||
return matchCounts.values().stream().noneMatch((count) -> count != 1);
|
||||
}, Arrays.toString(matchers));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@ -100,7 +100,7 @@ public class SpringIntegrationMetricsIntegrationTests {
|
||||
(e) -> e.id("toJson"))
|
||||
.handle(String.class, this::fahrenheitToCelsius,
|
||||
(e) -> e.id("temperatureConverter"))
|
||||
.transform(this::extractResult, e -> e.id("toResponse"));
|
||||
.transform(this::extractResult, (e) -> e.id("toResponse"));
|
||||
}
|
||||
|
||||
private double extractResult(String json) {
|
||||
|
@ -157,7 +157,7 @@ public class FlywayAutoConfiguration {
|
||||
private String getProperty(Supplier<String> property,
|
||||
Supplier<String> defaultValue) {
|
||||
String value = property.get();
|
||||
return value == null ? defaultValue.get() : value;
|
||||
return (value == null ? defaultValue.get() : value);
|
||||
}
|
||||
|
||||
private void checkLocationExists(String... locations) {
|
||||
|
@ -57,16 +57,19 @@ public final class JettyCustomizer {
|
||||
propertyMapper.from(jettyProperties::getSelectors).whenNonNull()
|
||||
.to(factory::setSelectors);
|
||||
propertyMapper.from(serverProperties::getMaxHttpHeaderSize)
|
||||
.when(JettyCustomizer::isPositive).to(maxHttpHeaderSize ->
|
||||
customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize));
|
||||
.when(JettyCustomizer::isPositive)
|
||||
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
|
||||
maxHttpHeaderSize));
|
||||
propertyMapper.from(jettyProperties::getMaxHttpPostSize)
|
||||
.when(JettyCustomizer::isPositive)
|
||||
.to(maxHttpPostSize -> customizeMaxHttpPostSize(factory, maxHttpPostSize));
|
||||
.to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory,
|
||||
maxHttpPostSize));
|
||||
propertyMapper.from(serverProperties::getConnectionTimeout).whenNonNull()
|
||||
.to(connectionTimeout -> customizeConnectionTimeout(factory, connectionTimeout));
|
||||
.to((connectionTimeout) -> customizeConnectionTimeout(factory,
|
||||
connectionTimeout));
|
||||
propertyMapper.from(jettyProperties::getAccesslog)
|
||||
.when(ServerProperties.Jetty.Accesslog::isEnabled)
|
||||
.to(accesslog -> customizeAccessLog(factory, accesslog));
|
||||
.to((accesslog) -> customizeAccessLog(factory, accesslog));
|
||||
}
|
||||
|
||||
private static boolean isPositive(Integer value) {
|
||||
|
@ -58,29 +58,35 @@ public final class TomcatCustomizer {
|
||||
customizeRemoteIpValve(serverProperties, environment, factory);
|
||||
propertyMapper.from(tomcatProperties::getMaxThreads)
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(maxThreads -> customizeMaxThreads(factory, tomcatProperties.getMaxThreads()));
|
||||
.to((maxThreads) -> customizeMaxThreads(factory,
|
||||
tomcatProperties.getMaxThreads()));
|
||||
propertyMapper.from(tomcatProperties::getMinSpareThreads)
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(minSpareThreads -> customizeMinThreads(factory, minSpareThreads));
|
||||
propertyMapper.from(() -> determineMaxHttpHeaderSize(serverProperties, tomcatProperties))
|
||||
.to((minSpareThreads) -> customizeMinThreads(factory, minSpareThreads));
|
||||
propertyMapper
|
||||
.from(() -> determineMaxHttpHeaderSize(serverProperties,
|
||||
tomcatProperties))
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(maxHttpHeaderSize -> customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize));
|
||||
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
|
||||
maxHttpHeaderSize));
|
||||
propertyMapper.from(tomcatProperties::getMaxHttpPostSize)
|
||||
.when(maxHttpPostSize -> maxHttpPostSize != 0)
|
||||
.to(maxHttpPostSize -> customizeMaxHttpPostSize(factory, maxHttpPostSize));
|
||||
.when((maxHttpPostSize) -> maxHttpPostSize != 0)
|
||||
.to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory,
|
||||
maxHttpPostSize));
|
||||
propertyMapper.from(tomcatProperties::getAccesslog)
|
||||
.when(ServerProperties.Tomcat.Accesslog::isEnabled)
|
||||
.to(enabled -> customizeAccessLog(tomcatProperties, factory));
|
||||
.to((enabled) -> customizeAccessLog(tomcatProperties, factory));
|
||||
propertyMapper.from(tomcatProperties::getUriEncoding).whenNonNull()
|
||||
.to(factory::setUriEncoding);
|
||||
propertyMapper.from(serverProperties::getConnectionTimeout).whenNonNull()
|
||||
.to(connectionTimeout -> customizeConnectionTimeout(factory, connectionTimeout));
|
||||
.to((connectionTimeout) -> customizeConnectionTimeout(factory,
|
||||
connectionTimeout));
|
||||
propertyMapper.from(tomcatProperties::getMaxConnections)
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(maxConnections -> customizeMaxConnections(factory, maxConnections));
|
||||
.to((maxConnections) -> customizeMaxConnections(factory, maxConnections));
|
||||
propertyMapper.from(tomcatProperties::getAcceptCount)
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(acceptCount -> customizeAcceptCount(factory, acceptCount));
|
||||
.to((acceptCount) -> customizeAcceptCount(factory, acceptCount));
|
||||
customizeStaticResources(serverProperties.getTomcat().getResource(), factory);
|
||||
}
|
||||
|
||||
@ -234,4 +240,5 @@ public final class TomcatCustomizer {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,21 +63,21 @@ public final class UndertowCustomizer {
|
||||
.to(factory::setAccessLogSuffix);
|
||||
propertyMapper.from(accesslogProperties::isRotate)
|
||||
.to(factory::setAccessLogRotate);
|
||||
propertyMapper.from(() ->
|
||||
getOrDeduceUseForwardHeaders(serverProperties, environment)).to(
|
||||
factory::setUseForwardHeaders);
|
||||
propertyMapper
|
||||
.from(() -> getOrDeduceUseForwardHeaders(serverProperties, environment))
|
||||
.to(factory::setUseForwardHeaders);
|
||||
propertyMapper.from(serverProperties::getMaxHttpHeaderSize)
|
||||
.when(UndertowCustomizer::isPositive)
|
||||
.to(maxHttpHeaderSize ->
|
||||
customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize));
|
||||
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
|
||||
maxHttpHeaderSize));
|
||||
propertyMapper.from(undertowProperties::getMaxHttpPostSize)
|
||||
.when(UndertowCustomizer::isPositive)
|
||||
.to(maxHttpPostSize ->
|
||||
customizeMaxHttpPostSize(factory, maxHttpPostSize));
|
||||
.to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory,
|
||||
maxHttpPostSize));
|
||||
propertyMapper.from(serverProperties::getConnectionTimeout)
|
||||
.to(connectionTimeout ->
|
||||
customizeConnectionTimeout(factory, connectionTimeout));
|
||||
factory.addDeploymentInfoCustomizers(deploymentInfo -> deploymentInfo
|
||||
.to((connectionTimeout) -> customizeConnectionTimeout(factory,
|
||||
connectionTimeout));
|
||||
factory.addDeploymentInfoCustomizers((deploymentInfo) -> deploymentInfo
|
||||
.setEagerFilterInit(undertowProperties.isEagerFilterInit()));
|
||||
}
|
||||
|
||||
|
@ -67,14 +67,14 @@ public class DefaultReactiveWebServerFactoryCustomizer
|
||||
map.from(this.serverProperties::getSsl).to(factory::setSsl);
|
||||
map.from(this.serverProperties::getCompression).to(factory::setCompression);
|
||||
map.from(this.serverProperties::getHttp2).to(factory::setHttp2);
|
||||
map.from(() -> factory).whenInstanceOf(TomcatReactiveWebServerFactory.class)
|
||||
.to(tomcatFactory -> TomcatCustomizer.customizeTomcat(
|
||||
this.serverProperties, this.environment, tomcatFactory));
|
||||
map.from(() -> factory).whenInstanceOf(JettyReactiveWebServerFactory.class)
|
||||
.to(jettyFactory -> JettyCustomizer.customizeJetty(this.serverProperties,
|
||||
map.from(() -> factory).whenInstanceOf(TomcatReactiveWebServerFactory.class).to(
|
||||
(tomcatFactory) -> TomcatCustomizer.customizeTomcat(this.serverProperties,
|
||||
this.environment, tomcatFactory));
|
||||
map.from(() -> factory).whenInstanceOf(JettyReactiveWebServerFactory.class).to(
|
||||
(jettyFactory) -> JettyCustomizer.customizeJetty(this.serverProperties,
|
||||
this.environment, jettyFactory));
|
||||
map.from(() -> factory).whenInstanceOf(UndertowReactiveWebServerFactory.class)
|
||||
.to(undertowFactory -> UndertowCustomizer.customizeUndertow(
|
||||
.to((undertowFactory) -> UndertowCustomizer.customizeUndertow(
|
||||
this.serverProperties, this.environment, undertowFactory));
|
||||
}
|
||||
|
||||
|
@ -83,17 +83,17 @@ public class DefaultServletWebServerFactoryCustomizer
|
||||
map.from(this.serverProperties::getHttp2).to(factory::setHttp2);
|
||||
map.from(this.serverProperties::getServerHeader).to(factory::setServerHeader);
|
||||
map.from(() -> factory).whenInstanceOf(TomcatServletWebServerFactory.class)
|
||||
.to(tomcatFactory -> {
|
||||
.to((tomcatFactory) -> {
|
||||
TomcatCustomizer.customizeTomcat(this.serverProperties,
|
||||
this.environment, tomcatFactory);
|
||||
TomcatServletCustomizer.customizeTomcat(this.serverProperties,
|
||||
this.environment, tomcatFactory);
|
||||
});
|
||||
map.from(() -> factory).whenInstanceOf(JettyServletWebServerFactory.class)
|
||||
.to(jettyFactory -> JettyCustomizer.customizeJetty(this.serverProperties,
|
||||
map.from(() -> factory).whenInstanceOf(JettyServletWebServerFactory.class).to(
|
||||
(jettyFactory) -> JettyCustomizer.customizeJetty(this.serverProperties,
|
||||
this.environment, jettyFactory));
|
||||
map.from(() -> factory).whenInstanceOf(UndertowServletWebServerFactory.class)
|
||||
.to(undertowFactory -> UndertowCustomizer.customizeUndertow(
|
||||
.to((undertowFactory) -> UndertowCustomizer.customizeUndertow(
|
||||
this.serverProperties, this.environment, undertowFactory));
|
||||
map.from(this.serverProperties.getServlet()::getContextParameters)
|
||||
.to(factory::setInitParameters);
|
||||
|
@ -60,11 +60,12 @@ public class CassandraRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(CityRepository.class);
|
||||
assertThat(context).hasSingleBean(Cluster.class);
|
||||
assertThat(getInitialEntitySet(context)).hasSize(1);
|
||||
});
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CityRepository.class);
|
||||
assertThat(context).hasSingleBean(Cluster.class);
|
||||
assertThat(getInitialEntitySet(context)).hasSize(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -58,16 +58,17 @@ public class MongoReactiveRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(ReactiveCityRepository.class);
|
||||
assertThat(context).hasSingleBean(MongoClient.class);
|
||||
MongoMappingContext mappingContext = context
|
||||
.getBean(MongoMappingContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(entities).hasSize(1);
|
||||
});
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(ReactiveCityRepository.class);
|
||||
assertThat(context).hasSingleBean(MongoClient.class);
|
||||
MongoMappingContext mappingContext = context
|
||||
.getBean(MongoMappingContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(entities).hasSize(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,16 +53,17 @@ public class MongoRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(CityRepository.class);
|
||||
assertThat(context).hasSingleBean(MongoClient.class);
|
||||
MongoMappingContext mappingContext = context
|
||||
.getBean(MongoMappingContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(entities).hasSize(1);
|
||||
});
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CityRepository.class);
|
||||
assertThat(context).hasSingleBean(MongoClient.class);
|
||||
MongoMappingContext mappingContext = context
|
||||
.getBean(MongoMappingContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(entities).hasSize(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -80,8 +81,9 @@ public class MongoRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void autoConfigurationShouldNotKickInEvenIfManualConfigDidNotCreateAnyRepositories() {
|
||||
this.contextRunner.withUserConfiguration(SortOfInvalidCustomConfiguration.class).run(
|
||||
(context) -> assertThat(context).doesNotHaveBean(CityRepository.class));
|
||||
this.contextRunner.withUserConfiguration(SortOfInvalidCustomConfiguration.class)
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(CityRepository.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -74,7 +74,8 @@ public class AuthenticationManagerConfigurationTests {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(TestConfigWithClientRegistrationRepository.class,
|
||||
AuthenticationManagerConfiguration.class)
|
||||
.run(((context) -> assertThat(context).doesNotHaveBean(InMemoryUserDetailsManager.class)));
|
||||
.run(((context) -> assertThat(context)
|
||||
.doesNotHaveBean(InMemoryUserDetailsManager.class)));
|
||||
}
|
||||
|
||||
private void testPasswordEncoding(Class<?> configClass, String providedPassword,
|
||||
|
@ -70,8 +70,8 @@ class PropertiesMigrationReporter {
|
||||
return report;
|
||||
}
|
||||
properties.forEach((name, candidates) -> {
|
||||
PropertySource<?> propertySource = mapPropertiesWithReplacement(report,
|
||||
name, candidates);
|
||||
PropertySource<?> propertySource = mapPropertiesWithReplacement(report, name,
|
||||
candidates);
|
||||
if (propertySource != null) {
|
||||
this.environment.getPropertySources().addBefore(name, propertySource);
|
||||
}
|
||||
@ -84,8 +84,8 @@ class PropertiesMigrationReporter {
|
||||
List<PropertyMigration> properties) {
|
||||
List<PropertyMigration> renamed = new ArrayList<>();
|
||||
List<PropertyMigration> unsupported = new ArrayList<>();
|
||||
properties.forEach((property) ->
|
||||
(isRenamed(property) ? renamed : unsupported).add(property));
|
||||
properties.forEach((property) -> (isRenamed(property) ? renamed : unsupported)
|
||||
.add(property));
|
||||
report.add(name, renamed, unsupported);
|
||||
if (renamed.isEmpty()) {
|
||||
return null;
|
||||
@ -133,7 +133,7 @@ class PropertiesMigrationReporter {
|
||||
List<ConfigurationMetadataProperty> candidates = this.allProperties.values()
|
||||
.stream().filter(filter).collect(Collectors.toList());
|
||||
getPropertySourcesAsMap().forEach((name, source) -> {
|
||||
candidates.forEach(metadata -> {
|
||||
candidates.forEach((metadata) -> {
|
||||
ConfigurationProperty configurationProperty = source
|
||||
.getConfigurationProperty(
|
||||
ConfigurationPropertyName.of(metadata.getId()));
|
||||
|
@ -359,8 +359,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
@Test
|
||||
public void annotatedGetter() {
|
||||
ConfigurationMetadata metadata = compile(AnnotatedGetter.class);
|
||||
assertThat(metadata).has(Metadata.withGroup("specific")
|
||||
.fromSource(AnnotatedGetter.class));
|
||||
assertThat(metadata)
|
||||
.has(Metadata.withGroup("specific").fromSource(AnnotatedGetter.class));
|
||||
assertThat(metadata).has(Metadata.withProperty("specific.name", String.class)
|
||||
.fromSource(AnnotatedGetter.class));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
@ -94,8 +94,8 @@ class InvalidConfigurationPropertyValueFailureAnalyzer
|
||||
private void appendReason(StringBuilder message,
|
||||
InvalidConfigurationPropertyValueException cause) {
|
||||
if (StringUtils.hasText(cause.getReason())) {
|
||||
message.append(String.format(" Validation failed for the following "
|
||||
+ "reason:%n%n"));
|
||||
message.append(String
|
||||
.format(" Validation failed for the following " + "reason:%n%n"));
|
||||
message.append(cause.getReason());
|
||||
}
|
||||
else {
|
||||
|
@ -75,8 +75,7 @@ public class InvalidConfigurationPropertyValueFailureAnalyzerTests {
|
||||
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException(
|
||||
"test.property", "invalid", null);
|
||||
FailureAnalysis analysis = performAnalysis(failure);
|
||||
assertThat(analysis.getAction())
|
||||
.contains("Review the value of the property.");
|
||||
assertThat(analysis.getAction()).contains("Review the value of the property.");
|
||||
assertThat(analysis.getDescription()).contains("No reason was provided.")
|
||||
.doesNotContain("Additionally, this property is also set");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@ -74,7 +74,7 @@ public abstract class AbstractDataSourcePoolMetadataTests<D extends AbstractData
|
||||
final JdbcTemplate jdbcTemplate = new JdbcTemplate(
|
||||
getDataSourceMetadata().getDataSource());
|
||||
jdbcTemplate.execute((ConnectionCallback<Void>) (connection) -> {
|
||||
jdbcTemplate.execute((ConnectionCallback<Void>) connection1 -> {
|
||||
jdbcTemplate.execute((ConnectionCallback<Void>) (connection1) -> {
|
||||
assertThat(getDataSourceMetadata().getActive()).isEqualTo(2);
|
||||
assertThat(getDataSourceMetadata().getUsage()).isEqualTo(1.0f);
|
||||
return null;
|
||||
|
@ -143,7 +143,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||
|
||||
protected ReactorClientHttpConnector buildTrustAllSslConnector() {
|
||||
return new ReactorClientHttpConnector(
|
||||
(options) -> options.sslSupport(sslContextBuilder -> {
|
||||
(options) -> options.sslSupport((sslContextBuilder) -> {
|
||||
sslContextBuilder.sslProvider(SslProvider.JDK)
|
||||
.trustManager(InsecureTrustManagerFactory.INSTANCE);
|
||||
}));
|
||||
@ -180,7 +180,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
clientKeyManagerFactory.init(clientKeyStore, "password".toCharArray());
|
||||
return new ReactorClientHttpConnector(
|
||||
(options) -> options.sslSupport(sslContextBuilder -> {
|
||||
(options) -> options.sslSupport((sslContextBuilder) -> {
|
||||
sslContextBuilder.sslProvider(SslProvider.JDK)
|
||||
.trustManager(InsecureTrustManagerFactory.INSTANCE)
|
||||
.keyManager(clientKeyManagerFactory);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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,7 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
|
||||
"management.server.port=0", "management.server.servlet.context-path=/management" })
|
||||
"management.server.port=0",
|
||||
"management.server.servlet.context-path=/management" })
|
||||
public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@ -97,8 +97,7 @@ class ApplicationBuilder {
|
||||
return resourcesJar;
|
||||
}
|
||||
|
||||
private void writePom(File appFolder, File resourcesJar)
|
||||
throws IOException {
|
||||
private void writePom(File appFolder, File resourcesJar) throws IOException {
|
||||
Map<String, Object> context = new HashMap<>();
|
||||
context.put("packaging", this.packaging);
|
||||
context.put("container", this.container);
|
||||
|
Loading…
Reference in New Issue
Block a user