Commit 60122502 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '1.2.x'

parents c086a6a7 2e2ebeb9
/* /*
* Copyright 2010-2014 the original author or authors. * Copyright 2012-2015 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.
...@@ -57,7 +57,7 @@ public class EmbeddedServerPortFileWriter ...@@ -57,7 +57,7 @@ public class EmbeddedServerPortFileWriter
* 'application.port'. * 'application.port'.
*/ */
public EmbeddedServerPortFileWriter() { public EmbeddedServerPortFileWriter() {
this.file = new File(DEFAULT_FILE_NAME); this(new File(DEFAULT_FILE_NAME));
} }
/** /**
......
/* /*
* Copyright 2010-2014 the original author or authors. * Copyright 2012-2015 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.
...@@ -66,7 +66,16 @@ public class EmbeddedServerPortFileWriterTests { ...@@ -66,7 +66,16 @@ public class EmbeddedServerPortFileWriterTests {
} }
@Test @Test
public void overridePortFile() throws Exception { public void overridePortFileWithDefault() throws Exception {
System.setProperty("PORTFILE", this.temporaryFolder.newFile().getAbsolutePath());
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter();
listener.onApplicationEvent(mockEvent("", 8080));
assertThat(FileCopyUtils.copyToString(
new FileReader(System.getProperty("PORTFILE"))), equalTo("8080"));
}
@Test
public void overridePortFileWithExplicitFile() throws Exception {
File file = this.temporaryFolder.newFile(); File file = this.temporaryFolder.newFile();
System.setProperty("PORTFILE", this.temporaryFolder.newFile().getAbsolutePath()); System.setProperty("PORTFILE", this.temporaryFolder.newFile().getAbsolutePath());
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file); EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file);
......
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