Merge branch '2.0.x'
This commit is contained in:
commit
42c053cf1b
|
@ -134,6 +134,7 @@ class CloudFoundryWebEndpointServletHandlerMapping
|
||||||
}
|
}
|
||||||
return this.delegate.handle(request, body);
|
return this.delegate.handle(request, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.springframework.context.annotation.Configuration;
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*
|
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -28,11 +28,11 @@ import io.micrometer.core.instrument.config.MeterFilter;
|
||||||
import org.springframework.boot.util.LambdaSafe;
|
import org.springframework.boot.util.LambdaSafe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurer to apply {@link MeterRegistryCustomizer customizers},
|
* Configurer to apply {@link MeterRegistryCustomizer customizers}, {@link MeterFilter
|
||||||
* {@link MeterFilter filters}, {@link MeterBinder binders} and {@link Metrics#addRegistry
|
* filters}, {@link MeterBinder binders} and {@link Metrics#addRegistry global
|
||||||
* global registration} to {@link MeterRegistry meter registries}. This configurer
|
* registration} to {@link MeterRegistry meter registries}. This configurer intentionally
|
||||||
* intentionally skips {@link CompositeMeterRegistry} with the assumptions that the
|
* skips {@link CompositeMeterRegistry} with the assumptions that the registries it
|
||||||
* registries it contains are beans and will be customized directly.
|
* contains are beans and will be customized directly.
|
||||||
*
|
*
|
||||||
* @author Jon Schneider
|
* @author Jon Schneider
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
|
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
|
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider;
|
||||||
import org.springframework.boot.security.servlet.ApplicationContextRequestMatcher;
|
import org.springframework.boot.security.servlet.ApplicationContextRequestMatcher;
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
|
@ -40,6 +41,7 @@ import org.springframework.security.web.util.matcher.OrRequestMatcher;
|
||||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory that can be used to create a {@link RequestMatcher} for actuator endpoint
|
* Factory that can be used to create a {@link RequestMatcher} for actuator endpoint
|
||||||
|
@ -114,7 +116,7 @@ public final class EndpointRequest {
|
||||||
* The request matcher used to match against {@link Endpoint actuator endpoints}.
|
* The request matcher used to match against {@link Endpoint actuator endpoints}.
|
||||||
*/
|
*/
|
||||||
public static final class EndpointRequestMatcher
|
public static final class EndpointRequestMatcher
|
||||||
extends ApplicationContextRequestMatcher<PathMappedEndpoints> {
|
extends ApplicationContextRequestMatcher<WebApplicationContext> {
|
||||||
|
|
||||||
private final List<Object> includes;
|
private final List<Object> includes;
|
||||||
|
|
||||||
|
@ -140,7 +142,7 @@ public final class EndpointRequest {
|
||||||
|
|
||||||
private EndpointRequestMatcher(List<Object> includes, List<Object> excludes,
|
private EndpointRequestMatcher(List<Object> includes, List<Object> excludes,
|
||||||
boolean includeLinks) {
|
boolean includeLinks) {
|
||||||
super(PathMappedEndpoints.class);
|
super(WebApplicationContext.class);
|
||||||
this.includes = includes;
|
this.includes = includes;
|
||||||
this.excludes = excludes;
|
this.excludes = excludes;
|
||||||
this.includeLinks = includeLinks;
|
this.includeLinks = includeLinks;
|
||||||
|
@ -163,32 +165,40 @@ public final class EndpointRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialized(Supplier<PathMappedEndpoints> pathMappedEndpoints) {
|
protected void initialized(
|
||||||
this.delegate = createDelegate(pathMappedEndpoints);
|
Supplier<WebApplicationContext> webApplicationContext) {
|
||||||
|
this.delegate = createDelegate(webApplicationContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RequestMatcher createDelegate(
|
private RequestMatcher createDelegate(
|
||||||
Supplier<PathMappedEndpoints> pathMappedEndpoints) {
|
Supplier<WebApplicationContext> webApplicationContext) {
|
||||||
try {
|
try {
|
||||||
return createDelegate(pathMappedEndpoints.get());
|
WebApplicationContext context = webApplicationContext.get();
|
||||||
|
PathMappedEndpoints pathMappedEndpoints = context
|
||||||
|
.getBean(PathMappedEndpoints.class);
|
||||||
|
DispatcherServletPathProvider pathProvider = context
|
||||||
|
.getBean(DispatcherServletPathProvider.class);
|
||||||
|
return createDelegate(pathMappedEndpoints, pathProvider.getServletPath());
|
||||||
}
|
}
|
||||||
catch (NoSuchBeanDefinitionException ex) {
|
catch (NoSuchBeanDefinitionException ex) {
|
||||||
return EMPTY_MATCHER;
|
return EMPTY_MATCHER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RequestMatcher createDelegate(PathMappedEndpoints pathMappedEndpoints) {
|
private RequestMatcher createDelegate(PathMappedEndpoints pathMappedEndpoints,
|
||||||
|
String servletPath) {
|
||||||
Set<String> paths = new LinkedHashSet<>();
|
Set<String> paths = new LinkedHashSet<>();
|
||||||
if (this.includes.isEmpty()) {
|
if (this.includes.isEmpty()) {
|
||||||
paths.addAll(pathMappedEndpoints.getAllPaths());
|
paths.addAll(pathMappedEndpoints.getAllPaths());
|
||||||
}
|
}
|
||||||
streamPaths(this.includes, pathMappedEndpoints).forEach(paths::add);
|
streamPaths(this.includes, pathMappedEndpoints).forEach(paths::add);
|
||||||
streamPaths(this.excludes, pathMappedEndpoints).forEach(paths::remove);
|
streamPaths(this.excludes, pathMappedEndpoints).forEach(paths::remove);
|
||||||
List<RequestMatcher> delegateMatchers = getDelegateMatchers(paths);
|
List<RequestMatcher> delegateMatchers = getDelegateMatchers(servletPath,
|
||||||
|
paths);
|
||||||
if (this.includeLinks
|
if (this.includeLinks
|
||||||
&& StringUtils.hasText(pathMappedEndpoints.getBasePath())) {
|
&& StringUtils.hasText(pathMappedEndpoints.getBasePath())) {
|
||||||
delegateMatchers.add(
|
delegateMatchers.add(new AntPathRequestMatcher(
|
||||||
new AntPathRequestMatcher(pathMappedEndpoints.getBasePath()));
|
servletPath + pathMappedEndpoints.getBasePath()));
|
||||||
}
|
}
|
||||||
return new OrRequestMatcher(delegateMatchers);
|
return new OrRequestMatcher(delegateMatchers);
|
||||||
}
|
}
|
||||||
|
@ -216,14 +226,16 @@ public final class EndpointRequest {
|
||||||
return annotation.id();
|
return annotation.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RequestMatcher> getDelegateMatchers(Set<String> paths) {
|
private List<RequestMatcher> getDelegateMatchers(String servletPath,
|
||||||
return paths.stream().map((path) -> new AntPathRequestMatcher(path + "/**"))
|
Set<String> paths) {
|
||||||
|
return paths.stream()
|
||||||
|
.map((path) -> new AntPathRequestMatcher(servletPath + path + "/**"))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean matches(HttpServletRequest request,
|
protected boolean matches(HttpServletRequest request,
|
||||||
Supplier<PathMappedEndpoints> context) {
|
Supplier<WebApplicationContext> context) {
|
||||||
return this.delegate.matches(request);
|
return this.delegate.matches(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,29 +245,41 @@ public final class EndpointRequest {
|
||||||
* The request matcher used to match against the links endpoint.
|
* The request matcher used to match against the links endpoint.
|
||||||
*/
|
*/
|
||||||
public static final class LinksRequestMatcher
|
public static final class LinksRequestMatcher
|
||||||
extends ApplicationContextRequestMatcher<WebEndpointProperties> {
|
extends ApplicationContextRequestMatcher<WebApplicationContext> {
|
||||||
|
|
||||||
private RequestMatcher delegate;
|
private RequestMatcher delegate;
|
||||||
|
|
||||||
private LinksRequestMatcher() {
|
private LinksRequestMatcher() {
|
||||||
super(WebEndpointProperties.class);
|
super(WebApplicationContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialized(Supplier<WebEndpointProperties> properties) {
|
protected void initialized(
|
||||||
this.delegate = createDelegate(properties.get());
|
Supplier<WebApplicationContext> webApplicationContext) {
|
||||||
|
try {
|
||||||
|
WebApplicationContext context = webApplicationContext.get();
|
||||||
|
WebEndpointProperties properties = context
|
||||||
|
.getBean(WebEndpointProperties.class);
|
||||||
|
DispatcherServletPathProvider pathProvider = context
|
||||||
|
.getBean(DispatcherServletPathProvider.class);
|
||||||
|
this.delegate = createDelegate(pathProvider.getServletPath(), properties);
|
||||||
|
}
|
||||||
|
catch (NoSuchBeanDefinitionException ex) {
|
||||||
|
this.delegate = EMPTY_MATCHER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RequestMatcher createDelegate(WebEndpointProperties properties) {
|
private RequestMatcher createDelegate(String path,
|
||||||
|
WebEndpointProperties properties) {
|
||||||
if (StringUtils.hasText(properties.getBasePath())) {
|
if (StringUtils.hasText(properties.getBasePath())) {
|
||||||
return new AntPathRequestMatcher(properties.getBasePath());
|
return new AntPathRequestMatcher(path + properties.getBasePath());
|
||||||
}
|
}
|
||||||
return EMPTY_MATCHER;
|
return EMPTY_MATCHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean matches(HttpServletRequest request,
|
protected boolean matches(HttpServletRequest request,
|
||||||
Supplier<WebEndpointProperties> context) {
|
Supplier<WebApplicationContext> context) {
|
||||||
return this.delegate.matches(request);
|
return this.delegate.matches(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||||
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider;
|
||||||
import org.springframework.boot.web.servlet.error.ErrorAttributes;
|
import org.springframework.boot.web.servlet.error.ErrorAttributes;
|
||||||
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
@ -92,4 +93,9 @@ class WebMvcEndpointChildContextConfiguration {
|
||||||
return new OrderedRequestContextFilter();
|
return new OrderedRequestContextFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DispatcherServletPathProvider childDispatcherServletPathProvider() {
|
||||||
|
return () -> "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,4 +124,5 @@ public class HealthEndpointAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,7 @@ public class SignalFxMetricsExportAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void autoConfigurationCanBeDisabled() {
|
public void autoConfigurationCanBeDisabled() {
|
||||||
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
|
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
|
||||||
.withPropertyValues(
|
.withPropertyValues("management.metrics.export.signalfx.enabled=false")
|
||||||
"management.metrics.export.signalfx.enabled=false")
|
|
||||||
.run((context) -> assertThat(context)
|
.run((context) -> assertThat(context)
|
||||||
.doesNotHaveBean(SignalFxMeterRegistry.class)
|
.doesNotHaveBean(SignalFxMeterRegistry.class)
|
||||||
.doesNotHaveBean(SignalFxConfig.class));
|
.doesNotHaveBean(SignalFxConfig.class));
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.junit.Test;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
public class SimplePropertiesTests {
|
public class SimplePropertiesTests {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.springframework.boot.actuate.endpoint.Operation;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoint;
|
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
|
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider;
|
||||||
import org.springframework.mock.web.MockHttpServletRequest;
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
import org.springframework.mock.web.MockServletContext;
|
import org.springframework.mock.web.MockServletContext;
|
||||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||||
|
@ -71,6 +72,19 @@ public class EndpointRequestTests {
|
||||||
assertMatcher(matcher).doesNotMatch("/actuator/baz");
|
assertMatcher(matcher).doesNotMatch("/actuator/baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toAnyEndpointWhenServletPathNotEmptyShouldMatch() {
|
||||||
|
RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
|
||||||
|
assertMatcher(matcher, "/actuator", "/spring").matches("/spring",
|
||||||
|
"/actuator/foo");
|
||||||
|
assertMatcher(matcher, "/actuator", "/spring").matches("/spring",
|
||||||
|
"/actuator/bar");
|
||||||
|
assertMatcher(matcher, "/actuator", "/spring").matches("/spring", "/actuator");
|
||||||
|
assertMatcher(matcher, "/actuator", "/spring").doesNotMatch("/spring",
|
||||||
|
"/actuator/baz");
|
||||||
|
assertMatcher(matcher, "/actuator", "/spring").doesNotMatch("", "/actuator/foo");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toEndpointClassShouldMatchEndpointPath() {
|
public void toEndpointClassShouldMatchEndpointPath() {
|
||||||
RequestMatcher matcher = EndpointRequest.to(FooEndpoint.class);
|
RequestMatcher matcher = EndpointRequest.to(FooEndpoint.class);
|
||||||
|
@ -114,6 +128,14 @@ public class EndpointRequestTests {
|
||||||
assertMatcher.doesNotMatch("/");
|
assertMatcher.doesNotMatch("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toLinksWhenServletPathNotEmptyShouldNotMatch() {
|
||||||
|
RequestMatcher matcher = EndpointRequest.toLinks();
|
||||||
|
RequestMatcherAssert assertMatcher = assertMatcher(matcher, "/actuator",
|
||||||
|
"/spring");
|
||||||
|
assertMatcher.matches("/spring/actuator");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void excludeByClassShouldNotMatchExcluded() {
|
public void excludeByClassShouldNotMatchExcluded() {
|
||||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint()
|
RequestMatcher matcher = EndpointRequest.toAnyEndpoint()
|
||||||
|
@ -179,6 +201,11 @@ public class EndpointRequestTests {
|
||||||
return assertMatcher(matcher, mockPathMappedEndpoints(basePath));
|
return assertMatcher(matcher, mockPathMappedEndpoints(basePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RequestMatcherAssert assertMatcher(RequestMatcher matcher, String basePath,
|
||||||
|
String servletPath) {
|
||||||
|
return assertMatcher(matcher, mockPathMappedEndpoints(basePath), servletPath);
|
||||||
|
}
|
||||||
|
|
||||||
private PathMappedEndpoints mockPathMappedEndpoints(String basePath) {
|
private PathMappedEndpoints mockPathMappedEndpoints(String basePath) {
|
||||||
List<ExposableEndpoint<?>> endpoints = new ArrayList<>();
|
List<ExposableEndpoint<?>> endpoints = new ArrayList<>();
|
||||||
endpoints.add(mockEndpoint("foo", "foo"));
|
endpoints.add(mockEndpoint("foo", "foo"));
|
||||||
|
@ -195,6 +222,11 @@ public class EndpointRequestTests {
|
||||||
|
|
||||||
private RequestMatcherAssert assertMatcher(RequestMatcher matcher,
|
private RequestMatcherAssert assertMatcher(RequestMatcher matcher,
|
||||||
PathMappedEndpoints pathMappedEndpoints) {
|
PathMappedEndpoints pathMappedEndpoints) {
|
||||||
|
return assertMatcher(matcher, pathMappedEndpoints, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private RequestMatcherAssert assertMatcher(RequestMatcher matcher,
|
||||||
|
PathMappedEndpoints pathMappedEndpoints, String servletPath) {
|
||||||
StaticWebApplicationContext context = new StaticWebApplicationContext();
|
StaticWebApplicationContext context = new StaticWebApplicationContext();
|
||||||
context.registerBean(WebEndpointProperties.class);
|
context.registerBean(WebEndpointProperties.class);
|
||||||
if (pathMappedEndpoints != null) {
|
if (pathMappedEndpoints != null) {
|
||||||
|
@ -205,6 +237,8 @@ public class EndpointRequestTests {
|
||||||
properties.setBasePath(pathMappedEndpoints.getBasePath());
|
properties.setBasePath(pathMappedEndpoints.getBasePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DispatcherServletPathProvider pathProvider = () -> servletPath;
|
||||||
|
context.registerBean(DispatcherServletPathProvider.class, () -> pathProvider);
|
||||||
return assertThat(new RequestMatcherAssert(context, matcher));
|
return assertThat(new RequestMatcherAssert(context, matcher));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,8 +253,12 @@ public class EndpointRequestTests {
|
||||||
this.matcher = matcher;
|
this.matcher = matcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void matches(String path) {
|
public void matches(String servletPath) {
|
||||||
matches(mockRequest(path));
|
matches(mockRequest(servletPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void matches(String servletPath, String pathInfo) {
|
||||||
|
matches(mockRequest(servletPath, pathInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void matches(HttpServletRequest request) {
|
private void matches(HttpServletRequest request) {
|
||||||
|
@ -228,8 +266,12 @@ public class EndpointRequestTests {
|
||||||
.as("Matches " + getRequestPath(request)).isTrue();
|
.as("Matches " + getRequestPath(request)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doesNotMatch(String path) {
|
public void doesNotMatch(String servletPath) {
|
||||||
doesNotMatch(mockRequest(path));
|
doesNotMatch(mockRequest(servletPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doesNotMatch(String servletPath, String pathInfo) {
|
||||||
|
doesNotMatch(mockRequest(servletPath, pathInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doesNotMatch(HttpServletRequest request) {
|
private void doesNotMatch(HttpServletRequest request) {
|
||||||
|
@ -237,8 +279,8 @@ public class EndpointRequestTests {
|
||||||
.as("Does not match " + getRequestPath(request)).isFalse();
|
.as("Does not match " + getRequestPath(request)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MockHttpServletRequest mockRequest(String path) {
|
private MockHttpServletRequest mockRequest(String servletPath) {
|
||||||
return mockRequest(null, path);
|
return mockRequest(servletPath, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MockHttpServletRequest mockRequest(String servletPath, String path) {
|
private MockHttpServletRequest mockRequest(String servletPath, String path) {
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider;
|
||||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||||
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
@ -62,6 +63,15 @@ public class WebMvcEndpointChildContextConfigurationTests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void contextShouldConfigureDispatcherServletPathProviderWithEmptyPath() {
|
||||||
|
this.contextRunner
|
||||||
|
.withUserConfiguration(WebMvcEndpointChildContextConfiguration.class)
|
||||||
|
.run((context) -> assertThat(context
|
||||||
|
.getBean(DispatcherServletPathProvider.class).getServletPath())
|
||||||
|
.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
static class ExistingConfig {
|
static class ExistingConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -44,7 +44,6 @@ public class BeansEndpoint {
|
||||||
/**
|
/**
|
||||||
* Creates a new {@code BeansEndpoint} that will describe the beans in the given
|
* Creates a new {@code BeansEndpoint} that will describe the beans in the given
|
||||||
* {@code context} and all of its ancestors.
|
* {@code context} and all of its ancestors.
|
||||||
*
|
|
||||||
* @param context the application context
|
* @param context the application context
|
||||||
* @see ConfigurableApplicationContext#getParent()
|
* @see ConfigurableApplicationContext#getParent()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -335,6 +335,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
||||||
}
|
}
|
||||||
super.serializeAsField(pojo, jgen, provider, writer);
|
super.serializeAsField(pojo, jgen, provider, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,4 +51,5 @@ public final class MissingParametersException extends InvalidEndpointRequestExce
|
||||||
public Set<OperationParameter> getMissingParameters() {
|
public Set<OperationParameter> getMissingParameters() {
|
||||||
return this.missingParameters;
|
return this.missingParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,8 +107,8 @@ public class EndpointMBean implements DynamicMBean {
|
||||||
return this.responseMapper.mapResponse(result);
|
return this.responseMapper.mapResponse(result);
|
||||||
}
|
}
|
||||||
catch (InvalidEndpointRequestException ex) {
|
catch (InvalidEndpointRequestException ex) {
|
||||||
throw new ReflectionException(new IllegalArgumentException(
|
throw new ReflectionException(new IllegalArgumentException(ex.getMessage()),
|
||||||
ex.getMessage()), ex.getMessage());
|
ex.getMessage());
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw new MBeanException(translateIfNecessary(ex), ex.getMessage());
|
throw new MBeanException(translateIfNecessary(ex), ex.getMessage());
|
||||||
|
|
|
@ -210,4 +210,5 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ public class EndpointMapping {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@code EndpointMapping} using the given {@code path}.
|
* Creates a new {@code EndpointMapping} using the given {@code path}.
|
||||||
*
|
|
||||||
* @param path the path
|
* @param path the path
|
||||||
*/
|
*/
|
||||||
public EndpointMapping(String path) {
|
public EndpointMapping(String path) {
|
||||||
|
|
|
@ -44,4 +44,5 @@ class DiscoveredWebEndpoint extends AbstractDiscoveredEndpoint<WebOperation>
|
||||||
public String getRootPath() {
|
public String getRootPath() {
|
||||||
return this.rootPath;
|
return this.rootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,6 +251,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping
|
||||||
|
|
||||||
Mono<ResponseEntity<Object>> handle(ServerWebExchange exchange,
|
Mono<ResponseEntity<Object>> handle(ServerWebExchange exchange,
|
||||||
Map<String, String> body);
|
Map<String, String> body);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -173,6 +173,7 @@ public class MetricsEndpoint {
|
||||||
public Set<String> getNames() {
|
public Set<String> getNames() {
|
||||||
return this.names;
|
return this.names;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,6 +229,7 @@ public class MetricsEndpoint {
|
||||||
public Set<String> getValues() {
|
public Set<String> getValues() {
|
||||||
return this.values;
|
return this.values;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -61,18 +61,17 @@ public class MetricsWebFilter implements WebFilter {
|
||||||
private Publisher<Void> filter(ServerWebExchange exchange, Mono<Void> call) {
|
private Publisher<Void> filter(ServerWebExchange exchange, Mono<Void> call) {
|
||||||
long start = System.nanoTime();
|
long start = System.nanoTime();
|
||||||
ServerHttpResponse response = exchange.getResponse();
|
ServerHttpResponse response = exchange.getResponse();
|
||||||
return call.doOnSuccess((done) -> success(exchange, start))
|
return call.doOnSuccess((done) -> success(exchange, start)).doOnError((cause) -> {
|
||||||
.doOnError((cause) -> {
|
if (response.isCommitted()) {
|
||||||
if (response.isCommitted()) {
|
error(exchange, start, cause);
|
||||||
error(exchange, start, cause);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
response.beforeCommit(() -> {
|
||||||
response.beforeCommit(() -> {
|
error(exchange, start, cause);
|
||||||
error(exchange, start, cause);
|
return Mono.empty();
|
||||||
return Mono.empty();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void success(ServerWebExchange exchange, long start) {
|
private void success(ServerWebExchange exchange, long start) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ public interface MappingDescriptionProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the mappings described by this provider.
|
* Returns the name of the mappings described by this provider.
|
||||||
*
|
|
||||||
* @return the name of the mappings
|
* @return the name of the mappings
|
||||||
*/
|
*/
|
||||||
String getMappingName();
|
String getMappingName();
|
||||||
|
|
|
@ -40,7 +40,6 @@ public class FilterRegistrationMappingDescription
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the servlet name mappings for the registered filter.
|
* Returns the servlet name mappings for the registered filter.
|
||||||
*
|
|
||||||
* @return the mappings
|
* @return the mappings
|
||||||
*/
|
*/
|
||||||
public Collection<String> getServletNameMappings() {
|
public Collection<String> getServletNameMappings() {
|
||||||
|
@ -49,7 +48,6 @@ public class FilterRegistrationMappingDescription
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the URL pattern mappings for the registered filter.
|
* Returns the URL pattern mappings for the registered filter.
|
||||||
*
|
|
||||||
* @return the mappings
|
* @return the mappings
|
||||||
*/
|
*/
|
||||||
public Collection<String> getUrlPatternMappings() {
|
public Collection<String> getUrlPatternMappings() {
|
||||||
|
|
|
@ -40,7 +40,6 @@ public class RegistrationMappingDescription<T extends Registration> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the registered Filter or Servlet.
|
* Returns the name of the registered Filter or Servlet.
|
||||||
*
|
|
||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -49,7 +48,6 @@ public class RegistrationMappingDescription<T extends Registration> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the class name of the registered Filter or Servlet.
|
* Returns the class name of the registered Filter or Servlet.
|
||||||
*
|
|
||||||
* @return the class name
|
* @return the class name
|
||||||
*/
|
*/
|
||||||
public String getClassName() {
|
public String getClassName() {
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class ServletRegistrationMappingDescription
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the mappings for the registered servlet.
|
* Returns the mappings for the registered servlet.
|
||||||
*
|
|
||||||
* @return the mappings
|
* @return the mappings
|
||||||
*/
|
*/
|
||||||
public Collection<String> getMappings() {
|
public Collection<String> getMappings() {
|
||||||
|
|
|
@ -81,4 +81,5 @@ public class OperationMethodTests {
|
||||||
String example(String name) {
|
String example(String name) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,4 +32,5 @@ class TestJmxOperationResponseMapper implements JmxOperationResponseMapper {
|
||||||
public Class<?> mapResponseType(Class<?> responseType) {
|
public Class<?> mapResponseType(Class<?> responseType) {
|
||||||
return responseType;
|
return responseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,16 +57,17 @@ public class ControllerEndpointDiscovererTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEndpointsWhenNoEndpointBeansShouldReturnEmptyCollection() {
|
public void getEndpointsWhenNoEndpointBeansShouldReturnEmptyCollection() {
|
||||||
this.contextRunner.withUserConfiguration(EmptyConfiguration.class).run(
|
this.contextRunner.withUserConfiguration(EmptyConfiguration.class)
|
||||||
assertDiscoverer((discoverer) ->
|
.run(assertDiscoverer(
|
||||||
assertThat(discoverer.getEndpoints()).isEmpty()));
|
(discoverer) -> assertThat(discoverer.getEndpoints()).isEmpty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEndpointsShouldIncludeControllerEndpoints() {
|
public void getEndpointsShouldIncludeControllerEndpoints() {
|
||||||
this.contextRunner.withUserConfiguration(TestControllerEndpoint.class)
|
this.contextRunner.withUserConfiguration(TestControllerEndpoint.class)
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||||
|
.getEndpoints();
|
||||||
assertThat(endpoints).hasSize(1);
|
assertThat(endpoints).hasSize(1);
|
||||||
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
||||||
assertThat(endpoint.getId()).isEqualTo("testcontroller");
|
assertThat(endpoint.getId()).isEqualTo("testcontroller");
|
||||||
|
@ -79,10 +80,11 @@ public class ControllerEndpointDiscovererTests {
|
||||||
@Test
|
@Test
|
||||||
public void getEndpointsShouldDiscoverProxyControllerEndpoints() {
|
public void getEndpointsShouldDiscoverProxyControllerEndpoints() {
|
||||||
this.contextRunner.withUserConfiguration(TestProxyControllerEndpoint.class)
|
this.contextRunner.withUserConfiguration(TestProxyControllerEndpoint.class)
|
||||||
.withConfiguration(AutoConfigurations.of(
|
.withConfiguration(
|
||||||
ValidationAutoConfiguration.class))
|
AutoConfigurations.of(ValidationAutoConfiguration.class))
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||||
|
.getEndpoints();
|
||||||
assertThat(endpoints).hasSize(1);
|
assertThat(endpoints).hasSize(1);
|
||||||
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
||||||
assertThat(endpoint.getId()).isEqualTo("testcontroller");
|
assertThat(endpoint.getId()).isEqualTo("testcontroller");
|
||||||
|
@ -96,7 +98,8 @@ public class ControllerEndpointDiscovererTests {
|
||||||
public void getEndpointsShouldIncludeRestControllerEndpoints() {
|
public void getEndpointsShouldIncludeRestControllerEndpoints() {
|
||||||
this.contextRunner.withUserConfiguration(TestRestControllerEndpoint.class)
|
this.contextRunner.withUserConfiguration(TestRestControllerEndpoint.class)
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||||
|
.getEndpoints();
|
||||||
assertThat(endpoints).hasSize(1);
|
assertThat(endpoints).hasSize(1);
|
||||||
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
||||||
assertThat(endpoint.getId()).isEqualTo("testrestcontroller");
|
assertThat(endpoint.getId()).isEqualTo("testrestcontroller");
|
||||||
|
@ -108,10 +111,11 @@ public class ControllerEndpointDiscovererTests {
|
||||||
@Test
|
@Test
|
||||||
public void getEndpointsShouldDiscoverProxyRestControllerEndpoints() {
|
public void getEndpointsShouldDiscoverProxyRestControllerEndpoints() {
|
||||||
this.contextRunner.withUserConfiguration(TestProxyRestControllerEndpoint.class)
|
this.contextRunner.withUserConfiguration(TestProxyRestControllerEndpoint.class)
|
||||||
.withConfiguration(AutoConfigurations.of(
|
.withConfiguration(
|
||||||
ValidationAutoConfiguration.class))
|
AutoConfigurations.of(ValidationAutoConfiguration.class))
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||||
|
.getEndpoints();
|
||||||
assertThat(endpoints).hasSize(1);
|
assertThat(endpoints).hasSize(1);
|
||||||
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
||||||
assertThat(endpoint.getId()).isEqualTo("testrestcontroller");
|
assertThat(endpoint.getId()).isEqualTo("testrestcontroller");
|
||||||
|
@ -125,7 +129,8 @@ public class ControllerEndpointDiscovererTests {
|
||||||
public void getEndpointsShouldNotDiscoverRegularEndpoints() {
|
public void getEndpointsShouldNotDiscoverRegularEndpoints() {
|
||||||
this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class)
|
this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class)
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||||
|
.getEndpoints();
|
||||||
List<String> ids = endpoints.stream().map(ExposableEndpoint::getId)
|
List<String> ids = endpoints.stream().map(ExposableEndpoint::getId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
assertThat(ids).containsOnly("testcontroller", "testrestcontroller");
|
assertThat(ids).containsOnly("testcontroller", "testrestcontroller");
|
||||||
|
@ -137,7 +142,8 @@ public class ControllerEndpointDiscovererTests {
|
||||||
this.contextRunner.withUserConfiguration(TestControllerWithOperation.class)
|
this.contextRunner.withUserConfiguration(TestControllerWithOperation.class)
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
this.thrown.expect(IllegalStateException.class);
|
this.thrown.expect(IllegalStateException.class);
|
||||||
this.thrown.expectMessage("ControllerEndpoints must not declare operations");
|
this.thrown.expectMessage(
|
||||||
|
"ControllerEndpoints must not declare operations");
|
||||||
discoverer.getEndpoints();
|
discoverer.getEndpoints();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,15 +67,16 @@ public class ServletEndpointDiscovererTests {
|
||||||
@Test
|
@Test
|
||||||
public void getEndpointsWhenNoEndpointBeansShouldReturnEmptyCollection() {
|
public void getEndpointsWhenNoEndpointBeansShouldReturnEmptyCollection() {
|
||||||
this.contextRunner.withUserConfiguration(EmptyConfiguration.class)
|
this.contextRunner.withUserConfiguration(EmptyConfiguration.class)
|
||||||
.run(assertDiscoverer((discoverer)
|
.run(assertDiscoverer(
|
||||||
-> assertThat(discoverer.getEndpoints()).isEmpty()));
|
(discoverer) -> assertThat(discoverer.getEndpoints()).isEmpty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEndpointsShouldIncludeServletEndpoints() {
|
public void getEndpointsShouldIncludeServletEndpoints() {
|
||||||
this.contextRunner.withUserConfiguration(TestServletEndpoint.class)
|
this.contextRunner.withUserConfiguration(TestServletEndpoint.class)
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
Collection<ExposableServletEndpoint> endpoints = discoverer.getEndpoints();
|
Collection<ExposableServletEndpoint> endpoints = discoverer
|
||||||
|
.getEndpoints();
|
||||||
assertThat(endpoints).hasSize(1);
|
assertThat(endpoints).hasSize(1);
|
||||||
ExposableServletEndpoint endpoint = endpoints.iterator().next();
|
ExposableServletEndpoint endpoint = endpoints.iterator().next();
|
||||||
assertThat(endpoint.getId()).isEqualTo("testservlet");
|
assertThat(endpoint.getId()).isEqualTo("testservlet");
|
||||||
|
@ -87,9 +88,11 @@ public class ServletEndpointDiscovererTests {
|
||||||
@Test
|
@Test
|
||||||
public void getEndpointsShouldDiscoverProxyServletEndpoints() {
|
public void getEndpointsShouldDiscoverProxyServletEndpoints() {
|
||||||
this.contextRunner.withUserConfiguration(TestProxyServletEndpoint.class)
|
this.contextRunner.withUserConfiguration(TestProxyServletEndpoint.class)
|
||||||
.withConfiguration(AutoConfigurations.of(ValidationAutoConfiguration.class))
|
.withConfiguration(
|
||||||
|
AutoConfigurations.of(ValidationAutoConfiguration.class))
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
Collection<ExposableServletEndpoint> endpoints = discoverer.getEndpoints();
|
Collection<ExposableServletEndpoint> endpoints = discoverer
|
||||||
|
.getEndpoints();
|
||||||
assertThat(endpoints).hasSize(1);
|
assertThat(endpoints).hasSize(1);
|
||||||
ExposableServletEndpoint endpoint = endpoints.iterator().next();
|
ExposableServletEndpoint endpoint = endpoints.iterator().next();
|
||||||
assertThat(endpoint.getId()).isEqualTo("testservlet");
|
assertThat(endpoint.getId()).isEqualTo("testservlet");
|
||||||
|
@ -102,7 +105,8 @@ public class ServletEndpointDiscovererTests {
|
||||||
public void getEndpointsShouldNotDiscoverRegularEndpoints() {
|
public void getEndpointsShouldNotDiscoverRegularEndpoints() {
|
||||||
this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class)
|
this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class)
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
Collection<ExposableServletEndpoint> endpoints = discoverer.getEndpoints();
|
Collection<ExposableServletEndpoint> endpoints = discoverer
|
||||||
|
.getEndpoints();
|
||||||
List<String> ids = endpoints.stream().map(ExposableEndpoint::getId)
|
List<String> ids = endpoints.stream().map(ExposableEndpoint::getId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
assertThat(ids).containsOnly("testservlet");
|
assertThat(ids).containsOnly("testservlet");
|
||||||
|
@ -114,7 +118,8 @@ public class ServletEndpointDiscovererTests {
|
||||||
this.contextRunner.withUserConfiguration(TestServletEndpointWithOperation.class)
|
this.contextRunner.withUserConfiguration(TestServletEndpointWithOperation.class)
|
||||||
.run(assertDiscoverer((discoverer) -> {
|
.run(assertDiscoverer((discoverer) -> {
|
||||||
this.thrown.expect(IllegalStateException.class);
|
this.thrown.expect(IllegalStateException.class);
|
||||||
this.thrown.expectMessage("ServletEndpoints must not declare operations");
|
this.thrown.expectMessage(
|
||||||
|
"ServletEndpoints must not declare operations");
|
||||||
discoverer.getEndpoints();
|
discoverer.getEndpoints();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -27,4 +27,5 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||||
interface ContextFactory {
|
interface ContextFactory {
|
||||||
|
|
||||||
ConfigurableApplicationContext createContext(List<Class<?>> configurationClasses);
|
ConfigurableApplicationContext createContext(List<Class<?>> configurationClasses);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link MetricsWebFilter}
|
* Tests for {@link MetricsWebFilter}
|
||||||
|
*
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
*/
|
*/
|
||||||
public class MetricsWebFilterTests {
|
public class MetricsWebFilterTests {
|
||||||
|
|
|
@ -331,4 +331,5 @@ public class HttpExchangeTracerTests {
|
||||||
}
|
}
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,6 +458,7 @@ public class RabbitProperties {
|
||||||
public void setCheckoutTimeout(Duration checkoutTimeout) {
|
public void setCheckoutTimeout(Duration checkoutTimeout) {
|
||||||
this.checkoutTimeout = checkoutTimeout;
|
this.checkoutTimeout = checkoutTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Connection {
|
public static class Connection {
|
||||||
|
|
|
@ -75,8 +75,7 @@ public class CacheAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CacheManagerValidator cacheAutoConfigurationValidator(
|
public CacheManagerValidator cacheAutoConfigurationValidator(
|
||||||
CacheProperties cacheProperties,
|
CacheProperties cacheProperties, ObjectProvider<CacheManager> cacheManager) {
|
||||||
ObjectProvider<CacheManager> cacheManager) {
|
|
||||||
return new CacheManagerValidator(cacheProperties, cacheManager);
|
return new CacheManagerValidator(cacheProperties, cacheManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -77,4 +77,5 @@ class FreeMarkerServletWebConfiguration extends AbstractFreeMarkerConfiguration
|
||||||
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
|
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
|
||||||
return new ResourceUrlEncodingFilter();
|
return new ResourceUrlEncodingFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,4 +34,5 @@ public interface GsonBuilderCustomizer {
|
||||||
* @param gsonBuilder the GsonBuilder to customize
|
* @param gsonBuilder the GsonBuilder to customize
|
||||||
*/
|
*/
|
||||||
void customize(GsonBuilder gsonBuilder);
|
void customize(GsonBuilder gsonBuilder);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -62,8 +62,8 @@ class DataSourceBeanCreationFailureAnalyzer
|
||||||
if (!StringUtils.hasText(cause.getProperties().getUrl())) {
|
if (!StringUtils.hasText(cause.getProperties().getUrl())) {
|
||||||
description.append("'url' attribute is not specified and ");
|
description.append("'url' attribute is not specified and ");
|
||||||
}
|
}
|
||||||
description.append(
|
description
|
||||||
String.format("no embedded datasource could be configured.%n"));
|
.append(String.format("no embedded datasource could be configured.%n"));
|
||||||
description.append(String.format("%nReason: %s%n", cause.getMessage()));
|
description.append(String.format("%nReason: %s%n", cause.getMessage()));
|
||||||
return description.toString();
|
return description.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@ public final class StaticResourceRequest {
|
||||||
getDelegateMatchers());
|
getDelegateMatchers());
|
||||||
return matcher.matches(exchange);
|
return matcher.matches(exchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,6 +191,7 @@ public class SessionAutoConfiguration {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -75,6 +75,7 @@ public class TransactionAutoConfiguration {
|
||||||
public TransactionTemplate transactionTemplate() {
|
public TransactionTemplate transactionTemplate() {
|
||||||
return new TransactionTemplate(this.transactionManager);
|
return new TransactionTemplate(this.transactionManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -957,6 +957,7 @@ public class ServerProperties {
|
||||||
public void setLogLatency(boolean logLatency) {
|
public void setLogLatency(boolean logLatency) {
|
||||||
this.logLatency = logLatency;
|
this.logLatency = logLatency;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,6 +205,7 @@ public class WebFluxAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -88,8 +88,12 @@ public class DispatcherServletAutoConfiguration {
|
||||||
|
|
||||||
private final WebMvcProperties webMvcProperties;
|
private final WebMvcProperties webMvcProperties;
|
||||||
|
|
||||||
public DispatcherServletConfiguration(WebMvcProperties webMvcProperties) {
|
private final ServerProperties serverProperties;
|
||||||
|
|
||||||
|
public DispatcherServletConfiguration(WebMvcProperties webMvcProperties,
|
||||||
|
ServerProperties serverProperties) {
|
||||||
this.webMvcProperties = webMvcProperties;
|
this.webMvcProperties = webMvcProperties;
|
||||||
|
this.serverProperties = serverProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
|
@Bean(name = DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
|
||||||
|
@ -112,6 +116,12 @@ public class DispatcherServletAutoConfiguration {
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DispatcherServletPathProvider mainDispatcherServletPathProvider() {
|
||||||
|
return () -> DispatcherServletConfiguration.this.serverProperties.getServlet()
|
||||||
|
.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.autoconfigure.web.servlet;
|
||||||
|
|
||||||
|
import org.springframework.web.servlet.DispatcherServlet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface that provides the path of the {@link DispatcherServlet} in an application
|
||||||
|
* context.
|
||||||
|
*
|
||||||
|
* @author Madhura Bhave
|
||||||
|
* @since 2.0.2
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface DispatcherServletPathProvider {
|
||||||
|
|
||||||
|
String getServletPath();
|
||||||
|
|
||||||
|
}
|
|
@ -752,11 +752,10 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
|
||||||
public void autoConfiguredCacheManagerCanBeSwapped() {
|
public void autoConfiguredCacheManagerCanBeSwapped() {
|
||||||
this.contextRunner
|
this.contextRunner
|
||||||
.withUserConfiguration(CacheManagerPostProcessorConfiguration.class)
|
.withUserConfiguration(CacheManagerPostProcessorConfiguration.class)
|
||||||
.withPropertyValues("spring.cache.type=caffeine")
|
.withPropertyValues("spring.cache.type=caffeine").run((context) -> {
|
||||||
.run((context) -> {
|
|
||||||
getCacheManager(context, SimpleCacheManager.class);
|
getCacheManager(context, SimpleCacheManager.class);
|
||||||
CacheManagerPostProcessor postProcessor = context.getBean(
|
CacheManagerPostProcessor postProcessor = context
|
||||||
CacheManagerPostProcessor.class);
|
.getBean(CacheManagerPostProcessor.class);
|
||||||
assertThat(postProcessor.cacheManagers).hasSize(1);
|
assertThat(postProcessor.cacheManagers).hasSize(1);
|
||||||
assertThat(postProcessor.cacheManagers.get(0))
|
assertThat(postProcessor.cacheManagers.get(0))
|
||||||
.isInstanceOf(CaffeineCacheManager.class);
|
.isInstanceOf(CaffeineCacheManager.class);
|
||||||
|
@ -1043,14 +1042,12 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
|
||||||
private final List<CacheManager> cacheManagers = new ArrayList<>();
|
private final List<CacheManager> cacheManagers = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object postProcessBeforeInitialization(Object bean,
|
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||||
String beanName) {
|
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object postProcessAfterInitialization(Object bean,
|
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||||
String beanName) {
|
|
||||||
if (bean instanceof CacheManager) {
|
if (bean instanceof CacheManager) {
|
||||||
this.cacheManagers.add((CacheManager) bean);
|
this.cacheManagers.add((CacheManager) bean);
|
||||||
return new SimpleCacheManager();
|
return new SimpleCacheManager();
|
||||||
|
|
|
@ -36,4 +36,3 @@ public class SampleAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -158,6 +158,7 @@ public class CassandraDataAutoConfigurationTests {
|
||||||
public String convert(Person o) {
|
public String convert(Person o) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Person {
|
private static class Person {
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -186,6 +186,7 @@ public class CouchbaseDataAutoConfigurationTests {
|
||||||
public Boolean convert(CouchbaseProperties value) {
|
public Boolean convert(CouchbaseProperties value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -76,6 +76,7 @@ public class ElasticsearchNodeTemplate {
|
||||||
Arrays.asList(Netty4Plugin.class));
|
Arrays.asList(Netty4Plugin.class));
|
||||||
new File("target/es/node/logs").mkdirs();
|
new File("target/es/node/logs").mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class ElasticsearchNode {
|
public final class ElasticsearchNode {
|
||||||
|
|
|
@ -291,6 +291,7 @@ public class GsonAutoConfigurationTests {
|
||||||
private String data = "nested";
|
private String data = "nested";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -80,16 +80,16 @@ public class IntegrationAutoConfigurationTests {
|
||||||
.withUserConfiguration(CustomIntegrationComponentScanConfiguration.class)
|
.withUserConfiguration(CustomIntegrationComponentScanConfiguration.class)
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(TestGateway.class);
|
assertThat(context).hasSingleBean(TestGateway.class);
|
||||||
assertThat(context).doesNotHaveBean(
|
assertThat(context)
|
||||||
IntegrationComponentScanConfiguration.class);
|
.doesNotHaveBean(IntegrationComponentScanConfiguration.class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noMBeanServerAvailable() {
|
public void noMBeanServerAvailable() {
|
||||||
ApplicationContextRunner contextRunnerWithoutJmx = new ApplicationContextRunner()
|
ApplicationContextRunner contextRunnerWithoutJmx = new ApplicationContextRunner()
|
||||||
.withConfiguration(AutoConfigurations.of(
|
.withConfiguration(
|
||||||
IntegrationAutoConfiguration.class));
|
AutoConfigurations.of(IntegrationAutoConfiguration.class));
|
||||||
contextRunnerWithoutJmx.run((context) -> {
|
contextRunnerWithoutJmx.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(TestGateway.class);
|
assertThat(context).hasSingleBean(TestGateway.class);
|
||||||
assertThat(context)
|
assertThat(context)
|
||||||
|
|
|
@ -232,6 +232,7 @@ public class ActiveMQAutoConfigurationTests {
|
||||||
factory.setUserName("foobar");
|
factory.setUserName("foobar");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,4 +96,5 @@ public class ArtemisEmbeddedConfigurationFactoryTests {
|
||||||
.getAddressConfigurations();
|
.getAddressConfigurations();
|
||||||
assertThat(addressConfigurations).hasSize(2);
|
assertThat(addressConfigurations).hasSize(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -55,6 +55,7 @@ public class JsonbAutoConfigurationTests {
|
||||||
public void setData(String data) {
|
public void setData(String data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -127,6 +127,7 @@ public class MustacheAutoConfigurationTests {
|
||||||
return Mustache.compiler().standardsMode(true)
|
return Mustache.compiler().standardsMode(true)
|
||||||
.withLoader(mustacheTemplateLoader);
|
.withLoader(mustacheTemplateLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,21 +87,24 @@ public class QuartzAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withDataSourceUseMemoryByDefault() {
|
public void withDataSourceUseMemoryByDefault() {
|
||||||
this.contextRunner.withConfiguration(AutoConfigurations.of(
|
this.contextRunner
|
||||||
DataSourceAutoConfiguration.class,
|
.withConfiguration(
|
||||||
DataSourceTransactionManagerAutoConfiguration.class)).run((context) -> {
|
AutoConfigurations.of(DataSourceAutoConfiguration.class,
|
||||||
assertThat(context).hasSingleBean(Scheduler.class);
|
DataSourceTransactionManagerAutoConfiguration.class))
|
||||||
Scheduler scheduler = context.getBean(Scheduler.class);
|
.run((context) -> {
|
||||||
assertThat(scheduler.getMetaData().getJobStoreClass())
|
assertThat(context).hasSingleBean(Scheduler.class);
|
||||||
.isAssignableFrom(RAMJobStore.class);
|
Scheduler scheduler = context.getBean(Scheduler.class);
|
||||||
});
|
assertThat(scheduler.getMetaData().getJobStoreClass())
|
||||||
|
.isAssignableFrom(RAMJobStore.class);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withDataSource() {
|
public void withDataSource() {
|
||||||
this.contextRunner.withUserConfiguration(QuartzJobsConfiguration.class)
|
this.contextRunner.withUserConfiguration(QuartzJobsConfiguration.class)
|
||||||
.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class,
|
.withConfiguration(
|
||||||
DataSourceTransactionManagerAutoConfiguration.class))
|
AutoConfigurations.of(DataSourceAutoConfiguration.class,
|
||||||
|
DataSourceTransactionManagerAutoConfiguration.class))
|
||||||
.withPropertyValues("spring.quartz.job-store-type=jdbc")
|
.withPropertyValues("spring.quartz.job-store-type=jdbc")
|
||||||
.run(assertDataSourceJobStore("dataSource"));
|
.run(assertDataSourceJobStore("dataSource"));
|
||||||
}
|
}
|
||||||
|
@ -109,8 +112,8 @@ public class QuartzAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void withDataSourceNoTransactionManager() {
|
public void withDataSourceNoTransactionManager() {
|
||||||
this.contextRunner.withUserConfiguration(QuartzJobsConfiguration.class)
|
this.contextRunner.withUserConfiguration(QuartzJobsConfiguration.class)
|
||||||
.withConfiguration(AutoConfigurations.of(
|
.withConfiguration(
|
||||||
DataSourceAutoConfiguration.class))
|
AutoConfigurations.of(DataSourceAutoConfiguration.class))
|
||||||
.withPropertyValues("spring.quartz.job-store-type=jdbc")
|
.withPropertyValues("spring.quartz.job-store-type=jdbc")
|
||||||
.run(assertDataSourceJobStore("dataSource"));
|
.run(assertDataSourceJobStore("dataSource"));
|
||||||
}
|
}
|
||||||
|
@ -131,13 +134,13 @@ public class QuartzAutoConfigurationTests {
|
||||||
Scheduler scheduler = context.getBean(Scheduler.class);
|
Scheduler scheduler = context.getBean(Scheduler.class);
|
||||||
assertThat(scheduler.getMetaData().getJobStoreClass())
|
assertThat(scheduler.getMetaData().getJobStoreClass())
|
||||||
.isAssignableFrom(LocalDataSourceJobStore.class);
|
.isAssignableFrom(LocalDataSourceJobStore.class);
|
||||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(context.getBean(
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(
|
||||||
datasourceName, DataSource.class));
|
context.getBean(datasourceName, DataSource.class));
|
||||||
assertThat(jdbcTemplate.queryForObject(
|
assertThat(jdbcTemplate.queryForObject(
|
||||||
"SELECT COUNT(*) FROM QRTZ_JOB_DETAILS", Integer.class)).isEqualTo(2);
|
"SELECT COUNT(*) FROM QRTZ_JOB_DETAILS", Integer.class)).isEqualTo(2);
|
||||||
assertThat(jdbcTemplate.queryForObject(
|
assertThat(jdbcTemplate.queryForObject(
|
||||||
"SELECT COUNT(*) FROM QRTZ_SIMPLE_TRIGGERS", Integer.class))
|
"SELECT COUNT(*) FROM QRTZ_SIMPLE_TRIGGERS", Integer.class))
|
||||||
.isEqualTo(0);
|
.isEqualTo(0);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +188,9 @@ public class QuartzAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withQuartzProperties() {
|
public void withQuartzProperties() {
|
||||||
this.contextRunner.withPropertyValues(
|
this.contextRunner
|
||||||
"spring.quartz.properties.org.quartz.scheduler.instanceId=FOO")
|
.withPropertyValues(
|
||||||
|
"spring.quartz.properties.org.quartz.scheduler.instanceId=FOO")
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(Scheduler.class);
|
assertThat(context).hasSingleBean(Scheduler.class);
|
||||||
Scheduler scheduler = context.getBean(Scheduler.class);
|
Scheduler scheduler = context.getBean(Scheduler.class);
|
||||||
|
@ -204,8 +208,6 @@ public class QuartzAutoConfigurationTests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Import(ComponentThatUsesScheduler.class)
|
@Import(ComponentThatUsesScheduler.class)
|
||||||
@Configuration
|
@Configuration
|
||||||
protected static class BaseQuartzConfiguration {
|
protected static class BaseQuartzConfiguration {
|
||||||
|
|
|
@ -69,4 +69,5 @@ public class WebFluxSecurityConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -203,6 +203,7 @@ public class TransactionAutoConfigurationTests {
|
||||||
public AnotherServiceImpl anotherService() {
|
public AnotherServiceImpl anotherService() {
|
||||||
return new AnotherServiceImpl();
|
return new AnotherServiceImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -304,6 +304,7 @@ public class ValidationAutoConfigurationTests {
|
||||||
interface AnotherSampleService {
|
interface AnotherSampleService {
|
||||||
|
|
||||||
void doSomething(@Min(42) Integer counter);
|
void doSomething(@Min(42) Integer counter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validated
|
@Validated
|
||||||
|
@ -313,6 +314,7 @@ public class ValidationAutoConfigurationTests {
|
||||||
public void doSomething(Integer counter) {
|
public void doSomething(Integer counter) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ -382,6 +384,7 @@ public class ValidationAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,6 +373,7 @@ public class WebFluxAutoConfigurationTests {
|
||||||
public CodecCustomizer firstCodecCustomizer() {
|
public CodecCustomizer firstCodecCustomizer() {
|
||||||
return mock(CodecCustomizer.class);
|
return mock(CodecCustomizer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ -388,6 +389,7 @@ public class WebFluxAutoConfigurationTests {
|
||||||
public ViewResolver anotherViewResolver() {
|
public ViewResolver anotherViewResolver() {
|
||||||
return mock(ViewResolver.class);
|
return mock(ViewResolver.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ -407,6 +409,7 @@ public class WebFluxAutoConfigurationTests {
|
||||||
public HttpHandler httpHandler() {
|
public HttpHandler httpHandler() {
|
||||||
return (serverHttpRequest, serverHttpResponse) -> null;
|
return (serverHttpRequest, serverHttpResponse) -> null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -311,6 +311,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
|
||||||
public String bodyValidation(@Valid @RequestBody DummyBody body) {
|
public String bodyValidation(@Valid @RequestBody DummyBody body) {
|
||||||
return body.getContent();
|
return body.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,8 @@ public class DispatcherServletAutoConfigurationTests {
|
||||||
assertThat(registration.getUrlMappings().toString())
|
assertThat(registration.getUrlMappings().toString())
|
||||||
.isEqualTo("[/spring/*]");
|
.isEqualTo("[/spring/*]");
|
||||||
assertThat(registration.getMultipartConfig()).isNull();
|
assertThat(registration.getMultipartConfig()).isNull();
|
||||||
|
assertThat(context.getBean(DispatcherServletPathProvider.class)
|
||||||
|
.getServletPath()).isEqualTo("/spring");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -109,4 +109,5 @@ public class TomcatServletWebServerFactoryCustomizerTests {
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -829,12 +829,13 @@ public class WebMvcAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void contentNegotiationStrategySkipsPathExtension() throws Exception {
|
public void contentNegotiationStrategySkipsPathExtension() throws Exception {
|
||||||
ContentNegotiationStrategy delegate = mock(ContentNegotiationStrategy.class);
|
ContentNegotiationStrategy delegate = mock(ContentNegotiationStrategy.class);
|
||||||
ContentNegotiationStrategy strategy = new WebMvcAutoConfiguration
|
ContentNegotiationStrategy strategy = new WebMvcAutoConfiguration.OptionalPathExtensionContentNegotiationStrategy(
|
||||||
.OptionalPathExtensionContentNegotiationStrategy(delegate);
|
delegate);
|
||||||
|
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
request.setAttribute(PathExtensionContentNegotiationStrategy.class
|
request.setAttribute(
|
||||||
.getName() + ".SKIP", Boolean.TRUE);
|
PathExtensionContentNegotiationStrategy.class.getName() + ".SKIP",
|
||||||
|
Boolean.TRUE);
|
||||||
ServletWebRequest webRequest = new ServletWebRequest(request);
|
ServletWebRequest webRequest = new ServletWebRequest(request);
|
||||||
List<MediaType> mediaTypes = strategy.resolveMediaTypes(webRequest);
|
List<MediaType> mediaTypes = strategy.resolveMediaTypes(webRequest);
|
||||||
assertThat(mediaTypes).containsOnly(MediaType.ALL);
|
assertThat(mediaTypes).containsOnly(MediaType.ALL);
|
||||||
|
|
|
@ -68,8 +68,7 @@ public class WelcomePageHandlerMappingTests {
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
WelcomePageHandlerMapping handler = context
|
WelcomePageHandlerMapping handler = context
|
||||||
.getBean(WelcomePageHandlerMapping.class);
|
.getBean(WelcomePageHandlerMapping.class);
|
||||||
assertThat(handler.getOrder())
|
assertThat(handler.getOrder()).isEqualTo(2);
|
||||||
.isEqualTo(2);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,8 @@ class ProjectGenerationRequest {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
catch (URISyntaxException ex) {
|
catch (URISyntaxException ex) {
|
||||||
throw new ReportableException("Invalid service URL (" + ex.getMessage() + ")");
|
throw new ReportableException(
|
||||||
|
"Invalid service URL (" + ex.getMessage() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -42,4 +42,5 @@ public class JestClientCustomizationExample {
|
||||||
|
|
||||||
}
|
}
|
||||||
// end::customizer[]
|
// end::customizer[]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class UserServiceAutoConfigurationTests {
|
||||||
// tag::runner[]
|
// tag::runner[]
|
||||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||||
.withConfiguration(AutoConfigurations.of(UserServiceAutoConfiguration.class));
|
.withConfiguration(AutoConfigurations.of(UserServiceAutoConfiguration.class));
|
||||||
|
|
||||||
// end::runner[]
|
// end::runner[]
|
||||||
|
|
||||||
// tag::test-env[]
|
// tag::test-env[]
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -69,4 +69,5 @@ class DataNeo4jTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter
|
||||||
protected Set<Class<?>> getComponentIncludes() {
|
protected Set<Class<?>> getComponentIncludes() {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,7 @@ import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link TestExecutionListener} for Spring REST Docs that removes the need for a
|
* A {@link TestExecutionListener} for Spring REST Docs that removes the need for a
|
||||||
* {@code @Rule} when using JUnit or manual before and after test calls when using
|
* {@code @Rule} when using JUnit or manual before and after test calls when using TestNG.
|
||||||
* TestNG.
|
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -39,4 +39,5 @@ public class ExampleEntry {
|
||||||
public void setDn(Name dn) {
|
public void setDn(Name dn) {
|
||||||
this.dn = dn;
|
this.dn = dn;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,4 +24,5 @@ import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||||
* @author Eddú Meléndez
|
* @author Eddú Meléndez
|
||||||
*/
|
*/
|
||||||
public interface ExampleRepository extends Neo4jRepository<ExampleGraph, Long> {
|
public interface ExampleRepository extends Neo4jRepository<ExampleGraph, Long> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,4 +123,5 @@ public class FilteredClassLoader extends URLClassLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,6 +353,7 @@ class ImportsContextCustomizer implements ContextCustomizer {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.key.toString();
|
return this.key.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -123,6 +123,7 @@ public class JsonbTester<T> extends AbstractJsonMarshalTester<T> {
|
||||||
Class<?> resourceLoadClass, ResolvableType type, Jsonb marshaller) {
|
Class<?> resourceLoadClass, ResolvableType type, Jsonb marshaller) {
|
||||||
return new JsonbTester<>(resourceLoadClass, type, marshaller);
|
return new JsonbTester<>(resourceLoadClass, type, marshaller);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,6 +419,7 @@ public class ApplicationContextAssertTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Foo {
|
private static class Foo {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -30,4 +30,5 @@ public class TestMethodConfiguration {
|
||||||
public Object method() {
|
public Object method() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -29,4 +29,5 @@ import java.io.OutputStream;
|
||||||
@TestConditionalOnClass(name = "java.io.InputStream", value = OutputStream.class)
|
@TestConditionalOnClass(name = "java.io.InputStream", value = OutputStream.class)
|
||||||
@TestAutoConfigureOrder(123)
|
@TestAutoConfigureOrder(123)
|
||||||
public class TestOrderedClassConfiguration {
|
public class TestOrderedClassConfiguration {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -151,8 +151,8 @@ public class ConfigurationMetadata {
|
||||||
}
|
}
|
||||||
candidates.removeIf((itemMetadata) -> !itemMetadata.hasSameType(metadata));
|
candidates.removeIf((itemMetadata) -> !itemMetadata.hasSameType(metadata));
|
||||||
if (candidates.size() > 1 && metadata.getType() != null) {
|
if (candidates.size() > 1 && metadata.getType() != null) {
|
||||||
candidates.removeIf((itemMetadata) ->
|
candidates.removeIf(
|
||||||
!metadata.getType().equals(itemMetadata.getType()));
|
(itemMetadata) -> !metadata.getType().equals(itemMetadata.getType()));
|
||||||
}
|
}
|
||||||
if (candidates.size() == 1) {
|
if (candidates.size() == 1) {
|
||||||
return candidates.get(0);
|
return candidates.get(0);
|
||||||
|
|
|
@ -742,8 +742,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||||
"java.lang.String", null, null, null, null, null);
|
"java.lang.String", null, null, null, null, null);
|
||||||
writeAdditionalMetadata(property);
|
writeAdditionalMetadata(property);
|
||||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||||
assertThat(metadata).has(Metadata.withGroup("simple")
|
assertThat(metadata)
|
||||||
.fromSource(SimpleProperties.class));
|
.has(Metadata.withGroup("simple").fromSource(SimpleProperties.class));
|
||||||
assertThat(metadata).has(Metadata.withProperty("simple", String.class));
|
assertThat(metadata).has(Metadata.withProperty("simple", String.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,10 @@ public interface RandomAccessData {
|
||||||
* @param length the number of bytes to be read
|
* @param length the number of bytes to be read
|
||||||
* @return the data
|
* @return the data
|
||||||
* @throws IOException if the data cannot be read
|
* @throws IOException if the data cannot be read
|
||||||
* @throws IndexOutOfBoundsException if offset is beyond the end of the file or subsection
|
* @throws IndexOutOfBoundsException if offset is beyond the end of the file or
|
||||||
* @throws EOFException if offset plus length is greater than the length of the file or subsection
|
* subsection
|
||||||
|
* @throws EOFException if offset plus length is greater than the length of the file
|
||||||
|
* or subsection
|
||||||
*/
|
*/
|
||||||
byte[] read(long offset, long length) throws IOException;
|
byte[] read(long offset, long length) throws IOException;
|
||||||
|
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -110,20 +110,23 @@ public class RandomAccessDataFileTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWhenOffsetIsBeyondEndOfSubsectionShouldThrowException() throws Exception {
|
public void readWhenOffsetIsBeyondEndOfSubsectionShouldThrowException()
|
||||||
|
throws Exception {
|
||||||
this.thrown.expect(IndexOutOfBoundsException.class);
|
this.thrown.expect(IndexOutOfBoundsException.class);
|
||||||
RandomAccessData subsection = this.file.getSubsection(0, 10);
|
RandomAccessData subsection = this.file.getSubsection(0, 10);
|
||||||
subsection.read(11, 0);
|
subsection.read(11, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWhenOffsetPlusLengthGreaterThanEOFShouldThrowException() throws Exception {
|
public void readWhenOffsetPlusLengthGreaterThanEOFShouldThrowException()
|
||||||
|
throws Exception {
|
||||||
this.thrown.expect(EOFException.class);
|
this.thrown.expect(EOFException.class);
|
||||||
this.file.read(256, 1);
|
this.file.read(256, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWhenOffsetPlusLengthGreaterThanEndOfSubsectionShouldThrowException() throws Exception {
|
public void readWhenOffsetPlusLengthGreaterThanEndOfSubsectionShouldThrowException()
|
||||||
|
throws Exception {
|
||||||
this.thrown.expect(EOFException.class);
|
this.thrown.expect(EOFException.class);
|
||||||
RandomAccessData subsection = this.file.getSubsection(0, 10);
|
RandomAccessData subsection = this.file.getSubsection(0, 10);
|
||||||
subsection.read(10, 1);
|
subsection.read(10, 1);
|
||||||
|
|
|
@ -199,4 +199,5 @@ public class AsciiBytesTests {
|
||||||
private void matchesSameAsString(String input) {
|
private void matchesSameAsString(String input) {
|
||||||
assertThat(new AsciiBytes(input).matches(input, NO_SUFFIX)).isTrue();
|
assertThat(new AsciiBytes(input).matches(input, NO_SUFFIX)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,6 +167,7 @@ public final class PropertyMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A source that is in the process of being mapped.
|
* A source that is in the process of being mapped.
|
||||||
|
*
|
||||||
* @param <T> the source type
|
* @param <T> the source type
|
||||||
*/
|
*/
|
||||||
public static final class Source<T> {
|
public static final class Source<T> {
|
||||||
|
|
|
@ -91,6 +91,7 @@ abstract class AggregateBinder<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal class used to supply the aggregate and cache the value.
|
* Internal class used to supply the aggregate and cache the value.
|
||||||
|
*
|
||||||
* @param <T> The aggregate type
|
* @param <T> The aggregate type
|
||||||
*/
|
*/
|
||||||
protected static class AggregateSupplier<T> {
|
protected static class AggregateSupplier<T> {
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue