Commit 45dd9f71 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 42e24136
......@@ -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\"")))
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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.
......
......@@ -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
});
}
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);
});
}
}
......
......@@ -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
......
......@@ -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> {
}
......@@ -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);
}
......
......@@ -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 {
@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 {
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();
......
......@@ -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 {
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 {
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 {
@Override
protected void renderMergedOutputModel(Map<String, Object> model,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
throws Exception {
response.getWriter().write("ERROR_BEAN");
}
};
......
......@@ -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.
......
......@@ -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:
----
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].
......
......@@ -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[]
......
/*
* 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.
@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 {
......
/*
* 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.
......
/*
* 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.
......
/*
* 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.
......
/*
* 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.
......
/*
* 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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment