|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
* Copyright 2012-2019 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.
|
|
|
@ -16,16 +16,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.web.embedded;
|
|
|
|
package org.springframework.boot.autoconfigure.web.embedded;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.TimeZone;
|
|
|
|
import java.util.TimeZone;
|
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.jetty.server.Connector;
|
|
|
|
import org.eclipse.jetty.server.Connector;
|
|
|
|
import org.eclipse.jetty.server.HttpConfiguration;
|
|
|
|
import org.eclipse.jetty.server.HttpConfiguration;
|
|
|
|
import org.eclipse.jetty.server.HttpConfiguration.ConnectionFactory;
|
|
|
|
import org.eclipse.jetty.server.HttpConfiguration.ConnectionFactory;
|
|
|
@ -33,6 +30,7 @@ import org.eclipse.jetty.server.NCSARequestLog;
|
|
|
|
import org.eclipse.jetty.server.RequestLog;
|
|
|
|
import org.eclipse.jetty.server.RequestLog;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
|
|
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
|
|
|
import org.springframework.boot.context.properties.bind.Bindable;
|
|
|
|
import org.springframework.boot.context.properties.bind.Bindable;
|
|
|
|
import org.springframework.boot.context.properties.bind.Binder;
|
|
|
|
import org.springframework.boot.context.properties.bind.Binder;
|
|
|
@ -43,6 +41,10 @@ import org.springframework.boot.web.embedded.jetty.JettyWebServer;
|
|
|
|
import org.springframework.mock.env.MockEnvironment;
|
|
|
|
import org.springframework.mock.env.MockEnvironment;
|
|
|
|
import org.springframework.test.context.support.TestPropertySourceUtils;
|
|
|
|
import org.springframework.test.context.support.TestPropertySourceUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tests for {@link JettyWebServerFactoryCustomizer}.
|
|
|
|
* Tests for {@link JettyWebServerFactoryCustomizer}.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -101,8 +103,7 @@ public class JettyWebServerFactoryCustomizerTests {
|
|
|
|
"server.jetty.accesslog.log-server=true",
|
|
|
|
"server.jetty.accesslog.log-server=true",
|
|
|
|
"server.jetty.accesslog.log-latency=true",
|
|
|
|
"server.jetty.accesslog.log-latency=true",
|
|
|
|
"server.jetty.accesslog.prefer-proxied-for-address=true",
|
|
|
|
"server.jetty.accesslog.prefer-proxied-for-address=true",
|
|
|
|
"server.jetty.accesslog.ignore-paths[0]=/a/path",
|
|
|
|
"server.jetty.accesslog.ignore-paths=/a/path,/b/path");
|
|
|
|
"server.jetty.accesslog.ignore-paths[1]=/b/path");
|
|
|
|
|
|
|
|
JettyWebServer server = customizeAndGetServer();
|
|
|
|
JettyWebServer server = customizeAndGetServer();
|
|
|
|
NCSARequestLog requestLog = getNCSARequestLog(server);
|
|
|
|
NCSARequestLog requestLog = getNCSARequestLog(server);
|
|
|
|
assertThat(requestLog.getFilename()).isEqualTo(logFile.getAbsolutePath());
|
|
|
|
assertThat(requestLog.getFilename()).isEqualTo(logFile.getAbsolutePath());
|
|
|
@ -118,8 +119,7 @@ public class JettyWebServerFactoryCustomizerTests {
|
|
|
|
assertThat(requestLog.getLogLatency()).isTrue();
|
|
|
|
assertThat(requestLog.getLogLatency()).isTrue();
|
|
|
|
assertThat(requestLog.getPreferProxiedForAddress()).isTrue();
|
|
|
|
assertThat(requestLog.getPreferProxiedForAddress()).isTrue();
|
|
|
|
assertThat(requestLog.getIgnorePaths().length).isEqualTo(2);
|
|
|
|
assertThat(requestLog.getIgnorePaths().length).isEqualTo(2);
|
|
|
|
assertThat(requestLog.getIgnorePaths()[0]).isEqualTo("/a/path");
|
|
|
|
assertThat(requestLog.getIgnorePaths()).containsExactly("/a/path", "/b/path");
|
|
|
|
assertThat(requestLog.getIgnorePaths()[1]).isEqualTo("/b/path");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -133,8 +133,8 @@ public class JettyWebServerFactoryCustomizerTests {
|
|
|
|
assertThat(requestLog.getLogCookies()).isFalse();
|
|
|
|
assertThat(requestLog.getLogCookies()).isFalse();
|
|
|
|
assertThat(requestLog.getLogServer()).isFalse();
|
|
|
|
assertThat(requestLog.getLogServer()).isFalse();
|
|
|
|
assertThat(requestLog.getLogLatency()).isFalse();
|
|
|
|
assertThat(requestLog.getLogLatency()).isFalse();
|
|
|
|
assertThat(requestLog.getIgnorePaths().length).isZero();
|
|
|
|
|
|
|
|
assertThat(requestLog.getPreferProxiedForAddress()).isFalse();
|
|
|
|
assertThat(requestLog.getPreferProxiedForAddress()).isFalse();
|
|
|
|
|
|
|
|
assertThat(requestLog.getIgnorePaths()).isNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private NCSARequestLog getNCSARequestLog(JettyWebServer server) {
|
|
|
|
private NCSARequestLog getNCSARequestLog(JettyWebServer server) {
|
|
|
|