File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
spring-boot-project/spring-boot/src
main/java/org/springframework/boot
test/java/org/springframework/boot Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ private CharSequence getStartedMessage(StopWatch stopWatch) {
87
87
message .append ("Started " );
88
88
appendApplicationName (message );
89
89
message .append (" in " );
90
- message .append (stopWatch .getTotalTimeSeconds () );
90
+ message .append (stopWatch .getTotalTimeMillis () / 1000.0 );
91
91
message .append (" seconds" );
92
92
try {
93
93
double uptime = ManagementFactory .getRuntimeMXBean ().getUptime () / 1000.0 ;
Original file line number Diff line number Diff line change 20
20
import org .junit .jupiter .api .Test ;
21
21
import org .mockito .ArgumentCaptor ;
22
22
23
+ import org .springframework .util .StopWatch ;
24
+
23
25
import static org .assertj .core .api .Assertions .assertThat ;
24
26
import static org .mockito .BDDMockito .given ;
25
27
import static org .mockito .Mockito .mock ;
31
33
* @author Dave Syer
32
34
* @author Andy Wilkinson
33
35
*/
34
- class StartUpLoggerTests {
36
+ class StartupInfoLoggerTests {
35
37
36
38
private final Log log = mock (Log .class );
37
39
@@ -44,4 +46,17 @@ void sourceClassIncluded() {
44
46
assertThat (captor .getValue ().toString ()).startsWith ("Starting " + getClass ().getSimpleName ());
45
47
}
46
48
49
+ @ Test
50
+ void startedFormat () {
51
+ StopWatch stopWatch = new StopWatch ();
52
+ stopWatch .start ();
53
+ given (this .log .isInfoEnabled ()).willReturn (true );
54
+ stopWatch .stop ();
55
+ new StartupInfoLogger (getClass ()).logStarted (this .log , stopWatch );
56
+ ArgumentCaptor <Object > captor = ArgumentCaptor .forClass (Object .class );
57
+ verify (this .log ).info (captor .capture ());
58
+ assertThat (captor .getValue ().toString ()).matches ("Started " + getClass ().getSimpleName ()
59
+ + " in \\ d+\\ .\\ d{1,3} seconds \\ (JVM running for \\ d+\\ .\\ d{1,3}\\ )" );
60
+ }
61
+
47
62
}
You can’t perform that action at this time.
0 commit comments