Skip to content

Commit 82cc7e9

Browse files
committed
Polish "Print the java version being used on startup"
See gh-21559
1 parent 731c192 commit 82cc7e9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,10 +16,14 @@
1616

1717
package org.springframework.boot;
1818

19+
import java.net.InetAddress;
20+
import java.net.UnknownHostException;
21+
1922
import org.apache.commons.logging.Log;
2023
import org.junit.jupiter.api.Test;
2124
import org.mockito.ArgumentCaptor;
2225

26+
import org.springframework.boot.system.ApplicationPid;
2327
import org.springframework.util.StopWatch;
2428

2529
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,12 +42,15 @@ class StartupInfoLoggerTests {
3842
private final Log log = mock(Log.class);
3943

4044
@Test
41-
void sourceClassIncluded() {
45+
void startingFormat() throws UnknownHostException {
4246
given(this.log.isInfoEnabled()).willReturn(true);
4347
new StartupInfoLogger(getClass()).logStarting(this.log);
4448
ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(Object.class);
4549
verify(this.log).info(captor.capture());
46-
assertThat(captor.getValue().toString()).startsWith("Starting " + getClass().getSimpleName());
50+
assertThat(captor.getValue().toString()).matches("Starting " + getClass().getSimpleName() + " using Java "
51+
+ System.getProperty("java.version") + " on " + InetAddress.getLocalHost().getHostName() + " with PID "
52+
+ new ApplicationPid() + " \\(started by " + System.getProperty("user.name") + " in "
53+
+ System.getProperty("user.dir") + "\\)");
4754
}
4855

4956
@Test

0 commit comments

Comments
 (0)