org.eclipse.rdf4j.rio.helpers.BasicParserSettings Java Examples
The following examples show how to use
org.eclipse.rdf4j.rio.helpers.BasicParserSettings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractNQuadsParserUnitTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testStatementWithInvalidLiteralContentAndStrictValidation() throws RDFHandlerException, IOException, RDFParseException { // Note: Float declare as int. final ByteArrayInputStream bais = new ByteArrayInputStream( ("<http://dbpedia.org/resource/Camillo_Benso,_conte_di_Cavour> " + "<http://dbpedia.org/property/mandatofine> " + "\"1380.0\"^^<http://www.w3.org/2001/XMLSchema#int> " + "<http://it.wikipedia.org/wiki/Camillo_Benso,_conte_di_Cavour#absolute-line=20> .") .getBytes()); parser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, true); parser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true); try { parser.parse(bais, "http://test.base.uri"); Assert.fail("Expected exception when passing in a datatype using an N3 style prefix"); } catch (RDFParseException rdfpe) { // FIXME: Fix line numbers for validation errors during the line // Assert.assertEquals(1, rdfpe.getLineNumber()); // FIXME: Enable column numbers when parser supports them // Assert.assertEquals(152, rdfpe.getColumnNumber()); } }
Example #2
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Tests whether an unknown language with the message and with a failure. */ @Test public final void testUnknownLanguageWithMessageWithFailCase1() throws Exception { Model expectedModel = getTestModel(UNKNOWN_LANGUAGE_VALUE, UNKNOWN_LANGUAGE_TAG); InputStream input = getUnknownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true); try { testParser.parse(input, BASE_URI); fail("Did not receive expected exception"); } catch (RDFParseException e) { // expected } assertErrorListener(0, 1, 0); assertModel(new LinkedHashModel()); }
Example #3
Source File: AbstractNQuadsParserUnitTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void verifyStatementWithInvalidDatatype(boolean useDatatypeVerification) throws RDFHandlerException, IOException, RDFParseException { TestRDFHandler rdfHandler = new TestRDFHandler(); parser.setRDFHandler(rdfHandler); parser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, useDatatypeVerification); parser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, useDatatypeVerification); if (!useDatatypeVerification) { parser.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES); parser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES); } final ByteArrayInputStream bais = new ByteArrayInputStream( ("<http://dbpedia.org/resource/Camillo_Benso,_conte_di_Cavour> " + "<http://dbpedia.org/property/mandatofine> " + "\"1380.0\"^^<http://dbpedia.org/invalid/datatype/second> " + "<http://it.wikipedia.org/wiki/Camillo_Benso,_conte_di_Cavour#absolute-line=20> .") .getBytes()); parser.parse(bais, "http://base-uri"); rdfHandler.assertHandler(1); }
Example #4
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Tests whether an unknown datatype with the message and with a failure. */ @Test public final void testUnknownDatatypeWithMessageWithFailCase1() throws Exception { Model expectedModel = getTestModel(UNKNOWN_DATATYPE_VALUE, UNKNOWN_DATATYPE_URI); InputStream input = getUnknownDatatypeStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true); try { testParser.parse(input, BASE_URI); fail("Did not receive expected exception"); } catch (RDFParseException e) { // expected } assertErrorListener(0, 1, 0); assertModel(new LinkedHashModel()); }
Example #5
Source File: CustomTurtleParserTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test780IRISpace() throws Exception { String ttl = "_:b25978837 a <http://purl.bioontology.org/ontology/UATC/\\u0020SERINE\\u0020\\u0020> ."; try { Rio.parse(new StringReader(ttl), "", RDFFormat.TURTLE); fail(); } catch (RDFParseException e) { // Invalid IRI } Model model = Rio.parse(new StringReader(ttl), "", RDFFormat.TURTLE, new ParserConfig().set(BasicParserSettings.VERIFY_URI_SYNTAX, false), SimpleValueFactory.getInstance(), new ParseErrorLogger()); assertEquals(1, model.size()); model.filter(null, RDF.TYPE, null) .objects() .forEach(obj -> assertEquals("http://purl.bioontology.org/ontology/UATC/ SERINE ", obj.stringValue())); }
Example #6
Source File: RDFWriterTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void testSES2030BNodeCollisionsInternal(boolean preserveBNodeIDs) throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); RDFWriter rdfWriter = rdfWriterFactory.getWriter(output); setupWriterConfig(rdfWriter.getWriterConfig()); rdfWriter.startRDF(); int count = 18; for (int i = 0; i < count; i++) { BNode bNode2 = vf.createBNode("a" + Integer.toHexString(i).toUpperCase()); // System.out.println(bNode2.getID()); rdfWriter.handleStatement(vf.createStatement(uri1, uri2, bNode2)); } rdfWriter.endRDF(); RDFParser rdfParser = rdfParserFactory.getParser(); setupParserConfig(rdfParser.getParserConfig()); if (preserveBNodeIDs) { rdfParser.getParserConfig().set(BasicParserSettings.PRESERVE_BNODE_IDS, true); } Model parsedModel = new LinkedHashModel(); rdfParser.setRDFHandler(new StatementCollector(parsedModel)); rdfParser.parse(new ByteArrayInputStream(output.toByteArray()), ""); // if (count != parsedModel.size()) { // Rio.write(parsedModel, System.out, RDFFormat.NQUADS); // } assertEquals(count, parsedModel.size()); }
Example #7
Source File: RDFWriterTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testBogusIRICharacters() throws Exception { Model model = new LinkedHashModel(); String illegal = " <>^|\t\n\r\"`"; for (int i = 0; i < illegal.length(); i++) { model.add(vf.createIRI("urn:test:char" + illegal.charAt(i)), RDF.TYPE, RDFS.RESOURCE); } ByteArrayOutputStream outputWriter = new ByteArrayOutputStream(); RDFWriter rdfWriter = rdfWriterFactory.getWriter(outputWriter); setupWriterConfig(rdfWriter.getWriterConfig()); rdfWriter.startRDF(); model.forEach(st -> rdfWriter.handleStatement(st)); rdfWriter.endRDF(); ByteArrayInputStream inputReader = new ByteArrayInputStream(outputWriter.toByteArray()); RDFParser rdfParser = rdfParserFactory.getParser(); setupParserConfig(rdfParser.getParserConfig().set(BasicParserSettings.VERIFY_URI_SYNTAX, false)); Model parsedOutput = new LinkedHashModel(); rdfParser.setRDFHandler(new StatementCollector(parsedOutput)); rdfParser.parse(inputReader, ""); Assert.assertEquals(model.size(), parsedOutput.size()); ByteArrayInputStream inputReader2 = new ByteArrayInputStream(outputWriter.toByteArray()); rdfParser.parse(inputReader2, ""); Assert.assertEquals(model.size(), parsedOutput.size()); }
Example #8
Source File: RDF4JProtocolSession.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public RDF4JProtocolSession(HttpClient client, ScheduledExecutorService executor) { super(client, executor); this.executor = executor; // we want to preserve bnode ids to allow Sesame API methods to match // blank nodes. getParserConfig().set(BasicParserSettings.PRESERVE_BNODE_IDS, true); // Sesame client has preference for binary response formats, as these are // most performant setPreferredTupleQueryResultFormat(TupleQueryResultFormat.BINARY); setPreferredRDFFormat(RDFFormat.BINARY); try { final String configuredValue = System.getProperty(Protocol.CACHE_TIMEOUT_PROPERTY); if (configuredValue != null) { int timeout = Integer.parseInt(configuredValue); pingDelay = TimeUnit.MILLISECONDS.convert(Math.max(timeout, 1), TimeUnit.SECONDS) / 2; } } catch (Exception e) { logger.warn("Could not read integer value of system property {}", Protocol.CACHE_TIMEOUT_PROPERTY); } }
Example #9
Source File: SPARQLProtocolSession.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public SPARQLProtocolSession(HttpClient client, ExecutorService executor) { this.httpClient = client; this.httpContext = new HttpClientContext(); this.background = new BackgroundResultExecutor(executor); valueFactory = SimpleValueFactory.getInstance(); httpContext.setCookieStore(new BasicCookieStore()); // parser used for processing server response data should be lenient parserConfig.addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES); parserConfig.addNonFatalError(BasicParserSettings.VERIFY_LANGUAGE_TAGS); // configure the maximum url length for SPARQL query GET requests int maximumUrlLength = DEFAULT_MAXIMUM_URL_LENGTH; String propertyValue = System.getProperty(MAXIMUM_URL_LENGTH_PARAM); if (propertyValue != null) { try { maximumUrlLength = Integer.parseInt(propertyValue); } catch (NumberFormatException e) { throw new RDF4JConfigException("integer value expected for property " + MAXIMUM_URL_LENGTH_PARAM, e); } } this.maximumUrlLength = maximumUrlLength; }
Example #10
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an known language with the correct settings will both generate no message and not fail when * addNonFatalError is called with the given setting. */ @Test public final void testKnownLanguageNoMessageNoFailCase4() throws Exception { Model expectedModel = getTestModel(KNOWN_LANGUAGE_VALUE, KNOWN_LANGUAGE_TAG); InputStream input = getKnownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, false); testParser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #11
Source File: RDFWriterTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testRDFStarConversion() throws IOException { Model model = new LinkedHashModel(); model.add(vf.createStatement(triple3, uri1, triple6, uri4)); model.add(vf.createStatement(uri1, uri2, uri3, uri5)); ByteArrayOutputStream outputWriter = new ByteArrayOutputStream(); RDFWriter rdfWriter = rdfWriterFactory.getWriter(outputWriter); setupWriterConfig(rdfWriter.getWriterConfig()); rdfWriter.getWriterConfig().set(BasicWriterSettings.CONVERT_RDF_STAR_TO_REIFICATION, true); rdfWriter.startRDF(); model.forEach(rdfWriter::handleStatement); rdfWriter.endRDF(); ByteArrayInputStream inputReader = new ByteArrayInputStream(outputWriter.toByteArray()); RDFParser rdfParser = rdfParserFactory.getParser(); setupParserConfig(rdfParser.getParserConfig().set(BasicParserSettings.VERIFY_URI_SYNTAX, false)); Model parsedOutput = new LinkedHashModel(); rdfParser.setRDFHandler(new StatementCollector(parsedOutput)); rdfParser.parse(inputReader, ""); // 1 non-RDF* statement // 1 RDF* statement whose conversion yields 20 additional statements: // 4 for triple3 // 4 for triple6 // 4 for triple2 (contained in triple6) // 4 for triple5 (contained in triple6) // 4 for triple1 (contained in triple5) assertEquals(22, parsedOutput.size()); }
Example #12
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an known language with the correct settings will both generate no message and not fail when * setNonFatalError is called with an empty set to reset the fatal errors */ @Test public final void testKnownLanguageNoMessageNoFailCase5() throws Exception { Model expectedModel = getTestModel(KNOWN_LANGUAGE_VALUE, KNOWN_LANGUAGE_TAG); InputStream input = getKnownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, false); testParser.getParserConfig().setNonFatalErrors(new HashSet<>()); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #13
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an known language with the message no fail. */ @Test public final void testKnownLanguageWithMessageNoFailCase1() throws Exception { Model expectedModel = getTestModel(KNOWN_LANGUAGE_VALUE, KNOWN_LANGUAGE_TAG); InputStream input = getKnownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true); testParser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #14
Source File: TurtleParserTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testParseIllegalURINoVerify() throws IOException { String data = " <urn:foo_bar\\r> <urn:foo> <urn:bar> ; <urn:foo2> <urn:bar2> . <urn:foobar> <urn:food> <urn:barf> . "; parser.getParserConfig().set(BasicParserSettings.VERIFY_URI_SYNTAX, false); parser.parse(new StringReader(data), baseURI); assertThat(errorCollector.getErrors()).isEmpty(); assertThat(errorCollector.getFatalErrors()).isEmpty(); assertThat(statementCollector.getStatements()).isNotEmpty(); assertThat(statementCollector.getStatements()).hasSize(3) .overridingErrorMessage("all triples should have been reported"); }
Example #15
Source File: TurtleWriter.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void writeBNode(BNode bNode, boolean canShorten) throws IOException { if (canShorten) { writer.write("[]"); return; } writer.write("_:"); String id = bNode.getID(); if (id.isEmpty()) { if (this.getWriterConfig().get(BasicParserSettings.PRESERVE_BNODE_IDS)) { throw new IOException("Cannot consistently write blank nodes with empty internal identifiers"); } writer.write("genid-hash-"); writer.write(Integer.toHexString(System.identityHashCode(bNode))); } else { if (!TurtleUtil.isNameStartChar(id.charAt(0))) { writer.write("genid-start-"); writer.write(Integer.toHexString(id.charAt(0))); } else { writer.write(id.charAt(0)); } for (int i = 1; i < id.length() - 1; i++) { if (TurtleUtil.isPN_CHARS(id.charAt(i))) { writer.write(id.charAt(i)); } else { writer.write(Integer.toHexString(id.charAt(i))); } } if (id.length() > 1) { if (!TurtleUtil.isNameEndChar(id.charAt(id.length() - 1))) { writer.write(Integer.toHexString(id.charAt(id.length() - 1))); } else { writer.write(id.charAt(id.length() - 1)); } } } }
Example #16
Source File: TurtleParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Parses a quoted string, which is either a "normal string" or a """long string""". * * @return string * @throws IOException * @throws RDFParseException */ protected String parseQuotedString() throws IOException, RDFParseException { String result = null; int c1 = readCodePoint(); // First character should be '"' or "'" verifyCharacterOrFail(c1, "\"\'"); // Check for long-string, which starts and ends with three double quotes int c2 = readCodePoint(); int c3 = readCodePoint(); if ((c1 == '"' && c2 == '"' && c3 == '"') || (c1 == '\'' && c2 == '\'' && c3 == '\'')) { // Long string result = parseLongString(c2); } else { // Normal string unread(c3); unread(c2); result = parseString(c1); } // Unescape any escape sequences try { result = TurtleUtil.decodeString(result); } catch (IllegalArgumentException e) { reportError(e.getMessage(), BasicParserSettings.VERIFY_DATATYPE_VALUES); } return result; }
Example #17
Source File: TurtleParserTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testParseIllegalURINonFatal() throws IOException { String data = " <urn:foo_bar\\r> <urn:foo> <urn:bar> ; <urn:foo2> <urn:bar2> . <urn:foobar> <urn:food> <urn:barf> . "; parser.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_URI_SYNTAX); parser.parse(new StringReader(data), baseURI); assertThat(errorCollector.getErrors()).hasSize(1); assertThat(errorCollector.getFatalErrors()).isEmpty(); assertThat(statementCollector.getStatements()).isNotEmpty(); assertThat(statementCollector.getStatements()).hasSize(1) .overridingErrorMessage("only syntactically legal triples should have been reported"); }
Example #18
Source File: TurtleParserTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testParseIllegalDatatypValueINoVerify() throws IOException { String data = " <urn:foo_bar> <urn:foo> \"a\"^^\"b\" ; <urn:foo2> <urn:bar2> . <urn:foobar> <urn:food> <urn:barf> . "; try { parser.getParserConfig().set(BasicParserSettings.VERIFY_URI_SYNTAX, false); parser.parse(new StringReader(data), baseURI); fail("literal as datatype should result in fatal error / parse exception"); } catch (RDFParseException e) { // expected } }
Example #19
Source File: TurtleParserTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testUnparsableIRINonFatal() throws IOException { // subject IRI is not processable by ParsedIRI String data = " <http://www:example.org/> <urn:foo> <urn:bar> . <urn:foo2> <urn:foo> <urn:bar> ."; parser.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_URI_SYNTAX); parser.parse(new StringReader(data), baseURI); assertThat(errorCollector.getErrors()).hasSize(1); assertThat(errorCollector.getFatalErrors()).isEmpty(); assertThat(statementCollector.getStatements()).isNotEmpty(); assertThat(statementCollector.getStatements()).hasSize(1) .overridingErrorMessage("only syntactically legal triples should have been reported"); }
Example #20
Source File: RDF4JStore.java From rmlmapper-java with MIT License | 5 votes |
@Override public void read(InputStream is, String base, RDFFormat format) throws Exception { if (base == null) { base = ""; } RDFParser parser = Rio.createParser(format); parser.set(BasicParserSettings.PRESERVE_BNODE_IDS, true); parser.setRDFHandler(new StatementCollector(model)); parser.parse(is, base); is.close(); }
Example #21
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an known language with the correct settings will both generate no message and not fail. */ @Test public final void testKnownLanguageNoMessageNoFailCase3() throws Exception { Model expectedModel = getTestModel(KNOWN_LANGUAGE_VALUE, KNOWN_LANGUAGE_TAG); InputStream input = getKnownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, false); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #22
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an unknown language with the message no fail. */ @Test public final void testUnknownLanguageWithMessageNoFailCase3() throws Exception { Model expectedModel = getTestModel(UNKNOWN_LANGUAGE_VALUE, UNKNOWN_LANGUAGE_TAG); InputStream input = getUnknownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true); testParser.getParserConfig() .setNonFatalErrors(Collections.<RioSetting<?>>singleton(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES)); testParser.parse(input, BASE_URI); assertErrorListener(0, 1, 0); assertModel(expectedModel); }
Example #23
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an unknown language with the message no fail. */ @Test public final void testUnknownLanguageWithMessageNoFailCase2() throws Exception { Model expectedModel = getTestModel(UNKNOWN_LANGUAGE_VALUE, UNKNOWN_LANGUAGE_TAG); InputStream input = getUnknownLanguageStream(expectedModel); testParser.getParserConfig().useDefaults(); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true); testParser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES); testParser.parse(input, BASE_URI); assertErrorListener(0, 1, 0); assertModel(expectedModel); }
Example #24
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an unknown language with the message no fail. */ @Test public final void testUnknownLanguageWithMessageNoFailCase1() throws Exception { Model expectedModel = getTestModel(UNKNOWN_LANGUAGE_VALUE, UNKNOWN_LANGUAGE_TAG); InputStream input = getUnknownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true); testParser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES); testParser.parse(input, BASE_URI); assertErrorListener(0, 1, 0); assertModel(expectedModel); }
Example #25
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an unknown language with the correct settings will both generate no message and not fail when * setNonFatalError is called with an empty set to reset the fatal errors */ @Test public final void testUnknownLanguageNoMessageNoFailCase5() throws Exception { Model expectedModel = getTestModel(UNKNOWN_LANGUAGE_VALUE, UNKNOWN_LANGUAGE_TAG); InputStream input = getUnknownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, false); testParser.getParserConfig().setNonFatalErrors(new HashSet<>()); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #26
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an unknown language with the correct settings will both generate no message and not fail when * addNonFatalError is called with the given setting. */ @Test public final void testUnknownLanguageNoMessageNoFailCase4() throws Exception { Model expectedModel = getTestModel(UNKNOWN_LANGUAGE_VALUE, UNKNOWN_LANGUAGE_TAG); InputStream input = getUnknownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, false); testParser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #27
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an unknown language with the correct settings will both generate no message and not fail. */ @Test public final void testUnknownLanguageNoMessageNoFailCase3() throws Exception { Model expectedModel = getTestModel(UNKNOWN_LANGUAGE_VALUE, UNKNOWN_LANGUAGE_TAG); InputStream input = getUnknownLanguageStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, false); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #28
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an known datatype with the message which generates a failure if the datatype is unknown. */ @Test public final void testKnownDatatypeWithMessageWhereUnknownWouldFailCase1() throws Exception { Model expectedModel = getTestModel(KNOWN_DATATYPE_VALUE, KNOWN_DATATYPE_URI); InputStream input = getKnownDatatypeStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #29
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an known datatype with the message no fail. */ @Test public final void testKnownDatatypeWithMessageNoFailCase3() throws Exception { Model expectedModel = getTestModel(KNOWN_DATATYPE_VALUE, KNOWN_DATATYPE_URI); InputStream input = getKnownDatatypeStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true); testParser.getParserConfig() .setNonFatalErrors(Collections.<RioSetting<?>>singleton(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES)); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
Example #30
Source File: AbstractParserHandlingTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Tests whether an known datatype with the message no fail. */ @Test public final void testKnownDatatypeWithMessageNoFailCase2() throws Exception { Model expectedModel = getTestModel(KNOWN_DATATYPE_VALUE, KNOWN_DATATYPE_URI); InputStream input = getKnownDatatypeStream(expectedModel); testParser.getParserConfig().useDefaults(); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true); testParser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }