Format with Eclipse Oxygen SR2

This commit is contained in:
Andy Wilkinson 2018-02-08 10:53:53 +00:00
parent b4f4dd3fdd
commit 76a450dfba
126 changed files with 556 additions and 611 deletions

View File

@ -115,9 +115,8 @@ public class CloudFoundryActuatorAutoConfiguration {
String cloudControllerUrl = environment.getProperty("vcap.application.cf_api");
boolean skipSslValidation = environment.getProperty(
"management.cloudfoundry.skip-ssl-validation", Boolean.class, false);
return (cloudControllerUrl == null ? null
: new CloudFoundrySecurityService(restTemplateBuilder, cloudControllerUrl,
skipSslValidation));
return (cloudControllerUrl == null ? null : new CloudFoundrySecurityService(
restTemplateBuilder, cloudControllerUrl, skipSslValidation));
}
private CorsConfiguration getCorsConfiguration() {

View File

@ -58,7 +58,8 @@ public class PropertiesMeterFilter implements MeterFilter {
public HistogramConfig configure(Meter.Id id, HistogramConfig config) {
HistogramConfig.Builder builder = HistogramConfig.builder();
Distribution distribution = this.properties.getDistribution();
builder.percentilesHistogram(lookup(distribution.getPercentilesHistogram(), id, null));
builder.percentilesHistogram(
lookup(distribution.getPercentilesHistogram(), id, null));
builder.percentiles(lookup(distribution.getPercentiles(), id, null));
builder.sla(convertSla(id.getType(), lookup(distribution.getSla(), id, null)));
return builder.build().merge(config);

View File

@ -134,8 +134,7 @@ class ServletManagementChildContextConfiguration {
accessLogValve.setPrefix(customizePrefix(accessLogValve.getPrefix()));
}
private AccessLogValve findAccessLogValve(
TomcatServletWebServerFactory factory) {
private AccessLogValve findAccessLogValve(TomcatServletWebServerFactory factory) {
for (Valve engineValve : factory.getEngineValves()) {
if (engineValve instanceof AccessLogValve) {
return (AccessLogValve) engineValve;
@ -151,8 +150,7 @@ class ServletManagementChildContextConfiguration {
@Override
public void customize(UndertowServletWebServerFactory factory) {
factory.setAccessLogPrefix(
customizePrefix(factory.getAccessLogPrefix()));
factory.setAccessLogPrefix(customizePrefix(factory.getAccessLogPrefix()));
}
}

View File

@ -101,15 +101,13 @@ public class CloudFoundryWebFluxEndpointIntegrationTests {
@Test
public void responseToOptionsRequestIncludesCorsHeaders() {
load(TestEndpointConfiguration.class,
(client) -> client.options().uri("/cfApplication/test")
.accept(MediaType.APPLICATION_JSON)
.header("Access-Control-Request-Method", "POST")
.header("Origin", "http://example.com").exchange().expectStatus()
.isOk().expectHeader()
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
.expectHeader()
.valueEquals("Access-Control-Allow-Methods", "GET,POST"));
load(TestEndpointConfiguration.class, (client) -> client.options()
.uri("/cfApplication/test").accept(MediaType.APPLICATION_JSON)
.header("Access-Control-Request-Method", "POST")
.header("Origin", "http://example.com").exchange().expectStatus().isOk()
.expectHeader()
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
.expectHeader().valueEquals("Access-Control-Allow-Methods", "GET,POST"));
}
@Test
@ -117,21 +115,19 @@ public class CloudFoundryWebFluxEndpointIntegrationTests {
given(tokenValidator.validate(any())).willReturn(Mono.empty());
given(securityService.getAccessLevel(any(), eq("app-id")))
.willReturn(Mono.just(AccessLevel.FULL));
load(TestEndpointConfiguration.class,
(client) -> client.get().uri("/cfApplication")
.accept(MediaType.APPLICATION_JSON)
.header("Authorization", "bearer " + mockAccessToken()).exchange()
.expectStatus().isOk().expectBody().jsonPath("_links.length()")
.isEqualTo(5).jsonPath("_links.self.href").isNotEmpty()
.jsonPath("_links.self.templated").isEqualTo(false)
.jsonPath("_links.info.href").isNotEmpty()
.jsonPath("_links.info.templated").isEqualTo(false)
.jsonPath("_links.env.href").isNotEmpty()
.jsonPath("_links.env.templated").isEqualTo(false)
.jsonPath("_links.test.href").isNotEmpty()
.jsonPath("_links.test.templated").isEqualTo(false)
.jsonPath("_links.test-part.href").isNotEmpty()
.jsonPath("_links.test-part.templated").isEqualTo(true));
load(TestEndpointConfiguration.class, (client) -> client.get()
.uri("/cfApplication").accept(MediaType.APPLICATION_JSON)
.header("Authorization", "bearer " + mockAccessToken()).exchange()
.expectStatus().isOk().expectBody().jsonPath("_links.length()")
.isEqualTo(5).jsonPath("_links.self.href").isNotEmpty()
.jsonPath("_links.self.templated").isEqualTo(false)
.jsonPath("_links.info.href").isNotEmpty()
.jsonPath("_links.info.templated").isEqualTo(false)
.jsonPath("_links.env.href").isNotEmpty().jsonPath("_links.env.templated")
.isEqualTo(false).jsonPath("_links.test.href").isNotEmpty()
.jsonPath("_links.test.templated").isEqualTo(false)
.jsonPath("_links.test-part.href").isNotEmpty()
.jsonPath("_links.test-part.templated").isEqualTo(true));
}
@Test

View File

@ -96,10 +96,9 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
.from(MockServerHttpRequest.get("/a")
.header(HttpHeaders.AUTHORIZATION, "bearer " + mockAccessToken())
.build());
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
.consumeErrorWith((ex) -> assertThat(
((CloudFoundryAuthorizationException) ex).getReason())
.isEqualTo(Reason.SERVICE_UNAVAILABLE))
StepVerifier.create(this.interceptor.preHandle(request, "/a")).consumeErrorWith(
(ex) -> assertThat(((CloudFoundryAuthorizationException) ex).getReason())
.isEqualTo(Reason.SERVICE_UNAVAILABLE))
.verify();
}
@ -109,10 +108,9 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
"my-app-id");
MockServerWebExchange request = MockServerWebExchange.from(MockServerHttpRequest
.get("/a").header(HttpHeaders.AUTHORIZATION, mockAccessToken()).build());
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
.consumeErrorWith((ex) -> assertThat(
((CloudFoundryAuthorizationException) ex).getReason())
.isEqualTo(Reason.SERVICE_UNAVAILABLE))
StepVerifier.create(this.interceptor.preHandle(request, "/a")).consumeErrorWith(
(ex) -> assertThat(((CloudFoundryAuthorizationException) ex).getReason())
.isEqualTo(Reason.SERVICE_UNAVAILABLE))
.verify();
}

View File

@ -94,36 +94,32 @@ public class CloudFoundryMvcWebEndpointIntegrationTests {
@Test
public void responseToOptionsRequestIncludesCorsHeaders() {
load(TestEndpointConfiguration.class,
(client) -> client.options().uri("/cfApplication/test")
.accept(MediaType.APPLICATION_JSON)
.header("Access-Control-Request-Method", "POST")
.header("Origin", "http://example.com").exchange().expectStatus()
.isOk().expectHeader()
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
.expectHeader()
.valueEquals("Access-Control-Allow-Methods", "GET,POST"));
load(TestEndpointConfiguration.class, (client) -> client.options()
.uri("/cfApplication/test").accept(MediaType.APPLICATION_JSON)
.header("Access-Control-Request-Method", "POST")
.header("Origin", "http://example.com").exchange().expectStatus().isOk()
.expectHeader()
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
.expectHeader().valueEquals("Access-Control-Allow-Methods", "GET,POST"));
}
@Test
public void linksToOtherEndpointsWithFullAccess() {
given(securityService.getAccessLevel(any(), eq("app-id")))
.willReturn(AccessLevel.FULL);
load(TestEndpointConfiguration.class,
(client) -> client.get().uri("/cfApplication")
.accept(MediaType.APPLICATION_JSON)
.header("Authorization", "bearer " + mockAccessToken()).exchange()
.expectStatus().isOk().expectBody().jsonPath("_links.length()")
.isEqualTo(5).jsonPath("_links.self.href").isNotEmpty()
.jsonPath("_links.self.templated").isEqualTo(false)
.jsonPath("_links.info.href").isNotEmpty()
.jsonPath("_links.info.templated").isEqualTo(false)
.jsonPath("_links.env.href").isNotEmpty()
.jsonPath("_links.env.templated").isEqualTo(false)
.jsonPath("_links.test.href").isNotEmpty()
.jsonPath("_links.test.templated").isEqualTo(false)
.jsonPath("_links.test-part.href").isNotEmpty()
.jsonPath("_links.test-part.templated").isEqualTo(true));
load(TestEndpointConfiguration.class, (client) -> client.get()
.uri("/cfApplication").accept(MediaType.APPLICATION_JSON)
.header("Authorization", "bearer " + mockAccessToken()).exchange()
.expectStatus().isOk().expectBody().jsonPath("_links.length()")
.isEqualTo(5).jsonPath("_links.self.href").isNotEmpty()
.jsonPath("_links.self.templated").isEqualTo(false)
.jsonPath("_links.info.href").isNotEmpty()
.jsonPath("_links.info.templated").isEqualTo(false)
.jsonPath("_links.env.href").isNotEmpty().jsonPath("_links.env.templated")
.isEqualTo(false).jsonPath("_links.test.href").isNotEmpty()
.jsonPath("_links.test.templated").isEqualTo(false)
.jsonPath("_links.test-part.href").isNotEmpty()
.jsonPath("_links.test-part.templated").isEqualTo(true));
}
@Test

View File

@ -60,9 +60,8 @@ public class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
@Test
public void keysToSanitizeCanBeConfiguredViaTheEnvironment() {
this.contextRunner.withUserConfiguration(Config.class)
.withPropertyValues(
"management.endpoint.configprops.keys-to-sanitize: .*pass.*, property")
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues(
"management.endpoint.configprops.keys-to-sanitize: .*pass.*, property")
.run(validateTestProperties("******", "******"));
}

View File

@ -88,9 +88,9 @@ public class AuditEventsEndpointDocumentationTests
parameterWithName("principal").description(
"Restricts the events to those with the given "
+ "principal. Optional."),
parameterWithName("type").description(
"Restricts the events to those with the given "
+ "type. Optional."))));
parameterWithName("type").description(
"Restricts the events to those with the given "
+ "type. Optional."))));
verify(this.repository).find("alice", now.toInstant(), "logout");
}

View File

@ -49,10 +49,9 @@ public class BeansEndpointDocumentationTests extends MockMvcEndpointDocumentatio
@Test
public void beans() throws Exception {
List<FieldDescriptor> beanFields = Arrays
.asList(fieldWithPath("aliases").description("Names of any aliases."),
fieldWithPath("scope")
.description("Scope of the bean."),
List<FieldDescriptor> beanFields = Arrays.asList(
fieldWithPath("aliases").description("Names of any aliases."),
fieldWithPath("scope").description("Scope of the bean."),
fieldWithPath("type").description("Fully qualified type of the bean."),
fieldWithPath("resource")
.description("Resource in which the bean was defined, if any.")

View File

@ -100,8 +100,8 @@ public class ConditionsReportEndpointDocumentationTests
this.mockMvc.perform(get("/actuator/conditions")).andExpect(status().isOk())
.andDo(MockMvcRestDocumentation.document("conditions",
preprocessResponse(
limit("contexts", getApplicationContext().getId(),
"positiveMatches"),
limit("contexts", getApplicationContext()
.getId(), "positiveMatches"),
limit("contexts", getApplicationContext().getId(),
"negativeMatches")),
responseFields(fieldWithPath("contexts")

View File

@ -71,12 +71,10 @@ public class EnvironmentEndpointDocumentationTests
@Test
public void env() throws Exception {
this.mockMvc.perform(get("/actuator/env")).andExpect(status().isOk())
.andDo(document("env/all",
preprocessResponse(replacePattern(
Pattern.compile(
"org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/"),
""), filterProperties()),
this.mockMvc.perform(get("/actuator/env")).andExpect(status().isOk()).andDo(
document("env/all", preprocessResponse(replacePattern(Pattern.compile(
"org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/"),
""), filterProperties()),
responseFields(activeProfiles, propertySources,
propertySourceName,
fieldWithPath("propertySources.[].properties")
@ -94,14 +92,13 @@ public class EnvironmentEndpointDocumentationTests
this.mockMvc.perform(get("/actuator/env/com.example.cache.max-size"))
.andExpect(status().isOk())
.andDo(document("env/single",
preprocessResponse(replacePattern(
Pattern.compile(
"org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/"),
preprocessResponse(replacePattern(Pattern.compile(
"org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/"),
"")),
responseFields(
fieldWithPath("property").description(
"Property from the environment, if found.")
.optional(),
.optional(),
fieldWithPath("property.source").description(
"Name of the source of the property."),
fieldWithPath("property.value")

View File

@ -50,16 +50,14 @@ public class FlywayEndpointDocumentationTests extends MockMvcEndpointDocumentati
@Test
public void flyway() throws Exception {
this.mockMvc.perform(get("/actuator/flyway")).andExpect(status().isOk())
.andDo(MockMvcRestDocumentation.document("flyway",
responseFields(
fieldWithPath("contexts")
.description("Application contexts keyed by id"),
.andDo(MockMvcRestDocumentation.document("flyway", responseFields(
fieldWithPath("contexts")
.description("Application contexts keyed by id"),
fieldWithPath("contexts.*.flywayBeans.*.migrations").description(
"Migrations performed by the Flyway instance, keyed by"
+ " Flyway bean name."))
.andWithPrefix(
"contexts.*.flywayBeans.*.migrations.[].",
migrationFieldDescriptors())
+ " Flyway bean name.")).andWithPrefix(
"contexts.*.flywayBeans.*.migrations.[].",
migrationFieldDescriptors())
.and(parentIdField())));
}
@ -84,9 +82,8 @@ public class FlywayEndpointDocumentationTests extends MockMvcEndpointDocumentati
"Rank of the applied migration, if any. Later migrations have "
+ "higher ranks.")
.optional(),
fieldWithPath("script")
.description(
"Name of the script used to execute the migration, if any.")
fieldWithPath("script").description(
"Name of the script used to execute the migration, if any.")
.optional(),
fieldWithPath("state").description("State of the migration. ("
+ describeEnumValues(MigrationState.class) + ")"),

View File

@ -52,10 +52,9 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati
@Test
public void health() throws Exception {
this.mockMvc.perform(get("/actuator/health")).andExpect(status().isOk())
.andDo(document("health",
responseFields(
fieldWithPath("status").description(
"Overall status of the application."),
.andDo(document("health", responseFields(
fieldWithPath("status")
.description("Overall status of the application."),
fieldWithPath("details").description(
"Details of the health of the application. Presence is controlled by "
+ "`management.endpoint.health.show-details`)."),

View File

@ -77,10 +77,9 @@ public class HttpTraceEndpointDocumentationTests
() -> UUID.randomUUID().toString());
given(this.repository.findAll()).willReturn(Arrays.asList(trace));
this.mockMvc.perform(get("/actuator/httptrace")).andExpect(status().isOk())
.andDo(document("httptrace",
responseFields(
fieldWithPath("traces").description(
"An array of traced HTTP request-response exchanges."),
.andDo(document("httptrace", responseFields(
fieldWithPath("traces").description(
"An array of traced HTTP request-response exchanges."),
fieldWithPath("traces.[].timestamp").description(
"Timestamp of when the traced exchange occurred."),
fieldWithPath("traces.[].principal")
@ -90,9 +89,8 @@ public class HttpTraceEndpointDocumentationTests
.description("Name of the principal.").optional(),
fieldWithPath("traces.[].request.method")
.description("HTTP method of the request."),
fieldWithPath("traces.[].request.remoteAddress")
.description(
"Remote address from which the request was received, if known.")
fieldWithPath("traces.[].request.remoteAddress").description(
"Remote address from which the request was received, if known.")
.optional().type(JsonFieldType.STRING),
fieldWithPath("traces.[].request.uri")
.description("URI of the request."),

View File

@ -53,13 +53,13 @@ public class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentation
responseFields(beneathPath("git"),
fieldWithPath("branch")
.description("Name of the Git branch, if any."),
fieldWithPath("commit")
.description("Details of the Git commit, if any."),
fieldWithPath("commit.time")
.description("Timestamp of the commit, if any.")
.type(JsonFieldType.VARIES),
fieldWithPath("commit.id")
.description("ID of the commit, if any.")),
fieldWithPath("commit").description(
"Details of the Git commit, if any."),
fieldWithPath("commit.time")
.description("Timestamp of the commit, if any.")
.type(JsonFieldType.VARIES),
fieldWithPath("commit.id")
.description("ID of the commit, if any.")),
responseFields(beneathPath("build"),
fieldWithPath("artifact")
.description(
@ -76,9 +76,8 @@ public class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentation
.description(
"Version of the application, if any.")
.optional(),
fieldWithPath("time")
.description(
"Timestamp of when the application was built, if any.")
fieldWithPath("time").description(
"Timestamp of when the application was built, if any.")
.type(JsonFieldType.VARIES).optional())));
}

View File

@ -57,9 +57,10 @@ public class LiquibaseEndpointDocumentationTests
responseFields(
fieldWithPath("contexts")
.description("Application contexts keyed by id"),
changeSetsField).andWithPrefix(
"contexts.*.liquibaseBeans.*.changeSets[].",
getChangeSetFieldDescriptors()).and(parentIdField())));
changeSetsField).andWithPrefix(
"contexts.*.liquibaseBeans.*.changeSets[].",
getChangeSetFieldDescriptors())
.and(parentIdField())));
}
private List<FieldDescriptor> getChangeSetFieldDescriptors() {
@ -81,8 +82,8 @@ public class LiquibaseEndpointDocumentationTests
fieldWithPath("labels")
.description("Labels associated with the change set."),
fieldWithPath("checksum").description("Checksum of the change set."),
fieldWithPath("orderExecuted").description(
"Order of the execution of the change set."),
fieldWithPath("orderExecuted")
.description("Order of the execution of the change set."),
fieldWithPath("tag")
.description("Tag associated with the change set, if any.")
.optional().type(JsonFieldType.STRING));

View File

@ -67,10 +67,9 @@ public class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentat
new LoggerConfiguration("ROOT", LogLevel.INFO, LogLevel.INFO),
new LoggerConfiguration("com.example", LogLevel.DEBUG, LogLevel.DEBUG)));
this.mockMvc.perform(get("/actuator/loggers")).andExpect(status().isOk())
.andDo(MockMvcRestDocumentation.document("loggers/all",
responseFields(
fieldWithPath("levels").description(
"Levels support by the logging system."),
.andDo(MockMvcRestDocumentation.document("loggers/all", responseFields(
fieldWithPath("levels")
.description("Levels support by the logging system."),
fieldWithPath("loggers").description("Loggers keyed by name."))
.andWithPrefix("loggers.*.", levelFields)));
}
@ -90,13 +89,12 @@ public class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentat
.perform(post("/actuator/loggers/com.example")
.content("{\"configuredLevel\":\"debug\"}")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isNoContent())
.andDo(MockMvcRestDocumentation
.document("loggers/set",
.andExpect(status().isNoContent()).andDo(
MockMvcRestDocumentation.document("loggers/set",
requestFields(fieldWithPath("configuredLevel")
.description("Level for the logger. May be"
+ " omitted to clear the level.")
.optional())));
.optional())));
verify(this.loggingSystem).setLogLevel("com.example", LogLevel.DEBUG);
}

View File

@ -78,13 +78,13 @@ public class MappingsEndpointReactiveDocumentationTests
responseFields(
beneathPath("contexts.*.mappings.dispatcherHandlers")
.withSubsectionId("dispatcher-handlers"),
fieldWithPath("*").description(
"Dispatcher handler mappings, if any, keyed by "
+ "dispatcher handler bean name."),
fieldWithPath("*.[].handler")
.description("Handler for the mapping."),
fieldWithPath("*.[].predicate")
.description("Predicate for the mapping."))));
fieldWithPath("*").description(
"Dispatcher handler mappings, if any, keyed by "
+ "dispatcher handler bean name."),
fieldWithPath("*.[].handler")
.description("Handler for the mapping."),
fieldWithPath("*.[].predicate")
.description("Predicate for the mapping."))));
}
@Configuration

View File

@ -96,13 +96,13 @@ public class MappingsEndpointServletDocumentationTests
responseFields(
beneathPath("contexts.*.mappings.dispatcherServlets")
.withSubsectionId("dispatcher-servlets"),
fieldWithPath("*").description(
"Dispatcher servlet mappings, if any, keyed by "
+ "dispatcher servlet bean name."),
fieldWithPath("*.[].handler")
.description("Handler for the mapping."),
fieldWithPath("*.[].predicate")
.description("Predicate for the mapping.")),
fieldWithPath("*").description(
"Dispatcher servlet mappings, if any, keyed by "
+ "dispatcher servlet bean name."),
fieldWithPath("*.[].handler")
.description("Handler for the mapping."),
fieldWithPath("*.[].predicate")
.description("Predicate for the mapping.")),
responseFields(
beneathPath("contexts.*.mappings.servletFilters")
.withSubsectionId("servlet-filters"),

View File

@ -52,11 +52,10 @@ public class MetricsEndpointDocumentationTests extends MockMvcEndpointDocumentat
public void metric() throws Exception {
this.mockMvc.perform(get("/actuator/metrics/jvm.memory.max"))
.andExpect(status().isOk())
.andDo(document("metrics/metric",
responseFields(
fieldWithPath("name").description("Name of the metric"),
fieldWithPath("measurements")
.description("Measurements of the metric"),
.andDo(document("metrics/metric", responseFields(
fieldWithPath("name").description("Name of the metric"),
fieldWithPath("measurements")
.description("Measurements of the metric"),
fieldWithPath("measurements[].statistic")
.description("Statistic of the measurement. ("
+ describeEnumValues(Statistic.class) + ")."),
@ -72,10 +71,8 @@ public class MetricsEndpointDocumentationTests extends MockMvcEndpointDocumentat
@Test
public void metricWithTags() throws Exception {
this.mockMvc
.perform(get("/actuator/metrics/jvm.memory.max")
.param("tag", "area:nonheap")
.param("tag", "id:Compressed Class Space"))
this.mockMvc.perform(get("/actuator/metrics/jvm.memory.max")
.param("tag", "area:nonheap").param("tag", "id:Compressed Class Space"))
.andExpect(status().isOk())
.andDo(document("metrics/metric-with-tags",
requestParameters(parameterWithName("tag").description(

View File

@ -50,10 +50,9 @@ public class ScheduledTasksEndpointDocumentationTests
public void scheduledTasks() throws Exception {
this.mockMvc.perform(get("/actuator/scheduledtasks")).andExpect(status().isOk())
.andDo(document("scheduled-tasks",
preprocessResponse(replacePattern(
Pattern.compile(
"org.*\\.ScheduledTasksEndpointDocumentationTests\\$"
+ "TestConfiguration"),
preprocessResponse(replacePattern(Pattern.compile(
"org.*\\.ScheduledTasksEndpointDocumentationTests\\$"
+ "TestConfiguration"),
"com.example.Processor")),
responseFields(
fieldWithPath("cron").description("Cron tasks, if any."),

View File

@ -67,10 +67,10 @@ public class SessionsEndpointDocumentationTests
private static final Session sessionThree = createSession(
Instant.now().minusSeconds(60 * 60 * 2), Instant.now().minusSeconds(12));
private static final List<FieldDescriptor> sessionFields = Arrays
.asList(fieldWithPath("id").description("ID of the session."),
fieldWithPath("attributeNames").description(
"Names of the attributes stored in the session."),
private static final List<FieldDescriptor> sessionFields = Arrays.asList(
fieldWithPath("id").description("ID of the session."),
fieldWithPath("attributeNames")
.description("Names of the attributes stored in the session."),
fieldWithPath("creationTime")
.description("Timestamp of when the session was created."),
fieldWithPath("lastAccessedTime")

View File

@ -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.
@ -133,11 +133,9 @@ public class EnvironmentEndpoint {
String propertyName) {
Map<String, PropertyValueDescriptor> propertySources = new LinkedHashMap<>();
PlaceholdersResolver resolver = getResolver();
getPropertySourcesAsMap()
.forEach((sourceName, source) -> propertySources.put(sourceName,
source.containsProperty(propertyName)
? describeValueOf(propertyName, source, resolver)
: null));
getPropertySourcesAsMap().forEach((sourceName, source) -> propertySources
.put(sourceName, source.containsProperty(propertyName)
? describeValueOf(propertyName, source, resolver) : null));
return propertySources;
}

View File

@ -120,10 +120,8 @@ public class MetricsEndpoint {
}
private void mergeMeasurements(Map<Statistic, Double> samples, Meter meter) {
meter.measure()
.forEach((measurement) -> samples.merge(measurement.getStatistic(),
measurement.getValue(),
mergeFunction(measurement.getStatistic())));
meter.measure().forEach((measurement) -> samples.merge(measurement.getStatistic(),
measurement.getValue(), mergeFunction(measurement.getStatistic())));
}
private BiFunction<Double, Double, Double> mergeFunction(Statistic statistic) {

View File

@ -107,13 +107,13 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
throws ServletException, IOException {
filterAndRecordMetrics(request, response, filterChain);
}
private void filterAndRecordMetrics(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws IOException, ServletException, NestedServletException {
throws IOException, ServletException, NestedServletException {
Object handler = null;
try {
handler = getHandler(request);
@ -150,7 +150,7 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
private void filterAndRecordMetrics(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain, Object handler)
throws IOException, ServletException, NestedServletException {
throws IOException, ServletException, NestedServletException {
TimingContext timingContext = TimingContext.get(request);
if (timingContext == null) {
timingContext = startAndAttachTimingContext(request, handler);

View File

@ -75,7 +75,7 @@ public class HttpTraceFilter extends OncePerRequestFilter implements Ordered {
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
throws ServletException, IOException {
TraceableHttpServletRequest traceableRequest = new TraceableHttpServletRequest(
request);
HttpTrace trace = this.tracer.receivedRequest(traceableRequest);

View File

@ -100,12 +100,13 @@ public class BeansEndpointTests {
new ApplicationContextRunner()
.withUserConfiguration(EndpointConfiguration.class).withParent(parent)
.run((child) -> {
ApplicationBeans result = child.getBean(BeansEndpoint.class).beans();
assertThat(result.getContexts().get(parent.getId()).getBeans())
.containsKey("bean");
assertThat(result.getContexts().get(child.getId()).getBeans())
.containsKey("endpoint");
});
ApplicationBeans result = child.getBean(BeansEndpoint.class)
.beans();
assertThat(result.getContexts().get(parent.getId()).getBeans())
.containsKey("bean");
assertThat(result.getContexts().get(child.getId()).getBeans())
.containsKey("endpoint");
});
});
}

View File

@ -43,18 +43,20 @@ public class ConfigurationPropertiesReportEndpointParentTests {
new ApplicationContextRunner()
.withUserConfiguration(ClassConfigurationProperties.class)
.withParent(parent).run((child) -> {
ConfigurationPropertiesReportEndpoint endpoint = child
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint
.configurationProperties();
assertThat(applicationProperties.getContexts())
.containsOnlyKeys(child.getId(), parent.getId());
assertThat(applicationProperties.getContexts().get(child.getId())
.getBeans().keySet()).containsExactly("someProperties");
assertThat((applicationProperties.getContexts()
.get(parent.getId()).getBeans().keySet()))
.containsExactly("testProperties");
});
ConfigurationPropertiesReportEndpoint endpoint = child
.getBean(
ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint
.configurationProperties();
assertThat(applicationProperties.getContexts())
.containsOnlyKeys(child.getId(), parent.getId());
assertThat(applicationProperties.getContexts()
.get(child.getId()).getBeans().keySet())
.containsExactly("someProperties");
assertThat((applicationProperties.getContexts()
.get(parent.getId()).getBeans().keySet()))
.containsExactly("testProperties");
});
});
}
@ -66,17 +68,19 @@ public class ConfigurationPropertiesReportEndpointParentTests {
.withUserConfiguration(
BeanMethodConfigurationProperties.class)
.withParent(parent).run((child) -> {
ConfigurationPropertiesReportEndpoint endpoint = child
.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint
.configurationProperties();
assertThat(applicationProperties.getContexts().get(child.getId())
.getBeans().keySet())
.containsExactlyInAnyOrder("otherProperties");
assertThat((applicationProperties.getContexts()
.get(parent.getId()).getBeans().keySet()))
.containsExactly("testProperties");
});
ConfigurationPropertiesReportEndpoint endpoint = child
.getBean(
ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint
.configurationProperties();
assertThat(applicationProperties.getContexts()
.get(child.getId()).getBeans().keySet())
.containsExactlyInAnyOrder(
"otherProperties");
assertThat((applicationProperties.getContexts()
.get(parent.getId()).getBeans().keySet()))
.containsExactly("testProperties");
});
});
}

View File

@ -131,7 +131,7 @@ public class JerseyWebEndpointIntegrationTests extends
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
throws ServletException, IOException {
filterChain.doFilter(new HttpServletRequestWrapper(request) {
@Override

View File

@ -66,15 +66,13 @@ public class WebFluxEndpointIntegrationTests
@Test
public void responseToOptionsRequestIncludesCorsHeaders() {
load(TestEndpointConfiguration.class,
(client) -> client.options().uri("/test")
.accept(MediaType.APPLICATION_JSON)
.header("Access-Control-Request-Method", "POST")
.header("Origin", "http://example.com").exchange().expectStatus()
.isOk().expectHeader()
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
.expectHeader()
.valueEquals("Access-Control-Allow-Methods", "GET,POST"));
load(TestEndpointConfiguration.class, (client) -> client.options().uri("/test")
.accept(MediaType.APPLICATION_JSON)
.header("Access-Control-Request-Method", "POST")
.header("Origin", "http://example.com").exchange().expectStatus().isOk()
.expectHeader()
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
.expectHeader().valueEquals("Access-Control-Allow-Methods", "GET,POST"));
}
@Test

View File

@ -68,15 +68,13 @@ public class MvcWebEndpointIntegrationTests extends
@Test
public void responseToOptionsRequestIncludesCorsHeaders() {
load(TestEndpointConfiguration.class,
(client) -> client.options().uri("/test")
.accept(MediaType.APPLICATION_JSON)
.header("Access-Control-Request-Method", "POST")
.header("Origin", "http://example.com").exchange().expectStatus()
.isOk().expectHeader()
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
.expectHeader()
.valueEquals("Access-Control-Allow-Methods", "GET,POST"));
load(TestEndpointConfiguration.class, (client) -> client.options().uri("/test")
.accept(MediaType.APPLICATION_JSON)
.header("Access-Control-Request-Method", "POST")
.header("Origin", "http://example.com").exchange().expectStatus().isOk()
.expectHeader()
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
.expectHeader().valueEquals("Access-Control-Allow-Methods", "GET,POST"));
}
@Test
@ -147,7 +145,7 @@ public class MvcWebEndpointIntegrationTests extends
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
throws ServletException, IOException {
filterChain.doFilter(new HttpServletRequestWrapper(request) {
@Override

View File

@ -70,8 +70,8 @@ public class MetricsEndpointWebIntegrationTests {
@Test
public void selectByTag() {
client.get()
.uri("/actuator/metrics/jvm.memory.used?tag=id:Compressed%20Class%20Space")
client.get().uri(
"/actuator/metrics/jvm.memory.used?tag=id:Compressed%20Class%20Space")
.exchange().expectStatus().isOk().expectBody().jsonPath("$.name")
.isEqualTo("jvm.memory.used");
}

View File

@ -69,8 +69,8 @@ public class MetricsRestTemplateCustomizerTests {
.andRespond(MockRestResponseCreators.withSuccess("OK",
MediaType.APPLICATION_JSON));
String result = this.restTemplate.getForObject("/test/{id}", String.class, 123);
assertThat(this.registry.find("http.client.requests")
.meters()).anySatisfy((m) -> assertThat(
assertThat(this.registry.find("http.client.requests").meters())
.anySatisfy((m) -> assertThat(
StreamSupport.stream(m.getId().getTags().spliterator(), false)
.map(Tag::getKey)).doesNotContain("bucket"));
assertThat(this.registry.get("http.client.requests")

View File

@ -497,7 +497,7 @@ public class WebMvcMetricsFilterTests {
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
throws ServletException, IOException {
String misbehave = request.getHeader(TEST_MISBEHAVE_HEADER);
if (misbehave != null) {
response.setStatus(Integer.parseInt(misbehave));

View File

@ -205,12 +205,11 @@ public class HttpExchangeTracerTests {
@Test
public void mixedCaseSetCookieHeaderIsNotIncludedByDefault() {
HttpTrace trace = new HttpTrace(createRequest());
new HttpExchangeTracer(EnumSet.of(Include.RESPONSE_HEADERS))
.sendingResponse(trace,
createResponse(Collections.singletonMap(
mixedCase(HttpHeaders.SET_COOKIE),
Arrays.asList("test=test"))),
null, null);
new HttpExchangeTracer(EnumSet.of(Include.RESPONSE_HEADERS)).sendingResponse(
trace,
createResponse(Collections.singletonMap(mixedCase(HttpHeaders.SET_COOKIE),
Arrays.asList("test=test"))),
null, null);
assertThat(trace.getResponse().getHeaders()).isEmpty();
}

View File

@ -76,7 +76,7 @@ public class HttpTraceFilterTests {
@Override
protected void service(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException {
throws ServletException, IOException {
req.getSession(true);
}
@ -112,7 +112,7 @@ public class HttpTraceFilterTests {
@Override
protected void service(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException {
throws ServletException, IOException {
throw new IOException();
}

View File

@ -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.
@ -108,7 +108,7 @@ public class BatchAutoConfiguration {
@ConditionalOnMissingBean(JobOperator.class)
public SimpleJobOperator jobOperator(JobExplorer jobExplorer, JobLauncher jobLauncher,
ListableJobLocator jobRegistry, JobRepository jobRepository)
throws Exception {
throws Exception {
SimpleJobOperator factory = new SimpleJobOperator();
factory.setJobExplorer(jobExplorer);
factory.setJobLauncher(jobLauncher);

View File

@ -230,7 +230,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
private Class<?> doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
BeanDefinition definition)
throws Exception, ClassNotFoundException, LinkageError {
throws Exception, ClassNotFoundException, LinkageError {
if (StringUtils.hasLength(definition.getFactoryBeanName())
&& StringUtils.hasLength(definition.getFactoryMethodName())) {
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition);
@ -243,7 +243,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
private Class<?> getConfigurationClassFactoryBeanGeneric(
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
throws Exception {
throws Exception {
Method method = getFactoryMethod(beanFactory, definition);
Class<?> generic = ResolvableType.forMethodReturnType(method)
.as(FactoryBean.class).resolveGeneric();
@ -305,7 +305,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
private Class<?> getDirectFactoryBeanGeneric(
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
throws ClassNotFoundException, LinkageError {
throws ClassNotFoundException, LinkageError {
Class<?> factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(),
beanFactory.getBeanClassLoader());
Class<?> generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class)

View File

@ -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.
@ -248,7 +248,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
private Collection<String> getBeanNamesForType(ListableBeanFactory beanFactory,
String type, ClassLoader classLoader, boolean considerHierarchy)
throws LinkageError {
throws LinkageError {
try {
Set<String> result = new LinkedHashSet<>();
collectBeanNamesForType(result, beanFactory,

View File

@ -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.
@ -106,7 +106,7 @@ class OnPropertyCondition extends SpringBootCondition {
ConditionMessage.forCondition(ConditionalOnProperty.class, spec)
.found("different value in property",
"different value in properties")
.items(Style.QUOTE, nonMatchingProperties));
.items(Style.QUOTE, nonMatchingProperties));
}
return ConditionOutcome.match(ConditionMessage
.forCondition(ConditionalOnProperty.class, spec).because("matched"));

View File

@ -165,9 +165,8 @@ public class FlywayAutoConfiguration {
Assert.state(locations.length != 0,
"Migration script locations not configured");
boolean exists = hasAtLeastOneLocation(locations);
Assert.state(exists,
() -> "Cannot find migrations location in: " + Arrays.asList(
locations)
Assert.state(exists, () -> "Cannot find migrations location in: "
+ Arrays.asList(locations)
+ " (please add migrations or check your Flyway configuration)");
}
}

View File

@ -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.
@ -86,7 +86,7 @@ class ActiveMQConnectionFactoryFactory {
private <T extends ActiveMQConnectionFactory> T createConnectionFactoryInstance(
Class<T> factoryClass) throws InstantiationException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException {
InvocationTargetException, NoSuchMethodException {
String brokerUrl = determineBrokerUrl();
String user = this.properties.getUser();
String password = this.properties.getPassword();

View File

@ -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.
@ -47,7 +47,7 @@ class ArtemisXAConnectionFactoryConfiguration {
@Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" })
public ConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory,
ArtemisProperties properties, XAConnectionFactoryWrapper wrapper)
throws Exception {
throws Exception {
return wrapper.wrapConnectionFactory(
new ArtemisConnectionFactoryFactory(beanFactory, properties)
.createConnectionFactory(ActiveMQXAConnectionFactory.class));

View File

@ -292,13 +292,13 @@ public class JpaProperties {
private void applyNamingStrategies(Map<String, Object> properties,
ImplicitNamingStrategy implicitStrategyBean,
PhysicalNamingStrategy physicalStrategyBean) {
applyNamingStrategy(properties,
"hibernate.implicit_naming_strategy", implicitStrategyBean != null
? implicitStrategyBean : this.implicitStrategy,
applyNamingStrategy(properties, "hibernate.implicit_naming_strategy",
implicitStrategyBean != null ? implicitStrategyBean
: this.implicitStrategy,
DEFAULT_IMPLICIT_STRATEGY);
applyNamingStrategy(properties,
"hibernate.physical_naming_strategy", physicalStrategyBean != null
? physicalStrategyBean : this.physicalStrategy,
applyNamingStrategy(properties, "hibernate.physical_naming_strategy",
physicalStrategyBean != null ? physicalStrategyBean
: this.physicalStrategy,
DEFAULT_PHYSICAL_STRATEGY);
}

View File

@ -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.
@ -24,9 +24,9 @@ import org.springframework.security.web.server.WebFilterChainProxy;
/**
* Switches on {@link EnableWebFluxSecurity} for a reactive web application if this
* annotation has not been added by the user. It delegates
* to Spring Security's content-negotiation mechanism for authentication. This configuration also
* backs off if a bean of type {@link WebFilterChainProxy} has been configured in any other way.
* annotation has not been added by the user. It delegates to Spring Security's
* content-negotiation mechanism for authentication. This configuration also backs off if
* a bean of type {@link WebFilterChainProxy} has been configured in any other way.
*
* @author Madhura Bhave
*/

View File

@ -69,10 +69,8 @@ public class UserDetailsServiceAutoConfiguration {
ObjectProvider<PasswordEncoder> passwordEncoder) throws Exception {
SecurityProperties.User user = properties.getUser();
List<String> roles = user.getRoles();
return new InMemoryUserDetailsManager(
User.withUsername(user.getName())
.password(getOrDeducePassword(user,
passwordEncoder.getIfAvailable()))
return new InMemoryUserDetailsManager(User.withUsername(user.getName())
.password(getOrDeducePassword(user, passwordEncoder.getIfAvailable()))
.roles(roles.toArray(new String[roles.size()])).build());
}

View File

@ -191,10 +191,10 @@ public abstract class AbstractErrorWebExceptionHandler
StringBuilder builder = new StringBuilder();
Object message = error.get("message");
Date timestamp = (Date) error.get("timestamp");
builder.append("<html><body><h1>Whitelabel Error Page</h1>")
.append("<p>This application has no configured error view, so you are seeing this as a fallback.</p>")
.append("<div id='created'>").append(timestamp)
.append("</div>").append("<div>There was an unexpected error (type=")
builder.append("<html><body><h1>Whitelabel Error Page</h1>").append(
"<p>This application has no configured error view, so you are seeing this as a fallback.</p>")
.append("<div id='created'>").append(timestamp).append("</div>")
.append("<div>There was an unexpected error (type=")
.append(htmlEscape(error.get("error"))).append(", status=")
.append(htmlEscape(error.get("status"))).append(").</div>");
if (message != null) {

View File

@ -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.
@ -43,7 +43,7 @@ public class WebClientCodecCustomizer implements WebClientCustomizer {
.exchangeStrategies(ExchangeStrategies.builder()
.codecs((codecs) -> this.codecCustomizers
.forEach((customizer) -> customizer.customize(codecs)))
.build());
.build());
}
}

View File

@ -321,10 +321,9 @@ public class WebMvcAutoConfiguration {
CacheControl cacheControl = this.resourceProperties.getCache()
.getCachecontrol().toHttpCacheControl();
if (!registry.hasMappingForPattern("/webjars/**")) {
customizeResourceHandlerRegistration(
registry.addResourceHandler("/webjars/**")
.addResourceLocations(
"classpath:/META-INF/resources/webjars/")
customizeResourceHandlerRegistration(registry
.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/")
.setCachePeriod(getSeconds(cachePeriod))
.setCacheControl(cacheControl));
}
@ -334,8 +333,8 @@ public class WebMvcAutoConfiguration {
registry.addResourceHandler(staticPathPattern)
.addResourceLocations(getResourceLocations(
this.resourceProperties.getStaticLocations()))
.setCachePeriod(getSeconds(cachePeriod))
.setCacheControl(cacheControl));
.setCachePeriod(getSeconds(cachePeriod))
.setCacheControl(cacheControl));
}
}

View File

@ -765,9 +765,9 @@ public class CacheAutoConfigurationTests {
"spring.cache.cacheNames[0]=foo",
"spring.cache.cacheNames[1]=bar")
.run((context) ->
// see customizer
assertThat(getCacheManager(context, JCacheCacheManager.class)
.getCacheNames()).containsOnly("foo", "custom1"));
// see customizer
assertThat(getCacheManager(context, JCacheCacheManager.class).getCacheNames())
.containsOnly("foo", "custom1"));
}
finally {
Caching.getCachingProvider(cachingProviderClassName).close();

View File

@ -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.
@ -66,8 +66,8 @@ public class ElasticsearchAutoConfigurationTests {
public void createTransportClient() {
this.context = new AnnotationConfigApplicationContext();
new ElasticsearchNodeTemplate().doWithNode((node) -> {
TestPropertyValues
.of("spring.data.elasticsearch.cluster-nodes:localhost:"
TestPropertyValues.of(
"spring.data.elasticsearch.cluster-nodes:localhost:"
+ node.getTcpPort(),
"spring.data.elasticsearch.properties.path.home:target/es/client")
.applyTo(this.context);

View File

@ -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.
@ -194,15 +194,17 @@ public class NoSuchBeanDefinitionFailureAnalyzerTests {
}
private void assertActionMissingType(FailureAnalysis analysis, Class<?> type) {
assertThat(analysis.getAction()).startsWith(String
.format("Consider revisiting the conditions above or defining a bean of type '%s' "
+ "in your configuration.", type.getName()));
assertThat(analysis.getAction()).startsWith(String.format(
"Consider revisiting the conditions above or defining a bean of type '%s' "
+ "in your configuration.",
type.getName()));
}
private void assertActionMissingName(FailureAnalysis analysis, String name) {
assertThat(analysis.getAction()).startsWith(String
.format("Consider revisiting the conditions above or defining a bean named '%s' "
+ "in your configuration.", name));
assertThat(analysis.getAction()).startsWith(String.format(
"Consider revisiting the conditions above or defining a bean named '%s' "
+ "in your configuration.",
name));
}
private void assertBeanMethodDisabled(FailureAnalysis analysis, String description,

View File

@ -89,9 +89,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
@Test
public void customTemplateLoaderPath() {
this.contextRunner
.withPropertyValues(
"spring.freemarker.templateLoaderPath:classpath:/custom-templates/")
this.contextRunner.withPropertyValues(
"spring.freemarker.templateLoaderPath:classpath:/custom-templates/")
.run((context) -> {
MockServerWebExchange exchange = render(context, "custom");
String result = exchange.getResponse().getBodyAsString().block();

View File

@ -78,9 +78,8 @@ public class FreeMarkerAutoConfigurationTests {
@Test
public void nonExistentLocationAndEmptyLocation() {
new File("target/test-classes/templates/empty-directory").mkdir();
this.contextRunner
.withPropertyValues("spring.freemarker.templateLoaderPath:"
+ "classpath:/does-not-exist/,classpath:/templates/empty-directory/")
this.contextRunner.withPropertyValues("spring.freemarker.templateLoaderPath:"
+ "classpath:/does-not-exist/,classpath:/templates/empty-directory/")
.run((context) -> {
});
}

View File

@ -51,9 +51,8 @@ public class ProjectInfoAutoConfigurationTests {
@Test
public void gitPropertiesWithNoData() {
this.contextRunner
.withPropertyValues("spring.info.git.location="
+ "classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties")
this.contextRunner.withPropertyValues("spring.info.git.location="
+ "classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties")
.run((context) -> {
GitProperties gitProperties = context.getBean(GitProperties.class);
assertThat(gitProperties.getBranch()).isNull();
@ -87,9 +86,8 @@ public class ProjectInfoAutoConfigurationTests {
@Test
public void buildPropertiesCustomLocation() {
this.contextRunner
.withPropertyValues("spring.info.build.location="
+ "classpath:/org/springframework/boot/autoconfigure/info/build-info.properties")
this.contextRunner.withPropertyValues("spring.info.build.location="
+ "classpath:/org/springframework/boot/autoconfigure/info/build-info.properties")
.run((context) -> {
BuildProperties buildProperties = context
.getBean(BuildProperties.class);

View File

@ -139,9 +139,8 @@ public class JacksonAutoConfigurationTests {
@Test
public void customDateFormatClass() {
this.contextRunner
.withPropertyValues(
"spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat")
this.contextRunner.withPropertyValues(
"spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat")
.run((context) -> {
ObjectMapper mapper = context.getBean(ObjectMapper.class);
assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class);
@ -169,9 +168,8 @@ public class JacksonAutoConfigurationTests {
@Test
public void customPropertyNamingStrategyClass() {
this.contextRunner
.withPropertyValues(
"spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy")
this.contextRunner.withPropertyValues(
"spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy")
.run((context) -> {
ObjectMapper mapper = context.getBean(ObjectMapper.class);
assertThat(mapper.getPropertyNamingStrategy())

View File

@ -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.
@ -130,21 +130,20 @@ public class JmsAutoConfigurationTests {
@Test
public void testEnableJmsCreateDefaultContainerFactory() {
this.contextRunner.withUserConfiguration(EnableJmsConfiguration.class)
.run((context) -> assertThat(context)
.getBean("jmsListenerContainerFactory",
JmsListenerContainerFactory.class)
.run((context) -> assertThat(context).getBean(
"jmsListenerContainerFactory", JmsListenerContainerFactory.class)
.isExactlyInstanceOf(DefaultJmsListenerContainerFactory.class));
}
@Test
public void testJmsListenerContainerFactoryBackOff() {
this.contextRunner
.withUserConfiguration(TestConfiguration6.class,
EnableJmsConfiguration.class)
.run((context) -> assertThat(context)
.getBean("jmsListenerContainerFactory",
JmsListenerContainerFactory.class)
.isExactlyInstanceOf(SimpleJmsListenerContainerFactory.class));
this.contextRunner.withUserConfiguration(TestConfiguration6.class,
EnableJmsConfiguration.class).run(
(context) -> assertThat(context)
.getBean("jmsListenerContainerFactory",
JmsListenerContainerFactory.class)
.isExactlyInstanceOf(
SimpleJmsListenerContainerFactory.class));
}
@Test
@ -414,9 +413,8 @@ public class JmsAutoConfigurationTests {
@Test
public void enableJmsAutomatically() {
this.contextRunner.withUserConfiguration(NoEnableJmsConfiguration.class)
.run((context) -> assertThat(context)
.hasBean(
JmsListenerConfigUtils.JMS_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME)
.run((context) -> assertThat(context).hasBean(
JmsListenerConfigUtils.JMS_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME)
.hasBean(
JmsListenerConfigUtils.JMS_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME));
}

View File

@ -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.
@ -214,9 +214,8 @@ public class ArtemisAutoConfigurationTests {
@Test
public void embeddedServiceWithCustomArtemisConfiguration() {
this.contextRunner.withUserConfiguration(CustomArtemisConfiguration.class)
.run((context) -> assertThat(context
.getBean(
org.apache.activemq.artemis.core.config.Configuration.class)
.run((context) -> assertThat(context.getBean(
org.apache.activemq.artemis.core.config.Configuration.class)
.getName()).isEqualTo("customFooBar"));
}
@ -250,19 +249,22 @@ public class ArtemisAutoConfigurationTests {
this.contextRunner
.withPropertyValues("spring.artemis.embedded.queues=Queue2")
.run((second) -> {
ArtemisProperties firstProperties = first
.getBean(ArtemisProperties.class);
ArtemisProperties secondProperties = second
.getBean(ArtemisProperties.class);
assertThat(firstProperties.getEmbedded().getServerId())
.isLessThan(secondProperties.getEmbedded().getServerId());
DestinationChecker firstChecker = new DestinationChecker(first);
firstChecker.checkQueue("Queue1", true);
firstChecker.checkQueue("Queue2", true);
DestinationChecker secondChecker = new DestinationChecker(second);
secondChecker.checkQueue("Queue2", true);
secondChecker.checkQueue("Queue1", true);
});
ArtemisProperties firstProperties = first
.getBean(ArtemisProperties.class);
ArtemisProperties secondProperties = second
.getBean(ArtemisProperties.class);
assertThat(firstProperties.getEmbedded().getServerId())
.isLessThan(secondProperties.getEmbedded()
.getServerId());
DestinationChecker firstChecker = new DestinationChecker(
first);
firstChecker.checkQueue("Queue1", true);
firstChecker.checkQueue("Queue2", true);
DestinationChecker secondChecker = new DestinationChecker(
second);
secondChecker.checkQueue("Queue2", true);
secondChecker.checkQueue("Queue1", true);
});
});
}
@ -279,12 +281,13 @@ public class ArtemisAutoConfigurationTests {
// Do not start a specific one
"spring.artemis.embedded.enabled=false")
.run((secondContext) -> {
DestinationChecker firstChecker = new DestinationChecker(first);
firstChecker.checkQueue("Queue1", true);
DestinationChecker secondChecker = new DestinationChecker(
secondContext);
secondChecker.checkQueue("Queue1", true);
});
DestinationChecker firstChecker = new DestinationChecker(
first);
firstChecker.checkQueue("Queue1", true);
DestinationChecker secondChecker = new DestinationChecker(
secondContext);
secondChecker.checkQueue("Queue1", true);
});
});
}

View File

@ -77,12 +77,11 @@ public class LdapAutoConfigurationTests {
@Test
public void contextSourceWithExtraCustomization() {
this.contextRunner
.withPropertyValues("spring.ldap.urls:ldap://localhost:123",
"spring.ldap.username:root", "spring.ldap.password:secret",
"spring.ldap.anonymous-read-only:true",
"spring.ldap.base:cn=SpringDevelopers",
"spring.ldap.baseEnvironment.java.naming.security.authentication:DIGEST-MD5")
this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:123",
"spring.ldap.username:root", "spring.ldap.password:secret",
"spring.ldap.anonymous-read-only:true",
"spring.ldap.base:cn=SpringDevelopers",
"spring.ldap.baseEnvironment.java.naming.security.authentication:DIGEST-MD5")
.run((context) -> {
LdapContextSource contextSource = context
.getBean(LdapContextSource.class);

View File

@ -102,9 +102,8 @@ public class MongoReactiveAutoConfigurationTests {
@Test
public void customizerOverridesAutoConfig() {
this.contextRunner
.withPropertyValues(
"spring.data.mongodb.uri:mongodb://localhost/test?appname=auto-config")
this.contextRunner.withPropertyValues(
"spring.data.mongodb.uri:mongodb://localhost/test?appname=auto-config")
.withUserConfiguration(SimpleCustomizerConfig.class).run((context) -> {
assertThat(context).hasSingleBean(MongoClient.class);
MongoClient client = context.getBean(MongoClient.class);

View File

@ -63,10 +63,9 @@ public class CustomHibernateJpaAutoConfigurationTests {
@Test
public void namingStrategyDelegatorTakesPrecedence() {
this.contextRunner
.withPropertyValues(
"spring.jpa.properties.hibernate.ejb.naming_strategy_delegator:"
+ "org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator")
this.contextRunner.withPropertyValues(
"spring.jpa.properties.hibernate.ejb.naming_strategy_delegator:"
+ "org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator")
.run((context) -> {
JpaProperties bean = context.getBean(JpaProperties.class);
Map<String, Object> hibernateProperties = bean.getHibernateProperties(

View File

@ -131,10 +131,9 @@ public class HibernateJpaAutoConfigurationTests
@Test
public void testLiquibasePlusValidation() {
contextRunner()
.withPropertyValues("spring.datasource.initialization-mode:never",
"spring.liquibase.changeLog:classpath:db/changelog/db.changelog-city.yaml",
"spring.jpa.hibernate.ddl-auto:validate")
contextRunner().withPropertyValues("spring.datasource.initialization-mode:never",
"spring.liquibase.changeLog:classpath:db/changelog/db.changelog-city.yaml",
"spring.jpa.hibernate.ddl-auto:validate")
.withConfiguration(
AutoConfigurations.of(LiquibaseAutoConfiguration.class))
.run((context) -> assertThat(context).hasNotFailed());
@ -224,11 +223,10 @@ public class HibernateJpaAutoConfigurationTests
@Test
public void providerDisablesAutoCommitIsNotConfiguredIfPropertyIsSet() {
contextRunner()
.withPropertyValues(
"spring.datasource.type:" + HikariDataSource.class.getName(),
"spring.datasource.hikari.auto-commit:false",
"spring.jpa.properties.hibernate.connection.provider_disables_autocommit=false")
contextRunner().withPropertyValues(
"spring.datasource.type:" + HikariDataSource.class.getName(),
"spring.datasource.hikari.auto-commit:false",
"spring.jpa.properties.hibernate.connection.provider_disables_autocommit=false")
.run((context) -> {
Map<String, Object> jpaProperties = context
.getBean(LocalContainerEntityManagerFactoryBean.class)

View File

@ -74,10 +74,9 @@ public class JpaPropertiesTests {
@Test
public void hibernate5CustomNamingStrategies() {
this.contextRunner
.withPropertyValues(
"spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit",
"spring.jpa.hibernate.naming.physical-strategy:com.example.Physical")
this.contextRunner.withPropertyValues(
"spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit",
"spring.jpa.hibernate.naming.physical-strategy:com.example.Physical")
.run(assertJpaProperties((properties) -> {
Map<String, Object> hibernateProperties = properties
.getHibernateProperties(
@ -111,10 +110,9 @@ public class JpaPropertiesTests {
@Test
public void namingStrategyInstancesTakePrecedenceOverNamingStrategyProperties() {
this.contextRunner
.withPropertyValues(
"spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit",
"spring.jpa.hibernate.naming.physical-strategy:com.example.Physical")
this.contextRunner.withPropertyValues(
"spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit",
"spring.jpa.hibernate.naming.physical-strategy:com.example.Physical")
.run(assertJpaProperties((properties) -> {
ImplicitNamingStrategy implicitStrategy = mock(
ImplicitNamingStrategy.class);
@ -136,10 +134,9 @@ public class JpaPropertiesTests {
@Test
public void hibernatePropertiesCustomizerTakePrecedenceOverStrategyInstancesAndNamingStrategyProperties() {
this.contextRunner
.withPropertyValues(
"spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit",
"spring.jpa.hibernate.naming.physical-strategy:com.example.Physical")
this.contextRunner.withPropertyValues(
"spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit",
"spring.jpa.hibernate.naming.physical-strategy:com.example.Physical")
.run(assertJpaProperties((properties) -> {
ImplicitNamingStrategy implicitStrategy = mock(
ImplicitNamingStrategy.class);
@ -174,10 +171,9 @@ public class JpaPropertiesTests {
@Test
public void hibernate5CustomNamingStrategiesViaJpaProperties() {
this.contextRunner
.withPropertyValues(
"spring.jpa.properties.hibernate.implicit_naming_strategy:com.example.Implicit",
"spring.jpa.properties.hibernate.physical_naming_strategy:com.example.Physical")
this.contextRunner.withPropertyValues(
"spring.jpa.properties.hibernate.implicit_naming_strategy:com.example.Implicit",
"spring.jpa.properties.hibernate.physical_naming_strategy:com.example.Physical")
.run(assertJpaProperties((properties) -> {
Map<String, Object> hibernateProperties = properties
.getHibernateProperties(

View File

@ -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.
@ -187,9 +187,8 @@ public class OAuth2WebSecurityConfigurationTests {
private ClientRegistration getClientRegistration(String id, String userInfoUri) {
ClientRegistration.Builder builder = ClientRegistration
.withRegistrationId(id);
builder.clientName("foo").clientId("foo")
.clientAuthenticationMethod(
org.springframework.security.oauth2.core.ClientAuthenticationMethod.BASIC)
builder.clientName("foo").clientId("foo").clientAuthenticationMethod(
org.springframework.security.oauth2.core.ClientAuthenticationMethod.BASIC)
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
.scope("read").clientSecret("secret")
.redirectUriTemplate("http://redirect-uri.com")

View File

@ -46,8 +46,8 @@ import static org.mockito.Mockito.mock;
public class ReactiveUserDetailsServiceAutoConfigurationTests {
private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(ReactiveUserDetailsServiceAutoConfiguration.class));
.withConfiguration(AutoConfigurations
.of(ReactiveUserDetailsServiceAutoConfiguration.class));
@Test
public void configuresADefaultUser() {
@ -62,7 +62,8 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
@Test
public void doesNotConfigureDefaultUserIfUserDetailsServiceAvailable() {
this.contextRunner.withUserConfiguration(UserConfig.class, TestSecurityConfiguration.class)
this.contextRunner
.withUserConfiguration(UserConfig.class, TestSecurityConfiguration.class)
.run((context) -> {
ReactiveUserDetailsService userDetailsService = context
.getBean(ReactiveUserDetailsService.class);
@ -88,8 +89,7 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
@Test
public void userDetailsServiceWhenPasswordEncoderAbsentAndDefaultPassword() {
this.contextRunner
.withUserConfiguration(TestSecurityConfiguration.class)
this.contextRunner.withUserConfiguration(TestSecurityConfiguration.class)
.run(((context) -> {
MapReactiveUserDetailsService userDetailsService = context
.getBean(MapReactiveUserDetailsService.class);
@ -117,8 +117,7 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
private void testPasswordEncoding(Class<?> configClass, String providedPassword,
String expectedPassword) {
this.contextRunner
.withUserConfiguration(configClass)
this.contextRunner.withUserConfiguration(configClass)
.withPropertyValues("spring.security.user.password=" + providedPassword)
.run(((context) -> {
MapReactiveUserDetailsService userDetailsService = context

View File

@ -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,8 +38,11 @@ public class WebFluxSecurityConfigurationTests {
@Test
public void backsOffWhenWebFilterChainProxyBeanPresent() {
this.contextRunner.withUserConfiguration(WebFilterChainProxyConfiguration.class, WebFluxSecurityConfiguration.class)
.run(context -> assertThat(context).doesNotHaveBean(WebFluxSecurityConfiguration.class));
this.contextRunner
.withUserConfiguration(WebFilterChainProxyConfiguration.class,
WebFluxSecurityConfiguration.class)
.run(context -> assertThat(context)
.doesNotHaveBean(WebFluxSecurityConfiguration.class));
}
@Test

View File

@ -78,14 +78,15 @@ public class SecurityAutoConfigurationTests {
@Test
public void testDefaultFilterOrderWithSecurityAdapter() {
this.contextRunner.withConfiguration(AutoConfigurations.of(WebSecurity.class,
SecurityFilterAutoConfiguration.class)).run(
(context) -> assertThat(context
.getBean("securityFilterChainRegistration",
DelegatingFilterProxyRegistrationBean.class)
.getOrder()).isEqualTo(
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER
- 100));
this.contextRunner
.withConfiguration(AutoConfigurations.of(WebSecurity.class,
SecurityFilterAutoConfiguration.class))
.run((context) -> assertThat(context
.getBean("securityFilterChainRegistration",
DelegatingFilterProxyRegistrationBean.class)
.getOrder()).isEqualTo(
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER
- 100));
}
@Test
@ -118,14 +119,15 @@ public class SecurityAutoConfigurationTests {
@Test
public void testDefaultFilterOrder() {
this.contextRunner.withConfiguration(
AutoConfigurations.of(SecurityFilterAutoConfiguration.class)).run(
(context) -> assertThat(context
.getBean("securityFilterChainRegistration",
DelegatingFilterProxyRegistrationBean.class)
.getOrder()).isEqualTo(
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER
- 100));
this.contextRunner
.withConfiguration(
AutoConfigurations.of(SecurityFilterAutoConfiguration.class))
.run((context) -> assertThat(context
.getBean("securityFilterChainRegistration",
DelegatingFilterProxyRegistrationBean.class)
.getOrder()).isEqualTo(
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER
- 100));
}
@Test
@ -137,7 +139,7 @@ public class SecurityAutoConfigurationTests {
(context) -> assertThat(context
.getBean("securityFilterChainRegistration",
DelegatingFilterProxyRegistrationBean.class)
.getOrder()).isEqualTo(12345));
.getOrder()).isEqualTo(12345));
}
@Test

View File

@ -52,8 +52,8 @@ import static org.mockito.Mockito.mock;
public class UserDetailsServiceAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withUserConfiguration(TestSecurityConfiguration.class)
.withConfiguration(AutoConfigurations.of(UserDetailsServiceAutoConfiguration.class));
.withUserConfiguration(TestSecurityConfiguration.class).withConfiguration(
AutoConfigurations.of(UserDetailsServiceAutoConfiguration.class));
@Rule
public OutputCapture outputCapture = new OutputCapture();
@ -115,7 +115,8 @@ public class UserDetailsServiceAutoConfigurationTests {
@Test
public void userDetailsServiceWhenPasswordEncoderAbsentAndDefaultPassword() {
this.contextRunner.withUserConfiguration(TestSecurityConfiguration.class).run(((context) -> {
this.contextRunner.withUserConfiguration(TestSecurityConfiguration.class)
.run(((context) -> {
InMemoryUserDetailsManager userDetailsService = context
.getBean(InMemoryUserDetailsManager.class);
String password = userDetailsService.loadUserByUsername("user")
@ -150,8 +151,7 @@ public class UserDetailsServiceAutoConfigurationTests {
private void testPasswordEncoding(Class<?> configClass, String providedPassword,
String expectedPassword) {
this.contextRunner
.withUserConfiguration(configClass)
this.contextRunner.withUserConfiguration(configClass)
.withPropertyValues("spring.security.user.password=" + providedPassword)
.run(((context) -> {
InMemoryUserDetailsManager userDetailsService = context

View File

@ -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.
@ -117,10 +117,9 @@ public class SessionAutoConfigurationJdbcTests
@Test
public void customTableName() {
this.contextRunner
.withPropertyValues("spring.session.store-type=jdbc",
"spring.session.jdbc.table-name=FOO_BAR",
"spring.session.jdbc.schema=classpath:session/custom-schema-h2.sql")
this.contextRunner.withPropertyValues("spring.session.store-type=jdbc",
"spring.session.jdbc.table-name=FOO_BAR",
"spring.session.jdbc.schema=classpath:session/custom-schema-h2.sql")
.run((context) -> {
JdbcOperationsSessionRepository repository = validateSessionRepository(
context, JdbcOperationsSessionRepository.class);

View File

@ -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.
@ -202,11 +202,9 @@ public class MultipartAutoConfigurationTests {
private void verify404() throws Exception {
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
ClientHttpRequest request = requestFactory
.createRequest(
new URI("http://localhost:"
+ this.context.getWebServer().getPort() + "/"),
HttpMethod.GET);
ClientHttpRequest request = requestFactory.createRequest(new URI(
"http://localhost:" + this.context.getWebServer().getPort() + "/"),
HttpMethod.GET);
ClientHttpResponse response = request.execute();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}

View File

@ -880,7 +880,7 @@ public class WebMvcAutoConfigurationTests {
@Override
protected void renderMergedOutputModel(Map<String, Object> model,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
throws Exception {
response.getOutputStream().write("Hello World".getBytes());
}

View File

@ -205,7 +205,7 @@ public class WelcomePageHandlerMappingTests {
@Override
protected void renderMergedOutputModel(Map<String, Object> model,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
throws Exception {
response.getWriter().print(name + " template");
}

View File

@ -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.
@ -259,7 +259,7 @@ public class BasicErrorControllerIntegrationTests {
@Override
protected void renderMergedOutputModel(Map<String, Object> model,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
throws Exception {
response.getWriter().write("ERROR_BEAN");
}
};

View File

@ -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.
@ -153,7 +153,7 @@ public class BasicErrorControllerMockMvcTests {
@Override
protected void renderMergedOutputModel(Map<String, Object> model,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
throws Exception {
response.getWriter().write("ERROR_BEAN");
}
};

View File

@ -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.
@ -183,7 +183,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private void writeJar(File file, Class<?>[] compiledClasses,
List<MatchedResource> classpathEntries, List<URL> dependencies)
throws FileNotFoundException, IOException, URISyntaxException {
throws FileNotFoundException, IOException, URISyntaxException {
final List<Library> libraries;
try (JarWriter writer = new JarWriter(file)) {
addManifest(writer, compiledClasses);

View File

@ -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.
@ -89,7 +89,7 @@ public abstract class CompilerAutoConfiguration {
*/
public void apply(GroovyClassLoader loader, GroovyCompilerConfiguration configuration,
GeneratorContext generatorContext, SourceUnit source, ClassNode classNode)
throws CompilationFailedException {
throws CompilationFailedException {
}
}

View File

@ -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,9 +38,8 @@ public class SpringSecurityCompilerAutoConfiguration extends CompilerAutoConfigu
@Override
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies
.ifAnyMissingClasses(
"org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity")
dependencies.ifAnyMissingClasses(
"org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity")
.add("spring-boot-starter-security");
}

View File

@ -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.
@ -53,7 +53,7 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
@Override
public void apply(GroovyClassLoader loader, GroovyCompilerConfiguration configuration,
GeneratorContext generatorContext, SourceUnit source, ClassNode classNode)
throws CompilationFailedException {
throws CompilationFailedException {
if (!AstUtils.hasAtLeastOneAnnotation(classNode, "RunWith")) {
AnnotationNode runWith = new AnnotationNode(ClassHelper.make("RunWith"));
runWith.addMember("value",

View File

@ -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,9 +38,8 @@ public class SpringWebsocketCompilerAutoConfiguration extends CompilerAutoConfig
@Override
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies
.ifAnyMissingClasses(
"org.springframework.web.socket.config.annotation.EnableWebSocket")
dependencies.ifAnyMissingClasses(
"org.springframework.web.socket.config.annotation.EnableWebSocket")
.add("spring-boot-starter-websocket").add("spring-messaging");
}

View File

@ -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.
@ -93,9 +93,8 @@ public class AetherGrapeEngine implements GrapeEngine {
private ProgressReporter getProgressReporter(DefaultRepositorySystemSession session,
boolean quiet) {
String progressReporter = (quiet ? "none"
: System.getProperty(
"org.springframework.boot.cli.compiler.grape.ProgressReporter"));
String progressReporter = (quiet ? "none" : System.getProperty(
"org.springframework.boot.cli.compiler.grape.ProgressReporter"));
if ("detail".equals(progressReporter)
|| Boolean.getBoolean("groovy.grape.report.downloads")) {
return new DetailedProgressReporter(session, System.out);

View File

@ -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.
@ -105,9 +105,8 @@ public class DependencyResolutionContext {
aetherDependency);
}
this.dependencyManagement = this.dependencyManagement == null
? dependencyManagement
: new CompositeDependencyManagement(dependencyManagement,
this.dependencyManagement);
? dependencyManagement : new CompositeDependencyManagement(
dependencyManagement, this.dependencyManagement);
this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
this.dependencyManagement);
}

View File

@ -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.
@ -47,8 +47,8 @@ public abstract class GroovyTemplate {
}
public static String template(TemplateEngine engine, String name,
Map<String, ?> model) throws IOException, CompilationFailedException,
ClassNotFoundException {
Map<String, ?> model)
throws IOException, CompilationFailedException, ClassNotFoundException {
Writable writable = getTemplate(engine, name).make(model);
StringWriter result = new StringWriter();
writable.writeTo(result);

View File

@ -60,8 +60,8 @@ public class RepositoryConfigurationFactoryTests {
@Test
public void activeByDefaultProfileRepositories() {
TestPropertyValues
.of("user.home:src/test/resources/maven-settings/active-profile-repositories")
TestPropertyValues.of(
"user.home:src/test/resources/maven-settings/active-profile-repositories")
.applyToSystemProperties(() -> {
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
.createDefaultRepositoryConfiguration();
@ -74,10 +74,9 @@ public class RepositoryConfigurationFactoryTests {
@Test
public void activeByPropertyProfileRepositories() {
TestPropertyValues
.of("user.home:src/test/resources/maven-settings/active-profile-repositories",
"foo:bar")
.applyToSystemProperties(() -> {
TestPropertyValues.of(
"user.home:src/test/resources/maven-settings/active-profile-repositories",
"foo:bar").applyToSystemProperties(() -> {
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
.createDefaultRepositoryConfiguration();
assertRepositoryConfiguration(repositoryConfiguration, "central",
@ -89,10 +88,9 @@ public class RepositoryConfigurationFactoryTests {
@Test
public void interpolationProfileRepositories() {
TestPropertyValues
.of("user.home:src/test/resources/maven-settings/active-profile-repositories",
"interpolate:true")
.applyToSystemProperties(() -> {
TestPropertyValues.of(
"user.home:src/test/resources/maven-settings/active-profile-repositories",
"interpolate:true").applyToSystemProperties(() -> {
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
.createDefaultRepositoryConfiguration();
assertRepositoryConfiguration(repositoryConfiguration, "central",

View File

@ -165,8 +165,7 @@ public class LocalDevToolsAutoConfiguration {
private final OptionalLiveReloadServer liveReloadServer;
LiveReloadServerEventListener(
OptionalLiveReloadServer liveReloadServer) {
LiveReloadServerEventListener(OptionalLiveReloadServer liveReloadServer) {
this.liveReloadServer = liveReloadServer;
}

View File

@ -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.
@ -50,7 +50,7 @@ public class RestTemplateProxyCustomizationExample {
@Override
public HttpHost determineProxy(HttpHost target,
HttpRequest request, HttpContext context)
throws HttpException {
throws HttpException {
if (target.getHostName().equals("192.168.0.5")) {
return null;
}

View File

@ -35,7 +35,7 @@ public class UserServiceAutoConfigurationTests {
// tag::runner[]
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(UserServiceAutoConfiguration.class));
// end::runner[]
// end::runner[]
// tag::test-env[]
@Test

View File

@ -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.
@ -93,7 +93,7 @@ public abstract class AnnotationCustomizableTypeExcludeFilter extends TypeExclud
@SuppressWarnings("unchecked")
protected final boolean isTypeOrAnnotated(MetadataReader metadataReader,
MetadataReaderFactory metadataReaderFactory, Class<?> type)
throws IOException {
throws IOException {
AnnotationTypeFilter annotationFilter = new AnnotationTypeFilter(
(Class<? extends Annotation>) type);
AssignableTypeFilter typeFilter = new AssignableTypeFilter(type);

View File

@ -43,9 +43,8 @@ class RestDocsRestAssuredBuilderCustomizer implements InitializingBean {
public void afterPropertiesSet() throws Exception {
PropertyMapper map = PropertyMapper.get();
String host = this.properties.getUriHost();
map.from(this.properties::getUriScheme)
.when((scheme) -> StringUtils.hasText(scheme)
&& StringUtils.hasText(host))
map.from(this.properties::getUriScheme).when(
(scheme) -> StringUtils.hasText(scheme) && StringUtils.hasText(host))
.to((scheme) -> this.delegate.baseUri(scheme + "://" + host));
map.from(this.properties::getUriPort).whenNonNull().to(this.delegate::port);
}

View File

@ -30,7 +30,8 @@ import org.springframework.context.annotation.Import;
*/
@Configuration
@ConditionalOnProperty(prefix = "spring.test.mockmvc", name = "secure", havingValue = "true", matchIfMissing = true)
@Import({ SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class, MockMvcSecurityConfiguration.class })
@Import({ SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class,
MockMvcSecurityConfiguration.class })
public class MockMvcSecurityAutoConfiguration {
}

View File

@ -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.
@ -58,13 +58,13 @@ public class TestDatabaseAutoConfigurationTests {
this.contextRunner
.withUserConfiguration(ExistingDataSourceConfiguration.class)
.run((secondContext) -> {
DataSource anotherDatasource = secondContext
.getBean(DataSource.class);
JdbcTemplate anotherJdbcTemplate = new JdbcTemplate(
anotherDatasource);
anotherJdbcTemplate
.execute("create table example (id int, name varchar);");
});
DataSource anotherDatasource = secondContext
.getBean(DataSource.class);
JdbcTemplate anotherJdbcTemplate = new JdbcTemplate(
anotherDatasource);
anotherJdbcTemplate.execute(
"create table example (id int, name varchar);");
});
});
}

View File

@ -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.
@ -53,7 +53,7 @@ public class ExampleJsonComponent {
@Override
protected ExampleCustomObject deserializeObject(JsonParser jsonParser,
DeserializationContext context, ObjectCodec codec, JsonNode tree)
throws IOException {
throws IOException {
return new ExampleCustomObject(
nullSafeValue(tree.get("value"), String.class));
}

View File

@ -363,7 +363,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
@Override
public PropertyValues postProcessPropertyValues(PropertyValues pvs,
PropertyDescriptor[] pds, final Object bean, String beanName)
throws BeansException {
throws BeansException {
ReflectionUtils.doWithFields(bean.getClass(),
(field) -> postProcessField(bean, field));
return pvs;

View File

@ -500,7 +500,7 @@ public class TestRestTemplate {
*/
public <T> ResponseEntity<T> postForEntity(String url, Object request,
Class<T> responseType, Map<String, ?> urlVariables)
throws RestClientException {
throws RestClientException {
return this.restTemplate.postForEntity(url, request, responseType, urlVariables);
}
@ -743,7 +743,7 @@ public class TestRestTemplate {
*/
public <T> ResponseEntity<T> exchange(String url, HttpMethod method,
HttpEntity<?> requestEntity, Class<T> responseType, Object... urlVariables)
throws RestClientException {
throws RestClientException {
return this.restTemplate.exchange(url, method, requestEntity, responseType,
urlVariables);
}
@ -788,7 +788,7 @@ public class TestRestTemplate {
*/
public <T> ResponseEntity<T> exchange(URI url, HttpMethod method,
HttpEntity<?> requestEntity, Class<T> responseType)
throws RestClientException {
throws RestClientException {
return this.restTemplate.exchange(applyRootUriIfNecessary(url), method,
requestEntity, responseType);
}
@ -871,7 +871,7 @@ public class TestRestTemplate {
*/
public <T> ResponseEntity<T> exchange(URI url, HttpMethod method,
HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
throws RestClientException {
throws RestClientException {
return this.restTemplate.exchange(applyRootUriIfNecessary(url), method,
requestEntity, responseType);
}
@ -939,7 +939,7 @@ public class TestRestTemplate {
*/
public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor, Object... urlVariables)
throws RestClientException {
throws RestClientException {
return this.restTemplate.execute(url, method, requestCallback, responseExtractor,
urlVariables);
}
@ -963,7 +963,7 @@ public class TestRestTemplate {
*/
public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor, Map<String, ?> urlVariables)
throws RestClientException {
throws RestClientException {
return this.restTemplate.execute(url, method, requestCallback, responseExtractor,
urlVariables);
}

View File

@ -52,8 +52,8 @@ import java.util.List;
* Each stringer may be used to encode a single top level value. Instances of this class
* are not thread safe. Although this class is nonfinal, it was not designed for
* inheritance and should not be subclassed. In particular, self-use by overrideable
* methods is not specified. See <i>Effective Java</i> Item 17,
* "Design and Document or inheritance or else prohibit it" for further information.
* methods is not specified. See <i>Effective Java</i> Item 17, "Design and Document or
* inheritance or else prohibit it" for further information.
*/
public class JSONStringer {

View File

@ -54,8 +54,8 @@ package org.springframework.boot.configurationprocessor.json;
* Each tokener may be used to parse a single JSON string. Instances of this class are not
* thread safe. Although this class is nonfinal, it was not designed for inheritance and
* should not be subclassed. In particular, self-use by overrideable methods is not
* specified. See <i>Effective Java</i> Item 17,
* "Design and Document or inheritance or else prohibit it" for further information.
* specified. See <i>Effective Java</i> Item 17, "Design and Document or inheritance or
* else prohibit it" for further information.
*/
public class JSONTokener {

View File

@ -349,10 +349,10 @@ public class ConfigurationMetadataAnnotationProcessorTests {
.fromSource(
org.springframework.boot.configurationsample.method.DeprecatedClassMethodConfig.Foo.class)
.withDeprecation(null, null));
assertThat(metadata).has(
Metadata.withProperty("foo.flag", Boolean.class).withDefaultValue(false)
.fromSource(
org.springframework.boot.configurationsample.method.DeprecatedClassMethodConfig.Foo.class)
assertThat(metadata).has(Metadata.withProperty("foo.flag", Boolean.class)
.withDefaultValue(false)
.fromSource(
org.springframework.boot.configurationsample.method.DeprecatedClassMethodConfig.Foo.class)
.withDeprecation(null, null));
}
@ -419,18 +419,14 @@ public class ConfigurationMetadataAnnotationProcessorTests {
ConfigurationMetadata metadata = compile(ClassWithNestedProperties.class);
assertThat(metadata).has(Metadata.withGroup("nestedChildProps")
.fromSource(ClassWithNestedProperties.NestedChildClass.class));
assertThat(metadata)
.has(Metadata
.withProperty("nestedChildProps.child-class-property",
Integer.class)
.fromSource(ClassWithNestedProperties.NestedChildClass.class)
.withDefaultValue(20));
assertThat(metadata)
.has(Metadata
.withProperty("nestedChildProps.parent-class-property",
Integer.class)
.fromSource(ClassWithNestedProperties.NestedChildClass.class)
.withDefaultValue(10));
assertThat(metadata).has(Metadata
.withProperty("nestedChildProps.child-class-property", Integer.class)
.fromSource(ClassWithNestedProperties.NestedChildClass.class)
.withDefaultValue(20));
assertThat(metadata).has(Metadata
.withProperty("nestedChildProps.parent-class-property", Integer.class)
.fromSource(ClassWithNestedProperties.NestedChildClass.class)
.withDefaultValue(10));
}
@Test
@ -830,14 +826,11 @@ public class ConfigurationMetadataAnnotationProcessorTests {
@Test
public void mergingOfHintWithProvider() throws Exception {
writeAdditionalHints(
new ItemHint("simple.theName",
Collections
.emptyList(),
Arrays.asList(
new ItemHint.ValueProvider("first",
Collections.singletonMap("target", "org.foo")),
new ItemHint.ValueProvider("second", null))));
writeAdditionalHints(new ItemHint("simple.theName", Collections.emptyList(),
Arrays.asList(
new ItemHint.ValueProvider("first",
Collections.singletonMap("target", "org.foo")),
new ItemHint.ValueProvider("second", null))));
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata).has(Metadata.withProperty("simple.the-name", String.class)
.fromSource(SimpleProperties.class)

View File

@ -32,7 +32,7 @@ public class EnabledEndpoint {
}
@ReadOperation
public String retrieve(String parameter, Integer anotherParameter) {
public String retrieve(String parameter, Integer anotherParameter) {
return "not a main read operation";
}

View File

@ -177,8 +177,8 @@ final class JavaPluginAction implements PluginApplicationAction {
SourceSet sourceSet) {
String locations = StringUtils
.collectionToCommaDelimitedString(sourceSet.getResources().getSrcDirs());
compile.getOptions().getCompilerArgs()
.add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations="
compile.getOptions().getCompilerArgs().add(
"-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations="
+ locations);
}

View File

@ -57,7 +57,8 @@ public class BuildInfo extends ConventionTask {
new File(getDestinationDir(), "build-info.properties"))
.writeBuildProperties(new ProjectDetails(
this.properties.getGroup(),
this.properties.getArtifact() == null ? "unspecified"
this.properties.getArtifact() == null
? "unspecified"
: this.properties.getArtifact(),
this.properties.getVersion(),
this.properties.getName(), coerceToStringValues(

View File

@ -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.
@ -50,8 +50,8 @@ public class BootWar extends War implements BootArchive {
*/
public BootWar() {
getWebInf().into("lib-provided",
(copySpec) -> copySpec
.from((Callable<Iterable<File>>) () -> this.providedClasspath == null
(copySpec) -> copySpec.from(
(Callable<Iterable<File>>) () -> this.providedClasspath == null
? Collections.emptyList() : this.providedClasspath));
}

Some files were not shown because too many files have changed in this diff Show More