|
22 | 22 | import static org.easymock.EasyMock.replay;
|
23 | 23 | import static org.easymock.EasyMock.verify;
|
24 | 24 |
|
| 25 | +import javax.xml.transform.TransformerException; |
25 | 26 | import javax.xml.transform.dom.DOMResult;
|
26 | 27 |
|
27 | 28 | import org.junit.jupiter.api.Test;
|
|
30 | 31 | import org.springframework.xml.transform.TransformerHelper;
|
31 | 32 | import org.w3c.dom.Document;
|
32 | 33 |
|
| 34 | +import java.io.IOException; |
| 35 | + |
33 | 36 | public class SoapEnvelopeDiffMatcherTest {
|
34 | 37 |
|
35 | 38 | @Test
|
@@ -76,4 +79,26 @@ public void nonMatch() {
|
76 | 79 | matcher.match(message);
|
77 | 80 | });
|
78 | 81 | }
|
| 82 | + |
| 83 | + @Test |
| 84 | + public void matchWithXmlIgnore() throws TransformerException, IOException { |
| 85 | + String xml = """ |
| 86 | + <?xml version='1.0'?> |
| 87 | + <soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'> |
| 88 | + <soap:Header><header xmlns='http://example.com'/></soap:Header> |
| 89 | + <soap:Body><payload xmlns='http://example.com'>%s</payload></soap:Body> |
| 90 | + </soap:Envelope>"""; |
| 91 | + |
| 92 | + String actual = String.format(xml, "1"); |
| 93 | + DOMResult result = new DOMResult(); |
| 94 | + TransformerHelper transformerHelper = new TransformerHelper(); |
| 95 | + transformerHelper.transform(new StringSource(actual), result); |
| 96 | + SoapMessage message = createMock(SoapMessage.class); |
| 97 | + expect(message.getDocument()).andReturn((Document) result.getNode()).once(); |
| 98 | + replay(message); |
| 99 | + |
| 100 | + String expected = String.format(xml, "${xmlunit.ignore}"); |
| 101 | + SoapEnvelopeDiffMatcher matcher = new SoapEnvelopeDiffMatcher(new StringSource(expected)); |
| 102 | + matcher.match(message); |
| 103 | + } |
79 | 104 | }
|
0 commit comments