Search in sources :

Example 6 with RDFParseException

use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.

the class TriGParserCustomTest method testBadPname02.

@Test
public void testBadPname02() throws Exception {
    try {
        Rio.parse(new StringReader("@prefix : <http://example/> . {:a%2 :p :o .}"), "", RDFFormat.TRIG);
        fail("Did not receive expected exception");
    } catch (RDFParseException e) {
    }
}
Also used : StringReader(java.io.StringReader) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) Test(org.junit.Test)

Example 7 with RDFParseException

use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.

the class CustomTurtleParserTest method testSES2086PeriodEndingLocalNamesFailure3.

@Test
public void testSES2086PeriodEndingLocalNamesFailure3() throws Exception {
    try {
        Rio.parse(new StringReader("@prefix ns: <http://example.org/data/> . ns:1 a ns:Product ; ns:affects ns:4 , ns:16 , ns:uriWithDot. ; ns:title \"An example entity with uriWithDot as an object\" . "), "", RDFFormat.TURTLE);
        fail("Did not receive an exception");
    } catch (RDFParseException e) {
        System.out.println(e.getMessage());
        assertTrue(e.getMessage().contains("Expected an RDF value here, found ';'"));
    }
}
Also used : StringReader(java.io.StringReader) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) Test(org.junit.Test)

Example 8 with RDFParseException

use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.

the class CustomTurtleParserTest method testSES2086PeriodEndingLocalNamesFailure2.

@Test
public void testSES2086PeriodEndingLocalNamesFailure2() throws Exception {
    try {
        Rio.parse(new StringReader("@prefix ns: <http://example.org/data/> . ns:uriWithDot. a ns:Product ; ns:title \"An example subject ending with a dot.\" . "), "", RDFFormat.TURTLE);
        fail("Did not receive an exception");
    } catch (RDFParseException e) {
        System.out.println(e.getMessage());
        assertTrue(e.getMessage().contains("Illegal predicate value: \"\"^^<http://www.w3.org/2001/XMLSchema#integer>"));
    }
}
Also used : StringReader(java.io.StringReader) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) Test(org.junit.Test)

Example 9 with RDFParseException

use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.

the class CustomTurtleParserTest method test780IRISpace.

@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/%20SERINE%20%20", obj.stringValue()));
}
Also used : ParseErrorLogger(org.eclipse.rdf4j.rio.helpers.ParseErrorLogger) StringReader(java.io.StringReader) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) ParserConfig(org.eclipse.rdf4j.rio.ParserConfig) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) Test(org.junit.Test)

Example 10 with RDFParseException

use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.

the class CustomTurtleParserTest method testSES2086PeriodEndingLocalNamesFailure4.

@Test
public void testSES2086PeriodEndingLocalNamesFailure4() throws Exception {
    try {
        Rio.parse(new StringReader("@prefix ns: <http://example.org/data/> . ns:1 a ns:uriWithDot. ; ns:title \"An example entity with uriWithDot as an object\" . "), "", RDFFormat.TURTLE);
        fail("Did not receive an exception");
    } catch (RDFParseException e) {
        System.out.println(e.getMessage());
        assertTrue(e.getMessage().contains("Expected an RDF value here, found ';'"));
    }
}
Also used : StringReader(java.io.StringReader) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) Test(org.junit.Test)

Aggregations

RDFParseException (org.eclipse.rdf4j.rio.RDFParseException)50 Test (org.junit.Test)22 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)19 IOException (java.io.IOException)16 StringReader (java.io.StringReader)13 StatementCollector (org.eclipse.rdf4j.rio.helpers.StatementCollector)9 RDFLoader (org.eclipse.rdf4j.repository.util.RDFLoader)8 Model (org.eclipse.rdf4j.model.Model)7 RDFParser (org.eclipse.rdf4j.rio.RDFParser)7 Statement (org.eclipse.rdf4j.model.Statement)6 LinkedHashModel (org.eclipse.rdf4j.model.impl.LinkedHashModel)6 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)5 RDFFormat (org.eclipse.rdf4j.rio.RDFFormat)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InputStream (java.io.InputStream)4 Reader (java.io.Reader)4 RDFInserter (org.eclipse.rdf4j.repository.util.RDFInserter)4 SAXException (org.xml.sax.SAXException)4 IRI (org.eclipse.rdf4j.model.IRI)3 Literal (org.eclipse.rdf4j.model.Literal)3