BATCH-2410 junit.framework.Assert is deprecated

This commit is contained in:
Philippe Marschall
2015-07-30 19:57:41 +02:00
committed by Michael Minella
parent 9279280b3e
commit 7ec7152c5e
21 changed files with 99 additions and 97 deletions

View File

@@ -16,12 +16,12 @@
package org.springframework.batch.test;
import static org.junit.Assert.assertEquals;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import junit.framework.Assert;
import org.springframework.core.io.Resource;
/**
@@ -39,11 +39,11 @@ public abstract class AssertFile {
int lineNum = 1;
for (String expectedLine = null; (expectedLine = expectedReader.readLine()) != null; lineNum++) {
String actualLine = actualReader.readLine();
Assert.assertEquals("Line number " + lineNum + " does not match.", expectedLine, actualLine);
assertEquals("Line number " + lineNum + " does not match.", expectedLine, actualLine);
}
String actualLine = actualReader.readLine();
Assert.assertEquals("More lines than expected. There should not be a line number " + lineNum + ".", null,
assertEquals("More lines than expected. There should not be a line number " + lineNum + ".", null,
actualLine);
}
finally {
@@ -53,7 +53,7 @@ public abstract class AssertFile {
}
public static void assertFileEquals(Resource expected, Resource actual) throws Exception {
AssertFile.assertFileEquals(expected.getFile(), actual.getFile());
assertFileEquals(expected.getFile(), actual.getFile());
}
public static void assertLineCount(int expectedLineCount, File file) throws Exception {
@@ -63,7 +63,7 @@ public abstract class AssertFile {
while (expectedReader.readLine() != null) {
lineCount++;
}
Assert.assertEquals(expectedLineCount, lineCount);
assertEquals(expectedLineCount, lineCount);
}
finally {
expectedReader.close();
@@ -71,6 +71,6 @@ public abstract class AssertFile {
}
public static void assertLineCount(int expectedLineCount, Resource resource) throws Exception {
AssertFile.assertLineCount(expectedLineCount, resource.getFile());
assertLineCount(expectedLineCount, resource.getFile());
}
}

View File

@@ -15,10 +15,10 @@
*/
package org.springframework.batch.test;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import junit.framework.AssertionFailedError;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.ComparisonFailure;
import org.junit.Test;
import org.springframework.core.io.FileSystemResource;
@@ -42,7 +42,7 @@ public class AssertFileTests {
executeAssertEquals("input1.txt", "input2.txt");
fail();
}
catch (AssertionFailedError e) {
catch (ComparisonFailure e) {
assertTrue(e.getMessage().startsWith("Line number 3 does not match."));
}
}
@@ -53,7 +53,7 @@ public class AssertFileTests {
executeAssertEquals("input3.txt", "input1.txt");
fail();
}
catch (AssertionFailedError e) {
catch (AssertionError e) {
assertTrue(e.getMessage().startsWith("More lines than expected. There should not be a line number 4."));
}
}
@@ -64,7 +64,7 @@ public class AssertFileTests {
executeAssertEquals("input1.txt", "input3.txt");
fail();
}
catch (AssertionFailedError e) {
catch (AssertionError e) {
assertTrue(e.getMessage().startsWith("Line number 4 does not match."));
}
}
@@ -80,7 +80,7 @@ public class AssertFileTests {
executeAssertEquals("blank.txt", "input1.txt");
fail();
}
catch (AssertionFailedError e) {
catch (AssertionError e) {
assertTrue(e.getMessage().startsWith("More lines than expected. There should not be a line number 1."));
}
}
@@ -91,7 +91,7 @@ public class AssertFileTests {
executeAssertEquals("input1.txt", "blank.txt");
fail();
}
catch (AssertionFailedError e) {
catch (AssertionError e) {
assertTrue(e.getMessage().startsWith("Line number 1 does not match."));
}
}