Browse Source

Move Application* and *FileWriter classes

Move `ApplicationHome`, `ApplicationPid` and `ApplicationTemp` to the
`system` package. Since `system` package is now much lower level, the
existing `FileWriter` implementations also needed to move to prevent
package tangles.

Fixes gh-8614
pull/11812/merge
Phillip Webb 8 years ago
parent
commit
c3ec316890
  1. 4
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/AtomikosJtaConfiguration.java
  2. 4
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/BitronixJtaConfiguration.java
  3. 4
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java
  4. 6
      spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTesterSpringApplication.java
  5. 4
      spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc
  6. 4
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java
  7. 6
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java
  8. 4
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java
  9. 6
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java
  10. 5
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java
  11. 6
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationTemp.java
  12. 5
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java
  13. 25
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/WebServerPortFileWriter.java
  14. 4
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/SessionStoreDirectory.java
  15. 4
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/ApplicationPidFileWriterTests.java
  16. 2
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java
  17. 3
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/ApplicationPidTests.java
  18. 4
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/ApplicationTempTests.java
  19. 18
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/context/WebServerPortFileWriterTest.java
  20. 4
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
  21. 4
      spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/com/example/DevToolsTestApplication.java
  22. 4
      spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/example/ResourceHandlingApplication.java

4
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/AtomikosJtaConfiguration.java

@ -1,5 +1,5 @@ @@ -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.
@ -28,7 +28,6 @@ import com.atomikos.icatch.config.UserTransactionServiceImp; @@ -28,7 +28,6 @@ import com.atomikos.icatch.config.UserTransactionServiceImp;
import com.atomikos.icatch.jta.UserTransactionManager;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
@ -39,6 +38,7 @@ import org.springframework.boot.jta.atomikos.AtomikosDependsOnBeanFactoryPostPro @@ -39,6 +38,7 @@ import org.springframework.boot.jta.atomikos.AtomikosDependsOnBeanFactoryPostPro
import org.springframework.boot.jta.atomikos.AtomikosProperties;
import org.springframework.boot.jta.atomikos.AtomikosXAConnectionFactoryWrapper;
import org.springframework.boot.jta.atomikos.AtomikosXADataSourceWrapper;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

4
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/BitronixJtaConfiguration.java

@ -1,5 +1,5 @@ @@ -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.
@ -26,7 +26,6 @@ import bitronix.tm.TransactionManagerServices; @@ -26,7 +26,6 @@ import bitronix.tm.TransactionManagerServices;
import bitronix.tm.jndi.BitronixContext;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
@ -37,6 +36,7 @@ import org.springframework.boot.jta.XADataSourceWrapper; @@ -37,6 +36,7 @@ import org.springframework.boot.jta.XADataSourceWrapper;
import org.springframework.boot.jta.bitronix.BitronixDependentBeanFactoryPostProcessor;
import org.springframework.boot.jta.bitronix.BitronixXAConnectionFactoryWrapper;
import org.springframework.boot.jta.bitronix.BitronixXADataSourceWrapper;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

4
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java

@ -1,5 +1,5 @@ @@ -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.
@ -28,7 +28,6 @@ import org.jboss.narayana.jta.jms.TransactionHelper; @@ -28,7 +28,6 @@ import org.jboss.narayana.jta.jms.TransactionHelper;
import org.jboss.tm.XAResourceRecoveryRegistry;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
@ -41,6 +40,7 @@ import org.springframework.boot.jta.narayana.NarayanaProperties; @@ -41,6 +40,7 @@ import org.springframework.boot.jta.narayana.NarayanaProperties;
import org.springframework.boot.jta.narayana.NarayanaRecoveryManagerBean;
import org.springframework.boot.jta.narayana.NarayanaXAConnectionFactoryWrapper;
import org.springframework.boot.jta.narayana.NarayanaXADataSourceWrapper;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

6
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTesterSpringApplication.java

@ -1,5 +1,5 @@ @@ -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.
@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
package org.springframework.boot.cli;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.system.EmbeddedServerPortFileWriter;
import org.springframework.boot.web.context.WebServerPortFileWriter;
import org.springframework.context.ConfigurableApplicationContext;
/**
@ -33,7 +33,7 @@ public class CliTesterSpringApplication extends SpringApplication { @@ -33,7 +33,7 @@ public class CliTesterSpringApplication extends SpringApplication {
@Override
protected void postProcessApplicationContext(ConfigurableApplicationContext context) {
context.addApplicationListener(new EmbeddedServerPortFileWriter());
context.addApplicationListener(new WebServerPortFileWriter());
}
}

4
spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc

@ -1337,8 +1337,8 @@ useful for process monitoring: @@ -1337,8 +1337,8 @@ useful for process monitoring:
* `ApplicationPidFileWriter` creates a file containing the application PID (by default,
in the application directory with a file name of `application.pid`).
* `EmbeddedServerPortFileWriter` creates a file (or files) containing the ports of the
embedded server (by default, in the application directory with a file name of
* `WebServerPortFileWriter` creates a file (or files) containing the ports of the
running web server (by default, in the application directory with a file name of
`application.port`).
By default, these writers are not activated, but you can enable:

4
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java

@ -1,5 +1,5 @@ @@ -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.
@ -22,6 +22,8 @@ import java.util.concurrent.Callable; @@ -22,6 +22,8 @@ import java.util.concurrent.Callable;
import org.apache.commons.logging.Log;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.context.ApplicationContext;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

6
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java → spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.system;
package org.springframework.boot.context;
import java.io.File;
import java.io.IOException;
@ -26,11 +26,11 @@ import java.util.concurrent.atomic.AtomicBoolean; @@ -26,11 +26,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.ApplicationPid;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.SpringApplicationEvent;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.boot.system.SystemProperties;
import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;
@ -58,7 +58,7 @@ import org.springframework.util.Assert; @@ -58,7 +58,7 @@ import org.springframework.util.Assert;
* @author Phillip Webb
* @author Tomasz Przybyla
* @author Madhura Bhave
* @since 1.4.0
* @since 2.0.0
*/
public class ApplicationPidFileWriter
implements ApplicationListener<SpringApplicationEvent>, Ordered {

4
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java

@ -1,5 +1,5 @@ @@ -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.
@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
package org.springframework.boot.logging;
import org.springframework.boot.ApplicationPid;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;

6
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationHome.java → spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java

@ -1,5 +1,5 @@ @@ -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.
@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot;
package org.springframework.boot.system;
import java.io.File;
import java.io.IOException;
@ -37,7 +37,7 @@ import org.springframework.util.StringUtils; @@ -37,7 +37,7 @@ import org.springframework.util.StringUtils;
*
* @author Phillip Webb
* @author Raja Kolli
* @since 1.2.0
* @since 2.0.0
*/
public class ApplicationHome {

5
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationPid.java → spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java

@ -1,5 +1,5 @@ @@ -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.
@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot;
package org.springframework.boot.system;
import java.io.File;
import java.io.FileNotFoundException;
@ -32,6 +32,7 @@ import org.springframework.util.ObjectUtils; @@ -32,6 +32,7 @@ import org.springframework.util.ObjectUtils;
* An application process ID.
*
* @author Phillip Webb
* @since 2.0.0
*/
public class ApplicationPid {

6
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationTemp.java → spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationTemp.java

@ -1,5 +1,5 @@ @@ -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.
@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot;
package org.springframework.boot.system;
import java.io.File;
import java.security.MessageDigest;
@ -28,7 +28,7 @@ import org.springframework.util.StringUtils; @@ -28,7 +28,7 @@ import org.springframework.util.StringUtils;
* restarting an application will give the same location.
*
* @author Phillip Webb
* @since 1.3.0
* @since 2.0.0
*/
public class ApplicationTemp {

5
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java

@ -1,5 +1,5 @@ @@ -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.
@ -20,8 +20,9 @@ package org.springframework.boot.system; @@ -20,8 +20,9 @@ package org.springframework.boot.system;
* Access to system properties.
*
* @author Phillip Webb
* @since 2.0.0
*/
final class SystemProperties {
public final class SystemProperties {
private SystemProperties() {
}

25
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/EmbeddedServerPortFileWriter.java → spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/WebServerPortFileWriter.java

@ -14,15 +14,14 @@ @@ -14,15 +14,14 @@
* limitations under the License.
*/
package org.springframework.boot.system;
package org.springframework.boot.web.context;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.system.SystemProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.util.Assert;
@ -38,42 +37,40 @@ import org.springframework.util.StringUtils; @@ -38,42 +37,40 @@ import org.springframework.util.StringUtils;
* @author David Liu
* @author Phillip Webb
* @author Andy Wilkinson
* @since 1.4.0
* @since 2.0.0
*/
public class EmbeddedServerPortFileWriter
public class WebServerPortFileWriter
implements ApplicationListener<WebServerInitializedEvent> {
private static final String DEFAULT_FILE_NAME = "application.port";
private static final String[] PROPERTY_VARIABLES = { "PORTFILE", "portfile" };
private static final Log logger = LogFactory
.getLog(EmbeddedServerPortFileWriter.class);
private static final Log logger = LogFactory.getLog(WebServerPortFileWriter.class);
private final File file;
/**
* Create a new {@link EmbeddedServerPortFileWriter} instance using the filename
* Create a new {@link WebServerPortFileWriter} instance using the filename
* 'application.port'.
*/
public EmbeddedServerPortFileWriter() {
public WebServerPortFileWriter() {
this(new File(DEFAULT_FILE_NAME));
}
/**
* Create a new {@link EmbeddedServerPortFileWriter} instance with a specified
* filename.
* Create a new {@link WebServerPortFileWriter} instance with a specified filename.
* @param filename the name of file containing port
*/
public EmbeddedServerPortFileWriter(String filename) {
public WebServerPortFileWriter(String filename) {
this(new File(filename));
}
/**
* Create a new {@link EmbeddedServerPortFileWriter} instance with a specified file.
* Create a new {@link WebServerPortFileWriter} instance with a specified file.
* @param file the file containing port
*/
public EmbeddedServerPortFileWriter(File file) {
public WebServerPortFileWriter(File file) {
Assert.notNull(file, "File must not be null");
String override = SystemProperties.get(PROPERTY_VARIABLES);
if (override != null) {

4
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/SessionStoreDirectory.java

@ -18,8 +18,8 @@ package org.springframework.boot.web.servlet.server; @@ -18,8 +18,8 @@ package org.springframework.boot.web.servlet.server;
import java.io.File;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.ApplicationTemp;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.boot.system.ApplicationTemp;
import org.springframework.util.Assert;
/**

4
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/ApplicationPidFileWriterTests.java → spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/ApplicationPidFileWriterTests.java

@ -1,5 +1,5 @@ @@ -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.
@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.system;
package org.springframework.boot.context;
import java.io.File;
import java.io.FileReader;

2
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java

@ -38,7 +38,6 @@ import org.junit.rules.TemporaryFolder; @@ -38,7 +38,6 @@ import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.slf4j.bridge.SLF4JBridgeHandler;
import org.springframework.boot.ApplicationPid;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationStartingEvent;
@ -51,6 +50,7 @@ import org.springframework.boot.logging.LoggingInitializationContext; @@ -51,6 +50,7 @@ import org.springframework.boot.logging.LoggingInitializationContext;
import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.logging.LoggingSystemProperties;
import org.springframework.boot.logging.java.JavaLoggingSystem;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;

3
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ApplicationPidTests.java → spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/ApplicationPidTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot;
package org.springframework.boot.system;
import java.io.File;
import java.io.FileReader;
@ -24,7 +24,6 @@ import org.junit.Test; @@ -24,7 +24,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.springframework.boot.ApplicationPid;
import org.springframework.util.FileCopyUtils;
import static org.assertj.core.api.Assertions.assertThat;

4
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ApplicationTempTests.java → spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/ApplicationTempTests.java

@ -1,5 +1,5 @@ @@ -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.
@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot;
package org.springframework.boot.system;
import java.io.File;

18
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/EmbeddedServerPortFileWriterTests.java → spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/context/WebServerPortFileWriterTest.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.system;
package org.springframework.boot.web.context;
import java.io.File;
import java.io.FileReader;
@ -27,8 +27,6 @@ import org.junit.Rule; @@ -27,8 +27,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.web.server.WebServer;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;
@ -38,13 +36,13 @@ import static org.mockito.BDDMockito.given; @@ -38,13 +36,13 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/**
* Tests {@link EmbeddedServerPortFileWriter}.
* Tests {@link WebServerPortFileWriter}.
*
* @author David Liu
* @author Phillip Webb
* @author Andy Wilkinson
*/
public class EmbeddedServerPortFileWriterTests {
public class WebServerPortFileWriterTest {
@Rule
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
@ -58,7 +56,7 @@ public class EmbeddedServerPortFileWriterTests { @@ -58,7 +56,7 @@ public class EmbeddedServerPortFileWriterTests {
@Test
public void createPortFile() throws Exception {
File file = this.temporaryFolder.newFile();
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file);
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("", 8080));
assertThat(FileCopyUtils.copyToString(new FileReader(file))).isEqualTo("8080");
}
@ -66,7 +64,7 @@ public class EmbeddedServerPortFileWriterTests { @@ -66,7 +64,7 @@ public class EmbeddedServerPortFileWriterTests {
@Test
public void overridePortFileWithDefault() throws Exception {
System.setProperty("PORTFILE", this.temporaryFolder.newFile().getAbsolutePath());
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter();
WebServerPortFileWriter listener = new WebServerPortFileWriter();
listener.onApplicationEvent(mockEvent("", 8080));
FileReader reader = new FileReader(System.getProperty("PORTFILE"));
assertThat(FileCopyUtils.copyToString(reader)).isEqualTo("8080");
@ -76,7 +74,7 @@ public class EmbeddedServerPortFileWriterTests { @@ -76,7 +74,7 @@ public class EmbeddedServerPortFileWriterTests {
public void overridePortFileWithExplicitFile() throws Exception {
File file = this.temporaryFolder.newFile();
System.setProperty("PORTFILE", this.temporaryFolder.newFile().getAbsolutePath());
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file);
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("", 8080));
FileReader reader = new FileReader(System.getProperty("PORTFILE"));
assertThat(FileCopyUtils.copyToString(reader)).isEqualTo("8080");
@ -85,7 +83,7 @@ public class EmbeddedServerPortFileWriterTests { @@ -85,7 +83,7 @@ public class EmbeddedServerPortFileWriterTests {
@Test
public void createManagementPortFile() throws Exception {
File file = this.temporaryFolder.newFile();
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file);
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("", 8080));
listener.onApplicationEvent(mockEvent("management", 9090));
assertThat(FileCopyUtils.copyToString(new FileReader(file))).isEqualTo("8080");
@ -104,7 +102,7 @@ public class EmbeddedServerPortFileWriterTests { @@ -104,7 +102,7 @@ public class EmbeddedServerPortFileWriterTests {
public void createUpperCaseManagementPortFile() throws Exception {
File file = this.temporaryFolder.newFile();
file = new File(file.getParentFile(), file.getName().toUpperCase());
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file);
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("management", 9090));
String managementFile = file.getName();
managementFile = managementFile.substring(0, managementFile.length()

4
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java

@ -86,8 +86,8 @@ import org.junit.rules.ExpectedException; @@ -86,8 +86,8 @@ import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.mockito.InOrder;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.ApplicationTemp;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.boot.system.ApplicationTemp;
import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.boot.testsupport.web.servlet.ExampleFilter;
import org.springframework.boot.testsupport.web.servlet.ExampleServlet;

4
spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/com/example/DevToolsTestApplication.java

@ -18,14 +18,14 @@ package com.example; @@ -18,14 +18,14 @@ package com.example;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.context.EmbeddedServerPortFileWriter;
import org.springframework.boot.web.context.WebServerPortFileWriter;
@SpringBootApplication
public class DevToolsTestApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(DevToolsTestApplication.class)
.listeners(new EmbeddedServerPortFileWriter("target/server.port"))
.listeners(new WebServerPortFileWriter("target/server.port"))
.run(args);
}

4
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/example/ResourceHandlingApplication.java

@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponse; @@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.context.EmbeddedServerPortFileWriter;
import org.springframework.boot.web.context.WebServerPortFileWriter;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
@ -41,7 +41,7 @@ public class ResourceHandlingApplication { @@ -41,7 +41,7 @@ public class ResourceHandlingApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ResourceHandlingApplication.class)
.properties("server.port:0")
.listeners(new EmbeddedServerPortFileWriter("target/server.port"))
.listeners(new WebServerPortFileWriter("target/server.port"))
.run(args);
}

Loading…
Cancel
Save