protected static final String FILE_NAME = “/Users/mcantrell/Documents/p9/Enron/andy_zipper_000_1_1.pst”;
protected static final String LICENSE_FILE = “/Users/mcantrell/dev/projects/platinum/storage/storage-expander/src/main/resources/Aspose.Total.Java.lic”;
protected static final int MAX_TEST_EXECUTION_MS = 30;
@BeforeClass()
public static void enableLicense() throws Exception {
License license = new License();
license.setLicense(new FileInputStream(LICENSE_FILE));
}
public void parsePst() throws Exception {
MessageDigest digest = MessageDigest.getInstance(“MD5”);
PersonalStorage pst = PersonalStorage.fromFile(FILE_NAME);
Stopwatch stopwatch = Stopwatch.createStarted();
explode(pst, pst.getRootFolder(), digest);
Long elapsed = stopwatch.stop().elapsed(TimeUnit.SECONDS);
assertEquals(“011585696df1c30d7bb03ac5e655550a”, encodeHexString(digest.digest()));
assertTrue(“Test execution time exceeded: " + elapsed + " seconds”, elapsed < MAX_TEST_EXECUTION_MS);
}
@SuppressWarnings(“UnusedDeclaration”)
protected void explode(PersonalStorage pst, FolderInfo folder, MessageDigest digest) {
for (MessageInfo info : folder.getContents()) {
MapiMessage msg = pst.extractMessage(info);
String subject = msg.getSubject();
String body = msg.getBody();
if (subject != null) digest.update(subject.trim().getBytes());
if (body != null) digest.update(body.trim().getBytes());
}
for (FolderInfo subFolder : folder.getSubFolders()) {
explode(pst, subFolder, digest);
}
}
protected static final String FILE_NAME = “/Users/mcantrell/Documents/p9/Enron/andy_zipper_000_1_1.pst”;
protected static final int MAX_TEST_EXECUTION_MS = 30;
public void parsePst() throws Exception {
MessageDigest digest = MessageDigest.getInstance(“MD5”);
PSTFile pstFile = new PSTFile(FILE_NAME);
Stopwatch stopwatch = Stopwatch.createStarted();
explode(pstFile.getRootFolder(), digest);
Long elapsed = stopwatch.stop().elapsed(TimeUnit.SECONDS);
assertEquals(“011585696df1c30d7bb03ac5e655550a”, encodeHexString(digest.digest()));
assertTrue(“Test execution time exceeded: " + elapsed + " seconds”, elapsed < MAX_TEST_EXECUTION_MS);
}
protected void explode(PSTFolder folder, MessageDigest digest) throws Exception {
if (folder.getContentCount() > 0) {
PSTMessage email = (PSTMessage) folder.getNextChild();
while (email != null) {
String subject = email.getSubject();
String body = email.getBody();
if (subject != null) digest.update(subject.trim().getBytes());
if (body != null) digest.update(body.trim().getBytes());
email = (PSTMessage) folder.getNextChild();
}
}
for (PSTFolder subFolder : folder.getSubFolders()) {
explode(subFolder, digest);
}
}