From 2f552b74493884a601d936515a29aa27853bf8ca Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 21 Oct 2015 14:15:46 +0100 Subject: [PATCH] Make FlatFileItemReaderTests Spring Framework 4.2 compatible Previously, FlatFileItemReaderTests made a precise assertion that involved the toString output from ByteArrayResource. This output has changed between Spring Framework 4.0.x and Spring Framework 4.2.x. As a result, the test fails when run as part of the Spring IO Platform build which forces the version of Spring Framework to 4.2.x. This commit updates the failing test so that it passes against both Spring Framework 4.0.x and Spring Framework 4.2.x by relaxing the assertion a little so that it is not dependent on the precise output of ByteArrayResource's toString method. --- .../batch/item/file/FlatFileItemReaderTests.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java index 4123d999d..4c1884e4c 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java @@ -15,15 +15,20 @@ */ package org.springframework.batch.item.file; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; +import javax.swing.Spring; + import org.junit.Before; import org.junit.Test; @@ -450,7 +455,8 @@ public class FlatFileItemReaderTests { assertEquals(2, expected.getLineNumber()); assertEquals("testLine2", expected.getInput()); assertEquals("Couldn't map line 2", expected.getCause().getMessage()); - assertEquals(String.format("Parsing error at line: 2 in resource=[%s], input=[testLine2]", inputResource1.toString()), expected.getMessage()); + assertThat(expected.getMessage(), startsWith("Parsing error at line: 2 in resource=[")); + assertThat(expected.getMessage(), endsWith("], input=[testLine2]")); } }