You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2021/01/13 20:39:38 UTC

[tika] 01/02: Make the two quine unit test files optional because they can be removed by antivirus software.

This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git

commit 8113c61a2cc818e3b70a0370f03b27dd40bb5938
Author: tallison <ta...@apache.org>
AuthorDate: Wed Jan 13 15:22:49 2021 -0500

    Make the two quine unit test files optional because they can be removed by antivirus software.
---
 .../tika/parser/pkg/CompressorParserTest.java      | 22 ++++++++--------------
 .../org/apache/tika/parser/pkg/ZipParserTest.java  |  7 +++++++
 .../org/apache/tika/parser/pkg/ZipParserTest.java  | 10 ----------
 3 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/test/java/org/apache/tika/parser/pkg/CompressorParserTest.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/test/java/org/apache/tika/parser/pkg/CompressorParserTest.java
index 5e221f0..c2424cf 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/test/java/org/apache/tika/parser/pkg/CompressorParserTest.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/test/java/org/apache/tika/parser/pkg/CompressorParserTest.java
@@ -18,31 +18,18 @@
 package org.apache.tika.parser.pkg;
 
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 import org.apache.commons.compress.compressors.CompressorStreamFactory;
 import org.apache.tika.TikaTest;
 import org.apache.tika.detect.zip.CompressorConstants;
 import org.apache.tika.exception.TikaException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.metadata.TikaCoreProperties;
 import org.apache.tika.mime.MediaType;
 import org.apache.tika.parser.ParseContext;
-import org.apache.tika.parser.RecursiveParserWrapper;
-import org.apache.tika.sax.AbstractRecursiveParserWrapperHandler;
+import org.junit.Assume;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -85,12 +72,19 @@ public class CompressorParserTest extends TikaTest {
 
     @Test(expected = TikaException.class)
     public void testQuineXHTML() throws Exception {
+        //Anti-virus can surreptitiously remove this file
+        Assume.assumeTrue(CompressorParserTest.class
+                .getResourceAsStream("/test-documents/quine.gz") != null);
+
         //https://blog.matthewbarber.io/2019/07/22/how-to-make-compressed-file-quines
         getXML("quine.gz");
     }
 
     @Test
     public void testQuineRecursive() throws Exception {
+        //Anti-virus can surreptitiously remove this file
+        Assume.assumeTrue(CompressorParserTest.class
+                .getResourceAsStream("/test-documents/quine.gz") != null);
         //https://blog.matthewbarber.io/2019/07/22/how-to-make-compressed-file-quines
         getRecursiveMetadata("quine.gz");
     }
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/test/java/org/apache/tika/parser/pkg/ZipParserTest.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/test/java/org/apache/tika/parser/pkg/ZipParserTest.java
index 9dd5ce0..96a246b 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/test/java/org/apache/tika/parser/pkg/ZipParserTest.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/test/java/org/apache/tika/parser/pkg/ZipParserTest.java
@@ -30,6 +30,7 @@ import org.apache.tika.exception.TikaException;
 import org.apache.tika.io.TikaInputStream;
 import org.apache.tika.metadata.Metadata;
 import org.apache.tika.sax.BodyContentHandler;
+import org.junit.Assume;
 import org.junit.Test;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.helpers.DefaultHandler;
@@ -119,6 +120,9 @@ public class ZipParserTest extends AbstractPkgTest {
 
     @Test
     public void testQuineRecursiveParserWrapper() throws Exception {
+        //Anti-virus can surreptitiously remove this file
+        Assume.assumeTrue(ZipParserTest.class
+                .getResourceAsStream("/test-documents/droste.zip") != null);
         //received permission from author via dm
         //2019-07-25 to include
         //http://alf.nu/s/droste.zip in unit tests
@@ -129,6 +133,9 @@ public class ZipParserTest extends AbstractPkgTest {
 
     @Test(expected = TikaException.class)
     public void testQuine() throws Exception {
+        //Anti-virus can surreptitiously remove this file
+        Assume.assumeTrue(ZipParserTest.class
+                .getResourceAsStream("/test-documents/droste.zip") != null);
         getXML("droste.zip");
     }
 
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/parser/pkg/ZipParserTest.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/parser/pkg/ZipParserTest.java
index 9294cfb..e375627 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/parser/pkg/ZipParserTest.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/parser/pkg/ZipParserTest.java
@@ -123,16 +123,6 @@ public class ZipParserTest extends AbstractPkgTest {
     }
 
     @Test
-    public void testQuineRecursiveParserWrapper() throws Exception {
-        //received permission from author via dm
-        //2019-07-25 to include
-        //http://alf.nu/s/droste.zip in unit tests
-        //Out of respect to the author, please maintain
-        //the original file name
-        getRecursiveMetadata("droste.zip");
-    }
-
-    @Test
     public void testDataDescriptorWithEmptyEntry() throws Exception {
 
         //test that an empty first entry does not cause problems