From 1b22786001ac7269c66e1bf57dc302831f706d9d Mon Sep 17 00:00:00 2001 From: sharifi Date: Thu, 12 Nov 2020 14:08:02 +0330 Subject: [PATCH] add clean up files improve code quality --- .../java/com/baeldung/aes/AESUtilUnitTest.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java index fd51ce6a62..ed3b5bd650 100644 --- a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java +++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java @@ -12,13 +12,8 @@ import java.nio.file.Paths; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; -//@SpringBootTest class AESUtilUnitTest implements WithAssertions { - @Test - void contextLoads() { - } - @Test void givenString_whenEncrypt_thenSuccess() throws NoSuchAlgorithmException { // given @@ -41,7 +36,8 @@ class AESUtilUnitTest implements WithAssertions { SecretKey key = AESUtil.generateKey(128); String algorithm = "AES/CBC/PKCS5Padding"; IvParameterSpec ivParameterSpec = AESUtil.generateIv(); - File inputFile = Paths.get("src/test/resources/baeldung.txt").toFile(); + File inputFile = Paths.get("src/test/resources/baeldung.txt") + .toFile(); File encryptedFile = new File("classpath:baeldung.encrypted"); File decryptedFile = new File("document.decrypted"); @@ -51,6 +47,8 @@ class AESUtilUnitTest implements WithAssertions { // then assertThat(inputFile).hasSameTextualContentAs(decryptedFile); + encryptedFile.delete(); + decryptedFile.delete(); } @Test @@ -66,7 +64,7 @@ class AESUtilUnitTest implements WithAssertions { Student object = (Student) AESUtil.decryptObject(algorithm, sealedObject, key, ivParameterSpec); // then - assertThat(student).isEqualToComparingFieldByField(object); + assertThat(student).isEqualTo(object); } @Test @@ -76,7 +74,7 @@ class AESUtilUnitTest implements WithAssertions { String password = "baeldung"; String salt = "12345678"; IvParameterSpec ivParameterSpec = AESUtil.generateIv(); - SecretKey key = AESUtil.getKeyFromPassword(password,salt); + SecretKey key = AESUtil.getKeyFromPassword(password, salt); // when String cipherText = AESUtil.encryptPasswordBased(plainText, key, ivParameterSpec); @@ -86,4 +84,3 @@ class AESUtilUnitTest implements WithAssertions { Assertions.assertEquals(plainText, decryptedCipherText); } } -