1616
1717package org .springframework .ws .test .support .matcher .xmlunit2 ;
1818
19- import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
20- import static org .easymock .EasyMock .createMock ;
21- import static org .easymock .EasyMock .expect ;
22- import static org .easymock .EasyMock .replay ;
23- import static org .easymock .EasyMock .verify ;
19+ import static org .assertj .core .api .Assertions .*;
20+ import static org .easymock .EasyMock .*;
2421
2522import jakarta .xml .soap .MessageFactory ;
2623
2724import org .junit .jupiter .api .Test ;
2825import org .springframework .ws .WebServiceMessage ;
29- import org .springframework .ws .soap .SoapMessage ;
3026import org .springframework .ws .soap .saaj .SaajSoapMessage ;
3127import org .springframework .xml .transform .StringSource ;
3228
@@ -35,12 +31,13 @@ public class PayloadDiffMatcherTest {
3531 @ Test
3632 public void match () {
3733
38- String xml = "<element xmlns='http://example.com'/>" ;
34+ var xml = "<element xmlns='http://example.com'/>" ;
3935 WebServiceMessage message = createMock (WebServiceMessage .class );
36+
4037 expect (message .getPayloadSource ()).andReturn (new StringSource (xml )).times (2 );
4138 replay (message );
4239
43- PayloadDiffMatcher matcher = new PayloadDiffMatcher (new StringSource (xml ));
40+ var matcher = new PayloadDiffMatcher (new StringSource (xml ));
4441 matcher .match (message );
4542
4643 verify (message );
@@ -49,31 +46,32 @@ public void match() {
4946 @ Test
5047 public void matchIgnoringWhitespace () {
5148
52- String xml = "<response><success>true</success></response>" ;
53- String xmlWithAdditionalWhitespace = "<response> <success>true</success> </response>" ;
49+ var xml = "<response><success>true</success></response>" ;
50+ var xmlWithAdditionalWhitespace = "<response> <success>true</success> </response>" ;
5451 WebServiceMessage message = createMock (WebServiceMessage .class );
52+
5553 expect (message .getPayloadSource ()).andReturn (new StringSource (xml )).times (2 );
5654 replay (message );
5755
58- PayloadDiffMatcher matcher = new PayloadDiffMatcher (new StringSource (xmlWithAdditionalWhitespace ));
56+ var matcher = new PayloadDiffMatcher (new StringSource (xmlWithAdditionalWhitespace ));
5957 matcher .match (message );
6058
6159 verify (message );
6260 }
6361
64-
6562 @ Test
6663 public void nonMatch () {
6764
6865 assertThatExceptionOfType (AssertionError .class ).isThrownBy (() -> {
6966
70- String actual = "<element1 xmlns='http://example.com'/>" ;
67+ var actual = "<element1 xmlns='http://example.com'/>" ;
7168 WebServiceMessage message = createMock (WebServiceMessage .class );
69+
7270 expect (message .getPayloadSource ()).andReturn (new StringSource (actual )).times (2 );
7371 replay (message );
7472
75- String expected = "<element2 xmlns='http://example.com'/>" ;
76- PayloadDiffMatcher matcher = new PayloadDiffMatcher (new StringSource (expected ));
73+ var expected = "<element2 xmlns='http://example.com'/>" ;
74+ var matcher = new PayloadDiffMatcher (new StringSource (expected ));
7775 matcher .match (message );
7876 });
7977 }
@@ -83,12 +81,11 @@ public void noPayload() {
8381
8482 assertThatExceptionOfType (AssertionError .class ).isThrownBy (() -> {
8583
86- PayloadDiffMatcher matcher = new PayloadDiffMatcher (new StringSource ("<message/>" ));
87- MessageFactory messageFactory = MessageFactory .newInstance ();
88- SoapMessage soapMessage = new SaajSoapMessage (messageFactory .createMessage ());
84+ var matcher = new PayloadDiffMatcher (new StringSource ("<message/>" ));
85+ var messageFactory = MessageFactory .newInstance ();
86+ var soapMessage = new SaajSoapMessage (messageFactory .createMessage ());
8987
9088 matcher .createDiff (soapMessage );
9189 });
9290 }
93-
9491}
0 commit comments