}
@Test
public void canEncrypt_toSourceFile_withBackup() throws Exception {
Path srcFile = Paths.get("src/test/resources/ch/inftec/ju/util/security/JuSecurityUtilsTest_toBeEncrypted.properties");
String original = new IOUtil().loadTextFromUrl(JuUrl.toUrl(srcFile));
Path testCopy = Paths.get("target/tests").resolve(srcFile.getFileName());
IOUtil.copyFile(srcFile, testCopy, true);
JuTextEncryptor encryptor = JuSecurityUtils.buildEncryptor().password("secret").createTextEncryptor();
Path backupFile = JuSecurityUtils.performEncryption()
.propertyFile(JuUrl.toUrl(testCopy))
.encryptor(encryptor)
.encryptToSourceFileWithBackup();
String res = new IOUtil().loadTextFromUrl(JuUrl.toUrl(testCopy));
Assert.assertFalse(res.contains("doENC("));
String backup = new IOUtil().loadTextFromUrl(JuUrl.toUrl(backupFile));
Assert.assertEquals(original, backup);
IOUtil.deleteFile(testCopy);
IOUtil.deleteFile(backupFile);
}