[
https://issues.apache.org/jira/browse/TIKA-1553?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tim Allison reopened TIKA-1553:
-------------------------------
I'd like to make this more general, rename it to MockParser and move it into
tika-core tests...we could also create a separate tika-test-framework module,
but given that we'd have at most two classes in there now (TikaTest?), I'm not
sure that makes sense yet.
The reason to move MockParser from tika-parsers to tika-core is that it isn't
of any use in testing parsers, but rather
frameworks/containers/executors/wrappers of parsers. I've been using this for
tika-batch, but we can also use it for further development of ForkParser and
for the next steps in making tika-server robust against ooms and hangs.
The idea is that a user can specify the actions of a parser by having
MockParser parse a mock.xml file.
Current design with all options is below. In this example, the parser would
add a metadata element, write some content, pause a bit and then throw an
IOException...<oom/> is just there as an example; the parser wouldn't reach
that, of course.
{noformat}
<?xml version="1.0" encoding="UTF-8" ?>
<mock>
<!-- action can be "add" or "set" -->
<metadata action="add" name="author">Nikolai Lobachevsky</metadata>
<!-- element is the name of the sax event to write, p=paragraph
if the element is not specified, the default is <p> -->
<write element="p">some content</write>
<!-- hang
millis: how many milliseconds to pause. The actual hang time will
probably
be a bit longer than the value specified.
heavy: whether or not the hang should do something computationally
expensive.
If the value is false, this just does a Thread.sleep(millis).
This attribute is optional, with default of heavy=false.
pulse_millis: (required if "heavy" is true), how often to check to see
whether the thread was interrupted or that the total hang time
exceeded the millis
interruptible: whether or not the parser will check to see if its thread
has been interrupted; this attribute is optional with default of
true
-->
<hang millis="100" heavy="true" pulse_millis="10" interruptible="true" />
<!-- throw an exception or error; optionally include a message or not -->
<throw class="java.io.IOException">not another IOException</throw>
<!-- perform a genuine OutOfMemoryError -->
<oom/>
</mock>
{noformat}
> Let's add an evil parser to be used in testing parser drivers
> -------------------------------------------------------------
>
> Key: TIKA-1553
> URL: https://issues.apache.org/jira/browse/TIKA-1553
> Project: Tika
> Issue Type: Test
> Reporter: Tim Allison
> Assignee: Tim Allison
> Priority: Minor
>
> As part of TIKA-1302 and as part of making Tika more robust generally, it
> would be useful to have an evil parser that will throw exceptions/errors and
> hang for lengths of time.
> This will allow us to test timeouts and handling of exceptions and errors in
> tika-server and in tika-batch.
> We could also use this for tests with ForkParser.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)