TurtleRecordWriter implements AutoCloseable { @Override public void close(){ try { bufferedWriter.flush(); bufferedWriter.close(); } catch (IOException e) { LOG.error("Error closing the buffer writer ", e); } } TurtleRecordWriter(OutputStream out); void write(Model m ); @Override void close();  }
@Test public void testValidTurtleOutput() throws IOException { InputStream rdfInput = TurtleRecordWriterTest.class.getClassLoader().getResourceAsStream(TTL_INPUT_TEST); Assert.assertNotNull(rdfInput); Model jenaModel = ModelFactory.createDefaultModel().read(rdfInput, "", "Turtle"); Assert.assertTrue("Turtle Format is invalid", ! jenaModel.isEmpty()); rdfInput.close(); }
@Test public void testInValidTurtleOutput() throws IOException { InputStream rdfInput = TurtleRecordWriterTest.class.getClassLoader().getResourceAsStream(WRONG_TTL_INPUT_TEST); Assert.assertNotNull(rdfInput); try { Model jenaModel = ModelFactory.createDefaultModel().read(rdfInput, "", "Turtle"); Assert.assertTrue("Turtle fomat is invalid", jenaModel.isEmpty()); rdfInput.close(); } catch (RiotException e) { Assert.assertTrue( ! e.getMessage().isEmpty()); } }