This commit is contained in:
Phillip Webb 2017-04-27 12:03:44 -07:00
parent 42e24136ef
commit 45dd9f7144
20 changed files with 75 additions and 71 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -65,7 +65,15 @@ public class DefaultErrorAttributes
private static final String ERROR_ATTRIBUTE = DefaultErrorAttributes.class.getName() private static final String ERROR_ATTRIBUTE = DefaultErrorAttributes.class.getName()
+ ".ERROR"; + ".ERROR";
private boolean includeException; private final boolean includeException;
/**
* Create a new {@link DefaultErrorAttributes} instance that does not include the
* "exception" attribute.
*/
public DefaultErrorAttributes() {
this(false);
}
/** /**
* Create a new {@link DefaultErrorAttributes} instance. * Create a new {@link DefaultErrorAttributes} instance.
@ -75,14 +83,6 @@ public class DefaultErrorAttributes
this.includeException = includeException; this.includeException = includeException;
} }
/**
* Create a new {@link DefaultErrorAttributes} instance that does not
* include the "exception" attribute.
*/
public DefaultErrorAttributes() {
this(false);
}
@Override @Override
public int getOrder() { public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE; return Ordered.HIGHEST_PRECEDENCE;

View File

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

View File

@ -79,7 +79,8 @@ public class ReactiveCassandraRepositoriesAutoConfigurationTests {
@Test @Test
public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() { public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
load(TestExcludeConfiguration.class, CustomizedConfiguration.class); 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); assertThat(getInitialEntitySet()).hasSize(1).containsOnly(City.class);
} }

View File

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

View File

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

View File

@ -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.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.display-name=application # Display name of the application.
server.max-http-header-size=0 # Maximum size in bytes of the HTTP message header. 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.include-stacktrace=never # When to include a "stacktrace" attribute.
server.error.path=/error # Path of the error controller. 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. server.error.whitelabel.enabled=true # Enable the default error page displayed in browsers in case of a server error.

View File

@ -640,7 +640,7 @@ Access logs can be configured for Tomcat, Undertow and Jetty via their respectiv
namespaces. namespaces.
For instance, the following logs access on Tomcat with a 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"] [source,properties,indent=0,subs="verbatim,quotes,attributes"]
---- ----
@ -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 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].

View File

@ -52,6 +52,8 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
:ant-manual: http://ant.apache.org/manual :ant-manual: http://ant.apache.org/manual
:code-examples: ../java/org/springframework/boot :code-examples: ../java/org/springframework/boot
:gradle-user-guide: https://docs.gradle.org/3.4.1/userguide :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[] include::documentation-overview.adoc[]

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -48,7 +48,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@SpringBootTest @SpringBootTest
// Enable JMX so we can test the MBeans (you can't do this in a properties file) // Enable JMX so we can test the MBeans (you can't do this in a properties file)
@TestPropertySource(properties = { "spring.jmx.enabled:true", @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") @ActiveProfiles("scratch")
// Separate profile for web tests to avoid clashing databases // Separate profile for web tests to avoid clashing databases
public class SampleDataJpaApplicationTests { public class SampleDataJpaApplicationTests {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.