Skip to content

SWS-1035 - XMLUnit migration from 1.5 to 2.6.2 #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<wss4j.version>2.2.0</wss4j.version>
<xmlsec.version>2.1.0</xmlsec.version>
<xml-schema-core.version>2.2.2</xml-schema-core.version>
<xmlunit.version>1.5</xmlunit.version>
<xmlunit.version>2.6.2</xmlunit.version>
<xws-security.version>3.0</xws-security.version>
<xom.version>1.2.5</xom.version>
</properties>
Expand Down Expand Up @@ -169,11 +169,23 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-assertj</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
<exclusions>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added because:

Dependency convergence error for org.assertj:assertj-core:2.9.0 paths to dependency are:
+-org.springframework.ws:spring-ws:3.0.4.BUILD-SNAPSHOT
  +-org.xmlunit:xmlunit-assertj:2.6.2
    +-org.assertj:assertj-core:2.9.0
and
+-org.springframework.ws:spring-ws:3.0.4.BUILD-SNAPSHOT
  +-org.assertj:assertj-core:3.9.0

<exclusion>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.springframework.xml.sax.SaxUtils;
import org.springframework.xml.transform.StringResult;

import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
Expand All @@ -56,7 +55,7 @@
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;

public abstract class AbstractWebServiceMessageTestCase {

Expand All @@ -78,7 +77,6 @@ public final void setUp() throws Exception {
transformer = transformerFactory.newTransformer();
webServiceMessage = createWebServiceMessage();
payload = new ClassPathResource("payload.xml", AbstractWebServiceMessageTestCase.class);
XMLUnit.setIgnoreWhitespace(true);
}

@Test
Expand All @@ -92,7 +90,7 @@ public void testDomPayload() throws Exception {
Document resultDocument = documentBuilder.newDocument();
DOMResult domResult = new DOMResult(resultDocument);
transformer.transform(webServiceMessage.getPayloadSource(), domResult);
assertXMLEqual(payloadDocument, resultDocument);
assertThat(resultDocument).and(payloadDocument).areSimilar();
validateMessage();
}

Expand All @@ -108,7 +106,7 @@ public void testEventReaderPayload() throws Exception {
Result staxResult = StaxUtils.createCustomStaxResult(eventWriter);
transformer.transform(webServiceMessage.getPayloadSource(), staxResult);
eventWriter.flush();
assertXMLEqual(getExpectedString(), stringWriter.toString());
assertThat(stringWriter.toString()).and(getExpectedString()).areSimilar();
validateMessage();
}

Expand All @@ -120,7 +118,7 @@ public void testReaderPayload() throws Exception {
StringWriter resultWriter = new StringWriter();
StreamResult streamResult = new StreamResult(resultWriter);
transformer.transform(webServiceMessage.getPayloadSource(), streamResult);
assertXMLEqual(getExpectedString(), resultWriter.toString());
assertThat(resultWriter.toString()).and(getExpectedString()).areSimilar();
}

@Test
Expand All @@ -129,7 +127,7 @@ public void testSaxPayload() throws Exception {
transformer.transform(saxSource, webServiceMessage.getPayloadResult());
StringResult stringResult = new StringResult();
transformer.transform(webServiceMessage.getPayloadSource(), stringResult);
assertXMLEqual(getExpectedString(), stringResult.toString());
assertThat(stringResult.toString()).and(getExpectedString()).areSimilar();
validateMessage();
}

Expand All @@ -142,7 +140,7 @@ public void testStreamPayload() throws Exception {
transformer.transform(webServiceMessage.getPayloadSource(), streamResult);
ByteArrayOutputStream expectedStream = new ByteArrayOutputStream();
FileCopyUtils.copy(payload.getInputStream(), expectedStream);
assertXMLEqual(expectedStream.toString("UTF-8"), resultStream.toString("UTF-8"));
assertThat(resultStream.toString("UTF-8")).and(expectedStream.toString("UTF-8")).areSimilar();
validateMessage();
}

Expand All @@ -158,7 +156,7 @@ public void testStreamReaderPayload() throws Exception {
Result staxResult = StaxUtils.createCustomStaxResult(streamWriter);
transformer.transform(webServiceMessage.getPayloadSource(), staxResult);
streamWriter.flush();
assertXMLEqual(getExpectedString(), stringWriter.toString());
assertThat(stringWriter.toString()).and(getExpectedString()).areSimilar();
validateMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import org.junit.AfterClass;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -118,7 +118,7 @@ public void sendSourceAndReceiveToResult() throws SAXException, IOException {
boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/echo",
new StringSource(messagePayload), result);
Assert.assertTrue("Invalid result", b);
assertXMLEqual(messagePayload, result.toString());
assertThat(result.toString()).and(messagePayload).areSimilar();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import org.junit.AfterClass;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -129,7 +129,7 @@ public void sendSourceAndReceiveToResult() throws SAXException, IOException {
boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/echo",
new StringSource(messagePayload), result);
Assert.assertTrue("Invalid result", b);
assertXMLEqual(messagePayload, result.toString());
assertThat(result.toString()).and(messagePayload).areSimilar();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -79,7 +79,7 @@ public void domPox() throws Exception {
StringResult result = new StringResult();
template.sendSourceAndReceiveToResult(baseUrl + "/pox", new StringSource(content),
result);
assertXMLEqual(content, result.toString());
assertThat(result.toString()).and(content).areSimilar();
try {
template.sendSourceAndReceiveToResult(baseUrl + "/errors/notfound",
new StringSource(content), new StringResult());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.junit.Test;
import org.w3c.dom.Document;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;

public class DomPoxMessageTest {

Expand All @@ -54,7 +54,7 @@ public void testGetPayload() throws Exception {
transformer.transform(source, message.getPayloadResult());
StringResult stringResult = new StringResult();
transformer.transform(message.getPayloadSource(), stringResult);
assertXMLEqual(content, stringResult.toString());
assertThat(stringResult.toString()).and(content).areSimilar();
}

@Test
Expand All @@ -64,7 +64,7 @@ public void testGetPayloadResultTwice() throws Exception {
transformer.transform(new StringSource(content), message.getPayloadResult());
StringResult stringResult = new StringResult();
transformer.transform(message.getPayloadSource(), stringResult);
assertXMLEqual(content, stringResult.toString());
assertThat(stringResult.toString()).and(content).areSimilar();
}

@Test
Expand All @@ -74,6 +74,6 @@ public void testWriteTo() throws Exception {
transformer.transform(source, message.getPayloadResult());
ByteArrayOutputStream os = new ByteArrayOutputStream();
message.writeTo(os);
assertXMLEqual(content, os.toString("UTF-8"));
assertThat(os.toString("UTF-8")).and(content).areSimilar();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.junit.Before;
import org.junit.Test;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -67,7 +67,7 @@ protected final void testSource(Source requestSource) throws Exception {
new DefaultMessageContext(new MockWebServiceMessage(requestSource), new MockWebServiceMessageFactory());
endpoint.invoke(context);
assertTrue("No response message created", context.hasResponse());
assertXMLEqual(RESPONSE, ((MockWebServiceMessage) context.getResponse()).getPayloadAsString());
assertThat(((MockWebServiceMessage) context.getResponse()).getPayloadAsString()).and(RESPONSE).areSimilar();
}

protected abstract MessageEndpoint createNoResponseEndpoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.junit.Before;
import org.junit.Test;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

Expand Down Expand Up @@ -63,7 +63,7 @@ protected final void testSource(Source requestSource) throws Exception {
assertNotNull("No response source returned", responseSource);
StringResult result = new StringResult();
transformer.transform(responseSource, result);
assertXMLEqual(RESPONSE, result.toString());
assertThat(result.toString()).and(RESPONSE).areSimilar();
}

protected abstract PayloadEndpoint createNoResponseEndpoint() throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import static org.easymock.EasyMock.*;
import org.junit.Assert;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -73,7 +73,7 @@ public Object unmarshal(Source source) throws XmlMappingException {
try {
StringWriter writer = new StringWriter();
transformer.transform(source, new StreamResult(writer));
assertXMLEqual("Invalid source", "<request/>", writer.toString());
assertThat(writer.toString()).and("<request/>").areSimilar();
return 42L;
}
catch (Exception e) {
Expand Down Expand Up @@ -112,7 +112,7 @@ protected Object invokeInternal(Object requestObject) throws Exception {
endpoint.invoke(context);
MockWebServiceMessage response = (MockWebServiceMessage) context.getResponse();
Assert.assertNotNull("Invalid result", response);
assertXMLEqual("Invalid response", "<result/>", response.getPayloadAsString());
assertThat(response.getPayloadAsString()).and("<result/>").areSimilar();

verify(factoryMock);
}
Expand All @@ -125,7 +125,7 @@ public Object unmarshal(Source source) throws XmlMappingException {
try {
StringWriter writer = new StringWriter();
transformer.transform(source, new StreamResult(writer));
assertXMLEqual("Invalid source", "<request/>", writer.toString());
assertThat(writer.toString()).and("<request/>").areSimilar();
return (long) 42;
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.apache.axiom.soap.SOAPFactory;
import org.junit.Test;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import static org.junit.Assert.*;

/**
Expand Down Expand Up @@ -114,7 +114,7 @@ public void testSaajResponse() throws Exception {
assertTrue("context has not response", context.hasResponse());
StringResult stringResult = new StringResult();
transformer.transform(context.getResponse().getPayloadSource(), stringResult);
assertXMLEqual(RESPONSE, stringResult.toString());
assertThat(stringResult.toString()).and(RESPONSE).areSimilar();
}

@Test
Expand All @@ -132,7 +132,7 @@ public void testAxiomResponse() throws Exception {
assertTrue("context has not response", context.hasResponse());
StringResult stringResult = new StringResult();
transformer.transform(context.getResponse().getPayloadSource(), stringResult);
assertXMLEqual(RESPONSE, stringResult.toString());
assertThat(stringResult.toString()).and(RESPONSE).areSimilar();
}

@Test
Expand Down Expand Up @@ -167,7 +167,7 @@ public void testAxiomResponseNoPayloadCaching() throws Exception {

StringResult stringResult = new StringResult();
transformer.transform(context.getResponse().getPayloadSource(), stringResult);
assertXMLEqual(RESPONSE, stringResult.toString());
assertThat(stringResult.toString()).and(RESPONSE).areSimilar();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.junit.Before;
import org.junit.Test;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import static org.easymock.EasyMock.*;

public class PayloadEndpointAdapterTest {
Expand Down Expand Up @@ -62,7 +62,7 @@ public void testInvoke() throws Exception {
public Source invoke(Source request) throws Exception {
StringWriter writer = new StringWriter();
transformer.transform(request, new StreamResult(writer));
assertXMLEqual("Invalid request", "<request/>", writer.toString());
assertThat(writer.toString()).and("<request/>").areSimilar();
return new StreamSource(new StringReader("<response/>"));
}
};
Expand All @@ -71,7 +71,7 @@ public Source invoke(Source request) throws Exception {
adapter.invoke(messageContext, endpoint);
MockWebServiceMessage response = (MockWebServiceMessage) messageContext.getResponse();
Assert.assertNotNull("No response created", response);
assertXMLEqual("Invalid payload", "<response/>", response.getPayloadAsString());
assertThat(response.getPayloadAsString()).and("<response/>").areSimilar();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.junit.Before;
import org.junit.Test;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.xmlunit.assertj.XmlAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -135,7 +135,7 @@ private void testHandleReturnValue(MessageContext messageContext) throws Excepti
Source responsePayload = messageContext.getResponse().getPayloadSource();
StringResult result = new StringResult();
transform(responsePayload, result);
assertXMLEqual(XML, result.toString());
assertThat(result.toString()).and(XML).areSimilar();
}
}

Expand Down
Loading