use of org.apache.jena.riot.RiotException in project jena by apache.
the class UnitTestBadSyntax method run4.
private void run4() {
Dataset ds = DatasetFactory.createGeneral();
try {
RDFDataMgr.read(ds, uri, uri, lang);
} catch (RiotException ex) {
return;
} catch (RuntimeException ex) {
ex.printStackTrace(System.err);
fail("Unexpected exception");
}
fail("Bad syntax test succeed in parsing the file");
}
use of org.apache.jena.riot.RiotException in project jena by apache.
the class UnitTestEval method run4.
private void run4() {
DatasetGraph dsg = DatasetGraphFactory.create();
try {
if (baseIRI != null)
RDFDataMgr.read(dsg, input, baseIRI, lang);
else
RDFDataMgr.read(dsg, input, lang);
Lang outLang = RDFLanguages.filenameToLang(output, Lang.NQUADS);
DatasetGraph results = DatasetGraphFactory.create();
try {
RDFDataMgr.read(results, output, outLang);
} catch (RiotException ex) {
fail("Failed to read results: " + ex.getMessage());
}
boolean b = isomorphic(dsg, results);
if (!b) {
System.out.println("**** Test: " + getName());
System.out.println("---- Parsed");
RDFDataMgr.write(System.out, dsg, Lang.TRIG);
System.out.println("---- Expected");
RDFDataMgr.write(System.out, results, Lang.TRIG);
System.out.println("--------");
}
assertTrue("Datasets not isomorphic", b);
} catch (RiotException ex) {
// Catch and rethrow - debugging.
throw ex;
} catch (RuntimeException ex) {
ex.printStackTrace(System.err);
throw ex;
}
}
use of org.apache.jena.riot.RiotException in project jena by apache.
the class UnitTestEval method run3.
// Triples test.
private void run3() {
Model model = ModelFactory.createDefaultModel();
try {
if (baseIRI != null)
RDFDataMgr.read(model, input, baseIRI, lang);
else
RDFDataMgr.read(model, input, lang);
Lang outLang = RDFLanguages.filenameToLang(output, Lang.NQUADS);
Model results = ModelFactory.createDefaultModel();
try {
RDFDataMgr.read(results, output, outLang);
} catch (RiotException ex) {
fail("Failed to read results: " + ex.getMessage());
}
boolean b = model.isIsomorphicWith(results);
if (!b) {
//model.isIsomorphicWith(results) ;
System.out.println("---- Parsed");
model.write(System.out, "TTL");
System.out.println("---- Expected");
results.write(System.out, "TTL");
System.out.println("--------");
}
assertTrue("Models not isomorphic", b);
} catch (RiotException ex) {
// Catch and rethrow - debugging.
throw ex;
} catch (RuntimeException ex) {
ex.printStackTrace(System.err);
throw ex;
}
}
use of org.apache.jena.riot.RiotException in project jena by apache.
the class REST_Quads_RW method doPutPostTxn.
private void doPutPostTxn(HttpAction action, boolean clearFirst) {
UploadDetails details = null;
action.beginWrite();
try {
DatasetGraph dsg = action.getActiveDSG();
if (clearFirst)
dsg.clear();
StreamRDF dest = StreamRDFLib.dataset(dsg);
details = Upload.incomingData(action, dest);
action.commit();
ServletOps.success(action);
} catch (RiotException ex) {
// Parse error
action.abort();
ServletOps.errorBadRequest(ex.getMessage());
} catch (ActionErrorException ex) {
action.abort();
throw ex;
} catch (Exception ex) {
// Something else went wrong. Backout.
action.abort();
ServletOps.errorOccurred(ex.getMessage());
} finally {
action.endWrite();
}
ServletOps.uploadResponse(action, details);
}
use of org.apache.jena.riot.RiotException in project jena by apache.
the class REST_Quads_RW method doPutPostNonTxn.
private void doPutPostNonTxn(HttpAction action, boolean clearFirst) {
DatasetGraph dsgTmp = DatasetGraphFactory.create();
StreamRDF dest = StreamRDFLib.dataset(dsgTmp);
UploadDetails details;
try {
details = Upload.incomingData(action, dest);
} catch (RiotException ex) {
ServletOps.errorBadRequest(ex.getMessage());
return;
}
// Now insert into dataset
action.beginWrite();
try {
DatasetGraph dsg = action.getActiveDSG();
if (clearFirst)
dsg.clear();
FusekiLib.addDataInto(dsgTmp, dsg);
action.commit();
ServletOps.success(action);
} catch (Exception ex) {
// but it might and there is no harm safely trying.
try {
action.abort();
} catch (Exception ex2) {
}
ServletOps.errorOccurred(ex.getMessage());
} finally {
action.endWrite();
}
ServletOps.uploadResponse(action, details);
}
Aggregations