Skip to content

Commit

Permalink
✔️ Updated test case
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 5, 2022
1 parent f3533c0 commit f5daacc
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/test/java/org/rrajesh1979/demo/MyCheckSumTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ void main() {

@Test
void getCheckSum() throws IOException, NoSuchAlgorithmException {
// File tempFile = createTempDataFile();
//
// String calculatedCheckSum = MyCheckSum.getCheckSum(tempFile.getAbsolutePath());
// // String calculatedCheckSum = new BigInteger(checkSumBytes).toString(16);
//
// tempFile.delete();
// String expectedCheckSum = "764efa883dda1e11db47671c4a3bbd9e";
// assertEquals(expectedCheckSum, calculatedCheckSum);
System.out.println("Testing getCheckSum");
File tempFile = createTempDataFile();
String calculatedCheckSum = new MyCheckSum().getCheckSum(tempFile);
tempFile.delete();
String expectedCheckSum = "f0ef7081e1539ac00ef5b761b4fb01b3";
System.out.println("Calculated CheckSum : " + calculatedCheckSum);
System.out.println("Expected CheckSum : " + expectedCheckSum);
assertEquals(expectedCheckSum, calculatedCheckSum);
}

static File createTempDataFile() throws IOException {
File tempFile = File.createTempFile("checksum", "test");
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
fileOutputStream.write("hi\n".getBytes());
fileOutputStream.write("Hello world\n".getBytes());
fileOutputStream.flush();
}
return tempFile;
Expand Down

0 comments on commit f5daacc

Please sign in to comment.