Polish "Print the java version being used on startup"
See gh-21559
This commit is contained in:
parent
731c192817
commit
82cc7e972d
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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,10 +16,14 @@
|
|||
|
||||
package org.springframework.boot;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.boot.system.ApplicationPid;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -38,12 +42,15 @@ class StartupInfoLoggerTests {
|
|||
private final Log log = mock(Log.class);
|
||||
|
||||
@Test
|
||||
void sourceClassIncluded() {
|
||||
void startingFormat() throws UnknownHostException {
|
||||
given(this.log.isInfoEnabled()).willReturn(true);
|
||||
new StartupInfoLogger(getClass()).logStarting(this.log);
|
||||
ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(Object.class);
|
||||
verify(this.log).info(captor.capture());
|
||||
assertThat(captor.getValue().toString()).startsWith("Starting " + getClass().getSimpleName());
|
||||
assertThat(captor.getValue().toString()).matches("Starting " + getClass().getSimpleName() + " using Java "
|
||||
+ System.getProperty("java.version") + " on " + InetAddress.getLocalHost().getHostName() + " with PID "
|
||||
+ new ApplicationPid() + " \\(started by " + System.getProperty("user.name") + " in "
|
||||
+ System.getProperty("user.dir") + "\\)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue