Skip to content

Commit 4e32eb5

Browse files
committed
TIKA-4355 -- LibPstParserConfig should be serializable
1 parent 347d58c commit 4e32eb5

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/libpst/LibPstParserConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
*/
1717
package org.apache.tika.parser.microsoft.libpst;
1818

19-
public class LibPstParserConfig {
19+
import java.io.Serializable;
20+
21+
public class LibPstParserConfig implements Serializable {
2022

2123
private long timeoutSeconds = 600;
2224
/**

tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/parser/fork/ForkParserIntegrationTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,18 @@
3737

3838
import org.apache.tika.MultiThreadedTikaTest;
3939
import org.apache.tika.Tika;
40+
import org.apache.tika.config.TikaConfig;
4041
import org.apache.tika.detect.Detector;
4142
import org.apache.tika.exception.TikaException;
4243
import org.apache.tika.fork.ForkParser;
4344
import org.apache.tika.metadata.Metadata;
4445
import org.apache.tika.mime.MediaType;
46+
import org.apache.tika.parser.AutoDetectParser;
4547
import org.apache.tika.parser.EmptyParser;
4648
import org.apache.tika.parser.ParseContext;
4749
import org.apache.tika.parser.Parser;
4850
import org.apache.tika.parser.RecursiveParserWrapper;
51+
import org.apache.tika.parser.microsoft.libpst.LibPstParser;
4952
import org.apache.tika.sax.BodyContentHandler;
5053

5154
/**
@@ -210,6 +213,23 @@ public void testForkedPackageParsing() throws Exception {
210213
}
211214
}
212215

216+
@Test
217+
public void testLibPstParser() throws Exception {
218+
if (! LibPstParser.checkQuietly()) {
219+
return;
220+
}
221+
TikaConfig tikaConfig = new TikaConfig(
222+
ForkParserIntegrationTest.class.getResourceAsStream("/configs/tika-config-lib-pst.xml"));
223+
try (ForkParser parser = new ForkParser(ForkParserIntegrationTest.class.getClassLoader(),
224+
new AutoDetectParser(tikaConfig))) {
225+
ContentHandler output = new BodyContentHandler();
226+
InputStream stream = getResourceAsStream("/test-documents/testPST.pst");
227+
ParseContext context = new ParseContext();
228+
parser.parse(stream, output, new Metadata(), context);
229+
assertContains("Barry Olddog", output.toString());
230+
}
231+
}
232+
213233
@Test
214234
@Disabled("use for development/one off testing. This is a beast and takes enormous " +
215235
"resources and time")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<properties>
19+
<parsers>
20+
<parser class="org.apache.tika.parser.DefaultParser">
21+
<parser-exclude class="org.apache.tika.parser.microsoft.pst.OutlookPSTParser"/>
22+
<parser-exclude class="org.apache.tika.parser.microsoft.pst.PSTMailItemParser"/>
23+
</parser>
24+
<parser class="org.apache.tika.parser.microsoft.libpst.LibPstParser"/>
25+
</parsers>
26+
</properties>

0 commit comments

Comments
 (0)