Browse Source

Polish

pull/9011/merge
Phillip Webb 9 years ago
parent
commit
45dd9f7144
  1. 24
      spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/AuditEventsMvcEndpointTests.java
  2. 3
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/ReactiveCassandraDataAutoConfiguration.java
  3. 4
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/ReactiveCassandraRepositoriesAutoConfiguration.java
  4. 2
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorProperties.java
  5. 2
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
  6. 42
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizer.java
  7. 18
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorAttributes.java
  8. 3
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/alt/cassandra/ReactiveCityCassandraRepository.java
  9. 3
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/ReactiveCassandraRepositoriesAutoConfigurationTests.java
  10. 8
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java
  11. 14
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java
  12. 2
      spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
  13. 4
      spring-boot-docs/src/main/asciidoc/howto.adoc
  14. 2
      spring-boot-docs/src/main/asciidoc/index.adoc
  15. 5
      spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java
  16. 2
      spring-boot-samples/spring-boot-sample-data-rest/src/test/java/sample/data/rest/SampleDataRestApplicationTests.java
  17. 2
      spring-boot-samples/spring-boot-sample-flyway/src/test/java/sample/flyway/SampleFlywayApplicationTests.java
  18. 2
      spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/SampleJpaApplicationTests.java
  19. 2
      spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/repository/JpaNoteRepositoryIntegrationTests.java
  20. 2
      spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/repository/JpaTagRepositoryIntegrationTests.java

24
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/AuditEventsMvcEndpointTests.java

@ -74,39 +74,39 @@ public class AuditEventsMvcEndpointTests { @@ -74,39 +74,39 @@ public class AuditEventsMvcEndpointTests {
@Test
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000"))
.andExpect(status().isOk())
this.mvc.perform(get("/application/auditevents").param("after",
"2016-11-01T10:00:00+0000")).andExpect(status().isOk())
.andExpect(header().string("Content-Type",
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
}
@Test
public void contentTypeCanBeApplicationJson() throws Exception {
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000")
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk())
.andExpect(header().string("Content-Type",
this.mvc.perform(
get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000")
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk()).andExpect(header().string("Content-Type",
MediaType.APPLICATION_JSON_UTF8_VALUE));
}
@Test
public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception {
this.context.getBean(AuditEventsMvcEndpoint.class).setEnabled(false);
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000"))
.andExpect(status().isNotFound());
this.mvc.perform(get("/application/auditevents").param("after",
"2016-11-01T10:00:00+0000")).andExpect(status().isNotFound());
}
@Test
public void invokeFilterByDateAfter() throws Exception {
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T13:00:00+0000"))
.andExpect(status().isOk())
this.mvc.perform(get("/application/auditevents").param("after",
"2016-11-01T13:00:00+0000")).andExpect(status().isOk())
.andExpect(content().string("{\"events\":[]}"));
}
@Test
public void invokeFilterByPrincipalAndDateAfter() throws Exception {
this.mvc.perform(get("/application/auditevents").param("principal", "user").param("after",
"2016-11-01T10:00:00+0000"))
this.mvc.perform(get("/application/auditevents").param("principal", "user")
.param("after", "2016-11-01T10:00:00+0000"))
.andExpect(status().isOk())
.andExpect(content().string(
containsString("\"principal\":\"user\",\"type\":\"login\"")))

3
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/ReactiveCassandraDataAutoConfiguration.java

@ -63,8 +63,7 @@ public class ReactiveCassandraDataAutoConfiguration { @@ -63,8 +63,7 @@ public class ReactiveCassandraDataAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public ReactiveCassandraTemplate reactiveCassandraTemplate(
ReactiveSession reactiveCassandraSession,
CassandraConverter converter) {
ReactiveSession reactiveCassandraSession, CassandraConverter converter) {
return new ReactiveCassandraTemplate(reactiveCassandraSession, converter);
}

4
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/ReactiveCassandraRepositoriesAutoConfiguration.java

@ -29,8 +29,8 @@ import org.springframework.data.cassandra.repository.config.EnableReactiveCassan @@ -29,8 +29,8 @@ import org.springframework.data.cassandra.repository.config.EnableReactiveCassan
import org.springframework.data.cassandra.repository.support.ReactiveCassandraRepositoryFactoryBean;
/**
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Cassandra
* Reactive Repositories.
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Cassandra Reactive
* Repositories.
*
* @author Eddú Meléndez
* @since 2.0.0

2
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorProperties.java

@ -35,7 +35,7 @@ public class ErrorProperties { @@ -35,7 +35,7 @@ public class ErrorProperties {
private String path = "/error";
/**
* Set whether to include the "exception" attribute.
* Include the "exception" attribute.
*/
private boolean includeException;

2
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java

@ -959,7 +959,7 @@ public class ServerProperties { @@ -959,7 +959,7 @@ public class ServerProperties {
/**
* Number of days before rotated log files are deleted.
*/
private int retentionPeriod = 31; // no days
private int retentionPeriod = 31; // no days
/**
* Append to log.

42
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizer.java

@ -544,7 +544,7 @@ public class DefaultServletWebServerFactoryCustomizer @@ -544,7 +544,7 @@ public class DefaultServletWebServerFactoryCustomizer
serverProperties.getConnectionTimeout());
}
if (jettyProperties.getAccesslog().isEnabled()) {
customizeAccesslog(factory, jettyProperties.getAccesslog());
customizeAccessLog(factory, jettyProperties.getAccesslog());
}
}
@ -643,32 +643,32 @@ public class DefaultServletWebServerFactoryCustomizer @@ -643,32 +643,32 @@ public class DefaultServletWebServerFactoryCustomizer
});
}
private static void customizeAccesslog(JettyServletWebServerFactory factory,
final ServerProperties.Jetty.Accesslog accesslog) {
private static void customizeAccessLog(JettyServletWebServerFactory factory,
final ServerProperties.Jetty.Accesslog properties) {
factory.addServerCustomizers(server -> {
NCSARequestLog requestLog = new NCSARequestLog();
if (accesslog.getFilename() != null) {
requestLog.setFilename(accesslog.getFilename());
NCSARequestLog log = new NCSARequestLog();
if (properties.getFilename() != null) {
log.setFilename(properties.getFilename());
}
if (accesslog.getFileDateFormat() != null) {
requestLog.setFilenameDateFormat(accesslog.getFileDateFormat());
if (properties.getFileDateFormat() != null) {
log.setFilenameDateFormat(properties.getFileDateFormat());
}
requestLog.setRetainDays(accesslog.getRetentionPeriod());
requestLog.setAppend(accesslog.isAppend());
requestLog.setExtended(accesslog.isExtendedFormat());
if (accesslog.getDateFormat() != null) {
requestLog.setLogDateFormat(accesslog.getDateFormat());
log.setRetainDays(properties.getRetentionPeriod());
log.setAppend(properties.isAppend());
log.setExtended(properties.isExtendedFormat());
if (properties.getDateFormat() != null) {
log.setLogDateFormat(properties.getDateFormat());
}
if (accesslog.getLocale() != null) {
requestLog.setLogLocale(accesslog.getLocale());
if (properties.getLocale() != null) {
log.setLogLocale(properties.getLocale());
}
if (accesslog.getTimeZone() != null) {
requestLog.setLogTimeZone(accesslog.getTimeZone().getID());
if (properties.getTimeZone() != null) {
log.setLogTimeZone(properties.getTimeZone().getID());
}
requestLog.setLogCookies(accesslog.isLogCookies());
requestLog.setLogServer(accesslog.isLogServer());
requestLog.setLogLatency(accesslog.isLogLatency());
server.setRequestLog(requestLog);
log.setLogCookies(properties.isLogCookies());
log.setLogServer(properties.isLogServer());
log.setLogLatency(properties.isLogLatency());
server.setRequestLog(log);
});
}
}

18
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorAttributes.java

@ -65,22 +65,22 @@ public class DefaultErrorAttributes @@ -65,22 +65,22 @@ public class DefaultErrorAttributes
private static final String ERROR_ATTRIBUTE = DefaultErrorAttributes.class.getName()
+ ".ERROR";
private boolean includeException;
private final boolean includeException;
/**
* Create a new {@link DefaultErrorAttributes} instance.
* @param includeException whether to include the "exception" attribute
* Create a new {@link DefaultErrorAttributes} instance that does not include the
* "exception" attribute.
*/
public DefaultErrorAttributes(boolean includeException) {
this.includeException = includeException;
public DefaultErrorAttributes() {
this(false);
}
/**
* Create a new {@link DefaultErrorAttributes} instance that does not
* include the "exception" attribute.
* Create a new {@link DefaultErrorAttributes} instance.
* @param includeException whether to include the "exception" attribute
*/
public DefaultErrorAttributes() {
this(false);
public DefaultErrorAttributes(boolean includeException) {
this.includeException = includeException;
}
@Override

3
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/alt/cassandra/ReactiveCityCassandraRepository.java

@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.data.alt.cassandra; @@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.data.alt.cassandra;
import org.springframework.boot.autoconfigure.data.cassandra.city.City;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
public interface ReactiveCityCassandraRepository extends ReactiveCrudRepository<City, Long> {
public interface ReactiveCityCassandraRepository
extends ReactiveCrudRepository<City, Long> {
}

3
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/ReactiveCassandraRepositoriesAutoConfigurationTests.java

@ -79,7 +79,8 @@ public class ReactiveCassandraRepositoriesAutoConfigurationTests { @@ -79,7 +79,8 @@ public class ReactiveCassandraRepositoriesAutoConfigurationTests {
@Test
public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
load(TestExcludeConfiguration.class, CustomizedConfiguration.class);
assertThat(this.context.getBean(ReactiveCityCassandraRepository.class)).isNotNull();
assertThat(this.context.getBean(ReactiveCityCassandraRepository.class))
.isNotNull();
assertThat(getInitialEntitySet()).hasSize(1).containsOnly(City.class);
}

8
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java

@ -412,7 +412,7 @@ public class DefaultServletWebServerFactoryCustomizerTests { @@ -412,7 +412,7 @@ public class DefaultServletWebServerFactoryCustomizerTests {
embeddedFactory.start();
try {
assertThat(embeddedFactory.getTomcat().getConnector().getMaxPostSize())
.isEqualTo(-1);
.isEqualTo(-1);
}
finally {
embeddedFactory.stop();
@ -556,11 +556,11 @@ public class DefaultServletWebServerFactoryCustomizerTests { @@ -556,11 +556,11 @@ public class DefaultServletWebServerFactoryCustomizerTests {
@Test
public void jettyAccessLogCanBeCustomized() throws IOException {
File f = File.createTempFile("jetty_log", ".log");
File logFile = File.createTempFile("jetty_log", ".log");
JettyServletWebServerFactory factory = new JettyServletWebServerFactory(0);
Map<String, String> map = new HashMap<>();
map.put("server.jetty.accesslog.enabled", "true");
map.put("server.jetty.accesslog.filename", f.getAbsolutePath());
map.put("server.jetty.accesslog.filename", logFile.getAbsolutePath());
map.put("server.jetty.accesslog.file-date-format", "yyyy-MM-dd");
map.put("server.jetty.accesslog.retention-period", "42");
map.put("server.jetty.accesslog.append", "true");
@ -576,7 +576,7 @@ public class DefaultServletWebServerFactoryCustomizerTests { @@ -576,7 +576,7 @@ public class DefaultServletWebServerFactoryCustomizerTests {
JettyWebServer webServer = (JettyWebServer) factory.getWebServer();
NCSARequestLog requestLog = getNCSARequestLog(webServer);
try {
assertThat(requestLog.getFilename()).isEqualTo(f.getAbsolutePath());
assertThat(requestLog.getFilename()).isEqualTo(logFile.getAbsolutePath());
assertThat(requestLog.getFilenameDateFormat()).isEqualTo("yyyy-MM-dd");
assertThat(requestLog.getRetainDays()).isEqualTo(42);
assertThat(requestLog.isAppend()).isTrue();

14
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java

@ -100,8 +100,8 @@ public class BasicErrorControllerIntegrationTests { @@ -100,8 +100,8 @@ public class BasicErrorControllerIntegrationTests {
load();
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity(createUrl("?trace=true"), Map.class);
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error",
null, "Expected!", "/");
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error", null,
"Expected!", "/");
assertThat(entity.getBody().containsKey("trace")).isFalse();
}
@ -123,8 +123,8 @@ public class BasicErrorControllerIntegrationTests { @@ -123,8 +123,8 @@ public class BasicErrorControllerIntegrationTests {
load("--server.error.include-stacktrace=never");
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity(createUrl("?trace=true"), Map.class);
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error",
null, "Expected!", "/");
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error", null,
"Expected!", "/");
assertThat(entity.getBody().containsKey("trace")).isFalse();
}
@ -134,8 +134,8 @@ public class BasicErrorControllerIntegrationTests { @@ -134,8 +134,8 @@ public class BasicErrorControllerIntegrationTests {
load("--server.error.include-stacktrace=always");
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity(createUrl("?trace=false"), Map.class);
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error",
null, "Expected!", "/");
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error", null,
"Expected!", "/");
assertThat(entity.getBody().containsKey("trace")).isTrue();
}
@ -272,7 +272,7 @@ public class BasicErrorControllerIntegrationTests { @@ -272,7 +272,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");
}
};

2
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

@ -153,7 +153,7 @@ content into your application; rather pick only the properties that you need. @@ -153,7 +153,7 @@ content into your application; rather pick only the properties that you need.
server.connection-timeout= # Time in milliseconds that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
server.display-name=application # Display name of the application.
server.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.error.include-exception=false # Set whether to include the "exception" attribute.
server.error.include-exception=false # Include the "exception" attribute.
server.error.include-stacktrace=never # When to include a "stacktrace" attribute.
server.error.path=/error # Path of the error controller.
server.error.whitelabel.enabled=true # Enable the default error page displayed in browsers in case of a server error.

4
spring-boot-docs/src/main/asciidoc/howto.adoc

@ -640,7 +640,7 @@ Access logs can be configured for Tomcat, Undertow and Jetty via their respectiv @@ -640,7 +640,7 @@ Access logs can be configured for Tomcat, Undertow and Jetty via their respectiv
namespaces.
For instance, the following logs access on Tomcat with a
https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Access_Logging[custom pattern].
{tomcat-documentation}/config/valve.html#Access_Logging[custom pattern].
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
----
@ -674,7 +674,7 @@ Finally, access logging for jetty can also be configured that way: @@ -674,7 +674,7 @@ Finally, access logging for jetty can also be configured that way:
----
By default, logs will be redirected to `System.err`. For more details, please refer to
https://www.eclipse.org/jetty/documentation/9.3.x/configuring-jetty-request-logs.html[the documentation].
{jetty-documentation}/configuring-jetty-request-logs.html[the documentation].

2
spring-boot-docs/src/main/asciidoc/index.adoc

@ -52,6 +52,8 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson; @@ -52,6 +52,8 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
:ant-manual: http://ant.apache.org/manual
:code-examples: ../java/org/springframework/boot
:gradle-user-guide: https://docs.gradle.org/3.4.1/userguide
:jetty-documentation: https://www.eclipse.org/jetty/documentation/9.3.x
:tomcat-documentation: https://tomcat.apache.org/tomcat-8.0-doc
// ======================================================================================
include::documentation-overview.adoc[]

5
spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -48,7 +48,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @@ -48,7 +48,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@SpringBootTest
// Enable JMX so we can test the MBeans (you can't do this in a properties file)
@TestPropertySource(properties = { "spring.jmx.enabled:true",
"spring.datasource.jmx-enabled:true", "spring.jpa.hibernate.use-new-id-generator-mappings=false" })
"spring.datasource.jmx-enabled:true",
"spring.jpa.hibernate.use-new-id-generator-mappings=false" })
@ActiveProfiles("scratch")
// Separate profile for web tests to avoid clashing databases
public class SampleDataJpaApplicationTests {

2
spring-boot-samples/spring-boot-sample-data-rest/src/test/java/sample/data/rest/SampleDataRestApplicationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.

2
spring-boot-samples/spring-boot-sample-flyway/src/test/java/sample/flyway/SampleFlywayApplicationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.

2
spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/SampleJpaApplicationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.

2
spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/repository/JpaNoteRepositoryIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.

2
spring-boot-samples/spring-boot-sample-jpa/src/test/java/sample/jpa/repository/JpaTagRepositoryIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.

Loading…
Cancel
Save