From 7803c1bc79139fb2596177643f22c9abdb30d0e5 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Wed, 30 Jan 2019 10:55:47 +0100 Subject: [PATCH] Fix integration tests (cherry picked from commit 422c233e3c46728c58b0f15350b7230d86e96235) --- build.gradle | 2 -- .../src/test/resources/expectedOutput.ldif | 4 ++-- .../item/json/JsonItemReaderFunctionalTests.java | 16 +++++++++++++++- .../AbstractStaxEventWriterItemWriterTests.java | 7 +++++-- .../item/xml/Jaxb2NamespaceMarshallingTests.java | 4 ++-- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index ffa5f40ed..3c91ce683 100644 --- a/build.gradle +++ b/build.gradle @@ -94,7 +94,6 @@ allprojects { sqlfireclientVersion = '1.0.3' sqliteVersion = '3.25.2' woodstoxVersion = '5.0.3' - xercesVersion = '2.11.0' //? xmlunitVersion = '2.6.2' xstreamVersion = '1.4.10' jrubyVersion = '1.7.26' @@ -465,7 +464,6 @@ project('spring-batch-infrastructure-tests') { } testCompile "org.apache.logging.log4j:log4j-api:$log4jVersion" testCompile "org.apache.logging.log4j:log4j-core:$log4jVersion" - testCompile "xerces:xercesImpl:$xercesVersion" testCompile "com.thoughtworks.xstream:xstream:$xstreamVersion" testCompile("com.fasterxml.woodstox:woodstox-core:$woodstoxVersion") { exclude group: 'stax', module: 'stax-api' diff --git a/spring-batch-core-tests/src/test/resources/expectedOutput.ldif b/spring-batch-core-tests/src/test/resources/expectedOutput.ldif index 82ac4e039..027fc24d0 100644 --- a/spring-batch-core-tests/src/test/resources/expectedOutput.ldif +++ b/spring-batch-core-tests/src/test/resources/expectedOutput.ldif @@ -23,8 +23,8 @@ dn: cn=Gern Jensen,ou=Product Testing,dc=airius,dc=com telephonenumber: +1 408 555 1212 uid: gernj description:: V2hhdCBhIGNhcmVmdWwgcmVhZGVyIHlvdSBhcmUhICBUaGlzIHZhbHVlIGlzIGJhc2UtNjQtZW5j -b2RlZCBiZWNhdXNlIGl0IGhhcyBhIGNvbnRyb2wgY2hhcmFjdGVyIGluIGl0IChhIENSKS4NICBC -eSB0aGUgd2F5LCB5b3Ugc2hvdWxkIHJlYWxseSBnZXQgb3V0IG1vcmUu + b2RlZCBiZWNhdXNlIGl0IGhhcyBhIGNvbnRyb2wgY2hhcmFjdGVyIGluIGl0IChhIENSKS4NICBC + eSB0aGUgd2F5LCB5b3Ugc2hvdWxkIHJlYWxseSBnZXQgb3V0IG1vcmUu objectclass: top objectclass: person objectclass: organizationalPerson diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java index ca5e5f23d..d8cf1a97c 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/json/JsonItemReaderFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2019 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. @@ -70,6 +70,20 @@ public abstract class JsonItemReaderFunctionalTests { Assert.assertEquals(new BigDecimal("1.4"), trade.getPrice()); Assert.assertEquals(2, trade.getQuantity()); + trade = itemReader.read(); + Assert.assertNotNull(trade); + Assert.assertEquals("789", trade.getIsin()); + Assert.assertEquals("foobar", trade.getCustomer()); + Assert.assertEquals(new BigDecimal("1.6"), trade.getPrice()); + Assert.assertEquals(3, trade.getQuantity()); + + trade = itemReader.read(); + Assert.assertNotNull(trade); + Assert.assertEquals("100", trade.getIsin()); + Assert.assertEquals("barfoo", trade.getCustomer()); + Assert.assertEquals(new BigDecimal("1.8"), trade.getPrice()); + Assert.assertEquals(4, trade.getQuantity()); + trade = itemReader.read(); Assert.assertNull(trade); } diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/xml/AbstractStaxEventWriterItemWriterTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/xml/AbstractStaxEventWriterItemWriterTests.java index 4013ba44a..b1f02e73a 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/xml/AbstractStaxEventWriterItemWriterTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/xml/AbstractStaxEventWriterItemWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 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. @@ -26,6 +26,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.xmlunit.builder.Input; +import org.xmlunit.diff.DefaultNodeMatcher; +import org.xmlunit.diff.ElementSelectors; import org.xmlunit.matchers.CompareMatcher; import org.springframework.batch.item.ExecutionContext; @@ -97,7 +99,8 @@ public abstract class AbstractStaxEventWriterItemWriterTests { assertThat( Input.from(expected.getFile()), - CompareMatcher.isSimilarTo(Input.from(resource.getFile()))); + CompareMatcher.isSimilarTo(Input.from(resource.getFile())) + .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))); } @Before diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/xml/Jaxb2NamespaceMarshallingTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/xml/Jaxb2NamespaceMarshallingTests.java index 271866e47..e2addf96c 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/xml/Jaxb2NamespaceMarshallingTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/xml/Jaxb2NamespaceMarshallingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2014 the original author or authors. + * Copyright 2010-2019 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. @@ -101,7 +101,7 @@ public class Jaxb2NamespaceMarshallingTests { assertThat( Input.from(expected.getFile()), - CompareMatcher.isSimilarTo(Input.from(resource.getFile()))); + CompareMatcher.isSimilarTo(Input.from(resource.getFile())).normalizeWhitespace()); } @Before