|
26 | 26 | import java.io.File; |
27 | 27 | import java.io.IOException; |
28 | 28 | import java.io.PrintStream; |
| 29 | +import java.io.Reader; |
29 | 30 | import java.net.URI; |
30 | 31 | import java.nio.file.FileVisitResult; |
31 | 32 | import java.nio.file.FileVisitor; |
|
34 | 35 | import java.nio.file.Paths; |
35 | 36 | import java.nio.file.attribute.BasicFileAttributes; |
36 | 37 | import java.util.HashSet; |
| 38 | +import java.util.List; |
37 | 39 | import java.util.Set; |
38 | 40 |
|
39 | 41 | import org.jetbrains.annotations.NotNull; |
|
44 | 46 | import org.junit.jupiter.api.io.TempDir; |
45 | 47 |
|
46 | 48 | import org.apache.tika.exception.TikaException; |
| 49 | +import org.apache.tika.metadata.Metadata; |
| 50 | +import org.apache.tika.metadata.TikaCoreProperties; |
| 51 | +import org.apache.tika.serialization.JsonMetadataList; |
47 | 52 | import org.apache.tika.utils.ProcessUtils; |
| 53 | +import org.apache.tika.utils.StringUtils; |
48 | 54 |
|
49 | 55 | /** |
50 | 56 | * Tests the Tika's cli |
@@ -285,6 +291,28 @@ public void testRUnpack() throws Exception { |
285 | 291 | testRecursiveUnpack("testPDFPackage.pdf", expectedChildren, 2); |
286 | 292 | } |
287 | 293 |
|
| 294 | + @Test |
| 295 | + public void testPSTRUnpack() throws Exception { |
| 296 | + String[] expectedChildren = new String[]{"testPST.pst.json", |
| 297 | + "testPST.pst-embed/00000007-First email.msg", |
| 298 | + "testPST.pst-embed/00000001-Feature Generators.msg", |
| 299 | + "testPST.pst-embed/00000008-First email.msg", |
| 300 | + "testPST.pst-embed/00000004-[jira] [Resolved] (TIKA-1249) Vcard files detection.msg", |
| 301 | + "testPST.pst-embed/00000003-Feature Generators.msg", |
| 302 | + "testPST.pst-embed/00000002-putstatic\".msg", |
| 303 | + "testPST.pst-embed/00000005-[jira] [Commented] (TIKA-1250) Process loops infintely processing a CHM file.msg", |
| 304 | + "testPST.pst-embed/00000009-attachment.docx", |
| 305 | + "testPST.pst-embed/00000006-[WEBINAR] - \"Introducing Couchbase Server 2.5\".msg"}; |
| 306 | + testRecursiveUnpack("testPST.pst", expectedChildren, 2); |
| 307 | + try (Reader reader = Files.newBufferedReader(extractDir.resolve("testPST.pst.json"))) { |
| 308 | + List<Metadata> metadataList = JsonMetadataList.fromJson(reader); |
| 309 | + for (Metadata m : metadataList) { |
| 310 | + String content = m.get(TikaCoreProperties.TIKA_CONTENT); |
| 311 | + assertFalse(StringUtils.isBlank(content)); |
| 312 | + } |
| 313 | + } |
| 314 | + } |
| 315 | + |
288 | 316 |
|
289 | 317 | /** |
290 | 318 | * Tests -l option of the cli |
@@ -378,7 +406,6 @@ private void testRecursiveUnpack(String targetFile, String[] expectedChildrenFil |
378 | 406 | .list(); |
379 | 407 | assertNotNull(jsonFile); |
380 | 408 | assertEquals(expectedLength, jsonFile.length); |
381 | | - //assertEquals(fileNames.size(), expectedChildrenFileNames.length); |
382 | 409 |
|
383 | 410 | for (String expectedChildName : expectedChildrenFileNames) { |
384 | 411 | assertTrue(fileNames.contains(expectedChildName)); |
|
0 commit comments