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/05/05 16:42:44 UTC
[tika] branch branch_1x updated (ba72c86 -> 6efea4f)
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a change to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git.
from ba72c86 TIKA-3382 -- improve writelimitreached handling in numerous parsers -- clean up PDFParser
new b7e53e4 TIKA-3386 allow a times parameter in MockParser
new 6efea4f TIKA-3386 -- fix conflicts
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../test/java/org/apache/tika/parser/mock/MockParser.java | 13 ++++++++++---
.../java/org/apache/tika/parser/mock/MockParserTest.java | 11 +++++++++++
.../src/test/resources/test-documents/mock_times.xml | 5 ++++-
3 files changed, 25 insertions(+), 4 deletions(-)
copy tika-batch/src/test/resources/test-input/max_restarts/test1_oom.xml => tika-core/src/test/resources/test-documents/mock_times.xml (86%)
[tika] 02/02: TIKA-3386 -- fix conflicts
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git
commit 6efea4f4d6039d53dc31edca6a1977b9710031a0
Author: tallison <ta...@apache.org>
AuthorDate: Wed May 5 12:42:30 2021 -0400
TIKA-3386 -- fix conflicts
---
.../src/test/java/org/apache/tika/parser/mock/MockParserTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tika-core/src/test/java/org/apache/tika/parser/mock/MockParserTest.java b/tika-core/src/test/java/org/apache/tika/parser/mock/MockParserTest.java
index ade8b90..8268ea1 100644
--- a/tika-core/src/test/java/org/apache/tika/parser/mock/MockParserTest.java
+++ b/tika-core/src/test/java/org/apache/tika/parser/mock/MockParserTest.java
@@ -22,7 +22,7 @@ import org.junit.Test;
import org.apache.tika.TikaTest;
import org.apache.tika.metadata.Metadata;
-import org.apache.tika.metadata.TikaCoreProperties;
+import org.apache.tika.sax.AbstractRecursiveParserWrapperHandler;
public class MockParserTest extends TikaTest {
@@ -36,6 +36,6 @@ public class MockParserTest extends TikaTest {
public void testTimes() throws Exception {
List<Metadata> metadataList = getRecursiveMetadata("mock_times.xml");
assertContainsCount("hello",
- metadataList.get(0).get(TikaCoreProperties.TIKA_CONTENT), 30);
+ metadataList.get(0).get(AbstractRecursiveParserWrapperHandler.TIKA_CONTENT), 30);
}
}
[tika] 01/02: TIKA-3386 allow a times parameter in MockParser
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git
commit b7e53e45eda1dceb92b869b6f9bb37a889ddf0ed
Author: tallison <ta...@apache.org>
AuthorDate: Wed May 5 12:38:38 2021 -0400
TIKA-3386 allow a times parameter in MockParser
---
.../org/apache/tika/parser/mock/MockParser.java | 13 ++++++++---
.../apache/tika/parser/mock/MockParserTest.java | 11 +++++++++
.../test/resources/test-documents/mock_times.xml | 26 ++++++++++++++++++++++
3 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java b/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java
index 5eea587..f06d192 100644
--- a/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java
+++ b/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java
@@ -394,10 +394,17 @@ public class MockParser extends AbstractParser {
if (eNode != null) {
elementType = eNode.getTextContent();
}
+ int times = 1;
+ Node tNode = attrs.getNamedItem("times");
+ if (tNode != null) {
+ times = Integer.parseInt(tNode.getTextContent());
+ }
String text = action.getTextContent();
- xhtml.startElement(elementType);
- xhtml.characters(text);
- xhtml.endElement(elementType);
+ for (int i = 0; i < times; i++) {
+ xhtml.startElement(elementType);
+ xhtml.characters(text);
+ xhtml.endElement(elementType);
+ }
}
diff --git a/tika-core/src/test/java/org/apache/tika/parser/mock/MockParserTest.java b/tika-core/src/test/java/org/apache/tika/parser/mock/MockParserTest.java
index 843d737..ade8b90 100644
--- a/tika-core/src/test/java/org/apache/tika/parser/mock/MockParserTest.java
+++ b/tika-core/src/test/java/org/apache/tika/parser/mock/MockParserTest.java
@@ -16,9 +16,13 @@
*/
package org.apache.tika.parser.mock;
+import java.util.List;
+
import org.junit.Test;
import org.apache.tika.TikaTest;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.metadata.TikaCoreProperties;
public class MockParserTest extends TikaTest {
@@ -27,4 +31,11 @@ public class MockParserTest extends TikaTest {
//just make sure there aren't any exceptions
getRecursiveMetadata("mock_fakeload.xml");
}
+
+ @Test
+ public void testTimes() throws Exception {
+ List<Metadata> metadataList = getRecursiveMetadata("mock_times.xml");
+ assertContainsCount("hello",
+ metadataList.get(0).get(TikaCoreProperties.TIKA_CONTENT), 30);
+ }
}
diff --git a/tika-core/src/test/resources/test-documents/mock_times.xml b/tika-core/src/test/resources/test-documents/mock_times.xml
new file mode 100644
index 0000000..a309655
--- /dev/null
+++ b/tika-core/src/test/resources/test-documents/mock_times.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ 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.
+-->
+
+<mock>
+
+ <metadata action="add" name="dc:creator">Nikolai Lobachevsky</metadata>
+ <write element="p" times="30"> hello </write>
+</mock>
\ No newline at end of file