use of org.eclipse.rdf4j.rio.helpers.ParseErrorCollector in project rdf4j by eclipse.
the class SPARQLXMLParserCustomTest method testEntityExpansionNoSecureProcessing.
/**
* Test with Secure processing setting off.
* <p>
* IMPORTANT: Only turn this on to verify it is still working, as there is
* no way to safely perform this test.
* <p>
* WARNING: This test will cause an OutOfMemoryException when it eventually
* fails, as it will eventually fail.
*
* @throws Exception
*/
@Ignore
@Test(timeout = 10000)
public void testEntityExpansionNoSecureProcessing() throws Exception {
QueryResultCollector handler = new QueryResultCollector();
ParseErrorCollector errorCollector = new ParseErrorCollector();
QueryResultParser aParser = QueryResultIO.createTupleParser(TupleQueryResultFormat.SPARQL).setQueryResultHandler(handler).set(XMLParserSettings.SECURE_PROCESSING, false).setParseErrorListener(errorCollector);
try {
// IMPORTANT: This will not use the entity limit
aParser.parseQueryResult(this.getClass().getResourceAsStream("/sparqlxml/bad-entity-expansion-limit.srx"));
fail("Parser did not throw an exception");
} catch (QueryResultParseException e) {
// assertTrue(e.getMessage().contains(
// "The parser has encountered more than \"64,000\" entity
// expansions in this document; this is the limit imposed by the"));
}
assertEquals(0, errorCollector.getWarnings().size());
assertEquals(0, errorCollector.getErrors().size());
assertEquals(1, errorCollector.getFatalErrors().size());
}
use of org.eclipse.rdf4j.rio.helpers.ParseErrorCollector in project rdf4j by eclipse.
the class TriXParserTest method setUp.
@Before
public void setUp() throws Exception {
platformLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
vf = SimpleValueFactory.getInstance();
parser = new TriXParser();
sc = new StatementCollector();
parser.setRDFHandler(sc);
el = new ParseErrorCollector();
parser.setParseErrorListener(el);
}
use of org.eclipse.rdf4j.rio.helpers.ParseErrorCollector in project rdf4j by eclipse.
the class TriGParserCustomTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
vf = SimpleValueFactory.getInstance();
settingsNoVerifyLangTag = new ParserConfig();
settingsNoVerifyLangTag.set(BasicParserSettings.VERIFY_LANGUAGE_TAGS, false);
errors = new ParseErrorCollector();
parser = Rio.createParser(RDFFormat.TRIG);
statementCollector = new StatementCollector(new LinkedHashModel());
parser.setRDFHandler(statementCollector);
}
use of org.eclipse.rdf4j.rio.helpers.ParseErrorCollector in project rdf4j by eclipse.
the class RDFXMLParserCustomTest method testEntityExpansionNoSecureProcessing.
/**
* Test with Secure processing setting off.
* <p>
* IMPORTANT: Only turn this on to verify it is still working, as there is no way to safely perform this
* test.
* <p>
* WARNING: This test will cause an OutOfMemoryException when it eventually fails, as it will eventually
* fail.
*
* @throws Exception
*/
@Ignore
@Test(timeout = 10000)
public void testEntityExpansionNoSecureProcessing() throws Exception {
final Model aGraph = new LinkedHashModel();
ParseErrorCollector errorCollector = new ParseErrorCollector();
RDFParser aParser = Rio.createParser(RDFFormat.RDFXML).setRDFHandler(new StatementCollector(aGraph)).set(XMLParserSettings.SECURE_PROCESSING, false).setParseErrorListener(errorCollector);
try {
// IMPORTANT: This will not use the entity limit
aParser.parse(this.getClass().getResourceAsStream("/testcases/rdfxml/openrdf/bad-entity-expansion-limit.rdf"), "http://example.org");
fail("Parser did not throw an exception");
} catch (RDFParseException e) {
// assertTrue(e.getMessage().contains(
// "The parser has encountered more than \"64,000\" entity expansions in this document; this is the limit imposed by the"));
}
assertEquals(0, errorCollector.getWarnings().size());
assertEquals(0, errorCollector.getErrors().size());
assertEquals(1, errorCollector.getFatalErrors().size());
}
use of org.eclipse.rdf4j.rio.helpers.ParseErrorCollector in project rdf4j by eclipse.
the class CustomTurtleParserTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
vf = ValueFactoryImpl.getInstance();
settingsNoVerifyLangTag = new ParserConfig();
settingsNoVerifyLangTag.set(BasicParserSettings.VERIFY_LANGUAGE_TAGS, false);
errors = new ParseErrorCollector();
parser = Rio.createParser(RDFFormat.TURTLE);
statementCollector = new StatementCollector(new LinkedHashModel());
parser.setRDFHandler(statementCollector);
}
Aggregations