1717package org .apache .logging .log4j .message ;
1818
1919import static org .assertj .core .api .Assertions .assertThat ;
20- import static org .junit .jupiter .api .Assertions .assertEquals ;
2120
2221import java .math .BigDecimal ;
2322import java .util .stream .Stream ;
2726import org .junit .jupiter .params .ParameterizedTest ;
2827import org .junit .jupiter .params .provider .MethodSource ;
2928
30- /**
31- *
32- */
3329public class ParameterizedMessageTest {
3430
3531 @ Test
3632 public void testNoArgs () {
3733 final String testMsg = "Test message {}" ;
3834 ParameterizedMessage msg = new ParameterizedMessage (testMsg , (Object []) null );
3935 String result = msg .getFormattedMessage ();
40- assertEquals ( testMsg , result );
36+ assertThat ( result ). isEqualTo ( testMsg );
4137 final Object [] array = null ;
4238 msg = new ParameterizedMessage (testMsg , array , null );
4339 result = msg .getFormattedMessage ();
44- assertEquals ( testMsg , result );
40+ assertThat ( result ). isEqualTo ( testMsg );
4541 }
4642
4743 @ Test
4844 public void testZeroLength () {
4945 final String testMsg = "" ;
5046 ParameterizedMessage msg = new ParameterizedMessage (testMsg , new Object [] {"arg" });
5147 String result = msg .getFormattedMessage ();
52- assertEquals ( testMsg , result );
48+ assertThat ( result ). isEqualTo ( testMsg );
5349 final Object [] array = null ;
5450 msg = new ParameterizedMessage (testMsg , array , null );
5551 result = msg .getFormattedMessage ();
56- assertEquals ( testMsg , result );
52+ assertThat ( result ). isEqualTo ( testMsg );
5753 }
5854
5955 @ Test
6056 public void testOneCharLength () {
6157 final String testMsg = "d" ;
6258 ParameterizedMessage msg = new ParameterizedMessage (testMsg , new Object [] {"arg" });
6359 String result = msg .getFormattedMessage ();
64- assertEquals ( testMsg , result );
60+ assertThat ( result ). isEqualTo ( testMsg );
6561 final Object [] array = null ;
6662 msg = new ParameterizedMessage (testMsg , array , null );
6763 result = msg .getFormattedMessage ();
68- assertEquals ( testMsg , result );
64+ assertThat ( result ). isEqualTo ( testMsg );
6965 }
7066
7167 @ Test
7268 public void testFormat3StringArgs () {
7369 final String testMsg = "Test message {}{} {}" ;
7470 final String [] args = {"a" , "b" , "c" };
7571 final String result = ParameterizedMessage .format (testMsg , args );
76- assertEquals ( "Test message ab c" , result );
72+ assertThat ( result ). isEqualTo ( "Test message ab c" );
7773 }
7874
7975 @ Test
8076 public void testFormatNullArgs () {
8177 final String testMsg = "Test message {} {} {} {} {} {}" ;
8278 final String [] args = {"a" , null , "c" , null , null , null };
8379 final String result = ParameterizedMessage .format (testMsg , args );
84- assertEquals ( "Test message a null c null null null" , result );
80+ assertThat ( result ). isEqualTo ( "Test message a null c null null null" );
8581 }
8682
8783 @ Test
8884 public void testFormatStringArgsIgnoresSuperfluousArgs () {
8985 final String testMsg = "Test message {}{} {}" ;
9086 final String [] args = {"a" , "b" , "c" , "unnecessary" , "superfluous" };
9187 final String result = ParameterizedMessage .format (testMsg , args );
92- assertEquals ( "Test message ab c" , result );
88+ assertThat ( result ). isEqualTo ( "Test message ab c" );
9389 }
9490
9591 @ Test
9692 public void testFormatStringArgsWithEscape () {
9793 final String testMsg = "Test message \\ {}{} {}" ;
9894 final String [] args = {"a" , "b" , "c" };
9995 final String result = ParameterizedMessage .format (testMsg , args );
100- assertEquals ( "Test message {}a b" , result );
96+ assertThat ( result ). isEqualTo ( "Test message {}a b" );
10197 }
10298
10399 @ Test
104100 public void testFormatStringArgsWithTrailingEscape () {
105101 final String testMsg = "Test message {}{} {}\\ " ;
106102 final String [] args = {"a" , "b" , "c" };
107103 final String result = ParameterizedMessage .format (testMsg , args );
108- assertEquals ( "Test message ab c\\ " , result );
104+ assertThat ( result ). isEqualTo ( "Test message ab c\\ " );
109105 }
110106
111107 @ Test
112108 public void testFormatStringArgsWithTrailingText () {
113109 final String testMsg = "Test message {}{} {}Text" ;
114110 final String [] args = {"a" , "b" , "c" };
115111 final String result = ParameterizedMessage .format (testMsg , args );
116- assertEquals ( "Test message ab cText" , result );
112+ assertThat ( result ). isEqualTo ( "Test message ab cText" );
117113 }
118114
119115 @ Test
120116 public void testFormatStringArgsWithTrailingEscapedEscape () {
121117 final String testMsg = "Test message {}{} {}\\ \\ " ;
122118 final String [] args = {"a" , "b" , "c" };
123119 final String result = ParameterizedMessage .format (testMsg , args );
124- assertEquals ( "Test message ab c\\ " , result );
120+ assertThat ( result ). isEqualTo ( "Test message ab c\\ " );
125121 }
126122
127123 @ Test
128124 public void testFormatStringArgsWithEscapedEscape () {
129125 final String testMsg = "Test message \\ \\ {}{} {}" ;
130126 final String [] args = {"a" , "b" , "c" };
131127 final String result = ParameterizedMessage .format (testMsg , args );
132- assertEquals ( "Test message \\ ab c" , result );
128+ assertThat ( result ). isEqualTo ( "Test message \\ ab c" );
133129 }
134130
135131 @ Test
@@ -141,12 +137,12 @@ public void testSafeWithMutableParams() { // LOG4J2-763
141137 // modify parameter before calling msg.getFormattedMessage
142138 param .set ("XYZ" );
143139 final String actual = msg .getFormattedMessage ();
144- assertEquals ( "Test message XYZ" , actual , " Should use current param value" );
140+ assertThat ( " Should use current param value"). isEqualTo ( "Test message XYZ" , actual );
145141
146142 // modify parameter after calling msg.getFormattedMessage
147143 param .set ("000" );
148144 final String after = msg .getFormattedMessage ();
149- assertEquals ( "Test message XYZ" , after , " Should not change after rendered once" );
145+ assertThat ( " Should not change after rendered once"). isEqualTo ( "Test message XYZ" , after );
150146 }
151147
152148 static Stream <Object > testSerializable () {
0 commit comments