Skip to content

Commit

Permalink
change Object handler
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus6n committed Oct 15, 2024
1 parent c7487bc commit d433536
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,15 @@ private static InputStream getStream(String name) {
@Test
public void testShareazaDownloadParser() throws IOException, SAXException, TikaException {
ShareazaDownloadParser parser = new ShareazaDownloadParser();
ToTextContentHandler handler = new ToTextContentHandler();
Metadata metadata = new Metadata();
ContentHandler handler = new ToTextContentHandler();
ParseContext context = new ParseContext();
parser.getSupportedTypes(context);

try (InputStream stream = getStream("test-files/test_shareazaDownload.sd")) {
parser.parse(stream, handler, metadata, context);

String parsedText = handler.toString();
String[] downloadHashes = metadata.getValues("download-hashes");
String[] contentType = metadata.getValues(Metadata.CONTENT_TYPE);

assertTrue(parsedText.contains("expected-file.mp3"));
assertTrue(parsedText.contains("expected-image.png"));
assertEquals(ShareazaDownloadParser.SHAREAZA_DOWNLOAD_META, contentType[0]);
assertEquals(1, downloadHashes.length);
assertEquals("abcdef1234567890", downloadHashes[0]);

assertTrue(parsedText.contains("Komodor - Electrize.mp3"));
assertTrue(parsedText.contains("File Length: 5,613,696 Bytes (5.4 MB)"));
Expand Down

0 comments on commit d433536

Please sign in to comment.