use of net.viperfish.journal.framework.JournalTransformer in project vsDiaryWriter by shilongdai.
the class CompressMacTest method testWrapper.
protected void testWrapper() {
JournalTransformer wrapper;
try {
CommonFunctions.initDir(testDir);
wrapper = createTransformer(new File(testDir.getCanonicalPath() + "/salt"));
} catch (IOException e) {
System.err.println("cannot load salt");
throw new RuntimeException(e);
}
try {
wrapper.setPassword("password");
} catch (FailToSyncCipherDataException e1) {
throw new RuntimeException(e1);
}
Journal j = new Journal();
j.setSubject("test get");
j.setContent("test get content");
try {
Journal result = wrapper.encryptJournal(j);
result = wrapper.decryptJournal(result);
String plainContent = result.getContent();
Assert.assertEquals("test get content", plainContent);
Assert.assertEquals("test get", result.getSubject());
} catch (CipherException | CompromisedDataException e) {
throw new RuntimeException(e);
}
}
Aggregations