Upgrade dependencies including Gradle
* Fix compatibility with upgraded dependencies * Move `What's New` for `5.4` to `history` * Add `XmlUnit` dependency since the latest AssertJ has deprecated its `isXmlEqualTo()` * Remove `javax.annotation-api` and `apiguardian-api` as redundant dependencies
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.integration.xml;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.xmlunit.assertj3.XmlAssert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -30,15 +30,14 @@ import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
@@ -56,7 +55,7 @@ public class DefaultXmlPayloadConverterTests {
|
||||
|
||||
private static Document testDocument;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
testDocument =
|
||||
DocumentBuilderFactory.newInstance()
|
||||
@@ -65,9 +64,9 @@ public class DefaultXmlPayloadConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDocumentWithString() throws Exception {
|
||||
public void testGetDocumentWithString() {
|
||||
Document doc = converter.convertToDocument(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(XmlTestUtil.docToString(doc)).isXmlEqualTo(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(doc).and(TEST_DOCUMENT_AS_STRING).areIdentical();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,15 +83,15 @@ public class DefaultXmlPayloadConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNodePassingString() throws Exception {
|
||||
public void testGetNodePassingString() {
|
||||
Node n = converter.convertToNode(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(XmlTestUtil.docToString((Document) n)).isXmlEqualTo(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(n).and(TEST_DOCUMENT_AS_STRING).areIdentical();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNodePassingDocument() throws Exception {
|
||||
Node n = converter.convertToNode(testDocument);
|
||||
assertThat(XmlTestUtil.docToString((Document) n)).isXmlEqualTo(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(n).and(TEST_DOCUMENT_AS_STRING).areIdentical();
|
||||
}
|
||||
|
||||
|
||||
@@ -152,14 +151,14 @@ public class DefaultXmlPayloadConverterTests {
|
||||
@Test
|
||||
public void testConvertBytesToDocument() throws Exception {
|
||||
Document doc = converter.convertToDocument(TEST_DOCUMENT_AS_STRING.getBytes());
|
||||
assertThat(XmlTestUtil.docToString(doc)).isXmlEqualTo(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(doc).and(TEST_DOCUMENT_AS_STRING).areIdentical();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertFileToDocument() throws Exception {
|
||||
File file = new ClassPathResource("org/springframework/integration/xml/customSource.data").getFile();
|
||||
Document doc = converter.convertToDocument(file);
|
||||
assertThat(XmlTestUtil.docToString(doc)).isXmlEqualTo(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(doc).and(TEST_DOCUMENT_AS_STRING).areSimilar();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,7 +166,7 @@ public class DefaultXmlPayloadConverterTests {
|
||||
InputStream inputStream = new ClassPathResource("org/springframework/integration/xml/customSource.data")
|
||||
.getInputStream();
|
||||
Document doc = converter.convertToDocument(inputStream);
|
||||
assertThat(XmlTestUtil.docToString(doc)).isXmlEqualTo(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(doc).and(TEST_DOCUMENT_AS_STRING).areSimilar();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,13 +174,13 @@ public class DefaultXmlPayloadConverterTests {
|
||||
ClassPathResource resource = new ClassPathResource("org/springframework/integration/xml/customSource.data");
|
||||
StreamSource source = new StreamSource(resource.getInputStream());
|
||||
Document doc = converter.convertToDocument(source);
|
||||
assertThat(XmlTestUtil.docToString(doc)).isXmlEqualTo(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(doc).and(TEST_DOCUMENT_AS_STRING).areSimilar();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertCustomSourceToDocument() throws Exception {
|
||||
public void testConvertCustomSourceToDocument() {
|
||||
Document doc = converter.convertToDocument(new MySource());
|
||||
assertThat(XmlTestUtil.docToString(doc)).isXmlEqualTo(TEST_DOCUMENT_AS_STRING);
|
||||
assertThat(doc).and(TEST_DOCUMENT_AS_STRING).areSimilar();
|
||||
}
|
||||
|
||||
private static class MySource implements Source {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,19 +16,17 @@
|
||||
|
||||
package org.springframework.integration.xml.source;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.xmlunit.assertj3.XmlAssert.assertThat;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
@@ -47,13 +45,10 @@ public class DomSourceFactoryTests {
|
||||
|
||||
private static Document doc;
|
||||
|
||||
private static Transformer transformer;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
StringReader reader = new StringReader(docContent);
|
||||
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(reader));
|
||||
transformer = TransformerFactory.newInstance().newTransformer();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,7 +56,7 @@ public class DomSourceFactoryTests {
|
||||
Source source = sourceFactory.createSource(doc);
|
||||
assertThat(source).isNotNull();
|
||||
assertThat(source).isInstanceOf(DOMSource.class);
|
||||
assertThat(XmlTestUtil.sourceToString(source)).isXmlEqualTo(docContent);
|
||||
assertThat(XmlTestUtil.sourceToString(source)).and(docContent).areIdentical();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,7 +64,7 @@ public class DomSourceFactoryTests {
|
||||
Source source = sourceFactory.createSource(docContent);
|
||||
assertThat(source).isNotNull();
|
||||
assertThat(source).isInstanceOf(DOMSource.class);
|
||||
assertThat(XmlTestUtil.sourceToString(source)).isXmlEqualTo(docContent);
|
||||
assertThat(XmlTestUtil.sourceToString(source)).and(docContent).areIdentical();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.springframework.integration.xml.source;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.xmlunit.assertj3.XmlAssert.assertThat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
@@ -46,7 +46,7 @@ public class StringSourceTests {
|
||||
BufferedReader reader = new BufferedReader(source.getReader());
|
||||
String docAsString = reader.readLine();
|
||||
|
||||
assertThat(docAsString).isXmlEqualTo(docString);
|
||||
assertThat(docAsString).and(docString).areIdentical();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class StringSourceTests {
|
||||
BufferedReader reader = new BufferedReader(source.getReader());
|
||||
String docAsString = reader.readLine();
|
||||
|
||||
assertThat(docAsString).isXmlEqualTo(docString);
|
||||
assertThat(docAsString).and(docString).areIdentical();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.xmlunit.assertj3.XmlAssert.assertThat;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -25,8 +25,8 @@ import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
import javax.xml.transform.sax.SAXResult;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
@@ -42,21 +42,21 @@ public class ResultToStringTransformerTests {
|
||||
|
||||
private ResultToStringTransformer transformer;
|
||||
|
||||
private String doc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><order><orderItem>test</orderItem></order>";
|
||||
private static final String doc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><order><orderItem>test</orderItem></order>";
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
transformer = new ResultToStringTransformer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDomResult() throws Exception {
|
||||
DOMResult result = XmlTestUtil.getDomResultForString(this.doc);
|
||||
DOMResult result = XmlTestUtil.getDomResultForString(doc);
|
||||
Object transformed = transformer.transformResult(result);
|
||||
assertThat(transformed).isInstanceOf(String.class);
|
||||
String transformedString = (String) transformed;
|
||||
assertThat(transformedString).isXmlEqualTo(this.doc);
|
||||
assertThat(transformedString).and(doc).areIdentical();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +78,7 @@ public class ResultToStringTransformerTests {
|
||||
Object transformed = transformer.transformResult(result);
|
||||
assertThat(transformed).isInstanceOf(String.class);
|
||||
String transformedString = (String) transformed;
|
||||
assertThat(transformedString).isXmlEqualTo(this.doc);
|
||||
assertThat(transformedString).and(doc).areIdentical();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.xmlunit.assertj3.XmlAssert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -29,10 +29,9 @@ import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.mockito.Mockito;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
@@ -67,10 +66,10 @@ public class XsltPayloadTransformerTests {
|
||||
|
||||
private final String outputAsString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><bob>test</bob>";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
@TempDir
|
||||
public File temporaryFolder;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
this.testTransformer = new XsltPayloadTransformer(getXslTemplates());
|
||||
this.testTransformer.setBeanFactory(Mockito.mock(BeanFactory.class));
|
||||
@@ -85,8 +84,7 @@ public class XsltPayloadTransformerTests {
|
||||
assertThat(transformed)
|
||||
.as("Wrong return type for document payload")
|
||||
.isInstanceOf(Document.class);
|
||||
Document transformedDocument = (Document) transformed;
|
||||
assertThat(XmlTestUtil.docToString(transformedDocument)).isXmlEqualTo(this.outputAsString);
|
||||
assertThat(transformed).and(this.outputAsString).areSimilar();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,9 +97,10 @@ public class XsltPayloadTransformerTests {
|
||||
.isInstanceOf(DOMResult.class);
|
||||
|
||||
DOMResult result = (DOMResult) transformed;
|
||||
assertThat(XmlTestUtil.docToString((Document) result.getNode()))
|
||||
assertThat(result.getNode())
|
||||
.as("Document incorrect after transformation")
|
||||
.isXmlEqualTo(this.outputAsString);
|
||||
.and(this.outputAsString)
|
||||
.areSimilar();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,10 +111,10 @@ public class XsltPayloadTransformerTests {
|
||||
.as("Wrong return type for document payload")
|
||||
.isInstanceOf(String.class);
|
||||
|
||||
String transformedString = (String) transformed;
|
||||
assertThat(transformedString)
|
||||
assertThat(transformed)
|
||||
.as("String incorrect after transform")
|
||||
.isXmlEqualTo(this.outputAsString);
|
||||
.and(this.outputAsString)
|
||||
.areIdentical();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,9 +127,10 @@ public class XsltPayloadTransformerTests {
|
||||
.isInstanceOf(DOMResult.class);
|
||||
|
||||
DOMResult result = (DOMResult) transformed;
|
||||
assertThat(XmlTestUtil.docToString((Document) result.getNode()))
|
||||
assertThat(result.getNode())
|
||||
.as("Document incorrect after transformation")
|
||||
.isXmlEqualTo(this.outputAsString);
|
||||
.and(this.outputAsString)
|
||||
.areSimilar();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -259,7 +259,8 @@ public class XsltPayloadTransformerTests {
|
||||
" <xsl:template match=\"order\">hello world</xsl:template>" +
|
||||
"</xsl:stylesheet>";
|
||||
|
||||
File xsltFile = this.temporaryFolder.newFile();
|
||||
this.temporaryFolder.mkdir();
|
||||
File xsltFile = File.createTempFile("test", null, this.temporaryFolder);
|
||||
FileCopyUtils.copy(xsl.getBytes(), xsltFile);
|
||||
return new FileSystemResource(xsltFile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user