@@ -47,17 +47,18 @@ void setUp() {
47
47
this .environment = new MockEnvironment ();
48
48
this .environment .setProperty ("spring.application.version" , "1.2.3" );
49
49
this .environment .setProperty ("spring.application.pid" , "42" );
50
+ this .environment .setProperty ("spring.application.name" , "spring-boot" );
50
51
}
51
52
52
53
@ Test
53
54
void startingFormat () {
54
55
given (this .log .isInfoEnabled ()).willReturn (true );
55
56
new StartupInfoLogger (getClass (), this .environment ).logStarting (this .log );
56
57
then (this .log ).should ()
57
- .info (assertArg (
58
- ( message ) -> assertThat ( message . toString ()). contains ("Starting " + getClass ().getSimpleName ()
59
- + " v1.2.3 using Java " + System .getProperty ("java.version" ) + " with PID 42 (started by "
60
- + System .getProperty ("user.name" ) + " in " + System .getProperty ("user.dir" ) + ")" )));
58
+ .info (assertArg (( message ) -> assertThat ( message . toString ())
59
+ . contains ("Starting " + getClass ().getSimpleName () + " \" spring-boot \" " + " v1.2.3 using Java "
60
+ + System .getProperty ("java.version" ) + " with PID 42 (started by "
61
+ + System .getProperty ("user.name" ) + " in " + System .getProperty ("user.dir" ) + ")" )));
61
62
}
62
63
63
64
@ Test
@@ -66,21 +67,33 @@ void startingFormatWhenVersionIsNotAvailable() {
66
67
given (this .log .isInfoEnabled ()).willReturn (true );
67
68
new StartupInfoLogger (getClass (), this .environment ).logStarting (this .log );
68
69
then (this .log ).should ()
69
- .info (assertArg (
70
- ( message ) -> assertThat ( message . toString ()). contains ("Starting " + getClass ().getSimpleName ()
71
- + " using Java " + System .getProperty ("java.version" ) + " with PID 42 (started by "
72
- + System .getProperty ("user.name" ) + " in " + System .getProperty ("user.dir" ) + ")" )));
70
+ .info (assertArg (( message ) -> assertThat ( message . toString ())
71
+ . contains ("Starting " + getClass ().getSimpleName () + " \" spring-boot \" " + " using Java "
72
+ + System .getProperty ("java.version" ) + " with PID 42 (started by "
73
+ + System .getProperty ("user.name" ) + " in " + System .getProperty ("user.dir" ) + ")" )));
73
74
}
74
75
75
76
@ Test
76
77
void startingFormatWhenPidIsNotAvailable () {
77
78
this .environment .setProperty ("spring.application.pid" , "" );
78
79
given (this .log .isInfoEnabled ()).willReturn (true );
79
80
new StartupInfoLogger (getClass (), this .environment ).logStarting (this .log );
81
+ then (this .log ).should ()
82
+ .info (assertArg ((message ) -> assertThat (message .toString ())
83
+ .contains ("Starting " + getClass ().getSimpleName () + " \" spring-boot\" " + " v1.2.3 using Java "
84
+ + System .getProperty ("java.version" ) + " (started by " + System .getProperty ("user.name" )
85
+ + " in " + System .getProperty ("user.dir" ) + ")" )));
86
+ }
87
+
88
+ @ Test
89
+ void startingFormatWhenApplicationNameIsNotAvailable () {
90
+ this .environment .setProperty ("spring.application.name" , "" );
91
+ given (this .log .isInfoEnabled ()).willReturn (true );
92
+ new StartupInfoLogger (getClass (), this .environment ).logStarting (this .log );
80
93
then (this .log ).should ()
81
94
.info (assertArg (
82
95
(message ) -> assertThat (message .toString ()).contains ("Starting " + getClass ().getSimpleName ()
83
- + " v1.2.3 using Java " + System .getProperty ("java.version" ) + " (started by "
96
+ + " v1.2.3 using Java " + System .getProperty ("java.version" ) + " with PID 42 (started by "
84
97
+ System .getProperty ("user.name" ) + " in " + System .getProperty ("user.dir" ) + ")" )));
85
98
}
86
99
@@ -92,10 +105,9 @@ void startingFormatInAotMode() {
92
105
new StartupInfoLogger (getClass (), this .environment ).logStarting (this .log );
93
106
then (this .log ).should ()
94
107
.info (assertArg ((message ) -> assertThat (message .toString ())
95
- .contains ("Starting AOT-processed " + getClass ().getSimpleName () + " v1.2.3 using Java "
96
- + System .getProperty ("java.version" ) + " with PID 42 (started by "
108
+ .contains ("Starting AOT-processed " + getClass ().getSimpleName () + " \" spring-boot \" "
109
+ + " v1.2.3 using Java " + System .getProperty ("java.version" ) + " with PID 42 (started by "
97
110
+ System .getProperty ("user.name" ) + " in " + System .getProperty ("user.dir" ) + ")" )));
98
-
99
111
}
100
112
finally {
101
113
System .clearProperty ("spring.aot.enabled" );
@@ -108,25 +120,25 @@ void startedFormat() {
108
120
new StartupInfoLogger (getClass (), this .environment ).logStarted (this .log , new TestStartup (1345L , "Started" ));
109
121
then (this .log ).should ()
110
122
.info (assertArg ((message ) -> assertThat (message .toString ()).matches ("Started " + getClass ().getSimpleName ()
111
- + " in \\ d+\\ .\\ d{1,3} seconds \\ (process running for 1.345\\ )" )));
123
+ + " \" spring-boot \" " + " in \\ d+\\ .\\ d{1,3} seconds \\ (process running for 1.345\\ )" )));
112
124
}
113
125
114
126
@ Test
115
127
void startedWithoutUptimeFormat () {
116
128
given (this .log .isInfoEnabled ()).willReturn (true );
117
129
new StartupInfoLogger (getClass (), this .environment ).logStarted (this .log , new TestStartup (null , "Started" ));
118
130
then (this .log ).should ()
119
- .info (assertArg ((message ) -> assertThat (message .toString ())
120
- . matches ( "Started " + getClass ().getSimpleName () + " in \\ d+\\ .\\ d{1,3} seconds" )));
131
+ .info (assertArg ((message ) -> assertThat (message .toString ()). matches (
132
+ "Started " + getClass ().getSimpleName () + " \" spring-boot \" " + " in \\ d+\\ .\\ d{1,3} seconds" )));
121
133
}
122
134
123
135
@ Test
124
136
void restoredFormat () {
125
137
given (this .log .isInfoEnabled ()).willReturn (true );
126
138
new StartupInfoLogger (getClass (), this .environment ).logStarted (this .log , new TestStartup (null , "Restored" ));
127
139
then (this .log ).should ()
128
- .info (assertArg ((message ) -> assertThat (message .toString ())
129
- . matches ( "Restored " + getClass ().getSimpleName () + " in \\ d+\\ .\\ d{1,3} seconds" )));
140
+ .info (assertArg ((message ) -> assertThat (message .toString ()). matches (
141
+ "Restored " + getClass ().getSimpleName () + " \" spring-boot \" " + " in \\ d+\\ .\\ d{1,3} seconds" )));
130
142
}
131
143
132
144
static class TestStartup extends Startup {
0 commit comments