List of usage examples for java.lang AssertionError getLocalizedMessage
public String getLocalizedMessage()
From source file:org.kalypso.commons.junit.FileAssert.java
/** * Asserts that the contents of two files is equal. *//*w w w. j a v a 2 s . c om*/ public static void assertFileContentEquals(final File expected, final File actual) { try { final List<String> actualLines = FileUtils.readLines(actual, (Charset) null); final List<String> expectedLines = FileUtils.readLines(expected, (Charset) null); final Iterator<String> actualIt = actualLines.iterator(); final Iterator<String> expectedIt = expectedLines.iterator(); int count = 0; while (expectedIt.hasNext() && actualIt.hasNext()) { count++; final Object expectedLine = expectedIt.next(); final Object actualLine = actualIt.next(); try { Assert.assertEquals(expectedLine, actualLine); } catch (final AssertionError e) { final String msg = String.format("Line %d: %s", count, e.getLocalizedMessage()); //$NON-NLS-1$ fail(msg); } } assertIteratorIsEmpty("Actual file is longer than expected: ", actualIt); //$NON-NLS-1$ assertIteratorIsEmpty("Expected file is longer than actual: ", expectedIt); //$NON-NLS-1$ } catch (final IOException e) { e.printStackTrace(); Assert.fail("Failed to access file: " + e.getLocalizedMessage()); //$NON-NLS-1$ } }