Merge branch '2.1.x'

This commit is contained in:
Madhura Bhave 2019-03-15 18:09:47 -07:00
commit 3d0219c315
35 changed files with 73 additions and 89 deletions

View File

@ -45,9 +45,9 @@ public enum ManagementPortType {
* Look at the given environment to determine if the {@link ManagementPortType} is
* {@link #DISABLED}, {@link #SAME} or {@link #DIFFERENT}.
* @param environment the Spring environment
* @return {@link #DISABLED} if `management.server.port` is set to a negative value,
* {@link #SAME} if `management.server.port` is not specified or equal to
* `server.port`and {@link #DIFFERENT} otherwise.
* @return {@link #DISABLED} if {@code management.server.port} is set to a negative
* value, {@link #SAME} if {@code management.server.port} is not specified or equal to
* {@code server.port} and {@link #DIFFERENT} otherwise.
* @since 2.1.4
*/
public static ManagementPortType get(Environment environment) {

View File

@ -1180,7 +1180,7 @@ shown in the following example:
}
----
JAXB is only available out of the box with Java 8. If you're using a more recent java
JAXB is only available out of the box with Java 8. If you're using a more recent Java
generation, add the following dependency to your project:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]

View File

@ -4,8 +4,8 @@ import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse
File repackaged = new File(basedir, "target/jar-classifier-main-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar")
File main = new File( basedir, "target/jar-classifier-main-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar")
File backup = new File( basedir, "target/jar-classifier-main-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar.original")
File main = new File(basedir, "target/jar-classifier-main-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar")
File backup = new File(basedir, "target/jar-classifier-main-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar.original")
new Verify.JarArchiveVerification(repackaged, Verify.SAMPLE_APP).verify();
assertTrue 'main artifact should exist', main.exists()
@ -22,6 +22,3 @@ assertFalse 'repackaged artifact should not have been installed',
file.text.contains ("Installing " + repackaged + " to")
assertFalse 'backup artifact should not have been installed',
file.text.contains ("Installing " + backup + "to")

View File

@ -4,8 +4,8 @@ import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse
File repackaged = new File(basedir, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT-test.jar")
File main = new File( basedir, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT.jar")
File backup = new File( basedir, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT.jar.original")
File main = new File(basedir, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT.jar")
File backup = new File(basedir, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT.jar.original")
new Verify.JarArchiveVerification(repackaged, Verify.SAMPLE_APP).verify();
assertTrue 'main artifact should exist', main.exists()

View File

@ -3,8 +3,8 @@ import org.springframework.boot.maven.*
import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse
File main = new File(basedir, "target/jar-classifier-source-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar");
File backup = new File( basedir, "target/jar-classifier-source-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar.original")
File main = new File(basedir, "target/jar-classifier-source-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar")
File backup = new File(basedir, "target/jar-classifier-source-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar.original")
new Verify.JarArchiveVerification(main, Verify.SAMPLE_APP).verify();
assertTrue 'backup artifact should exist', backup.exists()
@ -18,4 +18,3 @@ assertTrue 'backup artifact should have been installed',
file.text.contains ("Installing " + backup + " to")
assertFalse 'repackaged artifact should not have been installed',
file.text.contains ("Installing " + main + " to")

View File

@ -3,8 +3,8 @@ import org.springframework.boot.maven.*
import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertTrue
File repackaged = new File(basedir, "target/jar-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar");
File backup = new File( basedir, "target/jar-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar.original")
File repackaged = new File(basedir, "target/jar-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar")
File backup = new File(basedir, "target/jar-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar.original")
new Verify.JarArchiveVerification(repackaged, Verify.SAMPLE_APP).verify();
assertTrue 'backup artifact should exist', backup.exists()
@ -14,4 +14,3 @@ assertTrue 'repackaged artifact should have been replaced',
file.text.contains("Replacing artifact with classifier test with repackaged archive")
assertFalse 'backup artifact should not have been installed', file.text.contains ("Installing "+backup)
assertTrue 'repackaged artifact should have been installed', file.text.contains ("Installing "+repackaged)

View File

@ -2,6 +2,5 @@ import java.io.*;
import org.springframework.boot.maven.*;
Verify.verifyJar(
new File( basedir, "target/foo/jar-create-dir-0.0.1.BUILD-SNAPSHOT-foo.jar" ), "some.random.Main"
);
new File(basedir, "target/foo/jar-create-dir-0.0.1.BUILD-SNAPSHOT-foo.jar"), "some.random.Main"
)

View File

@ -2,13 +2,9 @@ import java.io.*;
import org.springframework.boot.maven.*;
Verify.verifyJar(
new File( basedir, "target/foo/jar-custom-dir-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main"
);
new File(basedir, "target/foo/jar-custom-dir-0.0.1.BUILD-SNAPSHOT.jar"), "some.random.Main"
)
Verify.verifyJar(
new File( localRepositoryPath, "org/springframework/boot/maven/it/jar-custom-dir/0.0.1.BUILD-SNAPSHOT/jar-custom-dir-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main"
);
new File(localRepositoryPath, "org/springframework/boot/maven/it/jar-custom-dir/0.0.1.BUILD-SNAPSHOT/jar-custom-dir-0.0.1.BUILD-SNAPSHOT.jar"), "some.random.Main"
)

View File

@ -2,6 +2,5 @@ import java.io.*;
import org.springframework.boot.maven.*;
Verify.verifyJar(
new File( basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main", "Hello world"
);
new File(basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar"), "some.random.Main", "Hello world"
)

View File

@ -1,11 +1,11 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/jar-exclude-artifact-0.0.1.BUILD-SNAPSHOT.jar");
File f = new File(basedir, "target/jar-exclude-artifact-0.0.1.BUILD-SNAPSHOT.jar")
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
super.verifyZipEntries(verifier)
verifier.assertHasNoEntryNameStartingWith("lib/servlet-api-2.5.jar")
}
}.verify();
}.verify()

View File

@ -17,11 +17,11 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/jar-exclude-entry-0.0.1.BUILD-SNAPSHOT.jar");
File f = new File(basedir, "target/jar-exclude-entry-0.0.1.BUILD-SNAPSHOT.jar")
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
super.verifyZipEntries(verifier)
verifier.assertHasNoEntryNameStartingWith("lib/servlet-api-2.5.jar")
}
}.verify();
}.verify()

View File

@ -17,11 +17,11 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/jar-exclude-group-0.0.1.BUILD-SNAPSHOT.jar");
File f = new File(basedir, "target/jar-exclude-group-0.0.1.BUILD-SNAPSHOT.jar")
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
super.verifyZipEntries(verifier)
verifier.assertHasNoEntryNameStartingWith("lib/log4j-api-2.4.1.jar")
}
}.verify();
}.verify()

View File

@ -2,7 +2,6 @@ import java.io.*;
import org.springframework.boot.maven.*;
Verify.verifyJar(
new File( basedir, "target/jar-executable-0.0.1.BUILD-SNAPSHOT.jar" ),
new File(basedir, "target/jar-executable-0.0.1.BUILD-SNAPSHOT.jar"),
"some.random.Main", "Spring Boot Startup Script", "MyFullyExecutableJarName",
"MyFullyExecutableJarDesc");
"MyFullyExecutableJarDesc")

View File

@ -2,6 +2,5 @@ import java.io.*;
import org.springframework.boot.maven.*;
Verify.verifyJar(
new File( basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main", false
);
new File(basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar"), "some.random.Main", false
)

View File

@ -1,7 +1,7 @@
import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse
File f = new File( basedir, "target/jar-skip-0.0.1.BUILD-SNAPSHOT.jar")
File f = new File(basedir, "target/jar-skip-0.0.1.BUILD-SNAPSHOT.jar")
assertTrue 'output file should have been generated', f.exists()
File shouldNotExist = new File( basedir, "target/jar-skip-0.0.1.BUILD-SNAPSHOT.jar.original")
File shouldNotExist = new File(basedir, "target/jar-skip-0.0.1.BUILD-SNAPSHOT.jar.original")
assertFalse 'repackage goal should not have run. .original should not exist', shouldNotExist.exists()

View File

@ -17,11 +17,11 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/jar-system-scope-default-0.0.1.BUILD-SNAPSHOT.jar");
File f = new File(basedir, "target/jar-system-scope-default-0.0.1.BUILD-SNAPSHOT.jar")
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
super.verifyZipEntries(verifier)
verifier.assertHasNoEntryNameStartingWith("BOOT-INF/lib/sample-1.0.0.jar")
}
}.verify();
}.verify()

View File

@ -17,11 +17,11 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/jar-system-scope-0.0.1.BUILD-SNAPSHOT.jar");
File f = new File(basedir, "target/jar-system-scope-0.0.1.BUILD-SNAPSHOT.jar")
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
super.verifyZipEntries(verifier)
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/sample-1.0.0.jar")
}
}.verify();
}.verify()

View File

@ -17,11 +17,11 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/jar-test-scope-0.0.1.BUILD-SNAPSHOT.jar");
File f = new File(basedir, "target/jar-test-scope-0.0.1.BUILD-SNAPSHOT.jar")
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
super.verifyZipEntries(verifier)
verifier.assertHasNoEntryNameStartingWith("lib/log4j-api-2.4.1.jar")
}
}.verify();
}.verify()

View File

@ -17,7 +17,7 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/jar-with-kotlin-module-0.0.1.BUILD-SNAPSHOT.jar");
File f = new File(basedir, "target/jar-with-kotlin-module-0.0.1.BUILD-SNAPSHOT.jar")
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
@ -27,4 +27,4 @@ new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
verifier.assertHasNonUnpackEntry("BOOT-INF/lib/kotlin-stdlib-")
verifier.assertHasNonUnpackEntry("BOOT-INF/lib/kotlin-reflect-")
}
}.verify();
}.verify()

View File

@ -17,7 +17,7 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/jar-with-unpack-0.0.1.BUILD-SNAPSHOT.jar");
File f = new File(basedir, "target/jar-with-unpack-0.0.1.BUILD-SNAPSHOT.jar")
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
@ -25,4 +25,4 @@ new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
verifier.assertHasUnpackEntry("BOOT-INF/lib/spring-core-")
verifier.assertHasNonUnpackEntry("BOOT-INF/lib/spring-context-")
}
}.verify();
}.verify()

View File

@ -2,6 +2,5 @@ import java.io.*;
import org.springframework.boot.maven.*;
Verify.verifyZip(
new File( basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar" )
);
new File(basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar")
)

View File

@ -17,7 +17,7 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "war/target/war-0.0.1.BUILD-SNAPSHOT.war")
File f = new File(basedir, "war/target/war-0.0.1.BUILD-SNAPSHOT.war")
new Verify.WarArchiveVerification(f) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {

View File

@ -17,7 +17,7 @@
import java.io.*;
import org.springframework.boot.maven.*;
File f = new File( basedir, "target/war-0.0.1.BUILD-SNAPSHOT.war")
File f = new File(basedir, "target/war-0.0.1.BUILD-SNAPSHOT.war")
new Verify.WarArchiveVerification(f) {
@Override
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {

View File

@ -2,6 +2,6 @@ import java.io.*;
import org.springframework.boot.maven.*;
Verify.verifyWar(
new File( basedir, "target/war-0.0.1.BUILD-SNAPSHOT.war" )
);
new File(basedir, "target/war-0.0.1.BUILD-SNAPSHOT.war")
)

View File

@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.PostConstruct;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.Condition;
import org.junit.After;
import org.junit.Before;
@ -1080,7 +1079,7 @@ public class SpringApplicationTests {
ExampleConfig.class);
application.addListeners(
(ApplicationListener<ApplicationEnvironmentPreparedEvent>) (event) -> {
Assertions.assertThat(event.getEnvironment())
assertThat(event.getEnvironment())
.isInstanceOf(StandardServletEnvironment.class);
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(
event.getEnvironment(), "foo=bar");

View File

@ -43,10 +43,10 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ManagementPortAndPathSampleActuatorApplicationTests {
@LocalServerPort
private int port = 9010;
private int port;
@LocalManagementPort
private int managementPort = 9011;
private int managementPort;
@Test
public void testHome() {

View File

@ -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");
* you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import java.util.Base64;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.assertj.core.api.Assertions;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -32,6 +31,7 @@ import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
@ -60,7 +60,7 @@ public class SampleActuatorLog4J2ApplicationTests {
@Test
public void testLogger() {
logger.info("Hello World");
Assertions.assertThat(this.output.toString()).contains("Hello World");
assertThat(this.output.toString()).contains("Hello World");
}
@Test

View File

@ -43,10 +43,10 @@ import static org.assertj.core.api.Assertions.assertThat;
public class SampleActuatorUiApplicationPortTests {
@LocalServerPort
private int port = 9010;
private int port;
@LocalManagementPort
private int managementPort = 9011;
private int managementPort;
@Test
public void testHome() {

View File

@ -44,10 +44,10 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ManagementAddressActuatorApplicationTests {
@LocalServerPort
private int port = 9010;
private int port;
@LocalManagementPort
private int managementPort = 9011;
private int managementPort;
@Test
public void testHome() {

View File

@ -46,10 +46,10 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ManagementPortAndPathSampleActuatorApplicationTests {
@LocalServerPort
private int port = 9010;
private int port;
@LocalManagementPort
private int managementPort = 9011;
private int managementPort;
@Autowired
private Environment environment;

View File

@ -43,10 +43,10 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ManagementPortSampleActuatorApplicationTests {
@LocalServerPort
private int port = 9010;
private int port;
@LocalManagementPort
private int managementPort = 9011;
private int managementPort;
@Test
public void testHome() {

View File

@ -2,6 +2,5 @@ import java.io.*;
import sample.layout.*;
Verify.verify(
new File( basedir, "target/custom-0.0.1.BUILD-SNAPSHOT.jar" ), "custom"
);
new File(basedir, "target/custom-0.0.1.BUILD-SNAPSHOT.jar"), "custom"
)

View File

@ -2,6 +2,5 @@ import java.io.*;
import sample.layout.*;
Verify.verify(
new File( basedir, "target/default-0.0.1.BUILD-SNAPSHOT.jar" ), "sample"
);
new File(basedir, "target/default-0.0.1.BUILD-SNAPSHOT.jar"), "sample"
)

View File

@ -41,10 +41,10 @@ import static org.assertj.core.api.Assertions.assertThat;
public class JerseyApplicationPathAndManagementPortTests {
@LocalServerPort
private int port = 9010;
private int port;
@LocalManagementPort
private int managementPort = 9011;
private int managementPort;
@Autowired
private TestRestTemplate testRestTemplate;

View File

@ -18,7 +18,6 @@ package sample.secure.webflux;
import java.util.Base64;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -37,6 +36,8 @@ import org.springframework.security.web.server.SecurityWebFilterChain;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.reactive.server.WebTestClient;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for separate management and main service ports.
*
@ -50,10 +51,10 @@ import org.springframework.test.web.reactive.server.WebTestClient;
public class ManagementPortSampleSecureWebFluxTests {
@LocalServerPort
private int port = 9010;
private int port;
@LocalManagementPort
private int managementPort = 9011;
private int managementPort;
@Autowired
private WebTestClient webClient;
@ -90,7 +91,7 @@ public class ManagementPortSampleSecureWebFluxTests {
String.class)
.exchange().expectStatus().isOk().expectBody(String.class).returnResult()
.getResponseBody();
Assertions.assertThat(responseBody).contains("\"status\":\"UP\"");
assertThat(responseBody).contains("\"status\":\"UP\"");
}
private String getBasicAuth() {