1
1
/*
2
- * Copyright 2012-2019 the original author or authors.
2
+ * Copyright 2012-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
17
17
package org .springframework .boot ;
18
18
19
+ import java .net .InetAddress ;
20
+ import java .net .UnknownHostException ;
21
+
19
22
import org .apache .commons .logging .Log ;
20
23
import org .junit .jupiter .api .Test ;
21
24
import org .mockito .ArgumentCaptor ;
22
25
26
+ import org .springframework .boot .system .ApplicationPid ;
23
27
import org .springframework .util .StopWatch ;
24
28
25
29
import static org .assertj .core .api .Assertions .assertThat ;
@@ -38,12 +42,15 @@ class StartupInfoLoggerTests {
38
42
private final Log log = mock (Log .class );
39
43
40
44
@ Test
41
- void sourceClassIncluded () {
45
+ void startingFormat () throws UnknownHostException {
42
46
given (this .log .isInfoEnabled ()).willReturn (true );
43
47
new StartupInfoLogger (getClass ()).logStarting (this .log );
44
48
ArgumentCaptor <Object > captor = ArgumentCaptor .forClass (Object .class );
45
49
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" ) + "\\ )" );
47
54
}
48
55
49
56
@ Test
0 commit comments