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.
This commit is contained in:
Andy Wilkinson
2015-10-21 14:15:46 +01:00
committed by Michael Minella
parent 68ee9a2916
commit 2f552b7449

View File

@@ -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]"));
}
}