Skip to content

Commit

Permalink
Examples: Add Apache TIKA parser
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanpadhye committed May 4, 2018
1 parent 028e4cc commit b0fb83e
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/pom.xml
Expand Up @@ -151,6 +151,12 @@
<artifactId>bcel</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.18</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2018, The Regents of the University of California
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package edu.berkeley.cs.jqf.examples.tika;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;

import com.pholser.junit.quickcheck.From;
import edu.berkeley.cs.jqf.examples.common.InputStreamGenerator;
import edu.berkeley.cs.jqf.fuzz.Fuzz;
import edu.berkeley.cs.jqf.fuzz.JQF;
import org.apache.tika.Tika;
import org.junit.runner.RunWith;

@RunWith(JQF.class)
public class TikaParserTest {

@Fuzz
public void fuzz(@From(InputStreamGenerator.class) InputStream in) throws IOException {
Tika tika = new Tika();
try(Reader reader = tika.parse(in)) {
char[] buf = new char[1024];
while (reader.read(buf) != -1); // Keep reading until EOF
}

}
}
1 change: 1 addition & 0 deletions examples/src/test/seeds/afl-all-testcases/hello_world.txt
@@ -0,0 +1 @@
hello
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/src/test/seeds/afl-all-testcases/simple_queries.sql
@@ -0,0 +1,3 @@
create table t1(one smallint);
insert into t1 values(1);
select * from t1;
Binary file added examples/src/test/seeds/afl-all-testcases/small.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
{\rtf1\pard Test\par}
@@ -0,0 +1 @@
<a b="c">d</a>
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions examples/src/test/seeds/afl-all-testcases/small_script.js
@@ -0,0 +1 @@
if (1==1) eval('1');

0 comments on commit b0fb83e

Please sign in to comment.