Search in sources :

Example 1 with ErrorHandler

use of org.apache.jena.riot.system.ErrorHandler in project jena by apache.

the class TestTriXBad method trix_bad.

@Test(expected = RiotException.class)
public void trix_bad() {
    ErrorHandler err = ErrorHandlerFactory.getDefaultErrorHandler();
    try {
        ErrorHandlerFactory.setDefaultErrorHandler(ErrorHandlerFactory.errorHandlerSimple());
        InputStream in = IO.openFile(fInput);
        StreamRDF sink = StreamRDFLib.sinkNull();
        RDFParser.source(in).lang(Lang.TRIX).parse(sink);
    } finally {
        ErrorHandlerFactory.setDefaultErrorHandler(err);
    }
}
Also used : ErrorHandler(org.apache.jena.riot.system.ErrorHandler) StreamRDF(org.apache.jena.riot.system.StreamRDF) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 2 with ErrorHandler

use of org.apache.jena.riot.system.ErrorHandler in project jena by apache.

the class TestReadData method load_18.

// Load quads into graph - warning on named graphs
@Test
public void load_18() {
    ErrorHandler err = ErrorHandlerFactory.getDefaultErrorHandler();
    try {
        ErrorHandlerFactory.setDefaultErrorHandler(new ErrorHandlerTestLib.ErrorHandlerEx());
        try {
            Graph g = RDFDataMgr.loadGraph(filename("D.trig"));
            fail("No expection generated");
        } catch (ErrorHandlerTestLib.ExWarning e) {
        }
        ErrorHandlerFactory.setDefaultErrorHandler(ErrorHandlerFactory.errorHandlerNoLogging);
        Graph g = RDFDataMgr.loadGraph(filename("D.trig"));
        assertFalse(g.isEmpty());
        assertEquals(1, g.size());
    } finally {
        ErrorHandlerFactory.setDefaultErrorHandler(err);
    }
}
Also used : ErrorHandler(org.apache.jena.riot.system.ErrorHandler) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 3 with ErrorHandler

use of org.apache.jena.riot.system.ErrorHandler in project jena by apache.

the class BaseTest2 method unsetTestLogging.

public static void unsetTestLogging() {
    if (errorHandlers.size() == 0) {
        Log.warn(BaseTest.class, "ErrorHandler not set for testing");
        // Panic measures
        ErrorHandlerFactory.setDefaultErrorHandler(ErrorHandlerFactory.errorHandlerStd);
        return;
    }
    ErrorHandler errHandler = errorHandlers.pop();
    ErrorHandlerFactory.setDefaultErrorHandler(errHandler);
}
Also used : ErrorHandler(org.apache.jena.riot.system.ErrorHandler)

Example 4 with ErrorHandler

use of org.apache.jena.riot.system.ErrorHandler in project jena by apache.

the class ActionSPARQL method parse.

public static void parse(HttpAction action, StreamRDF dest, InputStream input, Lang lang, String base) {
    try {
        if (!RDFParserRegistry.isRegistered(lang))
            ServletOps.errorBadRequest("No parser for language '" + lang.getName() + "'");
        ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(action.log);
        RDFParser.create().errorHandler(errorHandler).source(input).lang(lang).base(base).parse(dest);
    } catch (RiotException ex) {
        ServletOps.errorBadRequest("Parse error: " + ex.getMessage());
    }
}
Also used : ErrorHandler(org.apache.jena.riot.system.ErrorHandler)

Aggregations

ErrorHandler (org.apache.jena.riot.system.ErrorHandler)4 Test (org.junit.Test)2 InputStream (java.io.InputStream)1 BaseTest (org.apache.jena.atlas.junit.BaseTest)1 Graph (org.apache.jena.graph.Graph)1 StreamRDF (org.apache.jena.riot.system.StreamRDF)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1