JiriOndrusek commented on a change in pull request #998:
URL: https://github.com/apache/camel-quarkus/pull/998#discussion_r442055581



##########
File path: 
integration-tests/tika/src/test/java/org/apache/camel/quarkus/component/tika/it/TikaTest.java
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.camel.quarkus.component.tika.it;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import io.restassured.response.ValidatableResponse;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.txt.UniversalEncodingDetector;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.containsStringIgnoringCase;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.startsWith;
+
+@QuarkusTest
+class TikaTest {
+
+    @Test
+    public void testPdf() throws Exception {
+        testParse("quarkus.pdf", "application/pdf", "Hello Quarkus");
+    }
+
+    @Test
+    public void testOdf() throws Exception {
+        String body = testParse("testOpenOffice2.odt", 
"application/vnd.oasis.opendocument.text",
+                "This is a sample Open Office document, written in NeoOffice 
2.2.1 for the Mac");
+
+        Charset detectedCharset = null;
+        try {
+            InputStream bodyIs = new 
ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_16));
+            UniversalEncodingDetector encodingDetector = new 
UniversalEncodingDetector();
+            detectedCharset = encodingDetector.detect(bodyIs, new Metadata());
+        } catch (IOException e1) {
+            Assertions.fail();
+        }
+
+        
Assertions.assertTrue(detectedCharset.name().startsWith(StandardCharsets.UTF_16.name()));
+    }
+
+    @Test
+    public void testOffice() throws Exception {
+        String body = testParse("test.doc", "application/msword", "test");
+
+        Charset detectedCharset = null;
+        try {
+            InputStream bodyIs = new 
ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_16));
+            UniversalEncodingDetector encodingDetector = new 
UniversalEncodingDetector();
+            detectedCharset = encodingDetector.detect(bodyIs, new Metadata());
+        } catch (IOException e1) {
+            Assertions.fail();
+        }
+
+        
Assertions.assertTrue(detectedCharset.name().startsWith(StandardCharsets.UTF_16.name()));

Review comment:
       You are right. This is covered by camel itself 
(https://github.com/apache/camel/blob/master/components/camel-tika/src/test/java/org/apache/camel/component/tika/TikaParseTest.java#L71).
 I'll remove both parts.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to