FileStorage extends Storage { @Override public void initialize() { try { try { initDataset(); } catch (RiotNotFoundException e) { tryCreatingFile(); } } catch (RuntimeException e) { throw new OntoDriverInitializationException("Unable to initialize file storage at " + location, e); } } FileStorage(DriverConfiguration configuration); @Override void initialize();  }
@Test public void initializesStorageByReadingFileWithSingleGraph() throws Exception { final File file = Files.createTempFile("jena-onto", ".ttl").toFile(); file.deleteOnExit(); final Model model = generateModel(); try (final BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { model.write(writer, "TURTLE"); } final Storage result = new FileStorage(createConfiguration(file.getAbsolutePath())); result.initialize(); final Dataset dataset = result.getDataset(); assertNotNull(dataset); assertFalse(dataset.getDefaultModel().isEmpty()); }
@Test public void initializesStorageFromNonexistentFileByCreatingIt() { final String filePath = System.getProperty("java.io.tmpdir") + File.separator + "jena-test.ttl"; final Storage result = new FileStorage(createConfiguration(filePath)); result.initialize(); final Dataset dataset = result.getDataset(); assertNotNull(dataset); final File f = new File(filePath); assertTrue(f.exists()); f.deleteOnExit(); }