From bdb3ba8ebd67ca9341db99a7b8207a35a2100fd5 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 2 Dec 2020 17:20:46 -0500 Subject: [PATCH] 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 --- build.gradle | 62 +++++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- ...ingAnnotationsWithBeanAnnotationTests.java | 4 +- .../KafkaMessageListenerContainerSpec.java | 16 +--- .../webflux/dsl/WebFluxDslTests.java | 5 +- .../xml/DefaultXmlPayloadConverterTests.java | 33 ++++--- .../xml/source/DomSourceFactoryTests.java | 19 ++-- .../xml/source/StringSourceTests.java | 10 +- .../ResultToStringTransformerTests.java | 18 ++-- .../XsltPayloadTransformerTests.java | 39 ++++---- src/checkstyle/checkstyle.xml | 1 + src/reference/asciidoc/changes-5.3-5.4.adoc | 89 ++++++++++++++++++ src/reference/asciidoc/history.adoc | 2 + src/reference/asciidoc/index-header.adoc | 2 +- src/reference/asciidoc/preface.adoc | 4 +- src/reference/asciidoc/whats-new.adoc | 91 +------------------ 16 files changed, 195 insertions(+), 202 deletions(-) create mode 100644 src/reference/asciidoc/changes-5.3-5.4.adoc diff --git a/build.gradle b/build.gradle index f113947dd4..ee4e49c7b5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ buildscript { - ext.kotlinVersion = '1.4.10' + ext.kotlinVersion = '1.4.20' repositories { + mavenCentral() maven { url 'https://repo.spring.io/plugins-release' } } dependencies { @@ -14,7 +15,7 @@ plugins { id 'io.spring.nohttp' version '0.0.5.RELEASE' apply false id 'org.ajoberstar.grgit' version '4.1.0' id "io.spring.dependency-management" version '1.0.10.RELEASE' - id 'com.jfrog.artifactory' version '4.18.0' apply false + id 'com.jfrog.artifactory' version '4.18.2' apply false id 'org.jetbrains.dokka' version '0.10.1' id 'org.asciidoctor.jvm.pdf' version '3.3.0' id 'org.asciidoctor.jvm.gems' version '3.3.0' @@ -48,31 +49,30 @@ ext { activeMqVersion = '5.16.0' apacheSshdVersion = '2.5.1' aspectjVersion = '1.9.6' - assertjVersion = '3.17.2' + assertjVersion = '3.18.1' assertkVersion = '0.23' avroVersion = '1.10.0' awaitilityVersion = '4.0.3' commonsDbcp2Version = '2.8.0' commonsIoVersion = '2.8.0' - commonsNetVersion = '3.7' + commonsNetVersion = '3.7.2' curatorVersion = '4.3.0' derbyVersion = '10.14.2.0' ftpServerVersion = '1.1.1' googleJsr305Version = '3.0.2' groovyVersion = '3.0.6' hamcrestVersion = '2.2' - hazelcastVersion = '4.0.3' - hibernateVersion = '5.4.23.Final' + hazelcastVersion = '4.1' + hibernateVersion = '5.4.25.Final' hsqldbVersion = '2.5.1' h2Version = '1.4.200' - jacksonVersion = '2.11.3' + jacksonVersion = '2.12.0' javaxActivationVersion = '1.2.0' - javaxAnnotationVersion= '1.3.2' jaxbVersion = '2.3.3' jeroMqVersion = '0.5.2' jmsApiVersion = '2.0.1' jpa21ApiVersion = '1.0.2.Final' - jpaApiVersion = '2.2.1' + jpaApiVersion = '2.7.7' jrubyVersion = '9.2.13.0' jschVersion = '0.1.55' jsonpathVersion = '2.4.0' @@ -81,13 +81,13 @@ ext { jythonVersion = '2.7.2' kryoShadedVersion = '4.0.2' lettuceVersion = '6.0.1.RELEASE' - log4jVersion = '2.13.3' + log4jVersion = '2.14.0' mailVersion = '1.6.5' - micrometerVersion = '1.5.7' - mockitoVersion = '3.6.0' - mongoDriverVersion = '4.1.1' + micrometerVersion = '1.6.1' + mockitoVersion = '3.6.28' + mongoDriverVersion = '4.2.0-beta1' mysqlVersion = '8.0.22' - pahoMqttClientVersion = '1.2.4' + pahoMqttClientVersion = '1.2.5' postgresVersion = '42.2.18' r2dbch2Version='0.8.4.RELEASE' reactorVersion = '2020.0.1' @@ -99,14 +99,15 @@ ext { smackVersion = '4.3.5' soapVersion = '1.4.0' springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.3.1' - springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2020.0.1' - springKafkaVersion = '2.6.3' + springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2021.0.0-SNAPSHOT' + springKafkaVersion = '2.7.0-SNAPSHOT' springRetryVersion = '1.3.0' - springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.4.1' + springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.5.0-SNAPSHOT' springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.3.1' - springWsVersion = '3.0.10.RELEASE' - tomcatVersion = "9.0.39" - xstreamVersion = '1.4.13' + springWsVersion = '3.1.0-SNAPSHOT' + tomcatVersion = "9.0.40" + xmlUnitVersion = '2.8.1' + xstreamVersion = '1.4.14' javaProjects = subprojects - project(':spring-integration-bom') } @@ -124,6 +125,8 @@ allprojects { maven { url 'https://repo.spring.io/libs-snapshot' } } // maven { url 'https://repo.spring.io/libs-staging-local' } + + maven { url 'https://repository.apache.org/content/groups/staging/' } // Kafka Client } ext.javadocLinks = [ @@ -196,6 +199,10 @@ configure(javaProjects) { subproject -> targetCompatibility = 1.8 } + compileTestJava { + sourceCompatibility = 11 + } + compileKotlin { kotlinOptions { jvmTarget = '1.8' @@ -203,7 +210,7 @@ configure(javaProjects) { subproject -> } compileTestKotlin { kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '11' } } @@ -237,10 +244,6 @@ configure(javaProjects) { subproject -> testImplementation 'io.projectreactor:reactor-test' testImplementation "com.jayway.jsonpath:json-path:$jsonpathVersion" testImplementation 'com.fasterxml.jackson.core:jackson-databind' - testImplementation "javax.annotation:javax.annotation-api:$javaxAnnotationVersion" - - // To avoid compiler warnings about @API annotations in JUnit code - testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' @@ -325,7 +328,7 @@ configure(javaProjects) { subproject -> checkstyle { configDirectory.set(rootProject.file("src/checkstyle")) - toolVersion = project.hasProperty('checkstyleVersion') ? project.checkstyleVersion : '8.37' + toolVersion = project.hasProperty('checkstyleVersion') ? project.checkstyleVersion : '8.38' } jar { @@ -581,7 +584,7 @@ project('spring-integration-jpa') { dependencies { api project(':spring-integration-core') api 'org.springframework:spring-orm' - optionalApi "org.eclipse.persistence:javax.persistence:$jpaApiVersion" + optionalApi "org.eclipse.persistence:org.eclipse.persistence.jpa:$jpaApiVersion" testImplementation ('org.springframework.data:spring-data-jpa') { exclude group: 'org.springframework' @@ -589,7 +592,7 @@ project('spring-integration-jpa') { testImplementation "com.h2database:h2:$h2Version" testImplementation "org.hibernate:hibernate-entitymanager:$hibernateVersion" - testRuntimeOnly "org.hibernate.javax.persistence:hibernate-jpa-2.1-api:$jpa21ApiVersion" +// testRuntimeOnly "org.hibernate.javax.persistence:hibernate-jpa-2.1-api:$jpa21ApiVersion" } } @@ -723,7 +726,7 @@ project('spring-integration-sftp') { api project(':spring-integration-file') api "com.jcraft:jsch:$jschVersion" api 'org.springframework:spring-context-support' - optionalApi "javax.activation:javax.activation-api:$javaxActivationVersion" +// optionalApi "javax.activation:javax.activation-api:$javaxActivationVersion" optionalApi "org.apache.sshd:sshd-sftp:$apacheSshdVersion" testImplementation "org.apache.sshd:sshd-core:$apacheSshdVersion" @@ -848,6 +851,7 @@ project('spring-integration-xml') { } testImplementation "com.sun.xml.bind:jaxb-impl:$jaxbVersion" + testImplementation "org.xmlunit:xmlunit-assertj3:$xmlUnitVersion" } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index be52383ef4..4d9ca16491 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationsWithBeanAnnotationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationsWithBeanAnnotationTests.java index cb5dd0f3f8..9f08fb2558 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationsWithBeanAnnotationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationsWithBeanAnnotationTests.java @@ -27,8 +27,6 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Resource; - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -105,7 +103,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests { @Autowired private PollableChannel discardChannel; - @Resource(name = "collector") + @Autowired private List> collector; @Autowired(required = false) diff --git a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/dsl/KafkaMessageListenerContainerSpec.java b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/dsl/KafkaMessageListenerContainerSpec.java index bd7b735285..73e41fdf28 100644 --- a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/dsl/KafkaMessageListenerContainerSpec.java +++ b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/dsl/KafkaMessageListenerContainerSpec.java @@ -229,26 +229,12 @@ public class KafkaMessageListenerContainerSpec return this; } - /** - * Set whether the container should ack messages that throw exceptions or not. - * @param ackOnError whether the container should acknowledge messages that throw - * exceptions. - * @return the spec. - * @deprecated in favor of {@code GenericErrorHandler.isAckAfterHandle()}. - * @see ContainerProperties#setAckOnError(boolean) - */ - @Deprecated - public KafkaMessageListenerContainerSpec ackOnError(boolean ackOnError) { - this.target.getContainerProperties().setAckOnError(ackOnError); - return this; - } - /** * Set the group id for this container. Overrides any {@code group.id} property * provided by the consumer factory configuration. * @param groupId the group id. * @return the spec. - * @see ContainerProperties#setAckOnError(boolean) + * @see ContainerProperties#setGroupId(String) */ public KafkaMessageListenerContainerSpec groupId(String groupId) { this.target.getContainerProperties().setGroupId(groupId); diff --git a/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java b/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java index 0339ebb661..e97bff1c98 100644 --- a/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java +++ b/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java @@ -25,8 +25,6 @@ import java.security.Principal; import java.time.Duration; import java.util.Collections; -import javax.annotation.Resource; - import org.hamcrest.Matchers; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; @@ -120,7 +118,8 @@ public class WebFluxDslTests { @Qualifier("webFluxWithReplyPayloadToFlux.handler") private WebFluxRequestExecutingMessageHandler webFluxWithReplyPayloadToFlux; - @Resource(name = "httpReactiveProxyFlow.webflux:outbound-gateway#0") + @Autowired + @Qualifier("httpReactiveProxyFlow.webflux:outbound-gateway#0") private WebFluxRequestExecutingMessageHandler httpReactiveProxyFlow; @Autowired diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/DefaultXmlPayloadConverterTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/DefaultXmlPayloadConverterTests.java index 0d5a2808d0..849c4e2e8b 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/DefaultXmlPayloadConverterTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/DefaultXmlPayloadConverterTests.java @@ -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 { diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/source/DomSourceFactoryTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/source/DomSourceFactoryTests.java index a2e2a76b11..89d506241c 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/source/DomSourceFactoryTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/source/DomSourceFactoryTests.java @@ -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 diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/source/StringSourceTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/source/StringSourceTests.java index c0593c979a..fd13824b78 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/source/StringSourceTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/source/StringSourceTests.java @@ -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(); } diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/ResultToStringTransformerTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/ResultToStringTransformerTests.java index 5f58dbd3f5..528fb61df3 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/ResultToStringTransformerTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/ResultToStringTransformerTests.java @@ -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 = "test"; + private static final String doc = "test"; - @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 diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java index 4432359a34..3a0526a1b5 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java @@ -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 = "test"; - @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 { " hello world" + ""; - 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); } diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 6a12e3b499..4ce3280c1b 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -78,6 +78,7 @@