exceptionfactory commented on a change in pull request #5732:
URL: https://github.com/apache/nifi/pull/5732#discussion_r808401004



##########
File path: 
nifi-nar-bundles/nifi-media-bundle/nifi-media-processors/src/test/java/org/apache/nifi/processors/document/ExtractDocumentTextTest.java
##########
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.processors.document;
+
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+
+public class ExtractDocumentTextTest {
+
+    private TestRunner testRunner;
+
+    @BeforeEach
+    public void init() {
+        testRunner = TestRunners.newTestRunner(ExtractDocumentText.class);
+    }
+
+    @Test
+    public void processor_should_support_pdf_types_without_exception() {
+        try {
+            final String filename = "simple.pdf";
+            MockFlowFile flowFile = testRunner.enqueue(new 
FileInputStream("src/test/resources/" + filename));
+            Map<String, String> attrs = new HashMap<String, String>() {{ 
put("filename", filename); }};
+            flowFile.putAttributes(attrs);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        testRunner.assertValid();
+        testRunner.run();
+        testRunner.assertTransferCount(ExtractDocumentText.REL_FAILURE, 0);
+
+        List<MockFlowFile> successFiles = 
testRunner.getFlowFilesForRelationship(ExtractDocumentText.REL_SUCCESS);
+        for (MockFlowFile mockFile : successFiles) {
+            try {
+                String result = new String(mockFile.toByteArray(), "UTF-8");
+                String trimmedResult = result.trim();
+                assertTrue(trimmedResult.startsWith("A Simple PDF File"));
+                System.out.println("FILE:" + result);
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Test
+    public void processor_should_support_doc_types_without_exception() {
+        try {
+            final String filename = "simple.doc";

Review comment:
       That's fair, perhaps reducing to a single binary document would be a 
sufficient way to go.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to