setNonFatalErrors(nonFatalErrors);
@Test public void testAddMalformedLiteralsStrictConfig() throws Exception { Set<RioSetting<?>> empty = Collections.emptySet(); testCon.getParserConfig().setNonFatalErrors(empty); try { testCon.add( RepositoryConnectionTest.class.getResourceAsStream(TEST_DIR_PREFIX + "malformed-literals.ttl"), "", RDFFormat.TURTLE); fail("upload of malformed literals should fail with error in strict configuration"); } catch (RDFParseException e) { // ingnore, as expected. } }
@Deprecated @Override public void setStopAtFirstError(boolean stopAtFirstError) { getParserConfig().set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, stopAtFirstError); if (!stopAtFirstError) { getParserConfig().addNonFatalError(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); } else { // TODO: Add a ParserConfig.removeNonFatalError function to avoid // this Set<RioSetting<?>> set = new HashSet<RioSetting<?>>(getParserConfig().getNonFatalErrors()); set.remove(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); getParserConfig().setNonFatalErrors(set); } }
/** * Test method for * {@link org.openrdf.rio.ParserConfig#setNonFatalErrors(java.util.Set)}. */ @Test public final void testSetNonFatalErrors() { ParserConfig testConfig = new ParserConfig(); // Test that the defaults exist and are empty assertNotNull(testConfig.getNonFatalErrors()); assertTrue(testConfig.getNonFatalErrors().isEmpty()); // Test that we can add to the default before calling setNonFatalErrors // (SES-1801) testConfig.addNonFatalError(BasicParserSettings.PRESERVE_BNODE_IDS); assertFalse(testConfig.getNonFatalErrors().isEmpty()); assertTrue(testConfig.getNonFatalErrors().contains(BasicParserSettings.PRESERVE_BNODE_IDS)); assertFalse(testConfig.getNonFatalErrors().contains(BasicParserSettings.VERIFY_DATATYPE_VALUES)); // Test with a non-empty set that we remove the previous setting testConfig.setNonFatalErrors(Collections.<RioSetting<?>> singleton(BasicParserSettings.VERIFY_DATATYPE_VALUES)); assertNotNull(testConfig.getNonFatalErrors()); assertFalse(testConfig.getNonFatalErrors().isEmpty()); assertFalse(testConfig.getNonFatalErrors().contains(BasicParserSettings.PRESERVE_BNODE_IDS)); assertTrue(testConfig.getNonFatalErrors().contains(BasicParserSettings.VERIFY_DATATYPE_VALUES)); // Test with an empty set testConfig.setNonFatalErrors(new HashSet<RioSetting<?>>()); assertNotNull(testConfig.getNonFatalErrors()); assertTrue(testConfig.getNonFatalErrors().isEmpty()); }
@Test public void testAddMalformedLiteralsStrictConfig() throws Exception { Set<RioSetting<?>> empty = Collections.emptySet(); testCon.getParserConfig().setNonFatalErrors(empty); try { testCon.add( RepositoryConnectionTest.class.getResourceAsStream(TEST_DIR_PREFIX + "malformed-literals.ttl"), "", RDFFormat.TURTLE); fail("upload of malformed literals should fail with error in strict configuration"); } catch (RDFParseException e) { // ingnore, as expected. } }
/** * 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); }
/** * Tests whether an unknown datatype with the message no fail. */ @Test public final void testUnknownDatatypeWithMessageNoFailCase3() throws Exception { Model expectedModel = getTestModel(UNKNOWN_DATATYPE_VALUE, UNKNOWN_DATATYPE_URI); InputStream input = getUnknownDatatypeStream(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, 1, 0); assertModel(expectedModel); }
/** * Tests whether an known language with the message no fail. */ @Test public final void testKnownLanguageWithMessageNoFailCase3() 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().setNonFatalErrors( Collections.<RioSetting<?>> singleton(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES)); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
/** * 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); }
/** * 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<RioSetting<?>>()); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
/** * 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<RioSetting<?>>()); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
/** * Tests whether an unknown datatype 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 testUnknownDatatypeNoMessageNoFailCase5() throws Exception { Model expectedModel = getTestModel(UNKNOWN_DATATYPE_VALUE, UNKNOWN_DATATYPE_URI); InputStream input = getUnknownDatatypeStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, false); testParser.getParserConfig().setNonFatalErrors(new HashSet<RioSetting<?>>()); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }
/** * Tests whether an known datatype 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 testKnownDatatypeNoMessageNoFailCase5() throws Exception { Model expectedModel = getTestModel(KNOWN_DATATYPE_VALUE, KNOWN_DATATYPE_URI); InputStream input = getKnownDatatypeStream(expectedModel); testParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, false); testParser.getParserConfig().setNonFatalErrors(new HashSet<RioSetting<?>>()); testParser.parse(input, BASE_URI); assertErrorListener(0, 0, 0); assertModel(expectedModel); }